Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 221
gacon Avatar asked Aug 03 '09 10:08

gacon


People also ask

How to write IF condition in XSLT?

The <xsl:if> Element To put a conditional if test against the content of the XML file, add an <xsl:if> element to the XSL document.

Can we use if else in XSLT?

XSLT if-else elements contain a sequence of conditions with the expression values that work when a condition is true with the <xsl: when> statement. this <xsl:when> specifies unlimited instructions. XSL specifications implies a function<xsl: choose> to implement the functionality of if-else statements.

Can we use multiple When in XSLT?

yes, they are mutually exclusive - refer to stackoverflow.com/questions/18742988/…

Is XSLT case sensitive?

xslt. The values of the tableName XML element is case insensitive.


1 Answers

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> 
like image 53
gef Avatar answered Sep 24 '22 05:09

gef