Thanks a lot for your response.
I tried to run in 1.0 compatibility mode (version="1.0" on the xsl:function) and it works.
I tried your solution with "use-when" and it works also fine, I prefer this more elegant way, sticking in 2.0.
I actually didn't know the "use-when" attribute, seems usefull ! It seems to prevent compilation errors whereas choose/when test or (if test) don't in 2.0.
The only problem is that the <xsl:message> is displayed each time the function is called (a lot !). So I removed the error message from within the function and made a special function to display unavailable function message :
<xsl:message use-when="not(function-available('java-uri:new'))" >[WARNING] : java function is not available</xsl:message>
and a call it once from the <xsl:template match="/"> of my main xsl.
All those function are actually stored in a common xsl which only contains generic named templates and functions, I think I can't display igs:functions.available.test from within THIS "library xslt". (if I call igs:functions.available.test from a global variable in common.xsl, it will not be evaluated as long as the variable isn't used, and I can't call it once cause I have no <xsl:template match="..."> in this XSLT).
I think there is no way to generaly enforce an <xsl:message> to be displayed only once, except using terminate="yes" but I actually don't want to stop the transformation.
Well it becomes maybe out of topic ;-) and I'm fine with the one call in main.xsl.
Thanks for the tip about <xsl:value> and boolean, i'll change it to sequence everytime now !
All is sequence in xpath 2, I should remember that :) !
2012/11/1 Michael Kay <firstname.lastname@example.org>
In XPath 2.0 a function call to an unknown function is a static
error whether or not the function is actually called.
One workaround is to run in 1.0 compatibility mode (set
version="1.0" perhaps on the xsl:function element): in 1.0, calling
a function that doesn't exist was a dynamic error. Another solution,
rather better, is to use use-when:
<xsl:function name="igs:file-exists" as="xs:boolean">
<xsl:param name="uri" as="xs:string"/>
: java function is not available</xsl:message>
(Note: xsl:value-of constructs a text node. You don't want to do
that in a function that's supposed to return a boolean.)
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
saxon-help mailing list archived at http://saxon.markmail.org/
IGS-CP - Développeur XML
05 45 37 08 90