[
https://issues.apache.org/jira/browse/XMLBEANS-561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17407617#comment-17407617
]
PJ Fanning commented on XMLBEANS-561:
-------------------------------------
Could you provide a test case for the xpath namespace declaration not working?
There are test cases that show that it does work at least in some cases - eg
https://github.com/apache/xmlbeans/blob/trunk/src/test/java/xmlcursor/checkin/GetDocChangeStampTest.java
> XPath support for namespace prefix to URI mappings
> --------------------------------------------------
>
> Key: XMLBEANS-561
> URL: https://issues.apache.org/jira/browse/XMLBEANS-561
> Project: XMLBeans
> Issue Type: Improvement
> Components: XPath
> Affects Versions: Version 5.0.0
> Reporter: Dimitrios Lagkouvardos
> Priority: Major
>
> 5.0.0 supports Saxon and an XmlBeans xpath engine. I don't see a way to
> configure or supply at runtime namespace prefix to URI mappings.
> *Suggestions*:
> 1) One solution is to enhance XmlObject.selectPath(String,XmlOptions) to use
> the namespaces returned by XmlOptions.getLoadAdditionalNamespaces (or perhaps
> add a new method if this is deemed inappropriate).
> 2) An alternative is to add an extension to retrieve the mappings to be
> passed to the xpath engine (instead of passing it on each call to selectPath).
> *Note*: Adding the namespace declaration to the xpath expression as
> documented in [http://xmlbeans.apache.org/guide/XPathXQuery.html] does NOT
> work:
> ```
> java.lang.RuntimeException: net.sf.saxon.trans.XPathException: Namespace
> prefix 'table' has not been declared
> at
> org.apache.xmlbeans.impl.xpath.saxon.SaxonXPath.selectNodes(SaxonXPath.java:128)
> at
> org.apache.xmlbeans.impl.xpath.saxon.SaxonXPath.selectPath(SaxonXPath.java:133)
> at
> org.apache.xmlbeans.impl.xpath.saxon.SaxonXPathEngine.next(SaxonXPathEngine.java:60)
> at org.apache.xmlbeans.impl.store.Cursor._toSelection(Cursor.java:749)
> at org.apache.xmlbeans.impl.store.Cursor._toNextSelection(Cursor.java:736)
> at org.apache.xmlbeans.impl.store.Cursor._hasNextSelection(Cursor.java:728)
> at org.apache.xmlbeans.impl.store.Cursor.syncWrapHelper(Cursor.java:2520)
> at org.apache.xmlbeans.impl.store.Cursor.syncWrap(Cursor.java:2451)
> at org.apache.xmlbeans.impl.store.Cursor.hasNextSelection(Cursor.java:2022)
> at
> org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:496)
> ```
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]