[jira] [Created] (XMLBEANS-561) XPath support for namespace prefix to URI mappings

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (XMLBEANS-561) XPath support for namespace prefix to URI mappings

PJ Fanning (Jira)
Dimitrios Lagkouvardos created XMLBEANS-561:
-----------------------------------------------

             Summary: 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


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: [hidden email]
For additional commands, e-mail: [hidden email]