Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-561

XPath support for namespace prefix to URI mappings

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Version 5.0.0
    • None
    • XPath
    • None

    Description

      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)
      ```
       

      Attachments

        Activity

          People

            Unassigned Unassigned
            laguvard Dimitrios Lagkouvardos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: