el = DOMUtils.getNextElement(el);
}
}
}
if (xpaths != null && !xpaths.isEmpty()) {
XPathFactory factory = XPathFactory.newInstance();
for (String expression : xpaths) {
XPath xpath = factory.newXPath();
if (namespaces != null) {
xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
}
try {
NodeList list = (NodeList)xpath.evaluate(expression, saaj.getSOAPPart().getEnvelope(),
XPathConstants.NODESET);
for (int x = 0; x < list.getLength(); x++) {
Element el = (Element)list.item(x);
if (sign) {
WSEncryptionPart part = new WSEncryptionPart(el.getLocalName(),
el.getNamespaceURI(),
"Content",
WSConstants.PART_TYPE_ELEMENT);
part.setXpath(expression);
result.add(part);
} else {
WSEncryptionPart encryptedElem = new WSEncryptionPart(el.getLocalName(),
el.getNamespaceURI(),
"Element",
WSConstants
.PART_TYPE_ELEMENT);
encryptedElem.setXpath(expression);
String wsuId = el.getAttributeNS(WSConstants.WSU_NS, "Id");
if (!StringUtils.isEmpty(wsuId)) {
encryptedElem.setEncId(wsuId);
}
result.add(encryptedElem);
}
}
} catch (XPathExpressionException e) {
//REVISIT!!!!
}
}
}
if (contentXpaths != null && !contentXpaths.isEmpty()) {
XPathFactory factory = XPathFactory.newInstance();
for (String expression : contentXpaths) {
XPath xpath = factory.newXPath();
if (cnamespaces != null) {
xpath.setNamespaceContext(new MapNamespaceContext(cnamespaces));
}
try {
NodeList list = (NodeList)xpath.evaluate(expression, saaj.getSOAPPart().getEnvelope(),