Re: [xsl] Actual Date

Subject: Re: [xsl] Actual Date
From: Stephane Bortzmeyer <bortzmeyer@xxxxxx>
Date: Fri, 30 May 2003 11:15:48 +0000
On Wed, May 28, 2003 at 01:58:39PM +0200,
 Molnár Ágnes <agi@xxxxxxxxxxxxxxxxx> wrote 
 a message of 205 lines which said:

> Can I insert to a HTML code the actual date (ex. 28-05-2003) from
> XSL?

Combining replies you already received (params , portable but
inconvenient, and exslt, the best way but not portable), here is what
I do:

  <xsl:param name="current_date">(UNSPECIFIED)</xsl:param>

  <xsl:template match="/">
      <xsl:when test="function-available('date:date-time')">
        <!-- EXSLT available -->	
        <xsl:variable name="now" select="date:date-time()"/>
        <xsl:value-of select="date:year($now)"/>
        <xsl:value-of select="date:month-in-year($now)"/>
        <xsl:value-of select="date:day-in-month($now)"/>
	<xsl:text> (date obtained by the XSL processor)</xsl:text>
	<xsl:value-of select="$current_date"/>
	<xsl:text> (date obtained from the calling program)</xsl:text>

Passing the param depends on the XSLT processor. Here is a part of a
Makefile for xsltproc:

xsltproc -o $@ \
		--stringparam current_date "`date +%Y/%m/%d`" \

And for Sablotron :

sabcmd ${STYLESHEET} $< $@ "\$$current_date=`date +%Y/%m/%d`" 

 XSL-List info and archive:

Current Thread