[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] how to call extension function for side-effect, portably?

Subject: RE: [xsl] how to call extension function for side-effect, portably?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 19 Jan 2005 11:40:03 -0000

> > In general, if you're not using the result of a function 
> but still want it
> > called, then you should try to hoodwink the optimizer into 
> thinking that you
> > are using it. If it's a Java method that returns void, call it as
> > 
> > <xsl:sequence select="my:call(xyz)"/>
> > 
> > or call it as
> > 
> > <xsl:if test="my:call(xyz) = -1"><a/></xsl:if>
> > 
> > when you know the result will never be -1.
> Of course, this still doesn't guarantee any specific order of
> evaluation or even if the extension function will be called only once,
> or am I wrong?

There are things that give predictability with the current release of a
particular processor, but there is almost nothing that gives predictability
for all releases of all processors.

With Saxon today, the order of execution of variable declarations is not
easily predictable. But within a sequence of instructions forming a content
constructor, they are always evaluated sequentially.

Saxon tends to assume the worst case when rearranging expressions involving
extension functions, for example it doesn't move them out of a loop, because
it assumes that they might depend on the loop variables.

Michael Kay

Current Thread