Newer
Older
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, GetDOMNodeMemoryManager);
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
// 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, GetDOMNodeMemoryManager);
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, GetDOMNodeMemoryManager);
bool DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const{
DOMNode *thisNode = castToNode(this);
short type = thisNode->getNodeType();
switch (type) {
case DOMNode::ELEMENT_NODE: {
const XMLCh *prefix = thisNode->getPrefix();
// REVISIT: is it possible that prefix is empty string?
if (prefix == 0 || !*prefix) {
return XMLString::equals(namespaceURI, thisNode->getNamespaceURI());
if (thisNode->hasAttributes()) {
DOMElement *elem = (DOMElement *)thisNode;
DOMNode *attr = elem->getAttributeNodeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString);
if (attr != 0) {
const XMLCh *value = attr->getNodeValue();
return XMLString::equals(namespaceURI, value);
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
}
}
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;
}
}
David Abram Cargill
committed
DOMNode* DOMNodeImpl::getInterface(const XMLCh*) {
throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, GetDOMNodeMemoryManager);
// non-standard extension
void DOMNodeImpl::release()
{
// shouldn't reach here
throw DOMException(DOMException::INVALID_ACCESS_ERR,0, GetDOMNodeMemoryManager);