#include "../config/pathan_config.h" /* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #include #include #include #include NavStepImpl::Axis FollowingAxis::getAxis() const { return NavStepImpl::FOLLOWING; } Sequence FollowingAxis::makeList(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node, const XMLCh* const uri, DynamicContext* context) const { XPath2MemoryManager* memMgr=context->getMemoryManager(); Sequence returnList(memMgr); makeListHelper(node, &returnList, uri, context); return returnList; }//makeList void FollowingAxis::makeListHelper(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node, Sequence *retList, const XMLCh* const uri, DynamicContext* context) const { XPath2MemoryManager* memMgr=context->getMemoryManager(); const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *currentNode = node; while(currentNode != 0) { //First get the next sibling, if any, otherwise get the parent and keep going from there if(currentNode->getNextSibling() == 0) { if(currentNode->getNodeType() == XERCES_CPP_NAMESPACE_QUALIFIER DOMNode::ATTRIBUTE_NODE) { currentNode = static_cast(currentNode)->getOwnerElement(); } else { currentNode = currentNode->getParentNode(); } continue; }//if //otherwise there is a sibling, so keep on chugging currentNode = currentNode->getNextSibling(); // add the node only if it is not an entity reference if(currentNode->getNodeType() != XERCES_CPP_NAMESPACE_QUALIFIER DOMNode::ENTITY_REFERENCE_NODE && filterNode(currentNode,uri,context)) retList->addItem(memMgr->createNode(currentNode)); //recursively add descendants to the list if(currentNode->hasChildNodes()) { addTree(currentNode, retList, uri, context); }//if }//while }//makeListHelper void FollowingAxis::addTree(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node, Sequence *retList, const XMLCh* const uri, DynamicContext* context) const { XPath2MemoryManager* memMgr=context->getMemoryManager(); XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *child = node->getFirstChild(); while (child != 0) { // add the node only if it is not an entity reference if(child->getNodeType() != XERCES_CPP_NAMESPACE_QUALIFIER DOMNode::ENTITY_REFERENCE_NODE && filterNode(child,uri,context)) retList->addItem(memMgr->createNode(child)); //recursively add descendants to the list if(child->hasChildNodes()) { addTree(child, retList, uri, context); }//of child = child->getNextSibling(); }//while }//addTree