Improve variable handling in pure mode #164
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 !