Altova Mailing List Archives

RE: [xsl] Get value from update.xml and stored in source.xml(update source.xml)

From: "Shailesh" <shailesh@------------>
Date: 9/8/2005 9:20:00 AM

Using below xsl the output is like:

<?xml version="1.0" encoding="utf-8"?>
    <test1 id="0000001">

<test2> element is missing in source.xml which should be


-----Original Message-----
From: Joris Gillis [mailto:roac@xxxxxxxxxx] 
Sent: Thursday, September 08, 2005 2:26 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Get value from update.xml and stored in source.xml(update


Tempore 10:39:52, die 09/08/2004 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx
scripsit Shailesh <shailesh@xxxxxxxxxxxx>:

> Using xslt 1.0 I have to extract the value of <test2> which is in 
> <test1 id="0000001"> of update.xml and put it in <test2> which is in 
> <test1 id="0000001"> of source.xml.
> This should updates the <test2> of source.xml without any other changes.

Try applying the following stylesheet to 'source.xml'.

<xsl:stylesheet xmlns:xsl=""
version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space

<xsl:output method="xml" />

<xsl:variable name="update" select="document('update.xml')"/> <xsl:key
name="id" match="*" use="@id"/>

<xsl:template match="*[@id]">
	<xsl:variable name="id" select="@id"/>
		<xsl:apply-templates select="@*" />
		<xsl:for-each select="$update">
			<xsl:copy-of select="key('id',$id)/*"/>

<xsl:template match="node()|@*">
		<xsl:apply-templates select="node()|@*" />


Joris Gillis (
Deserta faciunt et innovationem appelant


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 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.