[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Conditional merge of 2 XML files

Subject: Conditional merge of 2 XML files
From: Thomas Tarpin-Lyonnet <bartleby@xxxxxxxxxx>
Date: Wed, 31 Aug 2005 10:40:49 +0800
conditional xml files
Hello,
I'm a newbie in XSL and I would like to do something with 2 XML files and i
can't manage to do it.
Here is my problem.
I have 2 XML files, file_1.xml and file_2.xml structured as follow:
file_1.xml:
<?xml version="1.0"?>
<firstTag>
  <secondTag>
    <thirdTag> Thomas </thirdTag>
    <thirdTag> Tarpin </thirdTag>
  </secondTag>
  <secondTag>
    <thirdTag> Pipo </thirdTag>
    <thirdTag> Pipolaki </thirdTag>
  </secondTag>
</firstTag>

file_2.xml:
<?xml version="1.0"?>
<firstTag>
  <secondTag>
    <thirdTag here="Yes"> Thomas </thirdTag>
    <thirdTag here="Yes"> - </thirdTag>
    <thirdTag here="Yes"> Lyonnet </thirdTag>
  </secondTag>
  <secondTag>
    <thirdTag here="Yes"> Pipo </thirdTag>
    <thirdTag here="Yes"> Pipolaki </thirdTag>
  </secondTag>
</firstTag>

I would like to be able to do the diff between the two files and generate
another xml that will be the result of the merging of the two files only if
there are some thirdTag that are defined in file_1.xml and missing in
file_2.xml. Otherwise if the two files contains the same thirdTag then the
result.xml will be the same as file_2.xml.
The resulting file would be something like that:
result.xml:
<?xml version="1.0"?>
<firstTag>
  <secondTag>
    <thirdTag here="Yes"> Thomas </thirdTag>
    <thirdTag here="No"> Tarpin </thirdTag>
    <thirdTag here="Yes"> - </thirdTag>
    <thirdTag here="Yes"> Lyonnet </thirdTag>
  </secondTag>
  <secondTag>
    <thirdTag here="Yes"> Pipo </thirdTag>
    <thirdTag here="Yes"> Pipolaki </thirdTag>
  </secondTag>
</firstTag>

I know that i have to use the document() function but i don't know how.
How can i do that ? I'm a bit confused, i tried but i can't.
Anybody to help me ?

Thanks

Thomas

*********************************
*     Thomas Tarpin-Lyonnet     *
* http://jaccal.sourceforge.net *
*********************************

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.