xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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: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
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor