diff --git a/pmd/xdocs/howtowritearule.xml b/pmd/xdocs/howtowritearule.xml index 2d7a180c6f..247a744a3b 100644 --- a/pmd/xdocs/howtowritearule.xml +++ b/pmd/xdocs/howtowritearule.xml @@ -270,13 +270,26 @@ public class WhileLoopsMustUseBracesRule extends AbstractRule {

-

Recently Dan Sheppard integrated an XPath engine into PMD, so now you can write rules as +

Recently Daniel Sheppard integrated an XPath engine into PMD, so now you can write rules as XPath expressions. For example, the XPath expression for our WhileLoopsMustUseBracesRule looks like this:

//WhileStatement[not(Statement/Block)]

Concise, eh? Here's an article with a lot more detail.

-

>Note that access modifiers are held as attributes, so, for example, +

Note that for XPath rules you'll need to set the + class attribute in the rule definition to net.sourceforge.pmd.rules.XPathRule. Like this: + + + + etc., etc. + ]]> + + +

+

Note that access modifiers are held as attributes, so, for example, //FieldDeclaration[@Private='true'] finds all private fields. You can see the code that determines all the attributes here