Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Date conversion in XSLT

Reply
Thread Tools

Date conversion in XSLT

 
 
Claudio Jolowicz
Guest
Posts: n/a
 
      02-18-2005
How do you convert time from seconds since 1 Jan 1970 to a local time
string in an XSLT stylesheet?

XSLT doesn't seem to offer a function for this, so I tried to call a
CGI script in the stylesheet:

<xsl:value-of select="document('strftime.cgi?{@time}')/time"/>

The script strftime.cgi converts its argument to local time and prints
it out as an XML document:

echo "Content-type: text/xml"
echo
echo "<time>$(./strftime $QUERY_STRING)</time>"

But the xsl:value-of produces no output, although the script works
when called directly from a browser.

What apparently happens is that the "{@time}" in the stylesheet does
not get evaluated. Instead, the script is passed the literal string
"{@time}".

Any suggestions?

Claudio


--
http://www.jolowicz.com
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-19-2005


Claudio Jolowicz wrote:


> XSLT doesn't seem to offer a function for this, so I tried to call a
> CGI script in the stylesheet:
>
> <xsl:value-of select="document('strftime.cgi?{@time}')/time"/>
>



> echo "Content-type: text/xml"
> echo
> echo "<time>$(./strftime $QUERY_STRING)</time>"
>
> But the xsl:value-of produces no output, although the script works
> when called directly from a browser.
>
> What apparently happens is that the "{@time}" in the stylesheet does
> not get evaluated. Instead, the script is passed the literal string
> "{@time}".


You could try
<xsl:value-of select="document(concat('strftime.cgi?', @time))/time" />


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Calling date conversion function before binding the date to a daragrid Sanjeeb ASP .Net Web Controls 2 01-26-2004 06:36 AM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C Programming 3 11-08-2003 09:07 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments