egoselfaxis
asked on
Need help adding if / else statements in XSL markup
I need to add some if / else statements to an XSL file.
I understand that I can do something like this:
<xsl:for-each select="CATALOG/CD">
<xsl:if match=".[TOPIC='topic1']">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="TOPIC"/></td>
</tr>
</xsl:if>
</xsl:for-each>
However, .. how would I extend this to have mutiple conditionals, .. and with some "NOT EQUAL TO" operators?
if topic = "topic1" OR topic = "topic2" OR topic = "topic3"
if topic != "topic1" AND topic != "topic2" AND topic != "topic3"
Is this possible somehow? If so, how?
Thanks!
- Yvan
I understand that I can do something like this:
<xsl:for-each select="CATALOG/CD">
<xsl:if match=".[TOPIC='topic1']">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="TOPIC"/></td>
</tr>
</xsl:if>
</xsl:for-each>
However, .. how would I extend this to have mutiple conditionals, .. and with some "NOT EQUAL TO" operators?
if topic = "topic1" OR topic = "topic2" OR topic = "topic3"
if topic != "topic1" AND topic != "topic2" AND topic != "topic3"
Is this possible somehow? If so, how?
Thanks!
- Yvan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so much! Your suggestion worked.
Cheers,
- Yvan
Cheers,
- Yvan
welcome
in XSLT2 you can say
<xsl:if test="not(topic = ('topic1', 'topic2', 'topic3')">