<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.0.9">
The result of:<BR>
is to set rootObject as the parent of objectA and to add objectA into the content of rootObject such that rootObject.getContent() will return a list that contains an objectA reference within it (rootObject.getContent().indexOf(objectA) will return a 0 or positive value). This assumes that objectA doesn't yet have a parent!<BR>
To add ObjectB to ObjectA you must:<BR>
Again objectB must not yet have a parent.<BR>
As Per said, you need to build your JDOM from whatever other representation you already have in memory using whatever logic your application needs!<BR>
I still don't understand where the problem is, but that's probably because I've no idea what you're really trying to achieve!<BR>
On Mon, 2004-02-02 at 13:59, Mikael Petterson (KI/EAB) wrote:
Sorry for not being very clear on what I want to do. I give it another try.
I import an xml file (1). I creat a JDOM tree and retrieve information about parent-child relations since the xml I have does not express that for my objects explicitly. Then I have to create an another xml file (2) that describes the relationship between the objects. I have to create xml (2) to look like this:
This describes that parent-child relation in xml. Which is fine. But when I extract the relationship and try to build xml (2) I get a problem with keeping the relations.
I addContent() to rootObject. Like this:
Will the resulting Element be rootObject+ObjectA.
So how can I then add ObjectB?
Hope it is a little bit more clear :-) Maybe ....
From: Per Norrman [mailto:email@example.com]
Sent: den 2 februari 2004 13:57
To: Mikael Petterson (KI/EAB); firstname.lastname@example.org
Subject: SV: [jdom-interest] create xml tree
this one was hard to understand ...
> I am trying to find out if there is a way of adding children
> in a way that the parent-child relation will be kept.
When you add one element (child) to another element (parent),
you create a parent-child relationship. Which parent-child
relationship do you want to be preserved?
> I have a method to create the relation inbetween parent and
> child. I then want to make a recursive add of
> children to each parent. I have about 8 levels of
> parent-child relations. Doing
> seems only to add the first level. How can I make it recursive?
You cannot make it recursive! Where are the grand children, and the
grand-grand children, etc?
> Do I have to keep track of the element that I start to add
> children to and when all my addContent have been done I add
> the first element to the root and last create a Document?
Not knowing what your'e trying to do, but here are two hints:
1) if youre tree is static, one alternative is to use a bottom-up
approach (although I do not really recommend the coding style):
Element e =
(At least the tree structure is obvious :-))
2) if your tree is dynamic, you must have some representation of it
you go off and construct the JDOM tree. This representation must then be
and the JDOM tree built up along the way.
This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you.
E-mail including attachments is susceptible to data corruption, interruption, unauthorized amendment, tampering and viruses, and we only send and receive e-mails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof.
To control your jdom-interest membership:</FONT>
<PRE><TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
Phil Weighill-Smith <<A HREF="mailto:email@example.com"><U>firstname.lastname@example.org</U></A>><BR>