Date conversion in XSLT

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Claudio Jolowicz

    Date conversion in XSLT

    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="documen t('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


    --

  • Martin Honnen

    #2
    Re: Date conversion in XSLT



    Claudio Jolowicz wrote:

    [color=blue]
    > 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="documen t('strftime.cgi ?{@time}')/time"/>
    >[/color]

    [color=blue]
    > 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}".[/color]

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


    --

    Martin Honnen

    Comment

    Working...