You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Chuck Morris <ch...@sbcglobal.net> on 2009/02/28 00:54:16 UTC

Another function-available problem

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