tags:

views:

316

answers:

1
+3  Q: 

switch case in XSL

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!!

+4  A: 

Hi yes, use if

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

or choose

<xsl:choose>
  <xsl:when test="expression">
    ... some output ...
  </xsl:when>
  <xsl:otherwise>
    ... some output ....
  </xsl:otherwise>
</xsl:choose>
gef
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
Yes you can have multiple <xsl:when .... 's. Obviously the test expression would be different in each case.
gef
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