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

M

Michael Hertz

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
 
T

Thomas Sommer

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
 
M

Mukul Gandhi

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
 
M

Martin Honnen

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top