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)
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.
如果您在xpath中有[]的动作,则它正在搜索外部xpath引擎。.您必须下载saxonb9-0-0-4j&xmlbeans-xpath-2.4.0.jar并将其添加到类路径中
您需要在类路径中使用一个XPath引擎,该引擎依赖于XMLBeans版本,请参见http://wiki.apache.org/xmlbeans/XmlBeansFaq#whatJars
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.