Multiple File input in XSLT transformation -


i want update 1 xml values other xml.

suppose have xml having root node

<customer>   <fname>john</fname>   <lname>smith<lname> </customer> 

the other xml having

<customer>                                   <lname>smith<lname> </customer> 

i want transfer <fname>john</fname> 1st 2nd xml if information not present in 2nd xml.

is possible using xslt in .net?

this stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">     <xsl:key name="kelementbyancestors" match="*"              use="concat(name(../..),'+',name(..))"/>     <xsl:key name="kattributebyancestors" match="@*"              use="concat(name(../..),'+',name(..))"/>     <xsl:param name="psource2" select="'source2.xml'"/>     <xsl:variable name="vsource2" select="document($psource2,/)"/>     <xsl:template match="*">         <xsl:variable name="vkey" select="concat(name(..),'+',name())"/>         <xsl:variable name="vcurrent" select="."/>         <xsl:copy>             <xsl:for-each select="$vsource2">                 <xsl:variable name="vnames">                     <xsl:text>|</xsl:text>                     <xsl:for-each select="$vcurrent/*">                         <xsl:value-of select="concat(name(),'|')"/>                     </xsl:for-each>                 </xsl:variable>                 <xsl:copy-of select="key('kattributebyancestors',$vkey)"/>                 <xsl:copy-of select="$vcurrent/@*"/>                 <xsl:copy-of                      select="key('kelementbyancestors',                                  $vkey)[not(contains($vnames,                                                      concat('|',                                                             name(),                                                             '|')))]"/>             </xsl:for-each>             <xsl:apply-templates select="node()"/>         </xsl:copy>     </xsl:template> </xsl:stylesheet> 

with input:

<customer>     <lname>smith</lname>     <data>data</data> </customer> 

and "source2.xml":

<customer test="test">     <fname>john</fname>     <lname>smith</lname> </customer> 

output:

<customer test="test">     <fname>john</fname>     <lname>smith</lname>     <data>data</data> </customer> 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -