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

Merging two xml documents using xslt

Subject: Merging two xml documents using xslt
From: Jianyu Lai <jlai@xxxxxxxx>
Date: Tue, 1 Feb 2005 08:57:59 -0800
merging two xml documents
Hi all,

I'm rather new to XSL. I am struggling trying to come up with an xslt to
solve the following problem:

First I have the source xml that looks like this:
<employee>
  <name>
    <first>Bob</first>
  </name>
</employee>

I have another xml (updates.xml) that contains information about how to
update the above source. Notice that this updates.xml is dynamically
generated, and its contents vary.

<updates>
  <elem xpath="/employee/address/country" xvalue="USA" />
  <elem xpath="/employee/name/first" xvalue="Bill" />
</updates>

I want to write an xslt that reads information from updates.xml, and updates
source.xml based on these criteria:
- if xpath in updates.xml exist in source.xml, replace source xml node with
xvalue;
- otherwise, create xml node in source(recursively if necessary), with
xvalue defined in updates.xml;

Basically here is the result xml that I need:
<employee>
  <name>
    <first>Bill</first>
  </name>
  <address>
    <country>USA</country>
  </address>
</employee>

Is this something that can be done by xslt? If so, could any one shed some
light on this? Your help is greatly appreciated.

Jianyu Lai

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.