mercoledì, gennaio 20, 2010

xsl:if and xsl:choose

I ran across a great article by Bob DuCharme on XML.com titled “Conditional Execution.” It illustrates the uses of xsl:if and xsl:choose in XSLT. A few samples to whet your appetite:

  <xsl:if test="@author='jm'">

    The poem's author is jm.

  </xsl:if>

And

  <xsl:choose>

    <xsl:when test="@year < 1638">

   The poem is one of Milton's earlier works.

    </xsl:when>

    <xsl:when test="@year < 1650">

   The poem is from Milton's middle period.

    </xsl:when>

    <xsl:otherwise>

      The poem was written after Milton's death.

    </xsl:otherwise>

  </xsl:choose>