W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2001

Re: [Moderator Action] Inheritance and Identity-constraint

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 22 Feb 2001 11:20:14 +0000
To: Eddie Robertsson <eddie@allette.com.au>
Cc: Faroukh Fekravar <fekravar@austin.apc.slb.com>, xmlschema-dev@w3.org
Message-ID: <f5b8zmzarrl.fsf@cogsci.ed.ac.uk>
Eddie Robertsson <eddie@allette.com.au> writes:

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

Yes -- I've underlined above the fact that I'm suggesting making the
whole document the scope for the key you're interested in.

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

Correct -- that's what I said above.

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

No, not equal, and the second as you suggest pretty useless.  Sorry
for the confusion, please try reading my original reply again.

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 Thursday, 22 February 2001 06:20:21 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:51 UTC