[jdom-interest] Moving Subtrees using JDOM
Elliotte Rusty Harold
elharo at metalab.unc.edu
Fri Feb 22 11:04:42 PST 2002
At 10:12 AM -0800 2/22/02, Jason Hunter wrote:
>An element retains its children when it's moved, so I don't know what
>problem you could be having. Just detach the element from its own
>parent and splice it somewhere else, and all its children will tag along
>for the ride.
>
I think what he's asking for is something more akin to
DocumentFragfment in DOM; i.e. he doesn't want to move an Element. He
wants to move a sequence of three elements, two text nodes, a
comment, and perhaps a few more text nodes. You might be able to do
this using Lists. I'm not sure.
OK, I just looked at the JavaDoc and I don't think we can do that, at
least not in the most general case. I think what we'd need would be
an addContent(List) method. We have setContent(List) but not
addContent(list). You could do it in two steps by retrieving the
content of the element you wanted to put it in with getContent() and
then using the methods of the List interface.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.ibiblio.org/xml/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list