SaxonXPathRuleQuery extends AbstractXPathRuleQuery { @Override public List<String> getRuleChainVisits() { initializeXPathExpression(); return super.getRuleChainVisits(); } @Deprecated  SaxonXPathRuleQuery();  SaxonXPathRuleQuery(DeprecatedAttrLogger attrCtx); @Override boolean isSupportedVersion(String version); @Override List<Node> evaluate(final Node node, final RuleContext data); static AtomicValue getAtomicRepresentation(final Object value); static Value getSequenceRepresentation(List<?> list); @Override List<String> getRuleChainVisits(); static NamePool getNamePool();  }
@Test public void ruleChainVisits() { SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(2, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertTrue(ruleChainVisits.contains("bar")); Assert.assertEquals(3, query.nodeNameToXPaths.size()); assertExpression("((self::node()[QuantifiedExpression(Atomizer(attribute::attribute(Image, xs:anyAtomicType)), ($qq:qq106374177 singleton eq \"baz\"))])/child::element(foo, xs:anyType))", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("(self::node()[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq609962972 singleton eq false()))])", query.nodeNameToXPaths.get("dummyNode").get(1)); assertExpression("self::node()", query.nodeNameToXPaths.get("dummyNode").get(2)); assertExpression("(self::node()[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq232307208 singleton eq \"true\"))])", query.nodeNameToXPaths.get("bar").get(0)); assertExpression("(((DocumentSorter(((((/)/descendant::element(dummyNode, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Image, xs:anyAtomicType)), ($qq:qq000 singleton eq \"baz\"))])/child::element(foo, xs:anyType))) | (((/)/descendant::element(bar, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq000 singleton eq \"true\"))])) | (((/)/descendant::element(dummyNode, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq000 singleton eq false()))])) | ((/)/descendant::element(dummyNode, xs:anyType)))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitsMultipleFilters() { SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(1, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertEquals(2, query.nodeNameToXPaths.size()); assertExpression("((self::node()[QuantifiedExpression(Atomizer(attribute::attribute(Test2, xs:anyAtomicType)), ($qq:qq1741979653 singleton eq true()))])[QuantifiedExpression(Atomizer(attribute::attribute(Test1, xs:anyAtomicType)), ($qq:qq1529060733 singleton eq false()))])", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("((((/)/descendant::element(dummyNode, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Test2, xs:anyAtomicType)), ($qq:qq1741979653 singleton eq true()))])[QuantifiedExpression(Atomizer(attribute::attribute(Test1, xs:anyAtomicType)), ($qq:qq1529060733 singleton eq false()))])", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitsCustomFunctions() { SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(1, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertEquals(2, query.nodeNameToXPaths.size()); assertExpression("(self::node()[pmd-dummy:typeIs(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer(attribute::attribute(Image, xs:anyAtomicType))))))])", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("DocumentSorter((((/)/descendant-or-self::node())/(child::element(dummyNode, xs:anyType)[pmd-dummy:typeIs(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer(attribute::attribute(Image, xs:anyAtomicType))))))])))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitsUnboundedPathExpressions() { SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(0, ruleChainVisits.size()); Assert.assertEquals(1, query.nodeNameToXPaths.size()); assertExpression("LetExpression(LazyExpression(((/)/descendant::element(ClassOrInterfaceType, xs:anyType))), (((/)/descendant::element(dummyNode, xs:anyType))[$zz:zz771775563]))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); query = createQuery(" ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(0, ruleChainVisits.size()); Assert.assertEquals(1, query.nodeNameToXPaths.size()); assertExpression("LetExpression(LazyExpression(((/)/descendant::element(ClassOrInterfaceType, xs:anyType))), (((/)/descendant::element(dummyNode, xs:anyType))[(ancestor::element(ClassOrInterfaceDeclaration, xs:anyType)[$zz:zz106374177])]))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); query = createQuery(" ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(0, ruleChainVisits.size()); Assert.assertEquals(1, query.nodeNameToXPaths.size()); assertExpression("LetExpression(LazyExpression((((/)/descendant::element(ClassOrInterfaceType, xs:anyType)) or ((/)/descendant::element(OtherNode, xs:anyType)))), (((/)/descendant::element(dummyNode, xs:anyType))[$zz:zz1364913072]))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitsNested() { SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(1, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertEquals(2, query.nodeNameToXPaths.size()); assertExpression("((((self::node()/child::element(foo, xs:anyType))/child::element())/child::element(bar, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Test, xs:anyAtomicType)), ($qq:qq166794956 singleton eq \"false\"))])", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("DocumentSorter(((((((/)/descendant::element(dummyNode, xs:anyType))/child::element(foo, xs:anyType))/child::element())/child::element(bar, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Test, xs:anyAtomicType)), ($qq:qq166794956 singleton eq \"false\"))]))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitsNested2() { SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(1, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertEquals(2, query.nodeNameToXPaths.size()); assertExpression("(((((self::node()/child::element(foo, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Baz, xs:anyAtomicType)), ($qq:qq306612792 singleton eq \"a\"))])/child::element())/child::element(bar, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Test, xs:anyAtomicType)), ($qq:qq1803669141 singleton eq \"false\"))])", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("DocumentSorter((((((((/)/descendant::element(dummyNode, xs:anyType))/child::element(foo, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Baz, xs:anyAtomicType)), ($qq:qq306612792 singleton eq \"a\"))])/child::element())/child::element(bar, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Test, xs:anyAtomicType)), ($qq:qq1803669141 singleton eq \"false\"))]))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitWithVariable() { PropertyDescriptor<String> testClassPattern = PropertyFactory.stringProperty("testClassPattern").desc("test").defaultValue("a").build(); SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(1, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertEquals(2, query.nodeNameToXPaths.size()); assertExpression("LetExpression(LazyExpression(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer($testClassPattern))))), (self::node()[matches(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer(attribute::attribute(SimpleName, xs:anyAtomicType))))), $zz:zz952562199)]))", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("LetExpression(LazyExpression(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer($testClassPattern))))), (((/)/descendant::element(dummyNode, xs:anyType))[matches(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer(attribute::attribute(SimpleName, xs:anyAtomicType))))), $zz:zz952562199)]))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitWithVariable2() { PropertyDescriptor<String> testClassPattern = PropertyFactory.stringProperty("testClassPattern").desc("test").defaultValue("a").build(); SaxonXPathRuleQuery query = createQuery(" List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(1, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertEquals(2, query.nodeNameToXPaths.size()); assertExpression("(LetExpression(LazyExpression(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer($testClassPattern))))), (self::node()[matches(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer(attribute::attribute(SimpleName, xs:anyAtomicType))))), $zz:zz952562199)]))/child::element(foo, xs:anyType))", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("DocumentSorter((LetExpression(LazyExpression(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer($testClassPattern))))), (((/)/descendant::element(dummyNode, xs:anyType))[matches(CardinalityChecker(ItemChecker(UntypedAtomicConverter(Atomizer(attribute::attribute(SimpleName, xs:anyAtomicType))))), $zz:zz952562199)]))/child::element(foo, xs:anyType)))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainVisitsCompatibilityMode() { SaxonXPathRuleQuery query = createQuery(" query.setVersion(XPathRuleQuery.XPATH_1_0_COMPATIBILITY); List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(2, ruleChainVisits.size()); Assert.assertTrue(ruleChainVisits.contains("dummyNode")); Assert.assertTrue(ruleChainVisits.contains("bar")); Assert.assertEquals(3, query.nodeNameToXPaths.size()); assertExpression("((self::node()[QuantifiedExpression(Atomizer(attribute::attribute(Image, xs:anyAtomicType)), ($qq:qq6519275 singleton eq \"baz\"))])/child::element(foo, xs:anyType))", query.nodeNameToXPaths.get("dummyNode").get(0)); assertExpression("(self::node()[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq1529060733 singleton eq \"false\"))])", query.nodeNameToXPaths.get("dummyNode").get(1)); assertExpression("(self::node()[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq1484171695 singleton eq \"true\"))])", query.nodeNameToXPaths.get("bar").get(0)); assertExpression("((DocumentSorter(((((/)/descendant::element(dummyNode, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Image, xs:anyAtomicType)), ($qq:qq692331943 singleton eq \"baz\"))])/child::element(foo, xs:anyType))) | (((/)/descendant::element(bar, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq2127036371 singleton eq \"true\"))])) | (((/)/descendant::element(dummyNode, xs:anyType))[QuantifiedExpression(Atomizer(attribute::attribute(Public, xs:anyAtomicType)), ($qq:qq1529060733 singleton eq \"false\"))]))", query.nodeNameToXPaths.get(SaxonXPathRuleQuery.AST_ROOT).get(0)); }
@Test public void ruleChainWithUnions() { SaxonXPathRuleQuery query = createQuery("( List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(0, ruleChainVisits.size()); }
@Test public void ruleChainWithUnionsAndFilter() { SaxonXPathRuleQuery query = createQuery("( List<String> ruleChainVisits = query.getRuleChainVisits(); Assert.assertEquals(0, ruleChainVisits.size()); }