You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Sandrine Pilon <sa...@mcc-soft.com> on 2002/04/30 10:45:15 UTC

Current date integration

Dear all,

How is it possible to integrate (simply) current date to a xsl stylesheet ?

This solution seems to be run, but it's constraining to define an own
namespace for one function.
****************************************************************************
********************
<xsl:stylesheet	version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:fo="http://www.w3.org/1999/XSL/Format"
		xmlns:func="http://www.exslt.org/functions"
		xmlns:user="http://www.mcc-soft.com/mynamespace"

		extension-element-prefixes="func"
        	exclude-result-prefixes="user">

<func:script implements-prefix="user" language="javascript">
<![CDATA[
        function today()
        {
		// body javascript function
        }
]]>
</func:script>
<xsl:template match="/">
	<xsl:value-of select="."/><br/>
	<xsl:variable name="today" select="user:today()"/>
</xsl:template>
</xsl:stylesheet>
****************************************************************************
********************

Thanks for your help & best regards,
Sandrine - Paris France



Re: Current date integration

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Sandrine Pilon wrote:
> How is it possible to integrate (simply) current date to a xsl stylesheet ?

Using javaScript is one solution, exactly as you did. With
Xalan, you can also use java.util.Date directly:
  http://www.biglist.com/lists/xsl-list/archives/200203/msg01243.html

Neither of these approaches is protable (yet). If you need
portability, pass the formatted date as a parameter to the
style sheet. You can pass parameters from the command line
as well as to an transformer object if you run an embedded
transformer. For Cocoon, it's best to write an apropriate
filter.

J.Pietschmann