[jdom-interest] Building JDOM tree from a DOM sub-tree

Oleg Ananiev oananiev at yahoo.com
Thu Jun 8 02:11:12 PDT 2000

I have found it quite useful to be able to build a JDOM tree based on a DOM
sub-tree, identified by its root node (it is also possible to build a tree
from a DocumentFragment). In my scenario, I am building a DOM tree in memory
and then let the consumer query it with Xpath expressions. Since JDOM does
not support XPath at the moment, I use some 3rd party package, which
requires DOM as an input. However, when the result nodes are returned to the
consumer, they are converted to JDOM.

In order to enable this, I added a new method to  DOMBuilder:

    public Document build(org.w3c.dom.Node rootNode) {
        Document doc = new Document(null);

        buildTree(rootNode, doc, null, true);

        return doc;

I think such support may also be useful in other, less twisted scenarios.

Oleg Ananiev
TTI Telecom Ltd.
oananiev at yahoo.com <mailto:oananiev at yahoo.com> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4576 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20000608/348841d6/winmail.bin

More information about the jdom-interest mailing list