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

Re: [Moderator Action] Key/Keyref definition

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 12 Apr 2001 18:58:23 +0100
To: "Ravindra Jain" <ravindra@ltp.soft.net>
Cc: <xmlschema-dev@w3.org>
Message-ID: <f5b4rvu9f0g.fsf@cogsci.ed.ac.uk>
"Ravindra Jain" <ravindra@ltp.soft.net> writes:

> My doubt is given a keyref defined in some element, where should be the key
> to which this keyref is referring ?
> Should they both be in the same element, or can keyref exist in some other
> element ?

Some other one is OK, as long as the element(s) which define the key may
appear at some depth inside it.

> here is one example :
> 
> <element name="LibraryList">
>         <complexType>
>              <sequence>
>                  <element ref="lib:Library" minOccurs="1" maxOccurs="1"/>
>              </sequence>
>         </complexType>
>         <key name="PK">
>             <selector xpath="Library/GuestAuthors/Author/BookForSigning"/>
>             <field xpath="ISBN"/>
>         </key>
> </element>
> <element name="Library">
>         <complexType>
>              <sequence>
>                  <element ref="lib:BookCatalogue" minOccurs="1"
> maxOccurs="1"/>
>                  <element ref="lib:GuestAuthors" minOccurs="1"
> maxOccurs="1"/>
>              </sequence>
>         </complexType>
> </element>
> <element name="BookCatalogue">
>  <complexType>
>       <sequence>
>            <element name="Book" minOccurs="0" maxOccurs="unbounded">
>                 <complexType>
>                   <sequence>
>                      <element name="Title" type="string" minOccurs="1"
> maxOccurs="1"/>
>                      <element name="ISBN" type="string" minOccurs="1"
> maxOccurs="1"/>
>                   </sequence>
>               </complexType>
>               <keyref name="isbnRef" refer="lib:PK">
>                  <selector xpath=""/>
>                  <field xpath="ISBN"/>
>               </keyref>
>          </element>
>      </sequence>
>  </complexType>
> </element>
> <element name="GuestAuthors">
>    <complexType>
>       <sequence>
>          <element name="Author" minOccurs="0" maxOccurs="unbounded">
>              <complexType>
>                 <sequence>
>                     <element name="Name" type="string" minOccurs="1"
> maxOccurs="1"/>
>                     <element name="BookForSigning" minOccurs="1"
> maxOccurs="unbounded">
>                        <complexType>
>                            <sequence>
>                               <element name="Title" type="string"
> minOccurs="1" maxOccurs="1"/>
>                               <element name="ISBN" type="string"
> minOccurs="1" maxOccurs="1"/>
>                            </sequence>
>                        </complexType>
>                     </element>
>                </sequence>
>           </complexType>
>        </element>
>     </sequence>
>  </complexType>
> </element>
> 
> 
> In the above code, the keyref is being defined in "Book" element, and it is
> referring to a key (PK) which is declared in the "LibraryList" element (i.e.
> outside the "Book" element)
> Is this valid ?

No, the keyref is too low down -- move it up to the Library level.

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, 12 April 2001 13:58:24 GMT

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