\ No newline at end of file
diff --git a/_includes/custom/series_customizing_next.html b/_includes/custom/series_customizing_next.html
new file mode 100644
index 0000000000..c18ca95c85
--- /dev/null
+++ b/_includes/custom/series_customizing_next.html
@@ -0,0 +1,10 @@
+
diff --git a/_posts/release_notes/2016-06-25-release-notes-5-5-0.md b/_posts/release_notes/2016-06-25-release-notes-5-5-0.md
index 6788ccc4d3..489487f4ad 100644
--- a/_posts/release_notes/2016-06-25-release-notes-5-5-0.md
+++ b/_posts/release_notes/2016-06-25-release-notes-5-5-0.md
@@ -11,7 +11,7 @@ folder: mydoc
## System requirements
->**Note:** PMD and CPD need at least a java7 runtime environment. For analyzing Salesforce.com Apex source code, you’ll need a java8 runtime environment.
+{% include note.html content="PMD and CPD need at least a java7 runtime environment. For analyzing Salesforce.com Apex source code, you’ll need a java8 runtime environment." %}
## New Supported Languages
diff --git a/pages/customizing/how_pmd_works.md b/pages/customizing/how_pmd_works.md
new file mode 100644
index 0000000000..17684c52b2
--- /dev/null
+++ b/pages/customizing/how_pmd_works.md
@@ -0,0 +1,33 @@
+---
+title: PMD How it Works
+short_title: How it Works
+tags: [customizing]
+summary: How PMD Works
+series: Customizing PMD
+weight: 1
+last_updated: July 3, 2016
+sidebar: mydoc_sidebar
+permalink: how_pmd_works.html
+folder: mydoc
+---
+
+{% include custom/series_customizing.html %}
+
+# How it works
+
+PMD checks source code against rules and produces a report. Like this:
+
+* Something passes a file name and a RuleSet into PMD
+* PMD hands an InputStream to the file off to a JavaCC-generated parser
+* PMD gets a reference to an Abstract Syntax Tree back from the parser
+* PMD hands the AST off to the symbol table layer which builds scopes, finds declarations, and find usages.
+* If any rules need data flow analysis, PMD hands the AST over to the DFA layer for building control flow graphs and data flow nodes.
+* Each Rule in the RuleSet gets to traverse the AST and check for problems. The rules can also poke around the symbol table and DFA nodes.
+* The Report is now filled with RuleViolations, and those get printed out in XML or HTML or whatever
+
+Not much detail here… if you think this document can be improved, please post [here](http://sourceforge.net/p/pmd/discussion/188192) and let us know how. Thanks!
+
+{% include custom/series_customizing_previous.html %}
+{% include custom/series_customizing_next.html %}
+
+{% include links.html %}
diff --git a/pages/customizing/making_rulesets.md b/pages/customizing/making_rulesets.md
new file mode 100644
index 0000000000..2a7b1a9fe6
--- /dev/null
+++ b/pages/customizing/making_rulesets.md
@@ -0,0 +1,145 @@
+---
+title: PMD Making Rulesets
+short_title: Making Custom Rulesets
+tags: [customizing]
+summary: Making Custom Rulesets for PMD
+series: Customizing PMD
+weight: 4
+last_updated: July 3, 2016
+sidebar: mydoc_sidebar
+permalink: making_rulesets.html
+folder: mydoc
+---
+
+{% include custom/series_customizing.html %}
+
+# How to make a new rule set
+
+Say you want to pick specific rules from various rule sets and customize them. You can do this by making your own rule set.
+
+## Create a new ruleset.xml file
+
+Use one of the current rulesets as an example. Copy and paste it into your new file, delete all the old rules from it, and change the name and description. Like this:
+
+```xml
+
+
+
+ This ruleset checks my code for bad stuff
+
+
+````
+
+## Add some rule references to it
+
+After you add these references it’ll look something like this:
+
+```xml
+
+
+
+
+ This ruleset checks my code for bad stuff
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
+>Notice that you can customize individual referenced rules. Everything but the class of the rule can be overridden in your custom ruleset.
+
+## Excluding rules from a ruleset
+
+You can also make a custom ruleset that excludes rules, like this:
+
+```xml
+
+
+ Just the braces rules I like
+
+
+
+
+
+```
+
+## Excluding files from a ruleset
+
+You can also exclude certain files from being processed by a ruleset using exclude patterns, with an optional overriding include pattern. A file will be excluded from processing when there is a matching exclude pattern, but no matching include pattern. Path separators in the source file path are normalized to be the ‘/’ character, so the same ruleset can be used on multiple platforms transparently. Additionally, this exclude/include technique works regardless of how PMD is used (e.g. command line, IDE, Ant), making it easier to keep application of your PMD rules consistent throughout your environment. Here is an example:
+
+```xml
+
+
+ My ruleset
+ .*/some/package/.*
+ .*/some/other/package/FunkyClassNamePrefix.*
+ .*/some/package/ButNotThisClass.*
+ ...
+
+```
+
+## Reference it in your Ant task
+
+You can specify the full path to your custom ruleset name alongside of the built-in PMD rulesets - like this:
+
+```xml
+
+
+
+
+
+
+```
+
+## To see it in your IDE, add it to rulesets/rulesets.properties
+
+At least, that’s the way some of the IDE plugins do it. Some have other ways of adding custom rulesets.
+
+## Send us feedback
+
+If you have suggestions on clarifying this document, please post them to [the forum](http://sourceforge.net/p/pmd/discussion/188192). Thanks!
+
+Finally, for many more details on building custom rulesets, pick up [PMD Applied](http://pmdapplied.com/)!
+
+{% include custom/series_customizing_previous.html %}
+{% include custom/series_customizing_next.html %}
+
+{% include links.html %}
diff --git a/pages/customizing/writing_pmd_rules.md b/pages/customizing/writing_pmd_rules.md
new file mode 100644
index 0000000000..e39284d7e9
--- /dev/null
+++ b/pages/customizing/writing_pmd_rules.md
@@ -0,0 +1,380 @@
+---
+title: PMD Writing a Custom Rule
+short_title: Writing a Custom Rule
+tags: [customizing]
+summary: Writing a Custom Rule for PMD
+series: "Customizing PMD"
+weight: 2
+last_updated: July 3, 2016
+sidebar: mydoc_sidebar
+permalink: writing_pmd_rules.html
+folder: mydoc
+---
+
+{% include custom/series_customizing.html %}
+
+# How to write a PMD rule
+
+Writing PMD rules is cool because you don’t have to wait for us to get around to implementing feature requests.
+
+## Get a development environment set up first
+ [Here’s some initial information on compiling PMD]
+
+## Java or XPath?
+
+There are two way to write rules:
+
+* Write a rule using Java
+* Write an XPath expression
+
+We’ll cover the Java way first and the XPath way second. Most of this documentation is applicable to both methods, too, so read on.
+
+## Figure out what you want to look for
+
+Lets’s figure out what problem we want to spot. We can use “While loops must use braces” as an example. In the source code below, it’s easy to get lost visually - it’s kind of hard to tell what the curly braces belong to.
+
+```java
+class Example {
+ void bar() {
+ while (baz)
+ buz.doSomething();
+ }
+}
+```
+
+So we know what an example in source code looks like, which is half the battle.
+
+## Write a test-data example and look at the AST
+
+PMD doesn’t use the source code directly; it uses a `JavaCC` generated parser to parse the source code and produce an AST (Abstract Syntax Tree). The AST for the code above looks like this:
+
+```
+CompilationUnit
+ TypeDeclaration
+ ClassDeclaration:(package private)
+ UnmodifiedClassDeclaration(Example)
+ ClassBody
+ ClassBodyDeclaration
+ MethodDeclaration:(package private)
+ ResultType
+ MethodDeclarator(bar)
+ FormalParameters
+ Block
+ BlockStatement
+ Statement
+ WhileStatement
+ Expression
+ PrimaryExpression
+ PrimaryPrefix
+ Name:baz
+ Statement
+ StatementExpression:null
+ PrimaryExpression
+ PrimaryPrefix
+ Name:buz.doSomething
+ PrimarySuffix
+ Arguments
+```
+
+You can generate this yourself by:
+
+* Run the batch file bin/designer.bat
+* Paste the code into the left text area and click the “Go” button
+* Note that there’s another panel and a textfield to test out XPath expressions; more on that later.
+* Here’s a screenshot: 
+
+So you can see in the example above that the AST for a `WhileStatement` looks kind of like this (excluding that expression gibberish for clarity):
+
+```
+WhileStatement
+ Expression
+ Statement
+ StatementExpression
+```
+
+If you were to add curly braces around the call to `buz.doSomething()` and click “Go” again, you’d see that the AST would change a bit. It’d look like this:
+
+```
+WhileStatement
+ Expression
+ Statement
+ Block
+ BlockStatement
+ Statement
+ StatementExpression
+```
+
+Ah ha! We see that the curly braces add a couple more AST nodes - a `Block` and a `BlockStatement`. So all we have to do is write a rule to detect a `WhileStatement` that has a `Statement` that’s not followed by a `Block`, and we’ve got a rule violation.
+
+By the way, all this structural information - i.e., the fact that a Statement may be followed a Block - is concisely defined in the [EBNF grammar](https://github.com/pmd/pmd/blob/master/pmd-java/etc/grammar/Java.jjt). So, for example, the Statement definition looks like this:
+
+```
+void Statement() :
+{}
+{
+ LOOKAHEAD( { isNextTokenAnAssert() } ) AssertStatement()
+| LOOKAHEAD(2) LabeledStatement()
+| Block()
+| EmptyStatement()
+| StatementExpression() ";"
+| SwitchStatement()
+| IfStatement()
+| WhileStatement()
+| DoStatement()
+| ForStatement()
+| BreakStatement()
+| ContinueStatement()
+| ReturnStatement()
+| ThrowStatement()
+| SynchronizedStatement()
+| TryStatement()
+}
+```
+
+showing that a Statement may be followed by all sorts of stuff.
+
+## Write a rule class
+
+Create a new Java class that extends `net.sourceforge.pmd.lang.java.rule.AbstractJavaRule`:
+
+```java
+import net.sourceforge.pmd.lang.java.rule.*;
+public class WhileLoopsMustUseBracesRule extends AbstractJavaRule {
+}
+```
+
+That was easy. PMD works by creating the AST and then traverses it recursively so a rule can get a callback for any type it’s interested in. So let’s make sure our rule gets called whenever the AST traversal finds a `WhileStatement`:
+
+```java
+import net.sourceforge.pmd.lang.java.rule.*;
+import net.sourceforge.pmd.lang.java.ast.*;
+public class WhileLoopsMustUseBracesRule extends AbstractJavaRule {
+ public Object visit(ASTWhileStatement node, Object data) {
+ System.out.println("hello world");
+ return data;
+ }
+}
+```
+
+We stuck a `println()` in there for now so we can see when our rule gets hit.
+
+## Put the WhileLoopsMustUseBracesRule rule in a ruleset file
+
+Now our rule is written - at least, the shell of it is - and now we need to tell PMD about it. We need to add it to a ruleset XML file. Look at `pmd-java/src/main/resources/rulesets/java/basic.xml`; it’s got lots of rule definitions in it. Copy and paste one of these rules into a new ruleset - call it `mycustomrules.xml` or something. Then fill in the elements and attributes:
+
+* name - WhileLoopsMustUseBracesRule
+* message - Use braces for while loops
+* class - Wherever you put the rule. Note this doesn’t have to be in `net.sourceforge.pmd`; it can be in `com.yourcompany.util.pmd` or whereever you want
+* description - Use braces for while loops
+* example - A little code snippet in CDATA tags that shows a rule violation
+
+The whole ruleset file should look something like this:
+
+```xml
+
+
+
+
+ Avoid using 'while' statements without using curly braces
+
+ 3
+
+
+
+
+
+
+```
+
+## Run PMD using your new ruleset
+
+OK, let’s run the new rule so we can see something work. Like this:
+
+```DOS
+pmd.bat c:\path\to\my\src xml c:\path\to\mycustomrules.xml
+```
+
+
+This time your “hello world” will show up right after the AST gets printed out. If it doesn’t, post a message to [the forum](http://sourceforge.net/p/pmd/discussion/188192) so we can improve this document :-)
+
+## Write code to add rule violations where appropriate
+
+Now that we’ve identified our problem, recognized the AST pattern that illustrates the problem, written a new rule, and plugged it into a ruleset, we need to actually make our rule find the problem, create a `RuleViolation`, and put it in the `Report`, which is attached to the `RuleContext`. Like this:
+
+```java
+import net.sourceforge.pmd.lang.ast.*;
+import net.sourceforge.pmd.lang.java.ast.*;
+import net.sourceforge.pmd.lang.java.rule.*;
+
+public class WhileLoopsMustUseBracesRule extends AbstractJavaRule {
+ public Object visit(ASTWhileStatement node, Object data) {
+ Node firstStmt = node.jjtGetChild(1);
+ if (!hasBlockAsFirstChild(firstStmt)) {
+ addViolation(data, node);
+ }
+ return super.visit(node,data);
+ }
+ private boolean hasBlockAsFirstChild(Node node) {
+ return (node.jjtGetNumChildren() != 0 && (node.jjtGetChild(0) instanceof ASTBlock));
+ }
+}
+```
+
+TODO - if you don’t understand the code for the rule, post a message to [the forum](http://sourceforge.net/p/pmd/discussion/188192) so we can improve this document :-)
+
+## Writing a rule as an XPath expression
+
+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](http://www.onjava.com/pub/a/onjava/2003/04/09/pmd_rules.html) with a lot more detail.
+
+Note that for XPath rules you’ll need to set the `class` attribute in the rule definition to `net.sourceforge.pmd.lang.rule.XPathRule.` Like this:
+
+```xml
+
+
+ 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](pmd-core/xref/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.html)
+
+Thanks to Miguel Griffa for writing a longer [XPath tutorial](xpathruletutorial.html).
+
+## I want to implement a rule that analyze more than the class!
+
+An obvious limitation of the previous mechanism is the “class-centric” focus of the rule. How can you implement a rule that checks stuff across the all source code? Let’s take a dummy example. Let’s say you want to implement a rule that count how many Expression Node you have in your source code (told you, it was a dummy example :) ).
+
+You realize quite simply. You just have to add static field to the RulesContext, as an attribute, and uses Rule.start() and Rule.end() hook to initialized and finalize your rule’s implementation:
+
+```java
+package net.sourceforge.pmd.rules;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import net.sourceforge.pmd.RuleContext;
+import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
+import net.sourceforge.pmd.lang.java.ast.ASTExpression;
+
+public class CountRule extends AbstractJavaRule {
+
+ private static final String COUNT = "count";
+
+ @Override
+ public void start(RuleContext ctx) {
+ ctx.setAttribute(COUNT, new AtomicLong());
+ super.start(ctx);
+ }
+
+ @Override
+ public Object visit(ASTExpression node, Object data) {
+ // How many Expression nodes are there in all files parsed! I must know!
+ RuleContext ctx = (RuleContext)data;
+ AtomicLong total = (AtomicLong)ctx.getAttribute(COUNT);
+ total.incrementAndGet();
+ return super.visit(node, data);
+ }
+
+ @Override
+ public void end(RuleContext ctx) {
+ AtomicLong total = (AtomicLong)ctx.getAttribute(COUNT);
+ addViolation(ctx, null, new Object[] { total });
+ ctx.removeAttribute(COUNT);
+ super.end(ctx);
+ }
+}
+```
+
+As you can see in this example, the method start will be call the first time the rule is going to be used, so you can initialize properly your rule here. Once the rule will have finished to parses the source code, the method end() will be invoke you can assert there if, or not, your rule has been violated.
+
+>Note that the example logs a violation **without** a proper classname. This is not really a good idea. Indeed, a lot of aggregating tools that PMD (Such as [XRadar](http://xradar.sourceforge.net), or [Sonar](http://www.sonarsource.com/)) probably uses this kind of meta data on their aggregation processes. So, when implements such a rule, always try to find a way to add classname to the violation report.
+
+## I need some kind of Type Resolution for my rule!
+
+### Inside an XPath query
+
+PMD XPath syntax includes now a new function called `typeof` which determines if a node (ClassOrInterfaceType only right now) is of the provided type. It also scans the type’s hierarchy, so if you extend a class it will also find this out.
+
+Here a an example of use, inside an XPath Query:
+
+```xpath
+//ClassOrInterfaceDeclaration[
+ //ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase','TestCase')]
+]
+```
+
+This query will match on such source code:
+
+```java
+import junit.framework.TestCase;
+
+public class Foo extends TestCase { }
+```
+
+### With Java code
+
+Below an other sample of use of type resolution inside a java code:
+
+```java
+/**
+ * A simple to detect the use of the class 'com.forbidden.class'.
+ */
+@SuppressWarnings("unchecked")
+public Object visit(ASTClassOrInterfaceType type, Object ruleCtx) {
+ Class clazz = type.getType();
+ if ("com.forbidden.class".equals(clazz.getName())) {
+ addViolation(ruleCtx,type);
+ }
+ return super.visit(type, ruleCtx);
+}
+````
+
+>Note, that this will only work, if the auxiliary classpath for PMD is setup correctly, so that PMD can actually find the (compiled) class “com.forbidden.class” and you get the actual Class instance by calling getType().
+
+Otherwise, you’ll have to string-compare the image, e.g. `"com.forbidden.class".equals(node.getImage())`
+
+## Thread safety, concurrency issues and reuse of rule instances
+
+When executing the rule, PMD will instantiate a new instance of your rule. If PMD is executed in multiple threads, then each thread is using its own instance of the rule. This means, that the rule implementation **does not need to care about threading issues**, as PMD makes sure, that a single instance is not used concurrently by multiple threads.
+
+However, for performance reasons, the rule instances are used for multiple files. This means, that the constructor of the rule is only executed once (per thread) and the rule instance is reused. If you rely on a proper initialization of instance properties, you can do the initialization e.g. in the visit-method of the `ASTCompilationUnit` AST node - which is visited as first node and only once per file. However, this solution would only work for rules written for the Java language. A language independent way is to override the method `apply` of the rule (and call super). The apply method is called exactly once per file.
+
+If you want to share data across multiple files, see the above section “I want to implement a rule that analyze more than the class”.
+
+## Bundle it up
+
+To use your rules as part of a nightly build or whatever, it’s helpful to bundle up both the rule and the ruleset.xml file in a jar file. Then you can put that jar file on the CLASSPATH of your build. Setting up a script or an Ant task to do this can save you some tedious typing.
+
+## Repeat as necessary
+
+I’ve found that my rules usually don’t work the first time, and so I have to go back and tweak them a couple times. That’s OK, if we were perfect programmers PMD would be useless anyhow :-).
+
+As an acceptance test of sorts, I usually run a rule on the JDK 1.4 source code and make sure that a random sampling of the problems found are in fact legitimate rule violations. This also ensures that the rule doesn’t get confused by nested inner classes or any of the other oddities that appear at various points in the JDK source.
+
+You’re rolling now. If you think a rule would benefit the Java development community as a whole, post a message to [the forum](http://sourceforge.net/p/pmd/discussion/188192) so we can get the rule moved into one of the core rulesets.
+
+Or, if you can improve one of the existing rules, that’d be great too! Thanks!
+
+Finally, for many more details on writing rules, pick up [PMD Applied](http://pmdapplied.com/)!
+
+{% include custom/series_customizing_previous.html %}
+{% include custom/series_customizing_next.html %}
+
+{% include links.html %}
diff --git a/pages/customizing/writing_xpath_rules.md b/pages/customizing/writing_xpath_rules.md
new file mode 100644
index 0000000000..349f19a941
--- /dev/null
+++ b/pages/customizing/writing_xpath_rules.md
@@ -0,0 +1,161 @@
+---
+title: PMD Writing XPath Rules
+short_title: Writing XPath Rules
+tags: [customizing]
+summary: "Writing XPath rules for PMD"
+series: "Customizing PMD"
+weight: 3
+last_updated: July 3, 2016
+sidebar: mydoc_sidebar
+permalink: writing_xpath_rules.html
+folder: mydoc
+---
+
+{% include custom/series_customizing.html %}
+
+# XPath Rule tutorial
+
+Writing PMD rules with XPath can be a bit easier than writing rules with Java code. Here’s an introduction on how to do that.
+
+## Introduction
+
+PMD provides a very handy method for writing rules by writing an XPath query. When the XPath query finds a match, a violation is added to the report. This document focuses on XPath rules. You can go [here](howtowritearule.html) for more information about writing a rule.
+
+## What is the Abstract Syntax Tree (AST)?
+
+From [FOLDOC](http://foldoc.org/abstract+syntax+tree) an AST is
+
+> A data structure representing something which has been parsed, often used as a compiler or interpreter’s internal representation of a program while it is being optimised and from which code generation is performed.
+
+In our context, this means that we basically have a tree representation of the Java source file. This tree can viewed as a structured document - just like XML. And since it’s conceptually similar to XML, it can be queried with XPath to find a pattern.
+
+## Using Designer
+
+PMD comes with a handy tool that you will love if you want to write an XPath rule. Designer, runnable from a script in `bin/`, is a very simple and useful utility for writing rules.
+
+The basic steps involved in writing XPath rules are these:
+
+1. Write a simple Java example source snippet in Designer
+2. See the AST for the class you wrote
+3. Write an XPath expression that matches the violation you are searching
+4. Modify the Java class and go back to previous step to refine the XPath expression
+
+## Simple XPath expressions
+
+This section provides hands-on examples of XPath queries over the AST. You will probably find this section more useful if you follow it with Designer and copy/paste the examples.
+
+Copy the following Java source code to Designer:
+
+```java
+public class a {
+ int fOne;
+ int fTwo;
+
+ private void run() {
+ int one;
+ int two;
+ }
+}
+```
+
+Let’s assume you want to match something on class variable names. You see in the ASTVviewer that VariableDeclaratorId contains the variable name - in XML terms, the name is in the `@Image` attribute. So you try an XPath expression as follows:
+
+`//VariableDeclaratorId`
+
+If you try this expression you’ll see that variables declared in methods are also matched. A more precise expression for matching field declarations is, well, using the FieldDeclaration node. This expression matches only the two fields declared in the class:
+
+`//FieldDeclaration`
+
+In a similar way, you can match only local variables with this expression
+
+`//LocalVariableDeclaration`
+
+With local variables we need to be more careful. Consider the following class:
+
+```java
+public class a {
+ private void run() {
+ final int one;
+ int two;
+
+ {
+ int a;
+ }
+ }
+}
+```
+
+Local variable declarations will match ‘a’, since it is a perfectly legal Java local variable. Now, a more interesting expression is to match variables declared in a method, and not on an internal block, nor in the class. Maybe you’ll start with an expression like this:
+
+`//MethodDeclaration//LocalVariableDeclaration`
+
+You’ll quickly see that all three local variables are matched. A possible solution for this is to request that the parent of the local variable declaration is the MethodDeclaration node:
+
+`//LocalVariableDeclaration[name(../../..) = 'MethodDeclaration']`
+
+## Matching variables by name
+
+Let’s consider that we are writing rules for logger. Let’s assume we use the Java logging API and we want to find all classes that have more than one logger. The following expression returns all variable declarations whose type is ‘Logger’.
+
+`//VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Logger']]`
+
+Finding a class with more than one logger is quite easy now. This expression matches the classes we are looking for.
+
+```xpath
+TypeDeclaration[count(//VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Logger']])>1
+```
+
+But let’s refine this expression a little bit more. Consider the following class:
+
+```java
+public class a {
+ Logger log = null;
+ Logger log = null;
+ int b;
+
+ void myMethod() {
+ Logger log = null;
+ int a;
+ }
+ class c {
+ Logger a;
+ Logger a;
+ }
+}
+```
+
+With this class we will only be matching one violation, when we probably would have wanted to produce two violations (one for each class). The following refined expression matches classes that contain more than one logger.
+
+```xpath
+//ClassOrInterfaceBodyDeclaration[count(//VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Logger']])>1]
+```
+
+Let’s assume we have a Factory class, that could be always declared final. We’ll search an xpath expression that matches all declarations of Factory and reports a violation if it is not declared final. Consider the following class:
+
+```java
+public class a {
+ Factory f1;
+
+ void myMethod() {
+ Factory f2;
+ int a;
+ }
+}
+```
+
+The following expression does the magic we need:
+
+```xpath
+//VariableDeclarator
+ [../Type/ReferenceType/ClassOrInterfaceType
+ [@Image = 'Factory'] and ..[@Final='false']]
+```
+
+We recommend at this point that you experiment with Designer putting the final modifier to the Factory and verifying that the results produced are those expected.
+
+Finally, for many more details on writing XPath rules, pick up [PMD Applied](http://pmdapplied.com/)!
+
+{% include custom/series_customizing_next.html %}
+{% include custom/series_customizing_previous.html %}
+
+{% include links.html %}