- From: Eddie Robertsson <eddie@allette.com.au>
- Date: Thu, 22 Feb 2001 10:03:37 +1100
- To: "Henry S. Thompson" <ht@cogsci.ed.ac.uk>
- CC: Faroukh Fekravar <fekravar@austin.apc.slb.com>, xmlschema-dev@w3.org
"Henry S. Thompson" wrote: > > 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"/> I'm a bit confused here. I thought that the declaration of the key needed to be declared in the element that defines the scope of the uniqueness. Isn't this the case? For example: If I have an instance like: <Root> <Item id="1">...</Item> <Item id="2">...</Item> <Item id="3">...</Item> </Root> If I want Item/@id to be unique within the scope of the Root element I thought the key declaration had to come in the element declaration of the Root element: <xsd:element name="Root" type="RootType"> <xsd:key name="ItemKey"> <xsd:selector xpath="Item"/> <xsd:field xpath="@Id"/> </xsd:key> </xsd:element> Is it really true that you can define the key within the Item element itself? Like: <xsd:element name="Item" type="ItemType"> <xsd:key name="ItemKey"> <xsd:selector xpath=".//Item"/> <xsd:field xpath="@Id"/> </xsd:key> </xsd:element> Are these two declarations equal and if they are how is the scope of the uniqueness defined? Cheers, /Eddie
Received on Wednesday, 21 February 2001 18:19:12 UTC