public String toXPath() { String xPathExpression; if ("*".equals(this.xPathExpression)) { xPathExpression = ".//*"; } else { xPathExpression = ".//*[self::" + this.xPathExpression + "]"; } ElementFilterList elementFilterList = this.elementFilterList; // should be a copy for (XPathComponent other : combinatedComponents) { elementFilterList = other.mergeIntoFilter(elementFilterList); xPathExpression = other.mergeIntoExpression(xPathExpression); } return "(" + xPathExpression + ")"; }