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