}
return null;
}
public NodeList selectElementNodes(Node contextNode, XPathFragment xPathFragment, XMLNamespaceResolver xmlNamespaceResolver) {
XMLNodeList xmlNodeList = new XMLNodeList();
Node child = contextNode.getFirstChild();
while (null != child) {
String elementNamespaceURI = null;
if(xmlNamespaceResolver != null) {
elementNamespaceURI = xmlNamespaceResolver.resolveNamespacePrefix(xPathFragment.getPrefix());
}
if ((child.getNodeType() == Node.ELEMENT_NODE) && sameName(child, xPathFragment.getLocalName()) && sameNamespaceURI(child, elementNamespaceURI)) {
XPathPredicate predicate = xPathFragment.getPredicate();
if(predicate != null) {
XPathFragment predicateFragment = predicate.getXPathFragment();
if(predicateFragment.isAttribute() && child.getAttributes() != null) {
Attr attr = (Attr)child.getAttributes().getNamedItemNS(predicateFragment.getNamespaceURI(), predicateFragment.getLocalName());
if(attr != null) {
String attribute = attr.getValue();
if(xPathFragment.getPredicate().getValue().equals(attribute)) {
xmlNodeList.add(child);
}
}
}
} else {
xmlNodeList.add(child);
}
}
child = child.getNextSibling();
}
return xmlNodeList;