Re: xs:key and nesting

Looking over the already recorded issues it seems that this is a 
manifestation of the
https://issues.apache.org/jira/browse/XERCESJ-832

A workaround is to replace

<xs:field xpath="wbr:footnoteExplanation | @footnoteRef"/>

with

<xs:field xpath="@footnoteRef | wbr:footnoteExplanation"/>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


George Cristian Bina wrote:
> The problem appears also with the latest SVN snapshot. I will report 
> that on Apache Jira as soon as that will be available, now I get 
> "Service Temporarily Unavailable" when trying to access Apache Jira.
> 
> Best Regards,
> George
> ---------------------------------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
> 
> 
> George Cristian Bina wrote:
>> Hi Richard,
>>
>> This looks to me like a bug in Xerces 2.7.1.
>> I will check that against the current Xerces SVN snapshot to see if it 
>> shows the same problem and let you know.
>>
>> Best Regards,
>> George
>> ---------------------------------------------------------------------
>> George Cristian Bina
>> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>>
>> richard.liu@ubs.com wrote:
>>> 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 Friday, 17 February 2006 08:34:37 UTC