Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve variable handling in pure mode #164

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

bertrand-lorentz
Copy link
Contributor

@bertrand-lorentz bertrand-lorentz commented Feb 14, 2024

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).

Make the evaluation of variables declared in <let> 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 phax#143, so enable the corresponding unit test.
This also resolves issue phax#88, so fix the corresponding unit test, as it
was checking for the current behaviour, which is not correct.
@phax phax self-assigned this Feb 14, 2024
@phax phax changed the base branch from master to v8 February 14, 2024 19:48
@phax
Copy link
Owner

phax commented Feb 14, 2024

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

@phax phax merged commit 02ab815 into phax:v8 Feb 14, 2024
3 checks passed
@bertrand-lorentz bertrand-lorentz deleted the improve-variable-handling branch February 15, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants