Return-Path: Delivered-To: apmail-xml-xerces-cvs-archive@www.apache.org Received: (qmail 30044 invoked from network); 12 Feb 2004 13:40:34 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 12 Feb 2004 13:40:34 -0000 Received: (qmail 65696 invoked by uid 500); 12 Feb 2004 13:40:31 -0000 Delivered-To: apmail-xml-xerces-cvs-archive@xml.apache.org Received: (qmail 65662 invoked by uid 500); 12 Feb 2004 13:40:31 -0000 Mailing-List: contact xerces-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: Delivered-To: mailing list xerces-cvs@xml.apache.org Received: (qmail 65646 invoked from network); 12 Feb 2004 13:40:30 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 12 Feb 2004 13:40:30 -0000 Received: (qmail 30027 invoked by uid 1756); 12 Feb 2004 13:40:33 -0000 Date: 12 Feb 2004 13:40:33 -0000 Message-ID: <20040212134033.30026.qmail@minotaur.apache.org> From: amassari@apache.org To: xml-xerces-cvs@apache.org Subject: cvs commit: xml-xerces/c/src/xercesc/dom/impl DOMNodeImpl.cpp X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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