Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Problems merging two xml documents

From: sp <spamthis@-------------->
To:
Date: 5/4/2009 4:32:00 PM
HI,

I'm trying to merge and copy two xml documents, into a new xml
document and in a nutshell no matter what xsl I write I have yet to
been able to get it to merge as I desire.

I don't just want the content of the elements, I want to make a copy
of each element making a new xml document. I've been utilizing the xsl
copy-of and the document() to try and do this, with merge and copy
examples as my guide.

After a day and a half of trying, I've gotten close, but still can't
get any one example to do what I need.  I don't know what of my many
efforts to provide as an example, so I thought I should just
illustrate below what I want and see if anyone can offer help.

thanks in advance for any suggestions or examples.

This document is merged with doc2, to form a new version of doc1.  Any
common elements from doc2 replace doc1s elements of the same name, any
new elements from doc2 are added

<doc1>

<a>
 <a1></a1>
 <a2></a2>
 <!-- etc -->
</a>

<b>
 <b1></b1>
 <b2></b2>
 <!--etc -->
</b>

<c>
 <c1></c1>
 <c2></c2>
 <!--etc -->
</c>

</doc1>

All except root element should be merged into doc1,  if element
already exists it replaces the ones in doc1

<doc2>

<c>
 <c1>more recent stuff</c1>
 <c2>more recent stuff</c2>
 <!--etc -->
</c>

<d> new element not in doc1 </d>

</doc2>


final doc, which is just a new version of doc1:


<doc1>

<a>
 <a1></a1>
 <a2></a2>
 <!-- etc -->
</a>

<b>
 <b1></b1>
 <b2></b2>
 <!--etc -->
</b>

<c>
 <c1>more recent stuff</c1>
 <c2>more recent stuff</c2>
 <!--etc -->
</c>

<d> new element not in doc1 </d>

</doc1>


thank you


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent