<P>hi </P><P>I have a following situation</P><P>1. A document is read. This document is constructed using MyCustomJDOMFactory<BR>2.The hierarchy of nodes is : <B>Element has a subclass MainNode and MainNode has subclasses SubNode, SubNode1 etc etc</B><BR>3. While constructing the document, the MyCustomJDOMFactory creates instance of MainNode.</P><P>Now I want MainNode to be converted into SubNode so that the methods of SubNode can be executed.</P><P>I am doing it this way</P><P>class SubNode extends MainNode {</P><P>public SubNode(String rootElement, List contentList){<BR> super(rootElement);<BR> setContent(contentList)<BR>}</P><P>}</P><P>When the above constructor is invoked with content from a node i.ie</P><P>new SubNode(node.getName(),node.getContent()) .. I get an IllegalAddException().. This comes as the element being added already has an existing parent. hence I detatched the element. But the same error is repeated</P><P>new SubNode(node.getName(),node.detach().getContent())</P><P><BR><FONT COLOR=BLUE>Is this the right way of achieving the above objective. &nbsp;<BR>Also, I cannot use SubNode instances in MyCustomJDOMFactory as there may be a few more SubNode1 SubNode2.. under the MainNode. and all of them will have different operations.</FONT></P><P><BR>thanks <BR>jasmeet</P>