I'm interested in using the saxon:evaluate in an XQuery (using the Oxygen XML Editor 24.0) and wanted to see it working in a very simple example using XPath 3.1 type expression so I can select a value from a parsed JSON object (using Saxon-EE XQuery 9.9). However in doing so I get an error returned reporting Static error in XPath expression supplied to saxon:evaluate: The XPath parser is not configured to allow use of XPath 3.1 syntax?
I tried the below:
let $rawJ :=
<jroot><![CDATA[
{
"siam_envelope":
{
"protocol_version": "1"
}
}]]>
</jroot>
let $j := parse-json($rawJ)
let $expression := "$p1?siam_envelope?protocol_version"
let $result := saxon:evaluate($expression, $j)
return $result
I expected this to return the value "1" but instead it reported the "Static error in XPath expression supplied to saxon:evaluate: The XPath parser is not configured to allow use of XPath 3.1 syntax"
Presumably, this is because I'm using a map type XPath which is only supported in XPath 3.1. However, since the error reports "not configured" then I'm holding some hope that there's some configuration I can apply to get this working? If not, does anyone in this community know how to run a dynamic XPath 3.1 type expression in XQuery? Surely this must be possible?
Thanks in advance for any useful suggestions!
Without using Saxon specific extensions, you can use
fn:transform
withxsl:evaluate
:That should work with any XQuery 3.1 implementation supporting
fn:transform
andxsl:evaluate
, so in the case of Saxon for HE that means 10 or later or for PE or EE I think 9.8 or later.