tng         2002/08/19 12:55:28

  Modified:    c/src/xercesc/dom/impl DOMNodeImpl.cpp
  Log:
  DOM L3: support DOMNode::isDefaultNamespace.   Added by Gareth Reakes.
  
  Revision  Changes    Path
  1.13      +58 -5     xml-xerces/c/src/xercesc/dom/impl/DOMNodeImpl.cpp
  
  Index: DOMNodeImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMNodeImpl.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DOMNodeImpl.cpp   16 Aug 2002 19:21:43 -0000      1.12
  +++ DOMNodeImpl.cpp   19 Aug 2002 19:55:28 -0000      1.13
  @@ -77,7 +77,6 @@
   #include <xercesc/util/PlatformUtils.hpp>
   #include <stdio.h>
   #include <assert.h>
  -
   const unsigned short DOMNodeImpl::READONLY     = 0x1<<0;
   const unsigned short DOMNodeImpl::SYNCDATA     = 0x1<<1;
   const unsigned short DOMNodeImpl::SYNCCHILDREN = 0x1<<2;
  @@ -912,9 +911,63 @@
       throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
   }
   
  -bool             DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const {
  -    throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
  -    return false;
  +
  +bool DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const{
  +     DOMNode *thisNode = castToNode(this);
  +    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 *ns = getNamespaceURI();
  +        const XMLCh *prefix = getPrefix();
  +
  +        if (thisNode->hasAttributes()) {
  +            DOMElement *elem = (DOMElement *)thisNode;
  +            DOMNode *attr = elem->getAttributeNodeNS(s_xmlnsURI, s_xmlns);
  +            if (attr != 0) {
  +                const XMLCh *value = attr->getNodeValue();
  +                return (XMLString::compareString(namespaceURI, value) == 0);
  +            }
  +        }
  +        DOMNode *ancestor = getElementAncestor(thisNode);
  +        if (ancestor != 0) {
  +            return ancestor->isDefaultNamespace(namespaceURI);
  +        }
  +
  +        return false;
  +    }
  +    case DOMNode::DOCUMENT_NODE:{
  +        return 
((DOMDocument*)thisNode)->getDocumentElement()->isDefaultNamespace(namespaceURI);
  +    }
  +
  +    case DOMNode::ENTITY_NODE :
  +    case DOMNode::NOTATION_NODE:
  +    case DOMNode::DOCUMENT_FRAGMENT_NODE:
  +    case DOMNode::DOCUMENT_TYPE_NODE:
  +        // type is unknown
  +        return false;
  +    case DOMNode::ATTRIBUTE_NODE:{
  +        if (fOwnerNode->getNodeType() == DOMNode::ELEMENT_NODE) {
  +            return fOwnerNode->isDefaultNamespace(namespaceURI);
  +
  +        }
  +        return false;
  +    }
  +    default:{
  +        DOMNode *ancestor = getElementAncestor(thisNode);
  +        if (ancestor != 0) {
  +            return ancestor->isDefaultNamespace(namespaceURI);
  +        }
  +        return false;
  +    }
  +
  +    }
   }
   
   DOMNode*         DOMNodeImpl::getInterface(const XMLCh* feature)      {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to