Re: [Moderator Action] Inheritance and Identity-constraint

Faroukh Fekravar <fekravar@austin.apc.slb.com> writes:

> 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>

Nope, sorry -- your xpath (which presumably was meant to read
 <selector xpath="Item1"/>

> 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="Schema/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>

Sure, just put the key in whatever element declaration covers the
document element, and change the selector to

  <selector xpath=".//Item"/>

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Wednesday, 21 February 2001 11:02:10 UTC