[core] Fix XPath 2.0 Rule Chain Analyzer
For the XPath expression (//ForStatement | //WhileStatement | //DoStatement)//AssignmentOperator we threw away "AssignmentOperator" and started visiting at this node. But that's not possible, because that's not at the root of the expr.
This commit is contained in:
1 parent
ca0f6535a4
commit
4e0e2d14ba
2 files changed
+11
-5
No files matched your search
+4
-5
@@ -66,17 +66,16 @@ public class RuleChainAnalyzer extends SaxonExprVisitor {
|
||||
if (rootElement != null && !rootElementReplaced) {
|
||||
if (result instanceof PathExpression) {
|
||||
PathExpression newPath = (PathExpression) result;
|
||||
if (newPath.getStepExpression() instanceof FilterExpression) {
|
||||
Expression step = newPath.getStepExpression();
|
||||
if (step instanceof FilterExpression) {
|
||||
FilterExpression filterExpression = (FilterExpression) newPath.getStepExpression();
|
||||
result = new FilterExpression(new AxisExpression(Axis.SELF, null), filterExpression.getFilter());
|
||||
rootElementReplaced = true;
|
||||
} else if (newPath.getStepExpression() instanceof AxisExpression) {
|
||||
} else if (step instanceof AxisExpression) {
|
||||
if (newPath.getStartExpression() instanceof RootExpression) {
|
||||
result = new AxisExpression(Axis.SELF, null);
|
||||
} else {
|
||||
result = new PathExpression(newPath.getStartExpression(), new AxisExpression(Axis.SELF, null));
|
||||
rootElementReplaced = true;
|
||||
}
|
||||
rootElementReplaced = true;
|
||||
}
|
||||
} else {
|
||||
result = new AxisExpression(Axis.DESCENDANT_OR_SELF, null);
|
||||
|
||||
+7
@@ -195,4 +195,11 @@ public class SaxonXPathRuleQueryTest {
|
||||
query.setXPath(xpath);
|
||||
return query;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ruleChainWithUnions() {
|
||||
SaxonXPathRuleQuery query = createQuery("(//ForStatement | //WhileStatement | //DoStatement)//AssignmentOperator");
|
||||
List<String> ruleChainVisits = query.getRuleChainVisits();
|
||||
Assert.assertEquals(0, ruleChainVisits.size());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user