[xsl] Choose conditional by tag value

Subject: [xsl] Choose conditional by tag value
From: "Amy Drayer" <amostrom@xxxxxxxxx>
Date: Mon, 13 Aug 2007 08:31:12 -0500
Dear XSL list:

I am new to this, and I've tried to figure out why this isn't working
using books and websites without any success.  Please share your
insight with me!

I am styling XML that is produced by third party software.  It gives a
list of events, and if there aren't any events, it gives a message in
the <title> tag that reads No Events Currently Scheduled.  I want that
to look different than days with actual events.  So:

 <xsl:template match="/">
     <xsl:choose>
      <xsl:when  test="[title='No Events Currently Scheduled']">
            <p>No events scheduled</p>
    </xsl:when>
    <xsl:otherwise>
       <xsl:for-each select="event/item">
         <div class="xmlitem">
         <h3>
           <span class="xmlfeedtitle">
            <a>
              <xsl:attribute name="href">
                <xsl:value-of select="link" />
              </xsl:attribute>
             <xsl:value-of select="title"
disable-output-escaping="yes"></xsl:value-of></a>
           </span>
         </h3>
         <p class="xmlitemdate">
           <xsl:value-of select="time"></xsl:value-of> at
           <span class="xmlfeedlocation">
             <xsl:value-of select="library"></xsl:value-of>
           </span>
         </p>
         </div>
       </xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>


And I have two XML samples to work with:
No events:
<event>
<item>
<title>No Events Currently Scheduled</title>
<date/>
<time/>
<description/>
<location/>
<library/>
<link/>
</item>
</event>

Events:
<item>
<title>Basic PC (Personal Computers)</title>
<date>Tuesday August 7th, 2007</date>
<time>09:00 AM</time>
<description>Want to learn how to use personal computer? This free,
one-hour basic computer training class is an excellent place to start.
Gain experience using the mouse, keyboard and Microsoft Windows
operating system.</description>
<location></location>
<library>Corinth Library</library>
<link>http://calendar.jocolibrary.org/evanced/lib/eventsignup.asp?ID=2623
</link>
</item>
</event>

Can anyone please tell me what I am doing wrong?  I thought it was the
spaces, but it's a string... right?  Thank you for your help.

-- 
In peace,

Amy M. Drayer
Web Interface Designer
amostrom@xxxxxxxxx
http://www.puzumaki.com

Current Thread