Closed bertrand-lorentz closed 1 month ago
Thanks a lot - integrated and will be part of the next 8.0.2 release :)
The change in the commit doesn't look right:
I think ((ForExpression) expr).getItemType ()
returns the type of a single item returned by the for expression, but in general a for expression returns a sequence of such items.
Because of this, in the unit test, $forVar evaluates to "c2". The correct value would be the list ("c2", "c3"). The test in the assert is not specific enough to catch this (my bad).
Okay, so you are proposing, that this will be mapped to the "Nodeset" type than???
Based on what I've seen, mapping ForExpression to NODESET might indeed be the best approach: it seems to work regardless of the type of the items in the sequence returned by the expression: node, string, etc.
So be it :)
Following the changes in issue #170, I've noticed that a variable defined with a for expression causes a warning.
For example, with the same xml used in the unit test for issue #170:
The warning is:
WARN com.helger.schematron.pure.xpath.XPathEvaluationHelper$SaxonEvaluator - Unknown Saxon expression type: net.sf.saxon.expr.ForExpression
The schematron still works, and the assert does not cause any failure (as expected), because after
XPathEvaluationHelper.evaluateWithTypeAutodetect
fails and produces the warning, thenXPathEvaluationHelper.evaluateAsNodeList
works and returns a node list.So this is not really a problem, but I thought it might be useful to report it anyways, for the completeness of the type autodetection magic. 😃