Subject: xsl:choose and xsl:when
From: oryann9 <oryann9@xxxxxxxxx>
Date: Tue, 28 Aug 2007 15:43:43 -0700 (PDT)
|
Hello all,
Still new to xsl and xml, but I am getting stuck on
one of my online class lessons from oreilly. I need to
use another xsl:when to output (HOME) when the TYPE
attribute is empty.
Here is what I have thus far:
Was not sure what it means to be empty in xsl, but I
have used <xsl:when test="(PHONE/@TYPE='')"> and other
similar trys with no luck.
please help
thx!
__CODE__
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>My Phone Book</TITLE>
</HEAD>
<BODY BGCOLOR="BLACK">
<xsl:apply-templates select="//LISTING" />
</BODY>
</HTML>
</xsl:template>
<xsl:template match="LISTING">
<FONT COLOR="WHITE"><xsl:value-of
select="LAST"/>,
<xsl:value-of select="FIRST"/></FONT>
<FONT COLOR="orange" SIZE="+2"><xsl:value-of
select="PHONE"/>
<xsl:choose>
<xsl:when test="boolean(PHONE/@TYPE)">
(<xsl:value-of select="PHONE/@TYPE" />)
</xsl:when>
<xsl:when test="(PHONE/@TYPE='')">
(HOME)
</xsl:when>
<xsl:otherwise>
(HOME)
</xsl:otherwise>
</xsl:choose>
</FONT>
</xsl:template>
</xsl:stylesheet>
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/
|