Object exArgs[] = { "dsig-xpath:XPath", "Transform" };
throw new TransformationException("xml.WrongContent", exArgs);
}
XPath2FilterContainer04 xpathContainer =
XPath2FilterContainer04.newInstance(xpathElement,
input.getSourceURI());
Document doc = this._transformObject.getElement().getOwnerDocument();
NodeList subtreeRoots = xPathFuncHereAPI.selectNodeList(doc,
xpathContainer.getXPathFilterTextNode(),
CachedXPathFuncHereAPI.getStrFromNode(xpathContainer.getXPathFilterTextNode()),
xpathContainer.getElement());
if (log.isDebugEnabled())
log.debug("subtreeRoots contains " + subtreeRoots.getLength()
+ " nodes");
/*
* foreach subtree
*/
Set selectedNodes = new HashSet();
for (int i = 0; i < subtreeRoots.getLength(); i++) {
Node currentRootNode = subtreeRoots.item(i);
int currentRootNodeType = currentRootNode.getNodeType();
if ((currentRootNodeType == Node.ELEMENT_NODE)
|| (currentRootNodeType == Node.DOCUMENT_NODE)) {
NodeList nodesInSubtree =
myXPathAPI
.selectNodeList(currentRootNode, Canonicalizer
.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE);
int jMax = nodesInSubtree.getLength();
for (int j = 0; j < jMax; j++) {
selectedNodes.add(nodesInSubtree.item(j));
}
} else if ((currentRootNodeType == Node.ATTRIBUTE_NODE)
|| (currentRootNodeType == Node.TEXT_NODE)
|| (currentRootNodeType == Node.CDATA_SECTION_NODE)
|| (currentRootNodeType
== Node.PROCESSING_INSTRUCTION_NODE)) {
selectedNodes.add(currentRootNode);
} else {
throw new RuntimeException("unknown node type: " + currentRootNodeType + " " + currentRootNode);
}
}
if (log.isDebugEnabled())
log.debug("selection process identified " + selectedNodes.size()
+ " nodes");
Set resultNodes = new HashSet();
if (xpathContainer.isIntersect()) {
Iterator inputSetIterator = inputSet.iterator();
while (inputSetIterator.hasNext()) {
Node currentInputNode = (Node) inputSetIterator.next();
// if the input node is selected, include it in the output
if (selectedNodes.contains(currentInputNode)) {
resultNodes.add(currentInputNode);
}
}
} else if (xpathContainer.isSubtract()) {
Iterator inputSetIterator = inputSet.iterator();
while (inputSetIterator.hasNext()) {
Node currentInputNode = (Node) inputSetIterator.next();
// if the input node is selected, do not include it
// otherwise, include it
if (!selectedNodes.contains(currentInputNode)) {
resultNodes.add(currentInputNode);
}
}
} else if (xpathContainer.isUnion()) {
Iterator inputSetIterator = inputSet.iterator();
while (inputSetIterator.hasNext()) {
Node currentInputNode = (Node) inputSetIterator.next();