dbertoni 01/02/12 09:03:05
Modified: c/samples/ExternalFunction foo.xsl Log: Added calls to function-available(). Revision Changes Path 1.5 +23 -20 xml-xalan/c/samples/ExternalFunction/foo.xsl Index: foo.xsl =================================================================== RCS file: /home/cvs/xml-xalan/c/samples/ExternalFunction/foo.xsl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- foo.xsl 2001/02/12 16:07:51 1.4 +++ foo.xsl 2001/02/12 17:03:05 1.5 @@ -2,32 +2,35 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:external="http://ExternalFunction.xalan-c++.xml.apache.org" exclude-result-prefixes="external"> - - <xsl:template match="/"> - <out> - <xsl:apply-templates/> - </out> - </xsl:template> - - <xsl:template match="//area"> - <given> - The area of each face of the cube is <xsl:value-of select="@value"/> - <xsl:text> square units </xsl:text> <xsl:value-of select="@units"/>. - </given> - <result> - Accordingly, the length of each side is <xsl:value-of select="external:square-root(@value)"/> - <xsl:text> </xsl:text><xsl:value-of select="@units"/> and the volume of the cube is - <xsl:value-of select="external:cube(external:square-root(@value))"/> - <xsl:text> cubic </xsl:text> <xsl:value-of select="@units"/>. - </result> + + <xsl:template match="area"> + <xsl:choose> + <xsl:when test="function-available('external:square-root') and function-available('external:cube')"> + <given> + The area of each face of the cube is <xsl:value-of select="@value"/> + <xsl:text> square units </xsl:text> <xsl:value-of select="@units"/>. + </given> + <result> + Accordingly, the length of each side is <xsl:value-of select="external:square-root(@value)"/> + <xsl:text> </xsl:text><xsl:value-of select="@units"/> and the volume of the cube is + <xsl:value-of select="external:cube(external:square-root(@value))"/> + <xsl:text> cubic </xsl:text> <xsl:value-of select="@units"/>. + </result> + </xsl:when> + <xsl:otherwise> + <result> + The functions external:square-root() and external cube() are not available! + </result> + </xsl:otherwise> + </xsl:choose> </xsl:template> - + <xsl:template match="now"> <when> Date and time when we figured all this out: <xsl:value-of select="asctime()"/>. </when> </xsl:template> - + </xsl:stylesheet>
