XPathVariable (XPathVariableDeclaration[] declarations, String referencedName) { for (XPathVariableDeclaration decl : declarations) { final XPathVariable v = decl.getVariable(); if (v != null) { if (referencedName.equals(v.getName())) { return v; } } } return null; }