Re: [xsl] XSL Calendar functions?

Subject: Re: [xsl] XSL Calendar functions?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 29 Mar 2007 22:40:41 +0200
Thomas Zastrow wrote:


I looked around for some calendar / date / functions in XSL, but there seems nothing to be in the standard? Are there any free stylesheets for creating a calendar or so?



Take a look at the XSLT Standard Library: http://xsltsl.sourceforge.net/, or, more specifically, here: http://xsltsl.sourceforge.net/date-time.html


If you can use XSLT 2.0, you will find that the standard has very many time/date functions, duration functions and date/time arithmetics using simple addition/subtraction. Also, XPath 2.0 adds the current-date(), current-time() and current-dateTime() functions, which were severely missing in XSLT 1.0.

If you do need the current date/time in XSLT 1.0 (which is not possible directly), you have five options (and neither are in the XSLT SL):

1. Use the document() function with a date/time server that returns its info in XHTML or XML

2. Use an extension function (i.e., Saxon provides an interface to .NET or Java)

3. Use a global parameter and set it from the calling app

4. Use a system-property and make sure it is set from the calling up right before the transformation starts

5. Some processors may offer you an extension instruction or function that gives the current date/time out of the box


HTH,


Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Current Thread