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 / F33710_withinRelative.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-29  |  1.8 KB  |  47 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:MyWithinRelEpsController="MyWithinRelEpsController"
  4. exclude-result-prefixes="xsl msxsl MyWithinRelEpsController" 
  5. >
  6.  
  7.   <xsl:import href="buildListWhile.xsl"/>
  8.  
  9.   <MyWithinRelEpsController:MyWithinRelEpsController/>
  10.   
  11.    <xsl:variable name="vMyWithinRelEpsController" select="document('')/*/MyWithinRelEpsController:*[1]"/>
  12.   
  13.   <xsl:template name="withinRelative">
  14.      <xsl:param name="pGenerator" select="/.."/>
  15.      <xsl:param name="pParam0" select="/.."/>
  16.      <xsl:param name="Eps" select="0.1"/>
  17.   
  18.       <xsl:variable name="vResultList">
  19.           <xsl:call-template name="buildListWhile">
  20.             <xsl:with-param name="pGenerator" select="$pGenerator"/>
  21.             <xsl:with-param name="pParam0" select="$pParam0"/>
  22.             <xsl:with-param name="pController" select="$vMyWithinRelEpsController"/>
  23.             <xsl:with-param name="pContollerParam" select="$Eps"/>
  24.           </xsl:call-template>
  25.       </xsl:variable>
  26.       
  27.       <xsl:value-of select="msxsl:node-set($vResultList)/*[last()]"/>
  28.   </xsl:template>
  29.  
  30.   <xsl:template name="MyWithinRelEpsController" match="*[namespace-uri()='MyWithinRelEpsController']">
  31.      <xsl:param name="pList" select="/.."/>
  32.      <xsl:param name="pParams"/>
  33.      
  34.      <xsl:choose>
  35.          <xsl:when test="count($pList) < 2">1</xsl:when>
  36.          <xsl:when test="count($pList) >= 2">
  37.            <xsl:variable name="lastDiff" select="$pList[last()] - $pList[last() - 1]"/>
  38.            <xsl:variable name="lastProd" select="$pParams * $pList[last()]"/>
  39.            
  40.            <xsl:if test="not($lastDiff <= $lastProd 
  41.                        and $lastDiff >= (0 - $lastProd))">1</xsl:if>
  42.          </xsl:when>
  43.          <xsl:otherwise>1</xsl:otherwise>
  44.      </xsl:choose>
  45.   </xsl:template>
  46.  
  47. </xsl:stylesheet>