XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old July 21st, 2003, 12:41 PM
rnsavvy rnsavvy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 10 rnsavvy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
xsl:if to test an element's contents?

Within XSL, how do I test if the contents of an element is equal to a specific string?

For example, I've got a list of games, each with a status. If the status = 'FINAL', I don't want to display the link.

<gameday>

<game id="1">
<status>FINAL</status>
<link>game1.html</link>
</game>

<game id="2">
<status>LIVE</status>
<link>game2.html</link>
</game>

<game id="3">
<status>7:05</status>
<link>game3.html</link>
</game>

</gameday>

I know how to output a value using...
<xsl:value-of select="status"/>

And have seen the if statement...
<xsl:if test="?????"></xsl:if>

Reply With Quote
  #2  
Old July 21st, 2003, 03:18 PM
rnsavvy rnsavvy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 10 rnsavvy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've decided to take the easy way out and just make status an attribute of game.

<xsl:choose>
<xsl:when test="@status='FINAL'"><!-- final --></xsl:when>
<xsl:otherwise><!-- not final --></xsl:otherwise>
</xsl:choose>

Reply With Quote
  #3  
Old July 22nd, 2003, 09:32 AM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
I think you are on the right track. Try it like this:

Code:
<xsl:template match="game">
   <xsl:if test="status = 'FINAL'">
      <xsl:value-of select="status"/> 
   </xsl:if>
</xsl:template>

Reply With Quote
  #4  
Old July 30th, 2003, 12:40 AM
mulligh mulligh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 19 mulligh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<xsl:template match="game">
<xsl:if test="not(status = 'FINAL')">
<a>
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="link"/>
</a>
</xsl:if>
</xsl:template>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > xsl:if to test an element's contents?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway