|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
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> |
|
#3
|
||||
|
||||
|
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>
|
|
#4
|
|||
|
|||
|
<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> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xsl:if to test an element's contents? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|