Subject: RE: XSLT - update attribute with new value
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 5 Nov 2004 15:39:46 -0000
|
Perhaps you aren't supplying a value for the two stylesheet parameters?
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Ann Marie Rubin [mailto:Annmarie.Rubin@xxxxxxx]
> Sent: 05 November 2004 14:37
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: XSLT - update attribute with new value
>
> 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>
|