Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Function to get System Date using XSLT

 
vishme vish
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I have an xml file. and i need to generate the html page out of it. I am using XSLT to achieve this. But When ever the page is rendered the user should get the current date. Can any one please explain how Can i achieve this using XSLT.

Thanks in Advance
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no way I can think of using standard XSLT. Not surprising really - XSLT is not really the technology you would use to make calls to the OS to get data like this. Its just a transformation mechanism.

That being said, depending on how you are performing the transformation, you might be able to find an extenstion which can do it (this for example claims to do it).

Alternatively, you could just render a bit of JavaScript which writes the current date in your HTML.
[ June 21, 2005: Message edited by: Paul Sturrock ]
 
Jessica Tan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Source: http://www.xslt.com/html/xsl-list/2005-03/msg00423.html)

Using the exslt functions in xslt 1.0 is not very hard. Here's what to do:


1) download the date and numerical format material from exslt.org
2) Put the following attribute in your xsl:stylesheet root element:


xmlns ate="http://exslt.org/dates-and-times";


3) put the following include at the top level of your document (right after the root element).
<xsl:include href="path-to-installed-the-exslt-elements/date.xsl" />


4) Add the function to your sheet where you want it to appear:


<xsl:choose>
<xsl:when test="function-available('date ate-time')">
(<xsl:value-of select="date ate-time()"/>
</xsl:when>
<xsl therwise>
</xsl therwise>
</xsl:choose>


The only problem I had when I did this, was there was a bad include in one of the exslt stylesheets (it was looking in the wrong directory for a padding stylesheet). It wasn't hard to fix, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic