Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
How to build multiple XML documents by mergeing two XML docu

How to build multiple XML documents by mergeing two XML docu

2007-11-23       - By Grzegorz Kaczor

 Back
Hi,

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.

Regards,
GK

2007/11/23, Jasmin_Mehta@(protected) <Jasmin_Mehta@(protected)>:
>
>
> I am building multiple dynamic xml documents from result set and storing
> them to an ArrayList called 'xmlDocumentList'.
> I have another static xml document called 'staticDocument'. Where static
> document looks like:
>
> <Transmission>
>       <TransmissionHeader>
>               <UserName />
>               <Password />
>         </TransmissionHeader>
>       <TransmissionBody>
>       <!-- -- here goes GLogXMLElement XML element ---->
>       </TransmissionBody>
>    </Transmission>
>
> 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'.
>
>
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
>         ArrayList dynamicDocumentList = xmlBuilder.getDynamicXmlDocuments
> ();
>         Document staticDocument = xmlBuilder.getStaticXmlWrapper();
>         ArrayList finalDocumentList = new ArrayList();
>         Element staticRoot = staticDocument.getRootElement();
>         Element staticChild = staticRoot.getChild("TransmissionBody");
>         Element dynamicRoot = null;
>         for(int i = 0; i < dynamicDocumentList.size(); i++)
>         {
>             dynamicRoot =
> ((Document)dynamicDocumentList.get(i)).getRootElement();
>             staticChild.addContent(dynamicRoot.detach());
>            finalDocumentList.add(staticDocument);
>         }
>           FileOutputStream finalXmlFile = null;
>           XMLOutputter xmlOutPutter = null;
>           for (int i = 0; i < finalDocumentList.size(); i++)
>           {
>             finalXmlFile =  new
> FileOutputStream("F:\\JavaProjects\\WorkspaceDev\\OTM\\xsl\\GLogFinal"+i+"
.xml");
>             xmlOutPutter = new XMLOutputter(Format.getPrettyFormat());
>             xmlOutPutter.output((Document)(finalDocumentList.get(i)),
> finalXmlFile);
>           }
>
> *
> ******************************************************************************
> *ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
> Our domain name is changing.  Please take note of the sender's
> e-Mail address and make changes to your personal address list,
> if needed.  Both domains will continue to work, only for a limited
> time.
>
> ******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
>
> Thank You!
> *
> ******************************************************************************
> *
>
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
>



--
"Cho? tyle wiemy w?asnym do?wiadczeniem:
W nas jest Raj, Piek?o - i do obu - szlaki."
J.K.

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@(protected)">Jasmin_Mehta@(protected)</a> &lt;<a href="mailto:Jasmin_Mehta
@(protected)">Jasmin_Mehta@(protected)</a>&gt;:</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 &#39;xmlDocumentList&
#39;.</font>
<br><font face="sans-serif" size="2">I have another static xml document called
&#39;staticDocument&#39;. Where static document looks like:</font>
<br>
<br><font face="sans-serif" size="2">&lt;Transmission&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &lt
;TransmissionHeader&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;UserName /&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;Password /&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &lt;
/TransmissionHeader&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &lt;TransmissionBody
&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &lt;!-- -- here
goes GLogXMLElement XML element ----&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &lt;/TransmissionBody
&gt;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp;&lt;/Transmission&gt;</font>
<br>
<br><font face="sans-serif" size="2">Now I want to create another ArrayList
&#39;finalDocumentList&#39; out of mergeing &#39;staticDocument&#39; with each
element
of &#39;xmlDocumentList&#39;. That will be like each element of &#39
;finalDocumentList&#39;
is made from merging &#39;staticDocument&#39; with &#39;xmlDocumentList[i]&#39;
(one of
dynamic document element) at &lt;TransmissionBody&gt;. 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
&#39;xmlDocumentList&#39; to build all elements of &#39;finalDocumentList&#39;.
</font>
<br>
<br><font face="sans-serif" size="2">-- ---- ---- ---- ---- ---- ---- ---- ----
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
-- -----</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; ArrayList
dynamicDocumentList = xmlBuilder.getDynamicXmlDocuments();</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; Document
staticDocument = xmlBuilder.getStaticXmlWrapper();</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; ArrayList
finalDocumentList = new ArrayList(); </font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; Element
staticRoot = staticDocument.getRootElement();</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; Element
staticChild = staticRoot.getChild(&quot;TransmissionBody&quot;);</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; Element
dynamicRoot = null;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; for(int
i = 0; i &lt; dynamicDocumentList.size(); i++)</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
dynamicRoot = ((Document)dynamicDocumentList.get(i)).getRootElement();</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
staticChild.addContent(dynamicRoot.detach()); </font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp
;finalDocumentList.add(staticDocument);</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
FileOutputStream
finalXmlFile = null;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
XMLOutputter
xmlOutPutter = null;</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for
(int i = 0; i &lt; finalDocumentList.size(); i++)</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
finalXmlFile = &nbsp;new FileOutputStream(&quot;F:\\JavaProjects\\WorkspaceDev\
\OTM\\xsl\\GLogFinal&quot;+i+&quot;.xml&quot;);</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
xmlOutPutter = new XMLOutputter(Format.getPrettyFormat());</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
xmlOutPutter.output((Document)(finalDocumentList.get(i)), finalXmlFile);</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp;</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.&nbsp; Please take note of the sender&
#39;s<br>e-Mail address and make changes to your personal address list,<br>if
needed.&nbsp; 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!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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@(protected)
" target="_blank">
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>&quot;Cho? tyle wiemy w?asnym
do?wiadczeniem:<br>W nas jest Raj, Piek?o - i do obu - szlaki.&quot;
<br>J.K.

__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.