phax / ph-schematron

Java Schematron library that supports XSLT and native application
Apache License 2.0
110 stars 36 forks source link

Improve variable handling in pure mode #164

Closed bertrand-lorentz closed 7 months ago

bertrand-lorentz commented 7 months ago

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

phax commented 7 months ago

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