#include "../config/pathan_config.h" /* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #include #include #include #include #include #include #include #include "../dom-extensions/impl/XPathNamespaceImpl.hpp" NavStepImpl::Axis NamespaceAxis::getAxis() const { return NavStepImpl::NAMESPACE; } Sequence NamespaceAxis::makeList(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node, const XMLCh* const uri, DynamicContext* context) const { XPath2MemoryManager* memMgr=context->getMemoryManager(); Sequence returnList = Sequence(memMgr); //If this isn't an element, then return nothing if(node->getNodeType() != XERCES_CPP_NAMESPACE_QUALIFIER DOMNode::ELEMENT_NODE) { return returnList; } namespaceMapType nsMap; //nsMap["xml"] = "http://www.w3.org/XML/1998/namespace"; nsMap[XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgXMLString] = XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgXMLURIName; std::map nodeMap; const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *tmpNode = node; while(tmpNode != 0) { //For each element, go through the attributes, and add any namespace bindings.. XPath2NSUtils::addBindings(tmpNode, &nsMap, memMgr); namespaceMapType::iterator i = nsMap.begin(); namespaceMapType::iterator e = nsMap.end(); for(;i != e; i++) { std::map::iterator tmpIter = nodeMap.find(i->first); if(tmpIter == nodeMap.end()) { XERCES_CPP_NAMESPACE_QUALIFIER DOMXPathNamespace *newNSNode = XPathNamespaceImpl::createXPathNamespace(i->first,i->second, static_cast(const_cast(tmpNode))); nodeMap[i->first] = newNSNode; if(filterNode(newNSNode, uri, context)) returnList.addItem(memMgr->createNode(newNSNode)); } } tmpNode = tmpNode->getParentNode(); } return returnList; }