From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Roger Kovack
Sent: 15 June 2005 18:08
To: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] FW: Transformation Error

In some cases I force Saxon to use a template or variable by directing it to output something that I know can never exist such as
<xsl:copy-of select="foobar"/>

I know there is no <foobar> node but Saxon does not know that at compile time so it does include the template and execute it.

Mike told me that the later Saxon optimizers will completely eliminate a template that does not appear to produce an output in a static evaluation. That optimizer cannot know that <foobar> does not exist so it spares that template's life. At least that's the way I understand it.

HTH,
Roger Kovack

 
I'm not quite sure how this is supposed to relate to the original problem.
 
There are cases where you have to "fool" Saxon into executing code that it might otherwise optimize out: the usual case is where you have an extension function with side-effects. If you call this using
 
<xsl:variable name="x" select="my:extension(123)"/>
 
and never reference $x, the variable will not be evaluated. If the method underpinning the extension function returns void, you can get round this by using <xsl:sequence select="my:extension(123)"/> - Saxon assumes that if you are calling a method that returns void, you are probably doing so for a reason.
 
Michael Kay
http://www.saxonica.com/