2009-02-09 82 views
2

我继承了一些使用XPath的代码,因此我是新手。我现在以便它加载该文件有它,但是当document.selectPath(QueryPath中),它总是失败,出现以下错误: XPath无法找到引擎

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) 

回答

2

您需要一个XPath引擎在类路径,这对XMLBeans的版本一个bepends ,请参阅 http://wiki.apache.org/xmlbeans/XmlBeansFaq#whatJars

+0

这是我继承的一个项目,所以我认为他们已经设置好了。打开我们的我的classpath中有正确的xbeans jar,但是错误的saxon jar,或者至少错误版本的2.我redownloaded并且现在都集合了。 – 2009-02-21 16:30:15

2

谢谢你jor的职位。我很困惑,因为之前的命令xml bean成功了。

没有撒克逊人,这仍然有效:

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

但是需要撒克逊的领域的明确选择标签内:

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'] 

我希望这可能是用于遇到类似问题的其他人。

1

移动如果你在xpath中有[],它正在搜索外部xpath引擎..你必须下载saxonb9-0-0-4j & xmlbeans-xpath-2.4.0.jar并添加到classpath