Re: [xsl] How to output the start execution time and the end execution time?

Subject: Re: [xsl] How to output the start execution time and the end execution time?
From: "Wolfgang Laun wolfgang.laun@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 6 Sep 2014 17:09:52 -0000
Dimitre,

given that the call to an external timepiece delivers the wallclock time:
how can one be sure that a call near the top of the  XSLT program is
executed first, e.g., before accessing the main document? And how can one
be sure that a call near the end of the program is the last thing the
program does, e.g., even after writing/serializing everything and flushing
all buffers?

Not really knowing what one measures? Not being sure how the data
influences the result?

-W



On 6 September 2014 18:31, Abel Braaksma (Exselt) abel@xxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Roger,
>
> Functions and constructs in XSLT and XPath are stable (barring a few
> exceptions). Calling a function with the same argument twice will yield the
> same result for both calls. The functions current-time(),
> current-dateTime() and current-date() will therefor always return the same
> time (with a slight caveat for static and dynamic evaluation phases, but
> let's not digress).
>
> The only way out here is extension functions, or a trick with XSLT 3.0
> using streaming, because the xsl:stream instruction is deemed non-stable
> (i.e., it will re-invoke the url at the href argument each time it is
> called). Whether an extension function helps depends whether your processor
> allows non-stable extension functions, but I believe most, if not all,
> processors do.
>
> Here's a (workable) trick that works with all XSLT 3.0 processors, however
> you might want to choose a local resource instead that returns the current
> date-time, for performance reasons.
>
>
> <xsl:mode streamable="yes" name="time" on-no-match="shallow-skip" >
>
> <!-- may need an actual argument to force re-evaluation -->
> <xsl:function name="my:current-time">
>   <xsl:stream href="http://time.is";>
>     <xsl:apply-templates mode="time" />
>   </xsl:stream>
> </xsl:function>
>
> <!-- match the element that contains the time -->
> <xsl:template match="div[@id = 'twd']">
>     <xsl:value-of select="." />
> </xsl:template>
>
> <xsl:template match="/">
>      <xsl:value-of select="my:current-time()" />
>      ... do the processing ...
>      <xsl:value-of select="my:current-time()" />
>  </xsl:template>
>
>
> Note: the page http://time.is currently does not deliver proper XML (and
> on my search for a time server that did deliver proper XML or even proper
> XHTML I did not find any). If you can convince your processor not to cache
> the result of unparsed-text, you can use the following with the same server
> as a workaround (ugly, but it shows the principle):
>
> <xsl:value-of select="replace(unparsed-text('http://time.is/'),
> '.+twd&quot;&gt;([^&lt;]+).*', '$1', 'sm')" />
>
> Cheers,
> Abel
>
>
> > -----Original Message-----
> > From: Costello, Roger L. costello@xxxxxxxxx [mailto:xsl-list-
> > service@xxxxxxxxxxxxxxxxxxxxxx]
> > Sent: Saturday, September 06, 2014 11:47 AM
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: [xsl] How to output the start execution time and the end
> execution
> > time?
> >
> > Hi Folks,
> >
> > I would like to:
> >
> > 1. Output the time that my XSLT program starts processing 2. Do the
> > processing 3. Output the time that my XSLT program finishes processing
> >
> > This doesn't work:
> >
> >     <xsl:template match="/">
> >         <xsl:value-of select="current-time()" />
> >         ... do the processing ...
> >         <xsl:value-of select="current-time()" />
> >     </xsl:template>
> >
> > What is the correct way to accomplish this?
> >
> > /Roger

Current Thread