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

Re: Date problem

Subject: Re: Date problem
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 9 Dec 2002 09:56:33 -0700 (MST)
xsl import href date.msxsl.xsl
Hélder Sousa wrote:
> 	<xsl:element name="input">
> 		<xsl:attribute name="type">hidden</xsl:attribute>
> 		<xsl:attribute name="name">todayDate</xsl:attribute>
> 		<xsl:attribute name="value">????????</xsl:attribute>
> 	</xsl:element>

> The question is: how I put the actual date in "????????"?

100% portable way:

Put <xsl:param name="dateval"/> at the top of your stylesheet
(just before the first template)

and pass $dateval as an external parameter when you invoke the
XSLT processor. (see your XSLT processor's API documentation for
how to do this)

> Is there any function in xsl that returns the actual date?

If your XSLT processor implements the EXSLT extension functions, yes.
See http://exslt.org/date/index.html, particularly date:date-time().
Note that there is even an implementation for MSXML (though you have
to embed it in your stylesheet).


<!--
  xsl:import must be the first thing after xsl:stylesheet.
  You need to get date.msxsl.xsl from
  http://exslt.org/date/functions/date-time/date.msxsl.xsl
-->
<xsl:import href="date.msxsl.xsl"/>

<xsl:param name="dateval"/>

...

<xsl:template ...>

  ...

  <input type="hidden" name="todayDate">
    <xsl:attribute name="value">
      <xsl:choose>
        <xsl:when test="function-available('date:date-time')"
         xmlns:date="http://exslt.org/dates-and-times">
          <xsl:value-of select="date:date-time()"/>
        </xsl:when>
        <xsl:when test="$dateval">
          <xsl:value-of select="$dateval"/>
        </xsl:when>
        <xsl:otherwise>unknown</xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
  </input>

  ...

</xsl:template>

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 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.