RE: [xsl] Error trapping in xsl

Subject: RE: [xsl] Error trapping in xsl
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 12 Jul 2001 12:06:47 +0300
> <xsl:choose>
>          <xsl:when test="foo"><!--ELEMENT CONTENT NOT EMPTY-->
>                 <!--SHOW IMAGE LINK VALUE-->
>                 <img><xsl:attribute name="src"><xsl:value-of
> select="image_link" /></xsl:attribute></img>
>          </xsl:when>
>          <xsl:otherwise><!--ELEMENT CONTENT EMPTY-->
>                 <!--SHOW NULL IMAGE-->
>                 <img><xsl:attribute
> name="src">null.gif</xsl:attribute></img>
>         </xsl:otherwise>
> </xsl:choose
> Is this the best/only method to use?

Do you mean the error trapping thingy to which Mike K. already answered, or
whether that is the best way of doing that particular thingy above? If
latter, you could write

    <xsl:attribute name="src">
        <xsl:when test="image_link != ''">
          <xsl:value-of select="image_link" />

Which would be a bit shorter, or

  <img src="{substring(concat('null.gif', image_link), not(image_link = '')
* 9, 1 div 0)}" />

Which would be even shorter. Hope this helps,


 XSL-List info and archive:

Current Thread