} else if (parent instanceof DocumentImpl) {
throw new OMHierarchyException(
"DOM doesn't support text nodes as children of a document");
} else {
DocumentImpl ownerDocument = (DocumentImpl)((ElementImpl)parent).getOwnerDocument();
TextNodeImpl txt;
if (type == OMNode.CDATA_SECTION_NODE) {
txt = new CDATASectionImpl(ownerDocument, text, this);
} else {
txt = new TextImpl(ownerDocument, text, type, this);
}