[
Lists Home |
Date Index |
Thread Index
]
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
|