You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2006/02/27 08:37:41 UTC
[jira] Resolved: (XERCESJ-1137) XPath correction applied only on
the first Path in Field.XPath class
[ http://issues.apache.org/jira/browse/XERCESJ-1137?page=all ]
Michael Glavassevich resolved XERCESJ-1137:
-------------------------------------------
Fix Version: 2.8.0
Resolution: Fixed
I've checked a fix into SVN. Now all XPath expressions in a union are fixed up.
> XPath correction applied only on the first Path in Field.XPath class
> --------------------------------------------------------------------
>
> Key: XERCESJ-1137
> URL: http://issues.apache.org/jira/browse/XERCESJ-1137
> Project: Xerces2-J
> Type: Bug
> Components: XML Schema Structures
> Versions: 2.7.1
> Reporter: George Cristian Bina
> Assignee: Michael Glavassevich
> Fix For: 2.8.0
>
> In Field.java on the inner XPath class there is the following comment and code:
> // NOTE: We have to prefix the field XPath with "./" in
> // order to handle selectors such as "@attr" that
> // select the attribute because the fields could be
> // relative to the selector element. -Ac
> // Unless xpath starts with a descendant node -Achille Fokoue
> // ... or a / or a . - NG
> super(((xpath.trim().startsWith("/") ||xpath.trim().startsWith("."))?
> xpath:"./"+xpath),
> symbolTable, context);
> From this it is clear that the XPath Paths should be corrected to start with ./ if they do not start with . or / but only the first one is corrected.
> Thus an instance like:
> <?xml version="1.0" encoding="UTF-8"?>
> <test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
> <a>
> <id1>v1</id1>
> </a>
> <a>
> <id1>v2</id1>
> </a>
> </test>
> will be reported invalid against test.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="test">
> <xs:complexType>
> <xs:sequence maxOccurs="unbounded">
> <xs:element ref="a"/>
> </xs:sequence>
> </xs:complexType>
> <xs:key name="aID">
> <xs:selector xpath=".//a"/>
> <xs:field xpath="./@id1|./@id2|id1|./id2"/>
> </xs:key>
> </xs:element>
> <xs:element name="a">
> <xs:complexType>
> <xs:choice minOccurs="0" maxOccurs="unbounded">
> <xs:element ref="a"/>
> <xs:element ref="id1"/>
> <xs:element ref="id2"/>
> </xs:choice>
> <xs:attribute name="id1" use="optional"/>
> <xs:attribute name="id2" use="optional"/>
> </xs:complexType>
> </xs:element>
> <xs:element name="id1" type="xs:string"/>
> <xs:element name="id2" type="xs:string"/>
> </xs:schema>
> Replacing:
> <xs:field xpath="./@id1|./@id2|id1|./id2"/>
> with
> <xs:field xpath="./@id1|./@id2|./id1|./id2"/>\
> makes Xerces report that the schema is valid.
> Regards,
> George
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org