If you call an extension function in the course of initializing a variable, then the most likely reason the function isn't being called is that the value of the variable is never used. Variables aren't evaluated until the value is needed, and if the value is never used, then the variable is never evaluated.

If you need the function to be called because it has side-effects, then you're skating on thin ice. XSLT is a functional language, and Saxon generally assumes that functions are pure (don't have side effects). However, you can get away with it if you're careful. The principle to follow is that Saxon will call the function if it needs to know the result; so make sure that the result is used (or that you fool the optimizer into thinking that the result is used) in constructing the result tree.

Michael Kay
Saxonica

On 09/06/2010 22:55, Full Midnight wrote:
Hi all,

I just implemented an extension function and it seems that it gets called only once by Saxon, even when it is present in the transformation multiple times. A sample below:

<xsl:variable name="v1">
    <xsl:copy-of select="f($p1)"/>
</xsl:variable>
<xsl:variable name="v2">
    <xsl:copy-of select="f($p2)"/>
</xsl:variable>
Any ideas about what I am doing wrong and why only the first time the f extension function gets called?

Thank you in advance!

------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help