[xsl] Problems merging two xml documents

Subject: [xsl] Problems merging two xml documents
From: sp <spamthis@xxxxxxxxxxxxxx>
Date: Mon, 4 May 2009 09:31:40 -0700
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

Current Thread