469,270 Members | 1,105 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Insert current timestamp/date from XSLT stylesheet into a XML document ???

I am performing a XSLT stylesheet on a XML document and produce a new XML document.
How can I insert in this new XML stylesheet a tag

<currtime>..."the current date/time"....</currtime>

where "the current date/time" above is replaced by the real current time (e.g.
12th Sep 2004 09:23:78

Michael

Jul 20 '05 #1
3 38297
Am Mon, 04 Oct 2004 07:41:38 +0200 schrieb Michael Hertz:
<currtime>..."the current date/time"....</currtime>


With xsltproc I use:
--stringparam date="`date stylesheet.xsl`"

Then you have to a xsl:param where the value is the momentary date

Thomas
Jul 20 '05 #2
Its possible with extension functions..

Please try this..
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:datetime="http://exslt.org/dates-and-times"
exclude-result-prefixes="datetime">

<xsl:template match="/">
<currtime>
<xsl:value-of select="datetime:dateTime()" />
</currtime>
</xsl:template>

</xsl:stylesheet>

(Tested with Xalan-J 2.6.0)

Regards,
Mukul

mh****@yahoo.com (Michael Hertz) wrote in message news:<cj*************@news.t-online.com>...
I am performing a XSLT stylesheet on a XML document and produce a new XML document.
How can I insert in this new XML stylesheet a tag

<currtime>..."the current date/time"....</currtime>

where "the current date/time" above is replaced by the real current time (e.g.
12th Sep 2004 09:23:78

Michael

Jul 20 '05 #3


Michael Hertz wrote:
I am performing a XSLT stylesheet on a XML document and produce a new XML document.
How can I insert in this new XML stylesheet a tag

<currtime>..."the current date/time"....</currtime>

where "the current date/time" above is replaced by the real current time (e.g.
12th Sep 2004 09:23:78


With XSLT 1.0/XPath 1.0 you need to define a global parameter e.g.
<xsl:param name="now" />
and then use processor specific means to set that parameter before you
run the transformation.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Thomas Mann | last post: by
7 posts views Thread by pintihar | last post: by
2 posts views Thread by Richard L Rosenheim | last post: by
16 posts views Thread by Brian Tkatch | last post: by
7 posts views Thread by Damir | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.