Reputation: 21
I have a header path and there should be current system date along with a string.
<xsl:template name="GetHeaderLine">
<xsl:text>A</xsl:text>
<xsl:text>,</xsl:text>
<xsl:text>Agency</xsl:text>
<xsl:value-of select="Date"/>
The output should be
A,Agency{CurrrentDate},
How can i fetch current date on xslt...?
Upvotes: 2
Views: 5191
Reputation: 21
Guys I got the answer....
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:cs="urn:cs">
<xsl:output method="xml" indent="yes"/>
<msxsl:script language="C#" implements-prefix="cs">
<![CDATA[
public string datenow()
{
return(System.DateTime.Now.ToString("yyyyMMdd"));
}
]]>
</msxsl:script>
<xsl:template name="GetHeaderLine">
<xsl:text>A</xsl:text>
<xsl:text>,</xsl:text>
<xsl:text>Agency</xsl:text>
<xsl:text>,</xsl:text>
<xsl:value-of select="cs:datenow()"/>
</xsl:template>
</xsl:stylesheet>
ThanQ so much for your help guys
Cheers
Upvotes: 0
Reputation: 655
I use
<xsl:variable name="now">
<xsl:value-of select="document('http://xobjex.com/service/date.xsl')/date/utc/@stamp"/>
</xsl:variable>
And then you can use the bits you need. You can add "?offset=" to the url for different time zones.
Upvotes: 1
Reputation: 134
If you are using XPath2, use: current-date()
but instead of this:
<xsl:text>A</xsl:text>
<xsl:text>,</xsl:text>
<xsl:text>Agency</xsl:text>
<xsl:value-of select="Date"/>
I'd be tempted to use something more akin to:
<xsl:value-of select="concat('A,Agency',current-date())"/>
Upvotes: 1