[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] FW: having problems with the "|" in field's element in the xs
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 -----Original Message----- From: Bob Foster [mailto:bob@o...] Sent: Wednesday, May 21, 2003 8:38 PM To: Jeff Lowery; xml-dev@l... Subject: Re: having problems with the "|" in field's element in the xs:key el ement From: Jeff Lowery >I'm not sure either one is doing a complete job of validating the schema. >While XSV is the most correct, it doesn't complain if you remove either >act:name or act:desc from the key's field XPath (neither does SQC). >It would seem that it should, since both fields are in a choice model >group, and if the one in the key field is missing XSV will throw a >document validation error. XSV doesn't complain if you remove, say, the act:desc alternative from the key field xpath, provided act:desc is never used in an activity instance. However, if act:desc is used in an instance instead of act:name, it complains "missing one or more fields...from key". This seems right. The validation rule in 3.11.4 para 4.2 only requires that all actual elements have unique keys. I don't see anything that requires a processor to warn that some otherwise valid instance might have a missing key. Bob ----------------------------------------------------------------- The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org> The list archives are at http://lists.xml.org/archives/xml-dev/ To subscribe or unsubscribe from this list use the subscription manager: <http://lists.xml.org/ob/adm.pl>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|