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

Re: Problems merging two xml documents

Subject: Re: Problems merging two xml documents
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Mon, 04 May 2009 19:07:03 +0200
Re:  Problems merging two xml documents
sp wrote:

final doc, which is just a new version of doc1:


 <!-- etc -->

 <!--etc -->

 <c1>more recent stuff</c1>
 <c2>more recent stuff</c2>
 <!--etc -->

<d> new element not in doc1 </d>


Here is a sample XSLT 2.0 stylesheet that does the job with Saxon 9 and the XML input samples you provided:


<xsl:output indent="yes"/>

  <xsl:param name="url2" select="'test2009050404.xml'"/>
  <xsl:variable name="d2" select="document($url2)"/>

<xsl:template match="/*">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="*"/>
<xsl:copy-of select="$d2/*/*[not(some $c in current()/* satisfies (node-name(.) eq node-name($c)))]"/>

<xsl:template match="/*/*">
<xsl:copy-of select="*[not(some $c in $d2/*/*[node-name(.) eq node-name(current())]/* satisfies (node-name(.) eq node-name($c)))]"/>
<xsl:copy-of select="$d2/*/*[node-name(.) eq node-name(current())]/*"/>



	Martin Honnen

Current Thread


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.
First Name
Last Name
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.