XSL check param length

Posted by AdRock on Stack Overflow See other posts from Stack Overflow or by AdRock
Published on 2010-04-22T09:46:11Z Indexed on 2010/04/22 10:43 UTC
Read the original article Hit count: 379

Filed under:
|
|
|

I need to check if a param has got a value in it and if it has then do this line otherwise do this line.

I've got it working whereas I don't get errors but it's not taking the right branch

Here is the template which holds the html in the XSL stylesheet

<xsl:call-template name="volunteer_role">
 <xsl:with-param name="volrole" select="volunteer/roles" />
</xsl:call-template>

and here is the template where there is a choice whether to take this brancg or that brach depending if the param is empty

<xsl:template name="volunteer_role">
 <xsl:param name="volrole" select="'Not Available'" />

 <div class="small bold">ROLES:</div>
 <div class="large">
  <xsl:choose>
   <xsl:when test="string-length($volrole)!=0">
    <xsl:value-of select="$volrole" />
   </xsl:when>
   <xsl:otherwise>
    <xsl:text> </xsl:text>
   </xsl:otherwise>
  </xsl:choose>
 </div>
</xsl:template>

© Stack Overflow or respective owner

Related posts about xslt

Related posts about param