-
Notifications
You must be signed in to change notification settings - Fork 18
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
XMLHelper.getPathToNode returns incorrect position number #31
Comments
Hi @bertrand-lorentz thanks for pointing that out. This is indeed an issue. That is of course an issue. I will investigate that further and see how to resolve this as backwards compatible as possible. I assume you refer to the usage in |
Thanks for the quick response.
Yes, it's that method that lead me to |
I heavily increased the "path to node" functionality to also handle attributes and namespaces etc. This is part of the 10.2.2 release |
@bertrand-lorentz I created a new ph-schematron release 6.3.4 for this: https://github.com/phax/ph-schematron/releases/tag/ph-schematron-parent-pom-6.3.4 |
Excellent, I just confirmed that the issue is fixed with ph-schematron 6.3.4. |
In
XMLHelper.getPathToNode
, if a node that is part of the path has one or more siblings with the same name, the path returned indicates the position of the node :/a/b[2]/c
But the position number seems to be off by one. For example, if the node is the first sibling, the position will be 0.
But with XPath, position numbers start at 1
This is visible in the unit test at https://github.com/phax/ph-commons/blob/master/ph-xml/src/test/java/com/helger/xml/XMLHelperTest.java#L319
The node passed to XMLHelper.getPathToNode is the second occurrence of "e1" :
//e1[2]
But the location returned indicates it as
.../e1[1]
This also affects
XMLHelper.getPathToNode2
, and this in turn affects ph-schematron in pure mode: the location attribute forfailed-assert
in SVRL validation reports is off by one.If this is indeed an issue and not the intended behavior, I can submit a pull request to correct this.
The text was updated successfully, but these errors were encountered: