Make the evaluation of variables declared in more consistent with the Schematron ISO spec and other implementation.
During bind(), store the variables as members of the bound item they are defined in: schema, pattern and rule. The variables declared in a phase are stored in the schema, as it is already bound to the phase. Each set of variables is stored as map of name to compiled XPath expression.
During validate(), for each item we evaluate the corresponding variables in the appropriate context, and store the result in a LetVariableResolver instance.
This instance is set as the XPathVariableResolver, so a variable value will be resolved when executing an XPath that references the variable.
This fixes issue #143, so enable the corresponding unit test. This also resolves issue #88, so fix the corresponding unit test, as it was checking for the current behaviour, which is not correct.
Note
The way the type of the variable value is handled in _evaluateVariables is not really nice, it just tries each possibility. Suggestions on how to improve this are welcome !
I haven't looked into _validateParallel(), so there are probably changes required there to align it with _validateSerial()
I've tried to follow the coding style guidelines, but I've probably missed some things. Feel free to correct them (or any other problem you see).
Thanks @bertrand-lorentz for the PR - highly appreciated!!
I created a new branch "v8" as this is a backwards-incompatible change and I will look at it in more details
Make the evaluation of variables declared in more consistent with the Schematron ISO spec and other implementation.
During bind(), store the variables as members of the bound item they are defined in: schema, pattern and rule. The variables declared in a phase are stored in the schema, as it is already bound to the phase. Each set of variables is stored as map of name to compiled XPath expression.
During validate(), for each item we evaluate the corresponding variables in the appropriate context, and store the result in a LetVariableResolver instance. This instance is set as the XPathVariableResolver, so a variable value will be resolved when executing an XPath that references the variable.
This fixes issue #143, so enable the corresponding unit test. This also resolves issue #88, so fix the corresponding unit test, as it was checking for the current behaviour, which is not correct.
Note
_evaluateVariables
is not really nice, it just tries each possibility. Suggestions on how to improve this are welcome !