Hi,<br><br>I think you should clone the staticDocument before running each merge. Now you have the same staticDocument stored multiple times in the finalDocumentList so all the output files are identical.<br><br>Regards,<br>
GK<br><br><div><span class="gmail_quote">2007/11/23, <a href="mailto:Jasmin_Mehta@nexweb.org">Jasmin_Mehta@nexweb.org</a> <<a href="mailto:Jasmin_Mehta@nexweb.org">Jasmin_Mehta@nexweb.org</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><font face="sans-serif" size="2">I am building multiple dynamic xml documents
from result set and storing them to an ArrayList called 'xmlDocumentList'.</font>
<br><font face="sans-serif" size="2">I have another static xml document called
'staticDocument'. Where static document looks like:</font>
<br>
<br><font face="sans-serif" size="2"><Transmission></font>
<br><font face="sans-serif" size="2"> <TransmissionHeader></font>
<br><font face="sans-serif" size="2">
<UserName /></font>
<br><font face="sans-serif" size="2">
<Password /></font>
<br><font face="sans-serif" size="2"> </TransmissionHeader></font>
<br><font face="sans-serif" size="2"> <TransmissionBody></font>
<br><font face="sans-serif" size="2"> <!----- here
goes GLogXMLElement XML element ----></font>
<br><font face="sans-serif" size="2"> </TransmissionBody></font>
<br><font face="sans-serif" size="2"> </Transmission></font>
<br>
<br><font face="sans-serif" size="2">Now I want to create another ArrayList
'finalDocumentList' out of mergeing 'staticDocument' with each element
of 'xmlDocumentList'. That will be like each element of 'finalDocumentList'
is made from merging 'staticDocument' with 'xmlDocumentList[i]' (one of
dynamic document element) at <TransmissionBody>. When I do that with
attached code snippet, it creates the GlogFinal0.xml, GlogFinal1, GlogFinal2..etc
file with all having same content in them. It uses only first element of
'xmlDocumentList' to build all elements of 'finalDocumentList'.</font>
<br>
<br><font face="sans-serif" size="2">----------------------------------------------------------------------------------------------------------------------------------</font>
<br><font face="sans-serif" size="2"> ArrayList
dynamicDocumentList = xmlBuilder.getDynamicXmlDocuments();</font>
<br><font face="sans-serif" size="2"> Document
staticDocument = xmlBuilder.getStaticXmlWrapper();</font>
<br><font face="sans-serif" size="2"> ArrayList
finalDocumentList = new ArrayList(); </font>
<br><font face="sans-serif" size="2"> Element
staticRoot = staticDocument.getRootElement();</font>
<br><font face="sans-serif" size="2"> Element
staticChild = staticRoot.getChild("TransmissionBody");</font>
<br><font face="sans-serif" size="2"> Element
dynamicRoot = null;</font>
<br><font face="sans-serif" size="2"> for(int
i = 0; i < dynamicDocumentList.size(); i++)</font>
<br><font face="sans-serif" size="2"> {</font>
<br><font face="sans-serif" size="2">
dynamicRoot = ((Document)dynamicDocumentList.get(i)).getRootElement();</font>
<br><font face="sans-serif" size="2">
staticChild.addContent(dynamicRoot.detach()); </font>
<br><font face="sans-serif" size="2"> finalDocumentList.add(staticDocument);</font>
<br><font face="sans-serif" size="2"> }</font>
<br><font face="sans-serif" size="2"> FileOutputStream
finalXmlFile = null;</font>
<br><font face="sans-serif" size="2"> XMLOutputter
xmlOutPutter = null;</font>
<br><font face="sans-serif" size="2"> for
(int i = 0; i < finalDocumentList.size(); i++)</font>
<br><font face="sans-serif" size="2"> {</font>
<br><font face="sans-serif" size="2">
finalXmlFile = new FileOutputStream("F:\\JavaProjects\\WorkspaceDev\\OTM\\xsl\\GLogFinal"+i+".xml");</font>
<br><font face="sans-serif" size="2">
xmlOutPutter = new XMLOutputter(Format.getPrettyFormat());</font>
<br><font face="sans-serif" size="2">
xmlOutPutter.output((Document)(finalDocumentList.get(i)), finalXmlFile);</font>
<br><font face="sans-serif" size="2"> }
</font><p><font size="1"><font face="arial,helvetica,sans-serif"><strong>******************************************************************************<br></strong><font color="#ff0000">ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
</font> <br>Our domain name is changing. Please take note of the sender's<br>e-Mail address and make changes to your personal address list,<br>if needed. Both domains will continue to work, only for a limited<br>time.
<br>******************************************************************************<br>This email and any files transmitted with it are intended solely for <br>the use of the individual or agency to whom they are addressed.
<br>If you have received this email in error please notify the Navy <br>Exchange Service Command e-mail administrator. This footnote <br>also confirms that this email message has been scanned for the<br>presence of computer viruses.
</font></font></p><p><font size="1"><font face="arial,helvetica,sans-serif">Thank You! <br><strong>******************************************************************************</strong></font></font></p>
<br>_______________________________________________<br>To control your jdom-interest membership:<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com" target="_blank">
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a><br></blockquote></div><br><br clear="all"><br>-- <br>"Choć tyle wiemy własnym doświadczeniem:<br>W nas jest Raj, Piekło - i do obu - szlaki."
<br>J.K.