W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

Re: Selector Clarification

From: Rahul Srivastava <Rahul.Srivastava@Sun.COM>
Date: Wed, 10 Apr 2002 10:15:08 +0000 (Asia/Calcutta)
Message-Id: <200204100452.g3A4qdF25661@blr-root.India.Sun.COM>
To: xmlschema-dev@w3.org
Cc: jeni@jenitennison.com
> Jeni Tennison wrote...
> 

Hi Jeni,

> > Rahul Srivastava wrote...
> >
> > I have two small schemas for an instance file defining Id/y
> > constraints. One works and the other does not. I doubt the other one
> > is invalid.
> 

<snip/>

> 
> On the other hand, in the one that doesn't work:
> 
> > schema2: This does not works
> >
> > <xsd:element name="root">
> >   <xsd:complexType>
> >     <xsd:sequence>
> >       <xsd:element name="Book" maxOccurs="unbounded">
> >         <xsd:complexType>
> >           <xsd:sequence>
> >             <xsd:element name="isbn" type="xsd:string"/>
> >           </xsd:sequence>
> >           <xsd:attribute name="name" type="xsd:string" use="required"/>
> >         </xsd:complexType>
> >
> >         <xsd:key name="BookKey">
> >           <xsd:selector xpath="."/>
> >           <xsd:field xpath="isbn"/>
> >         </xsd:key>
> >
> >       </xsd:element>
> >     </xsd:sequence>
> >   </xsd:complexType>
> > </xsd:element>
> 
> The key says:
> 
>   "Within each <Book> element, that <Book> element itself must have a
>    unique value for its <isbn> element child."
> 
> All that this actually tests is that the <Book> element doesn't have
> two <isbn> element children. You are only testing whether one <Book>
> element has a unique value.
> 
> The location of the identity constraint determines the scope in which
> it holds; the selector selects the elements that should have unique
> values; the fields select the attributes and elements of those
> elements that should be combined to give the unique values.
> 
> Basically, the only reason you'd ever want to use an XPath of '.'
> within xs:selector is if you were using the identity constraint as a
> hack to test a co-occurrence constraint.

But, is using a '.' as the XPath expr. for a selector valid?

The rec. says:
http://www.w3.org/TR/xmlschema-1/#section-Identity-constraint-Definition-Validation-Rules
[[
Validation Rule: Identity-constraint Satisfied 

For an element information item to be locally ·valid· with respect to an 
identity-constraint all of the following must be true:

1 The {selector}, with the element information item as the context node, evaluates to a 
node-set (as defined in [XPath]). [Definition:]  Call this the target node set. 

2 Each node in the ·target node set· is an element node among the descendants of the 
context node. 

....
]]

Looking at point 2 above, it reflects that, we cannot use '.' as the XPath expr. for a 
selector. Does *descendants of the context node* includes the context node?

On the other hand the production rule for the XPath expr. for the selector allows '.' as a 
valid XPath expr.
http://www.w3.org/TR/xmlschema-1/#coss-identity-constraint

Please clarify.

Thanks,
Rahul.
Received on Wednesday, 10 April 2002 00:52:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT