Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is there a way to generate a time stamp in XSL ?

 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wondering if I could generate a time stamp of some kind while I transform. Any function that you know...I checked the OOTB functions but seems like there is no easy way...
Any pointers please...
Thanks.
- madhav
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no standard function in XSLT 1.0., not sure about XSLT 2.0...
Here is less standard one
http://www.exslt.org/date/functions/time/date.time.function.xsl.html
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using a java based XLST transformer, there are chances that you can make java calls from your stylesheet.
Have a look at the following URL to see how to do this using Xalan:
Extension function Java calls
You may then use the SimpleDateFormat object to format your timestamp according to your taste.
Write a utility stylesheet (timestamp.xslt):

And call it from your stylesheet like this:

This should do the trick (with Xalan).
Cheers
[ December 16, 2002: Message edited by: Beno�t d'Oncieu ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it seems like I can use this to call any java class meassage.
Thanks.
- madhav
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beno�t:
I seems to be missing something.
When I use this example, I get an error
(on the first style sheet) saying
"This file is not valid. Function not found in the namespace."
The select pharase which has the Java:text...new() is highlighted.select="java:util.Date.new(). Although, I have to admit I din't get a chance to read the link you mentioned. While I try that I thought I will let you know and see if you any quick suggestions.......
All I did was copy paste your style sheets and try an example using XML Spy. Maybe I should tyy xalan also...
- madhav
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Madhav,
You have well assumed, this might only work with Xalan. I don't think XML Spy will like that...
Cheers
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timestamp is 20021217114337
Works with xalan.....
- madhav
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic