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

Michael Hertz

Usenet Archive
Joined
Jul 19, 2004
Messages
3
Reaction score
0
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
 

Thomas Sommer

Usenet Archive
Joined
Aug 29, 2004
Messages
20
Reaction score
0
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
 

Mukul Gandhi

Usenet Archive
Joined
Sep 14, 2004
Messages
43
Reaction score
0
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
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Michael said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top