views:

901

answers:

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)

A: 

We use jdom but apache commons is always a good choice for everything.

Kai
+2  A: 

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.

Guillaume
+1  A: 

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)

Brian Agnew
Don't really see how that helps. XPathFactory.newInstance() does not get you a XPathAPI...
paul
XPathFactory.newInstance().newXPath() gives you an XPath.
jamesh
Yes, but my question was about whether or not to use the XPathAPI class. It doesn't answer the question at all IMHO
paul
"... use the com.sun packages, which is never really a good idea". So if you're on Java 1.5, then you should be using the javax.xml.xpath package and its component classes (one of which is XPathFactory)
Brian Agnew
+1  A: 

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.

Alohci
A: 

I dropped in the Xalan jar (2.7.0) and used org.apache.xpath.XPathAPI in the import and the deprecation messages went away.

Guy Argo