File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Date Function to get System Date using XSLT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Date Function to get System Date using XSLT" Watch "Date Function to get System Date using XSLT" New topic
Author

Date Function to get System Date using XSLT

vishme vish
Greenhorn

Joined: Jun 07, 2005
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jessica Tan
Greenhorn

Joined: Mar 01, 2005
Posts: 11
(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.
 
 
subject: Date Function to get System Date using XSLT