I recommend using <xsl:value-of select="f()"> to call the function, at a point where writing empty text to the result tree is acceptable. Saxon takes care to ignore the fact that the method returns void, and is therefore known to have no effect; instead the method is called as if it were returning a string to be written to the result tree, and the resulting string is of course invisible because it is zero-length.

Although this guarantees that the function will be called exactly once, there are circumstances where the order of evaluation is not guaranteed. This arises specifically when multi-threading, for example Saxon-EE executes xsl:result-document in an independent thread. If order of evaluation is significant then you need to disable multi-threading.

Michael Kay
Saxonica


On 22 Nov 2013, at 16:17, Steve Carton <steve@chesbay.net> wrote:

I have a java XSLT extension function which I need to call to update certain state information. It has no return (public void add(...))

How do I make a call to this function? Since it isn't returning anything, it makes no sense to put it in an xsl:value-of. I tried assigning it to a variable, but it looks like variables don't actually get created until they are being used? The only way I got this to work was to then emit the (empty) variable in a comment in the output. But I don't need a bunch of empty comments in the output.

Is there another way in either Saxon or XSLT 2 in general to accomplish this? Is there a trick to make the extension function call at the time of variable assignment instead of use?

--
Steve   Carton
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help