timestamp with xslt

T

Thomas Mann

Hi,

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

Regards
Thomas
 
M

Martin Honnen

Thomas said:
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.
 
K

Klaus Johannes Rusch

Thomas said:
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($dateformat)"/>
<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>
 

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
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top