W3C home > Mailing lists > Public > public-qt-comments@w3.org > January 2004

[XSLT 2.0]Extension functions with side-effects and optimizations

From: Kenneth Stephen <y2kmvs@us.ibm.com>
Date: Fri, 2 Jan 2004 19:46:36 -0600
To: public-qt-comments@w3.org
Message-ID: <OF4FCA5305.C44D3080-ON86256E10.0008B599-86256E10.0009C272@us.ibm.com>


      On the topic of extension functions with side-effects, the spec
states :

"There is no prohibition on calling extension functions that have
side-effects (for example, an extension function that writes data to a
file). However, the order of execution of XSLT instructions is not defined
in this specification, so the effects of such functions are unpredictable."

      An extension function with side-effects can also be utilized in other
ways. For example, a global variable can be defined as a child of the
xsl:stylesheet element and the "select" can invoke the extension function.
The side-effect in question could be something like the creation of a file
indicating that XSLT processing has been done on something else. One of the
major XSLT (1.0) processors around optimizes such global variables away if
the value of the variable isnt being used for anything. I had some
correspondance with one of its maintainer recently, and this is what he had
to say on the topic :

"That's sorta the nature of the beast, I'm afraid. XSLT is a functional
language, and that means that stuff can get executed out-of-sequence or
optimized away... and that's only going to become more common as we
continue to work on improving stylesheet efficiency. Extensions with
side-effects are problematic at best; they really should be thought of as
extension Functions in the pure sense of the term.

The only way to force evaluation of a variable is to use that variable's
value. There are a few kluges that folks have come up with to use it and
throw it away, but it can be tricky to find one that is guaranteed not to
be optimized out in the future."

      This is a situation that doesnt seem to be explicitly addressed in
the 2.0 spec. While out of order execution of extension functions may be
kosher, is it ok to completely optimize away the variable itself?

Kenneth Stephen

T/L 793-6462
Received on Friday, 2 January 2004 23:57:12 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:56:52 UTC