Hi,
Using below xsl the output is like:
<?xml version="1.0" encoding="utf-8"?>
<test>
<chapter>
<test1 id="0000001">
</test1>
</chapter>
</test>
<test2> element is missing in source.xml which should be
<test2>ABCD</test2>.
--
Shailesh
-----Original Message-----
From: Joris Gillis [mailto:roac(_at_)pandora(_dot_)be]
Sent: Thursday, September 08, 2005 2:26 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Get value from update.xml and stored in source.xml(update
source.xml)
Hi,
Tempore 10:39:52, die 09/08/2004 AD, hinc in
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
scripsit Shailesh <shailesh(_at_)quagnito(_dot_)net>:
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="http://www.w3.org/1999/XSL/Transform"
version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space
elements="*"/>
<xsl:output method="xml" />
<xsl:variable name="update" select="document('update.xml')"/> <xsl:key
name="id" match="*" use="@id"/>
<xsl:template match="*[(_at_)id]">
<xsl:variable name="id" select="@id"/>
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:for-each select="$update">
<xsl:copy-of select="key('id',$id)/*"/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Deserta faciunt et innovationem appelant
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--