diff --git a/pmd/src/net/sourceforge/pmd/lang/xpath/MatchesFunction.java b/pmd/src/net/sourceforge/pmd/lang/xpath/MatchesFunction.java index b9338a2f79..99a0802d9d 100644 --- a/pmd/src/net/sourceforge/pmd/lang/xpath/MatchesFunction.java +++ b/pmd/src/net/sourceforge/pmd/lang/xpath/MatchesFunction.java @@ -3,6 +3,10 @@ */ package net.sourceforge.pmd.lang.xpath; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import net.sourceforge.pmd.lang.ast.xpath.Attribute; import org.jaxen.Context; @@ -11,10 +15,6 @@ import org.jaxen.FunctionCallException; import org.jaxen.SimpleFunctionContext; import org.jaxen.XPathFunctionContext; -import java.util.List; -import java.util.regex.Pattern; -import java.util.regex.Matcher; - // FIXME Can this function be extended to work on non-AST attributes? public class MatchesFunction implements Function { @@ -30,10 +30,12 @@ public class MatchesFunction implements Function { List attributes = (List) args.get(0); Attribute attr = (Attribute) attributes.get(0); - Pattern check = Pattern.compile((String) args.get(1)); - Matcher matcher = check.matcher(attr.getValue()); - if (matcher.find()) { - return context.getNodeSet(); + for(int i = 1; i < args.size(); i++) { + Pattern check = Pattern.compile((String) args.get(i)); + Matcher matcher = check.matcher(attr.getValue()); + if (matcher.find()) { + return context.getNodeSet(); + } } return Boolean.FALSE; }