Setting XPath Variables

An XPath expression supplied to the JAXP XPath API can contain undeclared variables, for example a valid expression might be //emp[@ssn=$SSN]. The value of the variable $SSN must be supplied by the calling application when the expression is evaluated. The mechanism for doing this is the VariableResolver: when Saxon encounters an undeclared variable like $SSN, it calls the user-supplied VariableResolver, which is expected to return the corresponding value.

The Java value returned by the VariableResolver is converted to an XDM value using the rules described at Converting Java values to XDM values.