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

Key and keyref in XSD

From: Eddie Robertsson <eddie@allette.com.au>
Date: Thu, 29 Mar 2001 12:38:05 +1000
Message-ID: <3AC2A00C.2CE8868C@allette.com.au>
To: XSD <xmlschema-dev@w3.org>
Hi all,

I've been experimenting with key and keyref constructs in XSD lately and
unfortunately I get strange error messages from XSV. I checked the XSV
site and saw that it still doesn't implement XPath fully so maybe that's
the reason I'm getting these errors. My XML instance look like this:

<Tournament xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 <Name>Allette Open</Name>
 <Participants nbrParticipants="2">
  <Name id="p1">Nick</Name>
  <Name id="p2">Marcus</Name>
 <Teams nbrTeams="2">
  <Team id="t1" Name="Team 1">
  <Team id="t2" Name="Team 2">
 <Matches nbrMatches="1">
  <Match id="m1">

The snippet that is important in my schema is:

<xsd:element name="Tournament" type="Tournament">
  <xsd:key name="key_Participant">
   <!-- Make sure that each Participant has a unique id -->
   <xsd:selector xpath="Participants/Participant"/>
   <xsd:field xpath="@id"/>
  <xsd:keyref name="ref_Participant" refer="key_Participant">
   <!-- Make sure that the value of each Member element in the Team
elements is an identifier for an existing Participant -->
   <xsd:selector xpath="Teams/Team"/>
   <xsd:field xpath="Member"/>

Full Instance and schema can be found at [1] and [2] respectively. When
I validate this using XSV I get the following errors:
Problems with the schema-validity of the target

"http://www.allette.com.au/Demo/XSV/Test/Tournament.xml:11:3: Invalid
per cvc-identity-constraint.2.3.2: no key in key_Participant for p1

http://www.allette.com.au/Demo/XSV/Test/Tournament.xml:14:3: Invalid per
cvc-identity-constraint.2.3.2: no key in key_Participant for p2"

The instance looks valid to me so this leaves me with to options:

1) My key and keyref declarations are wrong
2) This is not yet implemented in XSV (or XML Spy for that matter)


[1] http://www.allette.com.au/Demo/XSV/Test/Tournament.xml
[2] http://www.allette.com.au/Demo/XSV/Test/Tournament.xsd
Received on Wednesday, 28 March 2001 21:36:37 UTC

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