throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
case ENTITY_REFERENCE_NODE: {
userData = node.getUserDataRecord();
// remove node from wherever it is
Node parent = node.getParentNode();
if (parent != null) {
parent.removeChild(source);
}
// discard its replacement value
Node child;
while ((child = node.getFirstChild()) != null) {
node.removeChild(child);
}
// change ownership
node.setOwnerDocument(this);
if(userData != null)
setUserDataTable(node,userData);
// set its new replacement value if any
if (docType == null) {
break;
}
NamedNodeMap entities = docType.getEntities();
Node entityNode = entities.getNamedItem(node.getNodeName());
if (entityNode == null) {
break;
}
for (child = entityNode.getFirstChild();
child != null; child = child.getNextSibling()) {
Node childClone = child.cloneNode(true);
node.appendChild(childClone);
}
break;
}
case ELEMENT_NODE: {
userData = node.getUserDataRecord();
// remove node from wherever it is
Node parent = node.getParentNode();
if (parent != null) {
parent.removeChild(source);
}
// change ownership
node.setOwnerDocument(this);
if(userData != null)
setUserDataTable(node,userData);
// reconcile default attributes
((ElementImpl)node).reconcileDefaultAttributes();
break;
}
default: {
userData = node.getUserDataRecord();
// remove node from wherever it is
Node parent = node.getParentNode();
if (parent != null) {
parent.removeChild(source);
}
// change ownership
node.setOwnerDocument(this);
if(userData != null)
setUserDataTable(node,userData);