This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Merging two documents
- To: XSL-List at lists dot mulberrytech dot com
- Subject: [xsl] Merging two documents
- From: Martin Renner <m dot renner at tiscon dot com>
- Date: Tue, 10 Apr 2001 09:36:49 +0159
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi.
I have two xml files which have the same structure (and the same DTD). Those two
files should be merged into one single xml file, so that the resulting file will
still be valid (according to the DTD).
I already checked the xsl archive and the FAQ on http://www.dpawson.co.uk/xsl, but I
didn't find a solution for my problem. My problem is, that I cannot identify the
elements by an id.
file1.xml
<root>
<section1>
<elem>
<name>1</name>
nested data for elem "1"
</elem>
<elem>
<name>2</name>
nested data for elem "2"
</elem>
</section1>
<section2>
<something-else>
nested data 1
</something-else>
</section2>
</root>
file2.xml has the same structure. Here is just a very short example (usually,
file2.xml will also contain <section2>):
<root>
<section1>
<elem>
<name>3</name>
nested data for elem "3"
</elem>
</section1>
</root>
I need something like
for-each file1/root/section1/elem
copy to output
for-each file2/root/section1/elem
copy to output
for-each file1/section2/something-else
copy to output
for-each file2/section2/something-else
copy to output
How can I write that in XSL (and will this be a solution or are there any "smarter"
solutions)?
Martin
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list