W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > January to March 2001

Inheritance and Identity-constraint

From: Faroukh Fekravar <fekravar@austin.apc.slb.com>
Date: Tue, 20 Feb 2001 09:05:28 -0600
Message-ID: <3A9287B8.E25179DB@austin.apc.slb.com>
To: www-xml-schema-comments@w3.org
Hi folks,

I have two questions regarding Identity-constraint which give me
hard time!

1) in the example below the element "Item1" can be substituted by
element
"Item2". I have defined a key at the root (Project) level with
a xpath to 'Item1".
If I substitute "Item1" by "Item2" in my instance document,
is the key valid for "Item2" too?

<xsd:element name="Project">
 <xsd:complexType>
  <xsd:sequence>
  <xsd:element ref="Item1" maxOccurs="unbounded"/>
  </xsd:sequence>
 </xsd:complexType>

  <key name="Item1Key">
   <selector xpath="Item"/>
   <field xpath="@Id"/>
  </key>
</xsd:element>

<element name="Item1" type="Item1Type" />

 <complexType name="Item1Type" >
  <sequence>
   <element name="Id" type="string" minOccurs="1" maxOccurs="1"/>
  </sequence>
 </complexType>

<element name="Item2" type="Item2Type" substitutionGroup="Item1" />

 <complexType name="Item2Type" >
 <complexContent>
  <extension base= "Item1Type">
  <sequence>
   <element name="Name" type="string" minOccurs="0" maxOccurs="1"/>
  </sequence>
  </extension>
 </complexContent>
 </complexType>

2) I understand that the Identity-constraint is valid within a defined
scope. Is there anyway to
define the key in the example above within the "Item1" element but
declare somehow that
the scope is the whole document (something like this:)

<element name="Item1" type="Item1Type" >
  <key name="Item1Key">
   <selector xpath="Project/Item"/>
   <field xpath="@Id"/>
  </key>
</element>

<xsd:element name="Project">
<xsd:complexType>
 <xsd:sequence>
 <xsd:element ref="Item1" maxOccurs="unbounded"/>
 </xsd:sequence>
</xsd:complexType>
</xsd:element>

Thanks in advance,
Faroukh
Received on Tuesday, 20 February 2001 10:05:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:12:49 GMT