}
@SuppressWarnings("unchecked")
public Object clone() {
Document<T> doc = ((FOMFactory)factory).newDocument();
OMDocument omdoc = (OMDocument) doc;
for (Iterator i = getChildren(); i.hasNext();) {
OMNode node = (OMNode) i.next();
switch(node.getType()) {
case OMNode.COMMENT_NODE:
OMComment comment = (OMComment) node;
factory.createOMComment(omdoc, comment.getValue());
break;
case OMNode.DTD_NODE:
OMDocType doctype = (OMDocType) node;
factory.createOMDocType(omdoc, doctype.getValue());
break;
case OMNode.ELEMENT_NODE:
Element el = (Element) node;
omdoc.addChild((OMNode) el.clone());
break;
case OMNode.PI_NODE:
OMProcessingInstruction pi = (OMProcessingInstruction) node;
factory.createOMProcessingInstruction(omdoc, pi.getTarget(), pi.getValue());
break;