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

Probably a very simple xsl:if question

Subject: Probably a very simple xsl:if question
From: Jeroen Ruigrok/asmodai <asmodai@xxxxxx>
Date: Sat, 14 Feb 2004 10:12:09 +0100
xsl if date
Hi,

I am trying to get an evaluation working with <xsl:if> which I think
should work, but obviously I am missing something very specific, which I
haven't been able to find in any of my books (Learning XSLT not XSLT and
XPath On The Edge) nor on the Internet.

So I appeal to you lot. :)

I got a simple xml file of the form:

<news>
  <entry>
    <date>2004-02-14</date>
    <content>It is Valentine's Day today</content>
  </entry>
</news>

Now, in my .xsl file I do the following (don't mind the HTML4, need to convert
it to XHTML still, I also left out the CSS):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:date="http://exslt.org/dates-and-times"
  xmlns:exsl="http://exslt.org/common"
  extension-element-prefixes="date exsl">

  <xsl:output method="html" indent="yes"/>
  <xsl:output doctype-public="-//W3C//DTD HTML 4.01//EN"
    doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>

  <xsl:template match="news">
    <exsl:document href="news.html">
      <xsl:variable name="now" select="date:date-time()"/>
      <html dir="ltr" lang="en">
        <head>
          <title>News</title>
	</head>

        <body>
	  <h1>News - <xsl:value-of select="date:year($now)"/></h1>

	  <p>News - <xsl:value-of select="date:year($now)"/></p>

	  <xsl:for-each select="entry">
	    <xsl:sort data-type="date" order="descending" select="date"/>
	    <xsl:variable name="
	    <xsl:if test="date:year(date) = $now">
	      <li>
	      <b><xsl:value-of select="date"/></b>: <xsl:value-of select="content"/>
	      </li>
	    </xsl:if>
	  </xsl:for-each>
	</body>
      </html>
    </exsl:document>
  </xsl:template>
</xsl:stylesheet>

In the <xsl:if test=""> case what I have now yields 0 (xsltproc) whereas
if I replace $now with 2004 it works.  What obvious little thing am I
missing/forgetting here?

Thanks,

-- 
Jeroen Ruigrok van der Werven <asmodai(at)wxs.nl> / asmodai / kita no mono
PGP fingerprint: 2D92 980E 45FE 2C28 9DB7  9D88 97E6 839B 2EAC 625B
http://www.tendra.org/   | http://diary.in-nomine.org/
Every person takes the limits for their own field of vision for the
limits of the world...

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.