Insert current timestamp/date from XSLT stylesheet into a XML document ???

Discussion in 'XML' started by Michael Hertz, Oct 4, 2004.

  1. I am performing a XSLT stylesheet on a XML document and produce a new XML document.
    How can I insert in this new XML stylesheet a tag

    <currtime>..."the current date/time"....</currtime>

    where "the current date/time" above is replaced by the real current time (e.g.
    12th Sep 2004 09:23:78

    Michael
    Michael Hertz, Oct 4, 2004
    #1
    1. Advertising

  2. Am Mon, 04 Oct 2004 07:41:38 +0200 schrieb Michael Hertz:

    > <currtime>..."the current date/time"....</currtime>


    With xsltproc I use:
    --stringparam date="`date stylesheet.xsl`"

    Then you have to a xsl:param where the value is the momentary date

    Thomas
    Thomas Sommer, Oct 4, 2004
    #2
    1. Advertising

  3. Michael Hertz

    Mukul Gandhi Guest

    Its possible with extension functions..

    Please try this..
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:datetime="http://exslt.org/dates-and-times"
    exclude-result-prefixes="datetime">

    <xsl:template match="/">
    <currtime>
    <xsl:value-of select="datetime:dateTime()" />
    </currtime>
    </xsl:template>

    </xsl:stylesheet>

    (Tested with Xalan-J 2.6.0)

    Regards,
    Mukul

    (Michael Hertz) wrote in message news:<cjqnqh$asn$02$-online.com>...
    > I am performing a XSLT stylesheet on a XML document and produce a new XML document.
    > How can I insert in this new XML stylesheet a tag
    >
    > <currtime>..."the current date/time"....</currtime>
    >
    > where "the current date/time" above is replaced by the real current time (e.g.
    > 12th Sep 2004 09:23:78
    >
    > Michael
    Mukul Gandhi, Oct 4, 2004
    #3
  4. Re: Insert current timestamp/date from XSLT stylesheet into a XMLdocument ???

    Michael Hertz wrote:

    > I am performing a XSLT stylesheet on a XML document and produce a new XML document.
    > How can I insert in this new XML stylesheet a tag
    >
    > <currtime>..."the current date/time"....</currtime>
    >
    > where "the current date/time" above is replaced by the real current time (e.g.
    > 12th Sep 2004 09:23:78


    With XSLT 1.0/XPath 1.0 you need to define a global parameter e.g.
    <xsl:param name="now" />
    and then use processor specific means to set that parameter before you
    run the transformation.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 4, 2004
    #4
    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. Steven An
    Replies:
    1
    Views:
    490
    Martin Honnen
    Nov 23, 2004
  2. David Blickstein
    Replies:
    3
    Views:
    1,026
    David Blickstein
    Aug 2, 2005
  3. David Blickstein
    Replies:
    14
    Views:
    6,309
    Harrie
    Oct 16, 2005
  4. Replies:
    4
    Views:
    656
  5. jkflens
    Replies:
    2
    Views:
    1,448
    jkflens
    May 30, 2006
Loading...

Share This Page