[XML-SIG] Swap images for text elements using xsl?

Olivier CAYROL (Logilab) Olivier.Cayrol@logilab.fr
Wed, 28 Mar 2001 10:33:06 +0200 (CEST)


Hello,

On Tue, 27 Mar 2001 Lance_Hill/OLS.OLS@olsinc.net wrote:

> Currenly, I am using a table to display the text wrapped in each tag
> (generally a Y or N), but I would prefer to use an image selectred
> depending on the text element in each tag.

A solution is to use an <xsl:choose>, <xsl:when>, <xsl:otherwise>
statement (see example below).

  <xsl:template match=3D"/">
  <HTML>
  <BODY>
  <table border=3D"1">
  <tr>
    <th>New Client Status</th>
  ...etc.
  </tr>
 =20
 =20
   <xsl:for-each select=3D"status_report/agency">
    <tr>
    <td>

     <xsl:choose>
      <xsl:when test=3D"new-client_status =3D 'Y'">
       <IMG SRC=3D"image_yes.gif"/>
      </xsl:when>
      <xsl:otherwise>
       <IMG SRC=3D"image_no.gif"/>
      </xsl:otherwise>
     </xsl:choose>

    </td>
  ...etc.
 =20
    </tr>
    </xsl:for-each>
    </table>
    </BODY>
    </HTML>
    </xsl:template>
    </xsl:stylesheet>

Regards,

  O. CAYROL.
_________________________________________________________________________
Olivier CAYROL                                   LOGILAB - Paris (France)
                                                 http://www.logilab.com/
Change your millenium, try NARVAL the Intelligent Personal Assistant.
Changez de mill=E9naire, essayez NARVAL l'Assistant Personnel Intelligent.
_________________________________________________________________________