0

I am using Saxon 9 in Java to compile XPath expressions like this:

net.sf.saxon.xpath.XPathEvaluator.compile(expression)

I am aware of the changes between XPath 1 and XPath 2, so I am not surprised that Saxon cannot evaluate expressions like position() = '1'.

However, is there a way to at least compile, not evaluate the expression?

It would be much easier and more robust to recursively detect and fix type incompatibilities like the one above in a compiled Expression object, than to rely on string operations and regex.

1
  • Firstly, you are using XPathEvaluator whereas you should be using XPathCompiler to compile. Secondly, certain things can be compiled and certain things not, there is no fix-all solution. Please specify what you are trying to compile and share your attempt(code you have written) Commented Mar 21 at 16:53

1 Answer 1

0

No, there is no supported/tested mechanism in Saxon to invoke XPath parsing without also invoking type checking. However, it's open source code so you could work out what internal interfaces you could call to achieve this effect. The class XPathParser and its key methods like parse() are public.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.