xsl-list
[Top] [All Lists]

RE: [xsl] Forcing a call to a Java method

2006-06-24 00:29:30
I have a Java method I want to call from my XSLT script (I am 
using Saxon of course).  I use the following code: 
 
   <xsl:variable name="ignore" select="foo:bar()"/>

The bar method doesn't return anything of value, it really is 
a void method that I have returning the dummy value 1.  But 
the xsl:variable method is optimized out since I never use 
the returned value. 
 
What is the syntax to force the XSLT engine to call foo:bar? 

Firstly, extension functions are product-dependent so it would be more
appropriate to ask this on the Saxon list.

In Saxon, I suggest you do

  <xsl:sequence select="foo:bar()"/>

If the method is void, then the xsl:sequence returns an empty sequence, but
Saxon (deliberately) doesn't look at the external method signature to
determine in advance that it's void, so the function will actually be
called.

This approach also makes it much more likely that methods will be called in
the expected order.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>