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

Re: Actual Date

Subject: Re: Actual Date
From: Stephane Bortzmeyer <bortzmeyer@xxxxxx>
Date: Fri, 30 May 2003 11:15:48 +0000
xsl actual date
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:choose>
      <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:text>/</xsl:text>
        <xsl:value-of select="date:month-in-year($now)"/>
        <xsl:text>/</xsl:text>
        <xsl:value-of select="date:day-in-month($now)"/>
	<xsl:text> (date obtained by the XSL processor)</xsl:text>
      </xsl:when>
      <xsl:otherwise>
	<xsl:value-of select="$current_date"/>
	<xsl:text> (date obtained from the calling program)</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
...

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`" \
		...
		${STYLESHEET} $<

And for Sablotron :

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



 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.