Date conversion in XSLT

Discussion in 'XML' started by Claudio Jolowicz, Feb 18, 2005.

  1. 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
     
    Claudio Jolowicz, Feb 18, 2005
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Feb 19, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    631
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,332
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    549
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    745
    Richard Heathfield
    Nov 8, 2003
  5. Sanjeeb
    Replies:
    2
    Views:
    192
Loading...

Share This Page