|
From
a thread on [EMAIL PROTECTED] , I
am having problems parsing the instance below. I am using a "|" in
the field element of the key named kActivity in the Referenced
XML Schema file ( included ). My
last email on the xml-dev email list. It
seems from the discussion that you can have the Pipe, "|" in the
field xpath. So why does Xerces fails when parsing this student3.xml Xerces
fails when parsing the student3.xml SEVERE:
java.lang.RuntimeException: org.xml.sax.SAXParseException: Identity Constraint
error (cvc-identity-constraint.4.2.1):
element "studentActivities" has a key with no value. My
guess is that it only sees the act:name in the field definition <field
xpath="act:name|act:desc"/> Note:
If I have only name elements under activity. Xerces is happy. So
what is wrong ? Schema <?xml
version="1.0" encoding="UTF-8"?> <schema
targetNamespace="http://www.exampleU.com/activity"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:act="http://www.exampleU.com/activity"
elementFormDefault="qualified"> <element
name="studentActivity"> <complexType> <sequence>
<element name="studentID"
type="normalizedString"/>
<element name="activity" type="normalizedString"/>
<!--<element name="studentID"
type="IDREF"/> -->
</sequence> </complexType> </element> <element
name="activity"> <complexType> <sequence>
<choice>
<element name="name" type="normalizedString"/>
<element name="desc" type="normalizedString"/>
</choice>
<element name="fee" type="decimal"/>
</sequence> </complexType> </element> <element
name="studentActivities"> <complexType> <sequence> <element
ref="act:studentActivity" maxOccurs="unbounded"/>
<element name="activities">
<complexType>
<sequence>
<element ref="act:activity"
maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</sequence> </complexType> <keyref
name="krActivity" refer="act:kActivity"> <selector
xpath="act:studentActivity"/> <field
xpath="act:activity"/> </keyref> <key
name="kActivity"> <selector
xpath="act:activities/act:activity"/> <field
xpath="act:name|act:desc"/> </key> </element> </schema> instance <?xml
version="1.0" encoding="UTF-8"?> <!--
edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com)
by James L. Blunt (Landmark Graphics Corp.) --> <studentActivities
xmlns="http://www.exampleU.com/activity"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exampleU.com/activity student3.xsd"> <studentActivity>
<studentID>sn42</studentID>
<activity>Swimming</activity> </studentActivity> <studentActivity>
<studentID>sn44</studentID>
<activity>Polo</activity> </studentActivity> <studentActivity>
<studentID>sn49</studentID>
<activity>Swimming</activity> </studentActivity> <studentActivity>
<studentID>sn11</studentID>
<activity>Swimming</activity> </studentActivity> <studentActivity>
<studentID>sn43</studentID>
<activity>Bowling</activity> </studentActivity> <activities> <activity>
<!--<name>Swimming></name> --> <!-- if I
uncomment name -->
<desc>Swimming</desc>
<!-- and comment out desc -->
<fee>47.50</fee>
<!-- it works
--> </activity> <activity>
<name>Polo</name>
<!--<name>Swimming</name> -->
<fee>789.99</fee> </activity> <activity>
<name>Bowling</name>
<fee>38.50</fee> </activity> </activities> </studentActivities> Bill Riegel LandMark Graphics 713-839-3388 |
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
