tags:

views:

571

answers:

2

I inherited some code that is using XPath for which I am a novice. I have it now so that it loads the document, but when the document.selectPath(queryPath) it always fails with the following error:

java.lang.RuntimeException:  Trying XBeans path engine... Trying XQRL... Trying delegated path engine... FAILED on //
        at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:173)
        at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:130)
        at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:902)
        at org.apache.xmlbeans.impl.store.Cursor.selectPath(Cursor.java:2634)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:462)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:446)

A: 

You need an XPath engine in your classpath, which one bepends on the XMLBeans version, see http://wiki.apache.org/xmlbeans/XmlBeansFaq#whatJars

jor
This was on a project I inherited, so I assumed they had it all set up right. Turns our I had the right xbeans jar in my classpath but the wrong saxon jar, or at least wrong versions of the 2. i redownloaded both and now am all set.
Adam Lerman
A: 

Thank you jor for the post. I was confused as earlier commands to xml beans were successful.

Without saxon, this still works:

MapDocument doc; ... String cityQuery = "$this//City"; XmlObject[] cities = doc.selectPath(cityQuery);

However saxon is required for explicit selection of fields within tags:

String aveQuery= "$this//Street[Kind='Avenue']"; XmlObject[] avenues = doc.selectPath(aveQuery); // RuntimeException without saxon on path

java.lang.RuntimeException: Trying XBeans path engine... Trying XQRL... Trying delegated path engine... FAILED on $this//Street[Kind='Avenue']

I hope this might be of use to others that encounter a similar issue.