Appending a Doc

I have a xml document stored in Tamino


On the other hand I?m creating an XML doc using the DOM model which has name as it?s element. What I want to do is take the name document from the Tamino database and put it in my newly created document as an child elemet .
I have a class that extracts the name document from tamino, and in my other class where I?m creating a new xml doc I call on the name class eg

Document doc = db.newDocument();
Name name= new Name();
String nam = (String) name.extract();
Element nameEl = doc.createElement(nam);

When I run the program I get the name document and the newly created document separately and I want the name doc to be appended as a child element to the new document.
Can someone advice on how best can I do this .

I’ve made some progress but now have a different problem.

I get a TResponse object from a query and get an TXMLObject by doing a getFirstXMLObject().

Then I get a JDOM element by doing the getElement() method and casting it.

Now I want to append this JDOM element (using the addContent method) to a element of a different, newly created JDOM document.

I get an error

 org.jdom.IllegalAddException: The element "Organisation" could not be added as a child of "Submission": The element already has an existing parent "xql:result" 


How can I get a JDOM element from a Tamino query result without it having the parent xql:result? Is this possible?


You need to execute

myElement = myElement.detach()

to remove your element from its existing parent before you can attach it to another.

Please note that this is not a Tamino API issue; it relates only to the JDOM API. Please refer to your JDOM API documentation.


I used the

and it worked.