xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject cvs commit: xml-xerces/c/src/xercesc/dom/impl DOMNodeImpl.cpp
Date Thu, 12 Feb 2004 13:40:33 GMT
amassari    2004/02/12 05:40:33

  Modified:    c/src/xercesc/dom/impl DOMNodeImpl.cpp
  Log:
  Implemented setTextContent (patch by Erik Rydgren)
  
  Revision  Changes    Path
  1.30      +48 -3     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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- DOMNodeImpl.cpp	29 Jan 2004 11:44:27 -0000	1.29
  +++ DOMNodeImpl.cpp	12 Feb 2004 13:40:32 -0000	1.30
  @@ -1029,8 +1029,53 @@
   
   }
   
  -void DOMNodeImpl::setTextContent(const XMLCh*){
  -    throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
  +void DOMNodeImpl::setTextContent(const XMLCh* textContent){
  +    DOMNode *thisNode = castToNode(this);
  +    switch (thisNode->getNodeType()) 
  +    {
  +        case DOMNode::ELEMENT_NODE:
  +        case DOMNode::ENTITY_NODE:
  +        case DOMNode::ENTITY_REFERENCE_NODE:
  +        case DOMNode::DOCUMENT_FRAGMENT_NODE:
  +            {
  +                if (isReadOnly())
  +                  throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);
  +
  +                // Remove all childs
  +                DOMNode* current = thisNode->getFirstChild();
  +                while (current != NULL) 
  +                {
  +                    thisNode->removeChild(current);
  +                    current = thisNode->getFirstChild();
  +                }
  +                if (textContent != NULL) 
  +                {
  +                    // Add textnode containing data
  +                    current = ((DOMDocumentImpl*)thisNode->getOwnerDocument())->createTextNode(textContent);
  +                    thisNode->appendChild(current);
  +                }
  +            }
  +            break;
  +
  +        case DOMNode::ATTRIBUTE_NODE:
  +        case DOMNode::TEXT_NODE:
  +        case DOMNode::CDATA_SECTION_NODE:
  +        case DOMNode::COMMENT_NODE:
  +        case DOMNode::PROCESSING_INSTRUCTION_NODE:
  +            if (isReadOnly())
  +                throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);
  +
  +            thisNode->setNodeValue(textContent);
  +            break;
  +
  +        case DOMNode::DOCUMENT_NODE:
  +        case DOMNode::DOCUMENT_TYPE_NODE:
  +        case DOMNode::NOTATION_NODE:
  +            break;
  +
  +        default:
  +            throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
  +    }
   }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org


Mime
View raw message