[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Choose conditional by tag value

Subject: Choose conditional by tag value
From: "Amy Drayer" <amostrom@xxxxxxxxx>
Date: Mon, 13 Aug 2007 08:31:12 -0500
 Choose conditional by tag value
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.