himit 0 Newbie Poster

Hi,

Can we declare a variable at one place and assign it a value at another in XSLT? I know that we can assign a value to a variable only once (please correct me if I am wrong), however i am not sure whether we can do it in 2 parts i.e. to declare at one place, say at the start of the stylesheet, and assign some value in the middle of it.

Example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>

<xsl:variable name="temp"/>

<xsl:template match="/">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="catalog">
<xsl:for-each select="cd">
<singer>
<xsl:copy-of select="title"/>
<xsl:if test="country='UK'">
<!-- here i want to set the value for temp as yes-->
<xsl:variable name="temp" select="yes"/>
</xsl:if>
</singer>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Please advise is there any way to apply this logic in XSLT or not..