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.