protected static void createSubclassedChildren( Element oldElement, AbstractEditorElement newElement) { if (oldElement != null) { for (int i = 0; i < oldElement.getChildCount(); i++) { Node node = oldElement.getChild(i); Node newNode = null; if (node instanceof Text) { String value = node.getValue(); newNode = new Text(value); } else if (node instanceof Comment) { newNode = new Comment(node.getValue()); } else if (node instanceof ProcessingInstruction) { newNode = new ProcessingInstruction((ProcessingInstruction) node); } else if (node instanceof Element) { newNode = createEditorElement((Element) node); } else { throw new RuntimeException("Cannot create new node: " + node.getClass()); } newElement.appendChild(newNode); } } }
public static AbstractEditorElement createEditorElement(InputStream is) { Element element = XMLUtil.parseQuietlyToDocument(is).getRootElement(); AbstractEditorElement editorElement = AbstractEditorElement.createEditorElement(element); return editorElement; }