Date conversion in XSLT

C

Claudio Jolowicz

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
 
M

Martin Honnen

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" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top