From 17393cab32c76ee3782c09ed64958762ced4f613 Mon Sep 17 00:00:00 2001 From: Tinny Ng <tng@apache.org> Date: Fri, 27 Sep 2002 19:21:28 +0000 Subject: [PATCH] DOM L3 fix: lookupnamespaceURI and isDefaultNamespace. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174256 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/dom/impl/DOMNodeImpl.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/xercesc/dom/impl/DOMNodeImpl.cpp b/src/xercesc/dom/impl/DOMNodeImpl.cpp index b3404d221..1a3abdbe6 100644 --- a/src/xercesc/dom/impl/DOMNodeImpl.cpp +++ b/src/xercesc/dom/impl/DOMNodeImpl.cpp @@ -548,10 +548,10 @@ DOMNode* DOMNodeImpl::getElementAncestor (const DOMNode* currentNode) const { const XMLCh* DOMNodeImpl::lookupNamespacePrefix(const XMLCh* const namespaceURI, bool useDefault, DOMElement *el) const { DOMNode *thisNode = castToNode(this); - const XMLCh* ns = getNamespaceURI(); + const XMLCh* ns = thisNode->getNamespaceURI(); // REVISIT: if no prefix is available is it null or empty string, or // could be both? - const XMLCh* prefix = getPrefix(); + const XMLCh* prefix = thisNode->getPrefix(); if (ns != 0 && XMLString::equals(ns,namespaceURI)) { if (useDefault || prefix != 0) { @@ -602,8 +602,8 @@ const XMLCh* DOMNodeImpl::lookupNamespaceURI(const XMLCh* specifiedPrefix) const short type = thisNode->getNodeType(); switch (type) { case DOMNode::ELEMENT_NODE : { - const XMLCh* ns = getNamespaceURI(); - const XMLCh* prefix = getPrefix(); + const XMLCh* ns = thisNode->getNamespaceURI(); + const XMLCh* prefix = thisNode->getPrefix(); if (ns != 0) { // REVISIT: is it possible that prefix is empty string? if (specifiedPrefix == 0 && prefix == specifiedPrefix) { @@ -914,21 +914,11 @@ bool DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const{ short type = thisNode->getNodeType(); switch (type) { case DOMNode::ELEMENT_NODE: { - //if we dont find a xmlns and we are looking for "" then its true - if(thisNode->isSameNode(thisNode->getOwnerDocument()->getDocumentElement())) { - if(namespaceURI == 0) { - return true; - } - } - const XMLCh *prefix = thisNode->getPrefix(); + // REVISIT: is it possible that prefix is empty string? if (prefix == 0 || !*prefix) { - const XMLCh* ns = thisNode->getNamespaceURI(); - if (namespaceURI == 0) { - return (ns == namespaceURI); - } - return XMLString::equals(namespaceURI, ns); + return XMLString::equals(namespaceURI, thisNode->getNamespaceURI()); } if (thisNode->hasAttributes()) { -- GitLab