Reputation: 51
In my style sheet, in header position I have a date column in which the date should be the current date.
How can I do that?
My xsl file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
<fo:table-row>
<fo:table-cell border="solid" border-width="1pt" padding-left="-7mm">
<fo:block>
DATE
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid" border-width="1pt" padding-left="-9mm">
<fo:block>
current date should come here
</fo:block>
</fo:table-cell>
</fo:table-row>
Upvotes: 1
Views: 1134
Reputation: 655
For XSLT 1 you can use this:
<xsl:value-of select="document('http://xobjex.com/service/date.xsl')/date/utc/@rfc-822"/>
You can then use substrings or an xsl:choose to format the date to your needs
Upvotes: 2
Reputation: 117073
If you are using XSLT 1.0, you need to either:
(1) Pass the current date to the stylesheet as a parameter during runtime;
or
(2) Use the EXSLT date:date-time() extension function, which most (but not all) XSLT 1.0 processors support.
Upvotes: 1
Reputation: 11298
XSL Version 2.0 :
<fo:block>
<xsl:value-of select="current-dateTime()"/>
</fo:block>
Format DateTime :
<xsl:value-of select="format-dateTime(current-dateTime(),'[D]-[MN]-[Y] [FN] at [H]:[m01]:[s01]')"/>
Upvotes: 1