[
https://issues.apache.org/jira/browse/XERCESJ-1601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13558163#comment-13558163
]
Mukul Gandhi commented on XERCESJ-1601:
---------------------------------------
@ Octavian:
few personal opinions, please.
I've tried to understand the XSD spec for IDC constraints and have come to
following conclusions as of now,
1) I'm still not able to determine, if the XSD spec allows the use case you've
mentioned (originally mentioned in the xmlschema-dev thread you've cited). I'll
continue my reading.
The use case you've mentioned may probably be allowed (as has been said also by
Henry T on xmlschema-dev thread). If yes, then we've a bug.
For the interest of readers, here are references to older xmlschema-dev
discussions about this topic:
http://lists.w3.org/Archives/Public/xmlschema-dev/2001Jun/0184.html
http://lists.w3.org/Archives/Public/xmlschema-dev/2001Nov/0034.html
http://lists.w3.org/Archives/Public/xmlschema-dev/2005Sep/0056.html
2) I'm attaching few IDC "keyref" examples. The following validations work fine
with current Xerces implementation,
(i) keyref1.xml, keyref1_1.xsd
(ii) keyref1.xml, keyref1_2.xsd
(iii) keyref2.xml, keyref2.xsd
My reading of the spec makes me feel, that these use cases are allowed by the
spec. This is to say, that we've a pretty good coverage of IDC "keyref" use
cases.
I've a feeling that the Xerces team was aware of this issue long ago. But this
feature is currently not available perhaps because: 1) it'll break the
streaming nature of IDC implementation 2) the spec is not very clear wrt this,
and Xerces has treated it as implementation dependent.
Thanks.
> Keyref to a key in a different scope
> ------------------------------------
>
> Key: XERCESJ-1601
> URL: https://issues.apache.org/jira/browse/XERCESJ-1601
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.1 Structures
> Affects Versions: 2.11.0
> Reporter: Octavian Nadolu
> Priority: Minor
> Attachments: keyref1_1.xsd, keyref1_2.xsd, keyref1.xml, keyref2.xml,
> keyref2.xsd
>
>
> If I validate the "instance.xml" with the XML Schema "test.xsd" I get the
> following error:
> cvc-identity-constraint.4.3: Key 'kr' with value 'a2' not found for identity
> constraint of element 'parent'.
> I tested on the xml-schema-1.1-dev branch.
> Xerces discards all the key defined on "child" elements except the ones
> defined on the last "child" element. In the example only the "a1" and "a4"
> values are used when the keyref is checked.
> The schema added below defines a key on the "child" element selecting the
> "element/@id" attribute and a key reference on the "parent" element that
> specifies that "test/@ref" points to "child/element/@id" attributes.
> All the keys defined in the "child" elements should be valid, except the ones
> that are duplicates. There is a discussion about this on the XML Schema Dev
> list:
> http://lists.w3.org/Archives/Public/xmlschema-dev/2013Jan/0004.html
> ---- instance.xml------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <parent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="test.xsd">
> <child>
> <element id="a1"/>
> <element id="a2"/>
> </child>
> <child>
> <element id="a1"/>
> <element id="a4"/>
> </child>
> <test ref="a2"/>
> <test ref="a1"/>
> </parent>
> -------------------
> ------------test.xsd---------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
> <xs:element name="parent">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="child" maxOccurs="unbounded">
> <xs:complexType>
> <xs:sequence maxOccurs="unbounded">
> <xs:element name="element">
> <xs:complexType>
> <xs:attribute name="id" use="required"/>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> <xs:key name="k">
> <xs:selector xpath="element"/>
> <xs:field xpath="@id"/>
> </xs:key>
> </xs:element>
> <xs:element name="test" maxOccurs="unbounded">
> <xs:complexType>
> <xs:attribute name="ref"/>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> <xs:keyref name="kr" refer="k">
> <xs:selector xpath="test"/>
> <xs:field xpath="@ref"/>
> </xs:keyref>
> </xs:element>
> </xs:schema>
> ----------------------------------
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]