in xsec/transformers/TXFMXPathFilter.cpp [397:515]
void TXFMXPathFilter::walkDocument(DOMNode* n) {
// Non-recursive version
DOMNode * current = n;
DOMNode * next;
DOMNode * attParent = NULL; /* Assign NULL to remove spurious Forte warning */
bool done = false;
bool treeUp = false;
DOMNamedNodeMap * atts = n->getAttributes();
int attsSize = -1;
int currentAtt = -1;
lstsVectorType::iterator lstsIter;
while (done == false && current != NULL) {
if (treeUp == true) {
if (current == n) {
// We are complete.
done = true;
}
else {
// Remove this node from the ancestor lists
for (lstsIter = m_lsts.begin(); lstsIter != m_lsts.end(); ++lstsIter) {
if ((*lstsIter)->ancestorInScope == current) {
(*lstsIter)->ancestorInScope = NULL;
}
}
// Check for another sibling
next = current->getNextSibling();
if (next == NULL) {
current = current->getParentNode();
treeUp = true;
}
else {
current = next;
treeUp = false;
}
}
} /* treeUp == true */
else {
// Check if the current node is in the result set. The walk the children
// First check if this node is in any lists, and if so,
// set the appropriate ancestor nodes (if necessary)
for (lstsIter = m_lsts.begin(); lstsIter != m_lsts.end(); ++lstsIter) {
if ((*lstsIter)->ancestorInScope == NULL &&
(*lstsIter)->lst->hasNode(current)) {
(*lstsIter)->ancestorInScope = current;
}
}
// Now that the ancestor setup is done, check to see if this node is
// in scope.
if (checkNodeInScope(current) &&
checkNodeInInput(current, (atts != NULL ? attParent : NULL))) {
m_xpathFilterMap.addNode(current);
}
// Now find the next node!
if (atts != NULL) {
// Working on an attribute list
currentAtt++;
if (currentAtt == attsSize) {
// Attribute list complete
atts = NULL;
current = attParent;
next = current->getFirstChild();
if (next == NULL)
treeUp = true;
else {
current = next;
treeUp = false;
}
}
else {
current = atts->item(currentAtt);
}
}
else {
// Working on an element or other non-attribute node
atts = current->getAttributes();
if (atts != NULL && ((attsSize = atts->getLength()) > 0)) {
currentAtt = 0;
attParent = current;
current = atts->item(0);
treeUp = false;
}
else {
atts = NULL;
next = current->getFirstChild();
if (next != NULL) {
current = next;
treeUp = false;
}
else {
treeUp = true;
}
}
} /* ! atts == NULL */
}
} /* while */
}