27

I have a loop with the same tags to load content in ten cells but has a difference div title and background image, so I wonder is there any way to use the switch case just to put correct div title when I do for-each to load content for each cells in XSL? something like this: <...load the same tags content here...> Please help me because I'm new in XSL, and thank you in anyway!!

gef
  • 7,025
  • 4
  • 41
  • 48
gacon
  • 2,075
  • 4
  • 21
  • 32

1 Answers1

52

You may use the if condition

<xsl:if test="expression">
  ...some output if the expression is true...
</xsl:if>

or choose, if there's more than one condition to check

<xsl:choose>
  <xsl:when test="expression">
    ... some output ...
  </xsl:when>
  <xsl:when test="another expression">
    ... some output ...
  </xsl:when>
  <xsl:otherwise>
    ... some output ....
  </xsl:otherwise>
</xsl:choose>
gef
  • 7,025
  • 4
  • 41
  • 48
  • thank you for your help very much, but I wonder can I make multies xsl:choose like multies case: in switch or just one? – gacon Aug 04 '09 at 01:55
  • Yes you can have multiple – gef Aug 04 '09 at 11:13
  • 7
    Having a look at the documentation can be a real eye-opener sometimes. ;-) http://www.w3.org/TR/xslt#section-Conditional-Processing-with-xsl:choose – Tomalak Aug 04 '09 at 11:13