Closed bertrand-lorentz closed 1 year ago
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 PSXPathValidationHandlerSVRL._getPathToNode
- correct?
Thanks for the quick response.
I assume you refer to the usage in
PSXPathValidationHandlerSVRL._getPathToNode
- correct?
Yes, it's that method that lead me to XMLHelper.getPathToNode2
.
Please note I was only looking at the code, I haven't traced or debugged it. But after finding the unit test, I thought it best to file this issue.
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 hth
Excellent, I just confirmed that the issue is fixed with ph-schematron 6.3.4. Thanks !
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.