简体   繁体   English

我应该在Java 1.5中使用哪个XPathAPI?

[英]Which XPathAPI should I use in Java 1.5?

I have been using com.sun.org.apache.xpath.internal.XPathAPI for some time and it seems to work ok. 我已经使用com.sun.org.apache.xpath.internal.XPathAPI已有一段时间了,它似乎可以正常工作。 Recently I tried to use the TPTP profiler in Eclipse but it could not find the XPathAPI class. 最近,我尝试在Eclipse中使用TPTP探查器,但是找不到XPathAPI类。

I haven't figured this problem yet but it did make me wonder whether I should be using a class in an 'internal' package? 我还没有发现这个问题,但这确实让我怀疑我是否应该在“内部”包中使用一个类? Should I be using the Xalan library? 我应该使用Xalan库吗? Or what?? 要不然是啥??

(I'm currently using JRE 1.5.0_06 for this project) (我目前正在为此项目使用JRE 1.5.0_06)

All classes under the com.sun package are internal implementation details. com.sun软件包下的所有类都是内部实现细节。 You should never reference them directly. 您永远不要直接引用它们。

The base for xPath in the JDK is javax.xml.xpath . JDK中xPath的基础是javax.xml.xpath

我放入Xalan jar(2.7.0),并在导入中使用了org.apache.xpath.XPathAPI,弃用消息消失了。

Use the XPathFactory.newInstance() method in the javax.xml.path package. javax.xml.path包中使用XPathFactory.newInstance()方法。

I think this was introduced in Java 1.5. 我认为这是Java 1.5中引入的。 If you have to revert to Java 1.4 or earlier, I think you have to use the com.sun packages, which is never really a good idea (but sometimes unavoidable) 如果您必须恢复到Java 1.4或更早版本,我认为您必须使用com.sun软件包,这从来都不是一个好主意(但有时是不可避免的)

If performance is any sort of issue, whatever you do, don't use Xalan for this. 如果性能是任何问题,无论您做什么,都不要使用Xalan。 The Xalan XPathAPI interface is very slow. Xalan XPathAPI接口非常慢。 We wrap Jaxen to provide an XPathAPI-like interface. 我们包装Jaxen以提供类似XPathAPI的接口。 That is vastly quicker. 那要快得多。

我们使用jdom,但是apache commons始终是所有内容的不错选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM