Javadoc
If any EntityReference to be removed has descendants that are not
EntityReference, Text, or CDATASection nodes, the replaceWholeText method
must fail before performing any modification of the document, raising a
DOMException with the code NO_MODIFICATION_ALLOWED_ERR. Traverse previous
siblings of the node to be replaced. If a previous sibling is an
EntityReference node, get it's last child. If the last child was a Text
or CDATASection node and its previous siblings are neither a replaceable
EntityReference or Text or CDATASection nodes, return false. IF the last
child was neither Text nor CDATASection nor a replaceable EntityReference
Node, then return true. If the last child was a Text or CDATASection node
any its previous sibling was not or was an EntityReference that did not
contain only Text or CDATASection nodes, return false. Check this
recursively for EntityReference nodes.