- From: <richard.liu@ubs.com>
- Date: Wed, 15 Feb 2006 15:13:39 +0100
- To: <xmlschema-dev@w3.org>
I have the following schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.ubs.com/namespace/wbml-render" xmlns:wbr="http://www.ubs.com/namespace/wbml-render" xmlns="http://www.ubs.com/namespace/wbml-render" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="footnoteExplanation"> <xs:annotation> <xs:documentation>The text explaining the footnote.</xs:documentation> </xs:annotation> <xs:simpleContent> <xs:extension base="xs:string"/> </xs:simpleContent> </xs:complexType> <xs:complexType name="footnote"> <xs:annotation> <xs:documentation>Composed of base and explanation.</xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="footnoteBase" type="footnoteBase"/> <xs:element name="footnoteExplanation" type="footnoteExplanation" minOccurs="0"/> </xs:sequence> <xs:attribute name="footnoteId" type="xs:NMTOKEN" use="optional"/> <xs:attribute name="footnoteRef" type="xs:NMTOKEN" use="optional"/> </xs:complexType> <xs:complexType name="footnoteBase" mixed="true"> <xs:annotation> <xs:documentation>The text to which the footnote pertains.</xs:documentation> </xs:annotation> <xs:sequence> <xs:element ref="footnote" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:element name="footnote" type="footnote"> <!--<xs:key name="ref_or_explanation"> <xs:selector xpath="."/> <xs:field xpath="wbr:footnoteExplanation | @footnoteRef"/> </xs:key>--> </xs:element> <xs:element name="para"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="footnote" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:key name="ref_or_explanation"> <xs:selector xpath=".//wbr:footnote"/> <xs:field xpath="wbr:footnoteExplanation | @footnoteRef"/> </xs:key> </xs:element> </xs:schema> and the following XML schema instance <?xml version="1.0" encoding="UTF-8"?> <wbr:para xmlns:wbr="http://www.ubs.com/namespace/wbml-render" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ubs.com/namespace/wbml-render file:/Users/richard/Documents/Work/Accessibility/Schemas/test_footnote.x sd"> Now is <wbr:footnote footnoteRef="abc"> <wbr:footnoteBase>the</wbr:footnoteBase> <!--<wbr:footnoteExplanation>As Clinton said, "It depends on what you mean by 'the'."</wbr:footnoteExplanation>--> </wbr:footnote> for <wbr:footnote> <wbr:footnoteBase> <wbr:footnote> <wbr:footnoteBase> <wbr:footnote footnoteRef="x22"> <wbr:footnoteBase>all</wbr:footnoteBase> </wbr:footnote> good </wbr:footnoteBase> <wbr:footnoteExplanation>In some inner sense.</wbr:footnoteExplanation> </wbr:footnote> men </wbr:footnoteBase> <wbr:footnoteExplanation>Good women, too.</wbr:footnoteExplanation> </wbr:footnote> </wbr:para> The xs:key on the para element is supposed to ensure that each footnote descendant has either a footnoteExplanation child or a footnoteRef attribute. The first footnote child of para "works" as desired (in Oxygen 7, i.e., Xerces): Uncommenting the footnoteExplanation element results in an error, as does deleting the footnoteRef attribute. The second footnote element is rather complicated, because the model permits "nesting" footnotes. The XML seems valid: The second footnote element has a footnoteExplanation and no footnoteRef, so does its first footnote descendent, and the innermost footnote has a footnoteRef attribute and no footnoteExplanation. Nevertheless, I receive the following two error messages (I've pasted the offending statement after the Location): SystemID: /Users/richard/Documents/Work/Accessibility/Schemas/test_footnote.xml Location: 18:88 <wbr:footnoteExplanation>In some inner sense.</wbr:footnoteExplanation> Description: E Identity constraint error: field "./wbr:footnoteExplanation|@footnoteRef" matches more than one value within the scope of its selector; fields must match unique values. SystemID: /Users/richard/Documents/Work/Accessibility/Schemas/test_footnote.xml Location: 21:76 <wbr:footnoteExplanation>Good women, too.</wbr:footnoteExplanation> Description: E Identity constraint error: field "./wbr:footnoteExplanation|@footnoteRef" matches more than one value within the scope of its selector; fields must match unique values. Can anybody tell me what I'm missing? Thanks, Richard
Received on Wednesday, 15 February 2006 14:13:56 UTC