[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: current-dateTime()

Subject: Re: current-dateTime()
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Fri, 18 Apr 2008 08:04:45 -0700
Re:  current-dateTime()
Just use an extension function with an argument that it ignores (but
the XSLT processor has no way of knowing this) and call it every time
with different argument value, for example:

    for $i in 1 to 1000000
         return (ext:myTime($i), f:doSomething())



-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



On Fri, Apr 18, 2008 at 7:39 AM, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
> Andrew Welch wrote:
> > I wrongly thought that the "implementation dependent" part meant the
> > processor could return different values for multiple calls to
> > current-dateTime()... instead of merely the freedom to choose the
> > instant at which it takes the fixed value.
> >
> > It should be straightforward to write an extension function instead...
> >
> >
>
> it may be tempting to write an extension function, but that binds you to a
> certain implementation and it really is unnecessary. It'd be nicer to get
> the current time/date at any moment of processing by means of standard XSLT
> / XPath functionality. This discussion thread makes it seem that such a
> thing is not possible, but, with a little help from the Internet, it
> actually is possible.
>
> This is a short version of a related post of my, about one and a half years
> back.
>
> Ingredients:
>  1) XSLT 2.0 processor that supports the document() function with the the
> HTTP URI scheme
>  2) An internet (HTTP) source that returns the current time and date
>  3) Access to that source (configure your firewall if necessary)
>  4) a little effort to make XSLT 2.0 act non-pure-functional
>
> I assume for the moment that 1-3 are easy to grasp and arrange. Nr 4 may
> need a little help:
>
> <xsl:function name="my:randomString" as="xs:string">
>    <xsl:variable name="node">
>        <xsl:comment />
>    </xsl:variable>
>    <xsl:sequence select="generate-id($node)" />
> </xsl:function>
>
> <xsl:function name="my:current-DateTime" as="xs:dateTime">
>   <xsl:variable name="dateTimeUrl"
> select="concat('http://yourtimesite/getTimeDate.pl?', my:randomString())" />
>   <xsl:sequence select="document($dateTimeUrl)/currentDateTimeNode" />
> </xsl:function>
>
>
> There are obvious drawbacks and caveats to this solution, one being that the
> Net overhead is significant, the other being that the dependencies on
> external systems may be a larger problem to deal with then an extension
> function. But whatever it is, the point I was trying to make is that you can
> get the current date or time at the current execution point (regardless the
> ordered or unordered execution of the stylesheet) without using anything
> non-XSLT-like (I won't say non-declarative like, simply because the side
> effects I employ are not part of declarative programming).
>
> A time server can return either an XML document or, easier, a simple string.
> Then you'd use the unparsed-text() function.
>
> Cheers,
> -- Abel Braaksma

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.