Clarification required

Hi,

I think the following schema is invalid:

<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 point to note here is, the selector XPath is having the expr. '.'

The XMLSchema Rec. http://www.w3.org/TR/xmlschema-1/ says:
[[
{selector} specifies a restricted XPath ([XPath]) expression relative to instances of the 
element being declared. This must identify a node set of subordinate elements (i.e. contained 
within the declared element) to which the constraint applies.
]]

Further,

3.11.4 The Identity-constraint Definition Validation Rules, 
http://www.w3.org/TR/xmlschema-1/#section-Identity-constraint-Definition-Validation-Rules says:
[[
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. 

3 ....
.
.
.
]]

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.

Refer: http://lists.w3.org/Archives/Public/xmlschema-dev/2002Apr/0048.html

Thanks,
Rahul.

Sun Microsystems, Inc.

Received on Wednesday, 10 April 2002 05:21:19 UTC