This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Copying node but changing attributes
- To: XSL-List at mulberrytech dot com
- Subject: Copying node but changing attributes
- From: "Joerg Colberg" <joerg dot colberg at econovo dot com>
- Date: Fri, 29 Sep 100 09:50:10 EDT
- Reply-To: xsl-list at mulberrytech dot com
Hi all,
Here is my most recent problem: I want to copy nodes from the input
xml to the output xml but I want to change the contents of some of
their attributes. I found the following little template in Michael
Kay's book:
<xsl:template match="node">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
This template copies node plus their attributes. Now I thought
could modify the template but somehow I am stuck. I thought I
could loop over the attributes. But how do I change them. To give you
an example, some of the atributes contain placeholders. I want
to replace those with real data. How would I do this? Would the
following concept work? And how would I be able to change the
attributes? Would the xsl:copy copy the changed attributes?
<xsl:template match="node">
<xsl:copy>
<xsl:for-each select="@*">
<!-- DO SOMETHING WITH ATTR -->
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
Thanks for any help on this!
- Joerg
________________________________
Dr Joerg M Colberg
Econovo Software, Inc
joerg.colberg@econovo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list