help concat 2 variables

Here should go questions about transforming XML with XSLT and FOP.
mhewedy
Posts: 1
Joined: Wed Nov 11, 2009 6:04 pm

help concat 2 variables

Post by mhewedy »

Hi folks,

I need your help in the following scenario :

<xsl:variable name="var1" select="'SOME_DATA1'" />
<xsl:if test="'some_condition'">
<xsl:variable name="var2" >
<xsl:value-of select="'SOME_DATA2'"/>
</xsl:variable>
</xsl:if>
<data> <!-- I need here to contact var1 with var2, please help --> </data>

Thanks.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: help concat 2 variables

Post by george »

Using something like:
<xsl:if test="'some_condition'">
<xsl:variable name="var2" >
<xsl:value-of select="'SOME_DATA2'"/>
</xsl:variable>
</xsl:if>
does not make too much sense because the variable will not be available outside the xsl:if instruction. The way to work in such situations is to place the xsl:if inside the variable definition, like

Code: Select all


<xsl:variable name="var2" >
<xsl:if test="'some_condition'">
<xsl:value-of select="'SOME_DATA2'"/>
</xsl:if>
</xsl:variable>
[code]

Best Regards,
George
George Cristian Bina
Post Reply