XML Rules in 7.0.0 #4880
-
Hi all, While working on the Salesforce metadata module, I'm building some java rules in order to validate the approach (and add some basic rules to the module.) However, there is no Since
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @justinstroudbah , there is indeed no visitor or something like that. So far, we only have written XPath based rules, we didn't have a need yet to write Java rule. But the entry point for Java-based rules is:
We probably didn't write a visitor, because there are not really different node types - there is only one possible node type, and that is XmlNode... so, we would have a visitor with a single visit method... Of course, you now need to traverse the tree yourself (using children(), descendants(), ancestors(), etc.) If a visitor is really needed, we can of course add it. The visit method would then visit all nodes... |
Beta Was this translation helpful? Give feedback.
Hi @justinstroudbah ,
there is indeed no visitor or something like that. So far, we only have written XPath based rules, we didn't have a need yet to write Java rule.
But the entry point for Java-based rules is:
net.sourceforge.pmd.lang.xml.rule.AbstractXmlRule
void apply(Node target, RuleContext ctx)
net.sourceforge.pmd.lang.xml.ast.XmlNode
.We probably didn't write a visitor, because there are not really different node types - there is only one possible node type, and that is XmlNode... so, we would hav…