|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Reading two xmls and changing the attribute names
Hi,
Tempore 10:34:27, die 07/06/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Lakshmi narayana <lchintala@xxxxxxxxxxxx>: 6) Can any one send me the xsl code for this scenario.consider that the scond file is named 'second.xml' and the stylesheet is processed on the first file. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml"/> <xsl:key name="newName" match="destination" use="concat(local-name(../..),../source/@name)"/> <xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@*">
<xsl:with-param name="Type" select="@Type"/>
</xsl:apply-templates>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:param name="Type"/>
<xsl:variable name="name" select="local-name()"/>
<xsl:variable name="newname">
<xsl:for-each select="document('second.xml')">
<xsl:value-of select="key('newName',concat($Type,$name))/@name"/>
</xsl:for-each>
</xsl:variable>
<xsl:attribute name="{$newname}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template><xsl:template match="@Type"><xsl:copy/></xsl:template> </xsl:stylesheet> will produce: <A1 A-Element-Name="A1" A-sequence="1" A-Description="optional" Type="AGroup"> <B1 B-Element-Name="B1" B-sequence="101" B-order="first" Type="BGroup"/> <B2> <C1 C-Element-Name="C1" C-sequence="201" C-order="Sec" Type="CGroup"/> <C2 C-Element-Name="C2" C-sequence="202" C-order="Sec" Type="CGroup"> <C3/> <D1 D-Element-Name="D1" D-Min="1" D-Max="1" D-Reference="Trr" D-Predicate="" Type="DGroup"> <C2 C-Element-Name="C2" C-sequence="202" C-order="Sec" Type="CGroup"/> </D1> </C2> </B2> </A1>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








