|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Copying node but changing attributes
well, you've done 99% of the work, the only thing to
do is fill in <!-- DO SOMETHING WITH ATTR -->
(and take out xsl:copy)
but hard to say as you haven't said how you want to change the
attribute.
For example
<xsl:template match="node">
<xsl:copy>
<xsl:copy-of"@*[not(name()='x' or name()='y')]">
<xsl:attribute name="xxx">
<xsl:value-of select="@y"/>
</xsl:attribute>
<xsl:attribute name="yyy">
I was here
</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
copies any attribute not called x or y, makes a new attribute xxx with
the data from the old y attribute, makes a new attribute yyy
and doesn't use the old x attribute at all.
or perhaps
<xsl:template match="node">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:attribute name="new-{name()}">
<xsl:text>modified from </xsl:text>
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
which changes
<node a="1" b="2">
to
<node new-a="modified from 1" new-b="modified from 2">
or at least I hope it does, haven't checked:-)
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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








