It seems that function-available() only works if you subsequently call the function. This stylesheet returns "Not Available". If you uncomment the value-of instruction it returns a random number. I got the same results on versions 2.6.0 and 2.7.1.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
  <xsl:template match="/">
     <xsl:choose>
<xsl:when test="function-available('Math:random')" xmlns:Math="xalan://java.lang.Math">
            <!-- <xsl:value-of select="Math:random()"/> -->
        </xsl:when>
        <xsl:otherwise>Not Available</xsl:otherwise>
     </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

In most cases, code that calls function-available() will subsequently call the function anyway, but not always. I ran into this issue because my code generates a stylesheet, and the generated stylesheet calls the function.

- Chuck

Reply via email to