|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Date problem
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








