James M Snell
Fri, 12 Oct 2007 08:01:20 -0700
As with all of the core interfaces, XPath is designed to theoretically allow the underlying implementation to be replaced. I say theoretically because in many cases it would be exceedingly difficult to actually do such a replacement. The XPath component happens to be one of the easier bits. We currently use Jaxen for two reasons: one, that's what Axiom used and two, Jaxen provides a way of evaluating the xpath by navigating through the Axiom/FOM object structure; this means that the xpath evaluation works well with the parser implementation. However, if you did want to provide an alternative XPath, all you need to do is implement the XPath interface then:
a) launch the jvm with the option
-Dorg.apache.abdera.xpath.XPath=myImpl
*OR*
b) add a file called abdera.properties to your classpath and add
org.apache.abdera.xpath.XPath=myImpl
*OR*
c) add a file to the classpath classpath at:
/META-INF/services/org.apache.abdera.xpath.XPath where the
content of the file is the classname or your impl.
Each of these options provide various benefits. Option A is often good
for debugging if you want to test a new implementation without having to
change the configuration. Option B is good if you have multiple
implementations available in your classpath. Option C is the easiest
because you can usually add the file to the jar and simply drop the jar
into your classpath to automatically register it.
- James
Kiran Subbaraman wrote:
> Can I use any other classlibrary, instead of Jaxen, for XPath support?
> My observations:
> I should add this param: "org.apache.abdera.xpath.XPath" with the value:
> toMyXPathImpl, into my web.xml or anywhere else?
> The default value is "org.apache.abdera.parser.stax.FOMXPath"
> I got this information from:
> http://svn.apache.org/repos/asf/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java
>
> Am I on the right path? Thank you for your help
> Kiran
>