Page 1 of 1

xslt current-dateTime() not returning millisecond info

Posted: Wed May 07, 2008 4:49 pm
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

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

Posted: Wed May 07, 2008 5:59 pm
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

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

Posted: Wed May 07, 2008 6:09 pm
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?

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

Posted: Wed May 07, 2008 6:17 pm
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

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

Posted: Wed May 07, 2008 11:40 pm
by anboss
Thanks Sorin... Its working!!