<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:f="http://fxsl.sf.net/"
 xmlns:myMultiplyby3="f:myMultiplyby3" 
 xmlns:myPower2="f:myPower2" 
 xmlns:myLT100="f:myLT100"
 exclude-result-prefixes="f myMultiplyby3 myPower2 myLT100">

 <xsl:import href="../f/func-iter.xsl"/>

 <!-- To be applied on any xml file, or with initial template named "initial"
      
      Expected result: f:iter(4, $vMultBy3, 1) = 81
                       The biggest 2^n smaller than 100 =  64
 -->
 
 <xsl:output omit-xml-declaration="yes"/>
  
    <xsl:variable name="vLT100" select="document('')/*/myLT100:*[1]"/>
    <xsl:variable name="vMultBy2" select="document('')/*/myPower2:*[1]"/>
    
  <xsl:template name="initial" match="/">
   <xsl:variable name="vMultBy3" select="document('')/*/myMultiplyby3:*[1]"/>
   
    <xsl:sequence select="'f:iter(4, $vMultBy3, 1) = ',
                           f:iter(4, $vMultBy3, 1)"/>
    <xsl:text>&#xA;</xsl:text>
    
    <xsl:sequence select="'The biggest 2^n smaller than 100 = ', 
                           f:iterUntil($vLT100, $vMultBy2, 1) div 2"/>
  </xsl:template>
  
  <myMultiplyby3:myMultiplyby3/>
  <xsl:template match="myMultiplyby3:*" mode="f:FXSL">
    <xsl:param name="arg1"/>
    
    <xsl:value-of select="3 * $arg1"/>
  </xsl:template>
  
  <myPower2:myPower2/>
  <xsl:template match="myPower2:*" mode="f:FXSL">
    <xsl:param name="arg1"/>
    
    <xsl:value-of select="2 * $arg1"/>
  </xsl:template>

  <myLT100:myLT100/>
  <xsl:template match="myLT100:*" mode="f:FXSL">
    <xsl:param name="arg1"/>
    
    <xsl:value-of select="if($arg1 > 100)
                            then 1
                            else 0"/>
  </xsl:template>
    
</xsl:stylesheet>
