home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F30380_sqrt.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-03-10  |  2.0 KB  |  58 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  3. xmlns:MyRepeatGenerator="MyRepeatGenerator" 
  4. xmlns:MyRepeatableFunction="MyRepeatableFunction"
  5. exclude-result-prefixes="xsl msxsl MyRepeatGenerator MyRepeatableFunction" 
  6. >
  7.  
  8.   <xsl:import href="within.xsl"/>
  9.   <!-- <xsl:import href="withinRelative.xsl"/> -->
  10.  
  11.   <MyRepeatGenerator:MyRepeatGenerator/>
  12.   <MyRepeatableFunction:MyRepeatableFunction/>
  13.   
  14.    <xsl:variable name="vMyRepeat" select="document('')/*/MyRepeatGenerator:*[1]"/>
  15.    <xsl:variable name="vMyFunction" select="document('')/*/MyRepeatableFunction:*[1]"/>
  16.    
  17.   <xsl:template name="sqrt">
  18.     <xsl:param name="N"/>
  19.     <xsl:param name="Eps" select="0.1"/>
  20.     
  21.     <xsl:variable name="vrtfParams">
  22.       <param><xsl:value-of select="$N div 2"/></param>
  23.       <xsl:copy-of select="$vMyFunction"/>
  24.       <param><xsl:value-of select="$N"/></param>
  25.     </xsl:variable>
  26.  
  27.     <xsl:call-template name="within">
  28.       <xsl:with-param name="pGenerator" select="$vMyRepeat"/>
  29.       <xsl:with-param name="pParam0" select="msxsl:node-set($vrtfParams)/*"/>
  30.         <xsl:with-param name="Eps" select="$Eps"/>
  31.     </xsl:call-template>
  32.   </xsl:template>
  33.   
  34.   <xsl:template name="myRepeater" match="*[namespace-uri()='MyRepeatGenerator']">
  35.      <xsl:param name="pList" select="/.."/>
  36.      <xsl:param name="pParams"/>
  37.      
  38.      <xsl:choose>
  39.          <xsl:when test="not($pList)">
  40.             <xsl:copy-of select="$pParams[1]/node()"/>
  41.          </xsl:when>
  42.          <xsl:otherwise>
  43.            <xsl:apply-templates select="$pParams[2]">
  44.              <xsl:with-param name="X" select="$pList[last()]"/>
  45.              <xsl:with-param name="N" select="$pParams[3]/node()"/>
  46.            </xsl:apply-templates>
  47.          </xsl:otherwise>
  48.      </xsl:choose>
  49.   </xsl:template>
  50.  
  51.   <xsl:template name="myRptFn" match="*[namespace-uri()='MyRepeatableFunction']">
  52.      <xsl:param name="X"/>
  53.      <xsl:param name="N"/>
  54.      
  55.      <xsl:value-of select="($X + ($N div $X)) div 2"/>
  56.   </xsl:template>
  57.  
  58. </xsl:stylesheet>