简体   繁体   中英

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. Recently I tried to use the TPTP profiler in Eclipse but it could not find the XPathAPI class.

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? Or what??

(I'm currently using JRE 1.5.0_06 for this project)

All classes under the com.sun package are internal implementation details. You should never reference them directly.

The base for xPath in the JDK is javax.xml.xpath .

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

Use the XPathFactory.newInstance() method in the javax.xml.path package.

I think this was introduced in 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)

If performance is any sort of issue, whatever you do, don't use Xalan for this. The Xalan XPathAPI interface is very slow. We wrap Jaxen to provide an XPathAPI-like interface. That is vastly quicker.

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

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.

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