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

Variables are not evaluated in the order they are declared #177

Closed
bertrand-lorentz opened this issue Aug 1, 2024 · 1 comment · Fixed by #178
Closed

Variables are not evaluated in the order they are declared #177

bertrand-lorentz opened this issue Aug 1, 2024 · 1 comment · Fixed by #178

Comments

@bertrand-lorentz
Copy link
Contributor

With ph-schematron-pure 8.0.2, the following schematron will always cause a failed assert:

<let name="a" value="1"/>
<let name="a-plus-one" value="$a + 1"/>
<assert role="ERROR" test="$a-plus-one = 2">error message</assert>

I would expect the test to be always true.

After some debugging, it seems the declaration of a-plus-one is evaluated before the declaration of a.
So a-plus-one will then be equal to 1.

The current behavior is probably because the variables are stored in a sorted Map:
https://github.com/phax/ph-schematron/blob/master/ph-schematron-pure/src/main/java/com/helger/schematron/pure/binding/xpath/PSXPathVariables.java#L49

I guess using a Map that preserves insertion order would correct this.

@phax
Copy link
Owner

phax commented Aug 23, 2024

Part of the 8.0.3 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants