jruillier
jruillier

Reputation: 385

How to enable Saxon xpath expression caching?

How to enable Saxon xpath expression caching from net.sf.saxon.xpath.XPathFactoryImpl ?

In the documentation, the XPathCompiler is mentioned, but how can I get access to it ?

I'm using

    <dependency>
        <groupId>net.sf.saxon</groupId>
        <artifactId>Saxon-HE</artifactId>
        <version>9.6.0-7</version>
    </dependency>

Upvotes: 1

Views: 266

Answers (1)

Michael Kay
Michael Kay

Reputation: 163468

Automatic expression caching is not available in Saxon's implementation of the JAXP XPath API. You can of course implement it yourself as a layer on top. If you want to take advantage of automatic caching within Saxon, you will need to use the s9api interface which is documented here:

http://www.saxonica.com/documentation/index.html#!xpath-api/s9api-xpath

I'd really recommend moving to the s9api interface - it's a better fit with the XPath 2.0/3.1 data model, it integrates better with other Saxon features like XSLT/XQuery/XSD processing, and it has much stronger type safety. In principle the JAXP interface is more portable, but that's a bit of an illusion because so many of the details are implementation-defined.

Note that version 9.6 is getting a bit elderly, and isn't up to date with the final XPath 3.1 recommendation. You should move to 9.8.

Upvotes: 2

Related Questions