XSLT 1.0: set variable value depending on condition

2.2k views Asked by At

I want to set the value of a variable(b). If variable(a) is not empty then variable(b) equals to variable(a). If it is empty set the value to 0.00. I have tried a couple of methods but none of it works.

<xsl:variable name="aChecker" select="current()/money[last()]/value"/>

method 1:

<xsl:variable name="b">
    <xsl:choose>
        <xsl:when test="$aChecker != ''">
            <xsl:value-of select="$aChecker"/>
        <xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="0.00"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:variable>

i tried changing the

<xsl:when test="$aChecker != ''">

to

<xsl:when test="not($aChecker)">

method 2:

<xsl:choose>
    <xsl:when test="$aChecker != ''">
        <xsl:variable name="b" select="$aChecker"/>
    <xsl:when>
    <xsl:otherwise>
        <xsl:variable name="b" select="0.00"/>
    </xsl:otherwise>
</xsl:choose>
0

There are 0 answers