• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

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
0
egoselfaxis
Asked:
egoselfaxis
  • 3
1 Solution
 
Geert BormansCommented:
<xsl:if match=".[TOPIC='topic1']">
is NOT correct

<xsl:if test="TOPIC='topic1'">
likely is

for the rest you can simply do
<xsl:if test="topic != "topic1" and topic != "topic2" and topic != "topic3"">
0
 
Geert BormansCommented:
I messed up the quotes, inside the test attribute all should ne single quotes

in XSLT2 you can say

<xsl:if test="not(topic = ('topic1', 'topic2', 'topic3')">
0
 
egoselfaxisAuthor Commented:
Thanks so much!  Your suggestion worked.

Cheers,
- Yvan
0
 
Geert BormansCommented:
welcome
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now