Inside each document is a root element or node. It is just how one wraps the information. You can write a function that returns you the element / node and throw away the document. I have not looked at the code base for AXIS or JAXM, but I wonder how they do their conversion?

So, do I hear an enhancement request for the API to provide a conversion instead of a how-to ? ;-)

I once remember someone saying that DOM4J could be built where the Elements were W3C elements. James, perhaps you can address this.

Later,

Dave

Brain, Jim wrote:
Yes, but DOMReader only has a read method for org.w3c.dom.Document. I need
one that will read an org.w3c.dom.Element

When working with Apache AXIS and/or JAXM, they both deliver you Element(s),
not DOM Documents.

Jim


Jim Brain, [EMAIL PROTECTED]
"Researching tomorrow's decisions today."
(319) 369-2070 (work)
SYSTEMS ARCHITECT, ITS, AEGON FINANCIAL PARTNERS

-----Original Message-----
From: David D. Lucas [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 11:37 AM
To: Brain, Jim
Cc: 'James Strachan'; DOM4J Mailing List (E-mail)
Subject: Re: [dom4j-user] How do I convert a DOM element tree into a
DOM4J document

You should be able to create a method for either direction ( based off the code below) that takes in a dom4j element and returns a w3c node by manipulating the org.w3c.dom.Document interface and remove/detach the first child and return it.

The opposite direction would be the same, take in a node, and return it as an element by getRootElement and detaching it.

Does that help?

Dave


// I use this code to convert from dom4j to a w3c DOM
Element input = ...
org.dom4j.io.DOMWriter domOut = new org.dom4j.io.DOMWriter();
Document fragDoc = DocumentHelper.createDocument(input);
org.w3c.dom.Document w3cDom = domOut.write(fragDoc);

// I use this code to convert from w3c DOM to dom4j

org.dom4j.io.DOMReader domIn = new org.dom4j.io.DOMReader();
Document fragDoc = domIn.read(w3cDom);
Element output = fragDoc.getRootElement();
output.detach();
// do whatever with the element (top of tree)




--

+------------------------------------------------------------+
| David Lucas                        mailto:[EMAIL PROTECTED]  |
| Lucas Software Engineering, Inc.   (740) 964-6248 Voice    |
| Unix,Java,C++,CORBA,XML,EJB        (614) 668-4020 Mobile   |
| Middleware,Frameworks              (888) 866-4728 Fax/Msg  |
+------------------------------------------------------------+
| GPS Location:  40.0150 deg Lat,  -82.6378 deg Long         |
| IMHC: "Jesus Christ is the way, the truth, and the life."  |
| IMHC: "I know where I am; I know where I'm going."    <><  |
+------------------------------------------------------------+

Notes: PGP Key Block=http://www.lse.com/~ddlucas/pgpblock.txt
IMHO="in my humble opinion" IMHC="in my humble conviction"
All trademarks above are those of their respective owners.




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to