We have been using this implementation of setTextContent for some time
now and it works like a charm. Now that I upgraded to Xerces_2_4 I found
out the hard way that it isn't implemented in the current release of
Xerces either.
I wrote the current getTextContent implementation and wrote this at the
same time but I seem to have forgotten to submit it. Could someone
please revise and commit the following code?
Best regards
Erik Rydgren
Software engineer
Aptic AB
******************* CODE ************************
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(textCon
tent);
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]