Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

covert org.jdom.Document to org.w3c.dom.Document

843834Feb 14 2003 — edited Feb 17 2003

Hello,
How would I convert org.jdom.Document to org.w3c.dom.Document??

I'm creating org.jdom.Document from the servlet that reads from the database, which gets output like following.

// doc is org.jdom.Document
Document doc = new Document( root );

reportName = new Element( "REPORT_NAME" );
root.addContent( reportName );
reportName.setText( "Current Account Balance" );

// skip...

XMLOutputter outputter = new XMLOutputter(" ", true, "UTF-8");
outputter.output(doc, out);

And in my caller servlet, I read from the previous servlet using URL and parse it, trying to get Document, but it
InputSource xmlSource = new InputSource( url.openStream());

//Use a DOM Parser (org.apache.xerces.parsers.DOMParser)
DOMParser parser = new DOMParser();
parser.parse( xmlSource );
Document doc = parser.getDocument();

// and I do transformation.
DOMSource inXML = new DOMSource( doc );
StreamResult outXML = new StreamResult( out );
transformer.transform( inXML, outXML )


I'd like to skip passing around XML and share the same Document object so that I don't have parse it again...
Help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2003
Added on Feb 14 2003
2 comments
389 views