[xsl] XSLT - update attribute with new value

Subject: [xsl] XSLT - update attribute with new value
From: Ann Marie Rubin <Annmarie.Rubin@xxxxxxx>
Date: Fri, 05 Nov 2004 09:36:39 -0500
Hello David,

Thanks very much for your help.  At least I now know that this is possible.

My stylesheet outputs the xml file unchanged. It does not replace the
value with the value of $value.  I am probably doing something wrong
with the variable declaration but don't see the problem.  The stylesheet
looks like this:

Do you see what might be wrong?

Thanks very much,

Ann Marie

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output indent="yes" method="xml"/>
    <xsl:variable name="attr" select="deployment-version"/>
        <xsl:variable name="value" select='TEST'/>
<xsl:param name="attr"/>
<xsl:param name="value"/>


<xsl:template match="node()|@*">

<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
 
<xsl:template match="@*" priority="10">
<xsl:attribute name="{name()}">
 <xsl:choose>
   <xsl:when test="name()=$attr"><xsl:value-of select="$value"/></xsl:when>
   <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
  </xsl:choose>
</xsl:attribute>
</xsl:template>

 
</xsl:stylesheet>

Current Thread