Reputation: 3399
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)
Upvotes: 2
Views: 7760
Reputation: 11
worked for me:
<dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>4.0.0</version> </dependency> <dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>10.6</version> </dependency> <dependency> <groupId>org.dom4j</groupId> <artifactId>dom4j</artifactId> <version>2.1.3</version> </dependency>
Upvotes: 1
Reputation: 21
The movement if you have [] in your xpath, it is searching for the external xpath enginer.. you have to download saxonb9-0-0-4j & xmlbeans-xpath-2.4.0.jar and add to the classpath
Upvotes: 2
Reputation: 31
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.
Upvotes: 3
Reputation: 711
You need an XPath engine in your classpath, which one bepends on the XMLBeans version, see http://wiki.apache.org/xmlbeans/XmlBeansFaq#whatJars
Upvotes: 2