} else {
startDocument(node.getBaseURI());
}
if (!match || processChildren) {
XdmSequenceIterator iter = node.axisIterator(Axis.CHILD);
while (iter.hasNext()) {
XdmNode child = (XdmNode) iter.next();
traverse(child);
}
}
if (match) {
processor.processEndDocument(node);
} else {
endDocument();
}
} else if (node.getNodeKind() == XdmNodeKind.ELEMENT) {
if (match) {
processChildren = processor.processStartElement(node);
saw = 0;
} else {
addStartElement(node);
}
if (!match) {
XdmSequenceIterator iter = node.axisIterator(Axis.ATTRIBUTE);
// Walk through the attributes twice, processing all the *NON* matches first.
// That way if a matching node renames an attribute, it can replace any non-matching
// attribute with the same name.
while (iter.hasNext()) {
XdmNode child = (XdmNode) iter.next();
if (!matches(child)) {
traverse(child);
}
}
iter = node.axisIterator(Axis.ATTRIBUTE);
while (iter.hasNext()) {
XdmNode child = (XdmNode) iter.next();
if (matches(child)) {
traverse(child);
}
}
receiver.startContent();
}
if (!match || processChildren) {
XdmSequenceIterator iter = node.axisIterator(Axis.CHILD);
while (iter.hasNext()) {
XdmNode child = (XdmNode) iter.next();
traverse(child);
}
}
if (match) {