declare variable in xsl

may I know how do i assign a variable for the value selected below:
example:
<xsl:template match=“/”>
<xsl:value-of select=“catalog/cd/title”/>
</xsl:template>

using xsl:param how do i retreive the variable and concatenate it together with another variable to form a new string? please kindly help!

what is important is how to retrieve the variable such that i can fix that value into part of a URL?

can anyone please help me? thank you so much!

Hello there,

About xsl variable, there is an offside that you should be aware of : they are CONSTANT. That means that once you valued a variable it cannot be overwritten (counters are not available with xsl:variable). Overwriting is syntaxly possible (you won’t get any error, even at runtime) but it won’t work.

Let’s get to code :


<xsl:stylesheet version=“1.0” xmlns:xsl=“XSLT Namespace”>

<xsl:param name=“baseWebapp” select=“http://myBigHOST/myWebapp”/>

<xsl:template match=“/”>

<xsl:variable name=“title” select=“catalog/cd/title” />

<xsl:call-template name=“buildURL”>
<xsl:with-param name=“baseURL” select=“$baseWebapp” />
<xsl:with-param name=“title” select=“$title” />
</xsl:call-template>

</xsl:template>

<xsl:template name=“buildURL”>
<xsl:param name=“baseURL” />
<xsl:param name=“title” />

<xsl:value-of select=“$baseURL” />
xsl:text?title=</xsl:text>
<xsl:value-of select=“$title” />

</xsl:template>

</xsl:stylesheet>

Is this snippet enough for you. Feel free to ask for more.

Cheers

Bertrand Martel
Software AG France

Thanks Bertrand!

Gemi