Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Merging two xml documents using xslt

From: Jianyu Lai <jlai@-------->
To:
Date: 2/1/2005 4:58:00 PM
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


transparent
Print
Mail
Digg
delicious
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