xslt current-dateTime() not returning millisecond info

Here should go questions about transforming XML with XSLT and FOP.
anboss
Posts: 8
Joined: Wed May 07, 2008 4:43 pm

xslt current-dateTime() not returning millisecond info

Post by anboss »

i need time with millisecond info to be returned. i used current-dateTime() to get the current date and time. this function is not returning the millisecond info. i referred in the function spec site.. and saw that this function will return millisecond info. why does it didnt return in my case?

Thanks in advance
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: xslt current-dateTime() not returning millisecond info

Post by sorin_ristache »

Hello,

The function current-dateTime() returns the current time including milliseconds, for example: 2008-05-07T18:12:23.593+03:00 where .593 represents the milliseconds. If you want to extract only a fragment of the returned time you can apply the format-dateTime() function to the result of current-dateTime().


Regards,
Sorin
anboss
Posts: 8
Joined: Wed May 07, 2008 4:43 pm

Re: xslt current-dateTime() not returning millisecond info

Post by anboss »

Thanks for the reply. i used the same function which you have mentioned.

i am using xmlspy 2007. the following is my xslt.

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:func="http://exslt.org/functions" xmlns:ctvf="http://www.contivo.com/xslt/extensions" extension-element-prefixes="func ctvf" exclude-result-prefixes="xalan">
<xsl:template match="/">
<xsl:variable name="dateTime" select="current-dateTime()"/>
<xsl:value-of select="$dateTime"/>
</xsl:template>
</xsl:stylesheet>

but my output is : 2008-05-07T11:24:35-04:00

which is without the millisec info. why is it so?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: xslt current-dateTime() not returning millisecond info

Post by sorin_ristache »

That is what the XMLSpy processor returns. Use Saxon 9 for running the transformation if you need milliseconds in the result of the function. Oxygen comes with an embedded version of the Saxon 9 processor.


Regards,
Sorin
anboss
Posts: 8
Joined: Wed May 07, 2008 4:43 pm

Re: xslt current-dateTime() not returning millisecond info

Post by anboss »

Thanks Sorin... Its working!!
Post Reply