469,271 Members | 997 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

timestamp with xslt

Hi,

how can I make my XSLT-stylesheet insert a timestamp (date/time) into the
output file ?

Regards
Thomas
Jul 20 '05 #1
4 10035


Thomas Mann wrote:
how can I make my XSLT-stylesheet insert a timestamp (date/time) into the
output file ?


With XSLT 1.0 you need to define a global parameter e.g.
<xsl:param name="now" />
and set that parameter before the transformation. How you set parameters
depends on the XSLT processor you use.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
What about XSLT 2 ? Would that be an easier way to go ?
"Martin Honnen" <ma*******@yahoo.de> schrieb im Newsbeitrag
news:41***********************@newsread4.arcor-online.net...


Thomas Mann wrote:
how can I make my XSLT-stylesheet insert a timestamp (date/time) into the
output file ?


With XSLT 1.0 you need to define a global parameter e.g.
<xsl:param name="now" />
and set that parameter before the transformation. How you set parameters
depends on the XSLT processor you use.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3


Thomas Mann wrote:
What about XSLT 2 ? Would that be an easier way to go ?


XSLT 2.0 and XPath 2.0 are under development, it currently defines
http://www.w3.org/TR/xquery-operator...rrent-dateTime
a function to get at the current dateTime and current date so once XSLT
2.0 and XPath 2.0 are recommendations you are likely able to use those
functions in a stylesheet.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
Thomas Mann wrote:
how can I make my XSLT-stylesheet insert a timestamp (date/time) into the
output file ?


With current XSLT processors extension functions are required, for
example with Xalan-J you can use Java methods to format the timestamp:

<xsl:template name="dateformat">
<xsl:param name="dateformat">yyyy-MM-dd'T'HH:mm:ssZ</xsl:param>
<xsl:variable name="tz" select='java:java.util.SimpleTimeZone.new(0,
"GMT+00:00")' />
<xsl:variable name="formatter"
select="java:java.text.SimpleDateFormat.new($datef ormat)"/>
<xsl:variable name="settz" select="java:setTimeZone($formatter, $tz)" />
<xsl:variable name="date" select="java:java.util.Date.new()"/>
<xsl:value-of select="java:format($formatter, $date)" />
</xsl:template>
--
Klaus Johannes Rusch
Kl********@atmedia.net
http://www.atmedia.net/KlausRusch/
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Thomas Mann | last post: by
2 posts views Thread by rong.guo | last post: by
6 posts views Thread by Greg Collins [MVP] | last post: by
7 posts views Thread by JJ | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.