• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date Function to get System Date using XSLT

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
please buy this thing and then I get a fat cut of the action:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic