[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Error: not found for identity constraint of element

  • To: xml-dev@l...
  • Subject: Error: not found for identity constraint of element
  • From: "learning xml" <learning_xml@h...>
  • Date: Wed, 17 Mar 2004 11:05:40 +0200
  • Bcc:

identity constraint error
Hi,
I composed sport.xml and sport.xsd files. When I parse and validate with 
DOM. There are something wrong.
[Error] sport.xml:43:14: Key 'ref_Team' with value 'ID Value:
FIN
' not found for identity constraint of element 'Tournament'.
[Error] sport.xml:43:14: Key 'ref_Team' with value 'ID Value:
CHN
' not found for identity constraint of element 'Tournament'.
[Error] sport.xml:43:14: Key 'ref_Participant' with value 'ID Value:
FF
' not found for identity constraint of element 'Tournament'.
[Error] sport.xml:43:14: Key 'ref_Participant' with value 'ID Value:

Thanks,

The files are as foloows:
sport.xml
<?xml version="1.0" encoding="UTF-8"?>
<Tournament  xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
      xsd:noNamespaceSchemaLocation="/tmp/example/xml_1/sport.xsd">
<Name>
This is a description about a tourament by XML!
</Name>
<Type>
Those are football matches
</Type>
<Date>
2004-07-08
</Date>
<Participants nbrParticipants="2">
<Name id="1">
FF
</Name>
<Name id="2">
CC
</Name>
</Participants>
<Teams nbrTeams="2">
<Team id="x" Name="FIN">
<Member>
FF
</Member>
</Team>
<Team id="y" Name="CHN">
<Member>
CC
</Member>
</Team>
</Teams>
<Matches nbrMatches="1">
<Match id="Friendship">
<Team>
FIN
</Team>
<Team>
CHN
</Team>
</Match>
</Matches>
</Tournament>

sport.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Tournament">
  <xsd:sequence>
   <xsd:element name="Name" type="xsd:string"/>
   <xsd:element name="Type">
    <xsd:simpleType>
     <xsd:restriction base="xsd:string">
      <xsd:enumeration value="Singles"/>
      <xsd:enumeration value="Doubles"/>
     </xsd:restriction>
    </xsd:simpleType>
   </xsd:element>
   <xsd:element name="Date" type="xsd:date"/>
   <xsd:element name="Participants" type="Participants" minOccurs="0"/>
   <xsd:element name="Teams" type="Teams"/>
   <xsd:element name="Matches" type="Matches"/>
  </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Participants">
  <xsd:sequence>
   <xsd:element name="Name" minOccurs="2" maxOccurs="unbounded">
    <xsd:complexType>
     <xsd:simpleContent>
      <xsd:extension base="xsd:string">
       <xsd:attribute name="id" type="xsd:string" use="required"/>
      </xsd:extension>
     </xsd:simpleContent>
    </xsd:complexType>
   </xsd:element>
  </xsd:sequence>
  <xsd:attribute name="nbrParticipants" type="xsd:positiveInteger"
use="required"/>
</xsd:complexType>
<xsd:complexType name="Teams">
  <xsd:sequence>
   <xsd:element name="Team" minOccurs="2" maxOccurs="unbounded">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="Member" type="xsd:string" maxOccurs="2"/>
     </xsd:sequence>
     <xsd:attribute name="id" type="xsd:string" use="required"/>
     <xsd:attribute name="Name" type="xsd:string"/>
    </xsd:complexType>
   </xsd:element>
  </xsd:sequence>
  <xsd:attribute name="nbrTeams" type="xsd:positiveInteger"
use="required"/>
</xsd:complexType>
<xsd:complexType name="Matches">
  <xsd:sequence>
   <xsd:element name="Match" maxOccurs="unbounded">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="Team" type="xsd:string" minOccurs="2"
maxOccurs="2"/>
     </xsd:sequence>
     <xsd:attribute name="id" type="xsd:string" use="required"/>
    </xsd:complexType>
   </xsd:element>
  </xsd:sequence>
  <xsd:attribute name="nbrMatches" type="xsd:positiveInteger"
use="required"/>
</xsd:complexType>
<xsd:element name="Tournament" type="Tournament">
  <xsd:key name="key_Participant">
   <!-- Make sure that each Participant has a unique id -->
   <xsd:selector xpath="Participants/Name"/>
   <xsd:field xpath="@id"/>
  </xsd:key>
  <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/Member"/>
   <xsd:field xpath="."/>
  </xsd:keyref>
  <xsd:key name="key_Team">
   <!-- Make sure that each Team has a unique id -->
   <xsd:selector xpath="Teams/Team"/>
   <xsd:field xpath="@id"/>
  </xsd:key>
  <xsd:keyref name="ref_Team" refer="key_Team">
   <!-- Make sure that the value of each Team element in the Match
elements is an identifier for an existing Team -->
   <xsd:selector xpath="Matches/Match/Team"/>
   <xsd:field xpath="."/>
  </xsd:keyref>
  <xsd:unique name="unique_Match">
   <!-- Make sure that each Match has a unique id -->
   <xsd:selector xpath="Matches/Match"/>
   <xsd:field xpath="@id"/>
  </xsd:unique>
</xsd:element>
</xsd:schema>

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.