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

Selector Clarification

From: Rahul Srivastava <Rahul.Srivastava@Sun.COM>
Date: Mon, 8 Apr 2002 13:45:23 +0000 (Asia/Calcutta)
Message-Id: <200204080822.g388MpF10929@blr-root.India.Sun.COM>
To: xmlschema-dev@w3.org
Hi,

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.

schema1: This 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:element>
    </xsd:sequence>
  </xsd:complexType>
  
  <xsd:key name="BookKey">
    <xsd:selector xpath="./Book"/>
    <xsd:field xpath="isbn"/>
  </xsd:key>
  
</xsd:element>


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 spec says:
http://www.w3.org/TR/xmlschema-1/#Identity-constraint_Definition_details
[[
{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.
]]
but, there could be something that I have missed.

Can somebody clarify on this.

Cheers,
Rahul.

Sun Microsystems, Inc.
Received on Monday, 8 April 2002 04:22:55 GMT

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