[jdom-interest] sub classsig Document

Jasmeet.Singh at eontec.com Jasmeet.Singh at eontec.com
Mon Dec 3 07:06:35 PST 2001


Hi

I have created a my own Document class

public MyDocument extends Document{


}


This is now being used as


public MyClass {

private MyDocument myDocument;



public void someMethod(){

// I use SAX builder to build a document  as

     SAXBuilder builder = new SAXBuilder();
     Document doc = builder.build(new File("myxmlfile.xml"));
//

I want to set myDocument as the doc that has just now been created

I have tried the following ways

1. myDoucment = new MyDocument(doc.getRootElement(),doc.getDocType);
2. myDocument = new MyDocument(doc.getContent,doc.getDocType);

But all the above say throw IllegalAddExceptiion.. saying the root cannot
be set again.
The new MyDocument that I am trying top create has no relation with the doc
that has been read from the XML file. Both are separat references...
is there a way to copy the instance of doc and assign it to its subclass
... (.clone()) ., how does that work ..



}

}


Any help .

thanks
jasmeet









More information about the jdom-interest mailing list