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 / F29300_improvedDiff.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-11-08  |  3.3 KB  |  88 lines

  1. <xsl:stylesheet version="1.0" 
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  4. xmlns:myImproveGenerator="myImproveGenerator"
  5. xmlns:myImproveController="myImproveController" 
  6. exclude-result-prefixes="xsl msxsl myImproveGenerator myImproveController"
  7. >
  8.   <xsl:import href="improve.xsl"/>
  9.   <xsl:import href="takeWhile.xsl"/> 
  10.   <xsl:import href="easyDiffList.xsl"/>
  11.  
  12.   <myImproveGenerator:myImproveGenerator/>
  13.   <myImproveController:myImproveController/>
  14.   
  15.   <xsl:output indent="yes" omit-xml-declaration="yes"/>
  16.   
  17.   <xsl:template name="improvedDiff">
  18.     <xsl:param name="pFun" select="/.."/>
  19.     <xsl:param name="pX"/>
  20.     <xsl:param name="pH0" select="0.1"/>
  21.     <xsl:param name="pEpsRough" select="0.0001"/>
  22.     <xsl:param name="pEpsImproved" select="0.0000001"/>
  23.  
  24.      <xsl:variable name="vMyImproveGenerator" select="document('')/*/myImproveGenerator:*[1]"/>
  25.      <xsl:variable name="vMyImproveController" select="document('')/*/myImproveController:*[1]"/>
  26.      
  27.      <xsl:variable name="vrtfRoughResults">
  28.         <xsl:call-template name="easyDiffList">
  29.             <xsl:with-param name="pFun" select="$pFun"/>
  30.             <xsl:with-param name="pX" select="$pX"/>
  31.             <xsl:with-param name="pH0" select="$pH0"/>
  32.             <xsl:with-param name="pEps" select="$pEpsRough"/>
  33.         </xsl:call-template>
  34.      </xsl:variable>
  35.  
  36.     <xsl:variable name="vrtfResults">
  37.         <xsl:call-template name="takeWhile">
  38.           <xsl:with-param name="pGenerator" select="$vMyImproveGenerator"/>
  39.           <xsl:with-param name="pParam0" select="msxsl:node-set($vrtfRoughResults)/*"/>
  40.           <xsl:with-param name="pController" select="$vMyImproveController"/>
  41.           <xsl:with-param name="pContollerParam" select="$pEpsImproved"/>
  42.         </xsl:call-template>
  43.     </xsl:variable>
  44.     
  45.     <xsl:variable name="vResults" select="msxsl:node-set($vrtfResults)/*"/>
  46.     <xsl:value-of select="$vResults[last()]/*[2]"/>
  47.     
  48.      <!-- <xsl:copy-of select="msxsl:node-set($vrtfResults)/*"/>  -->
  49.     
  50.   </xsl:template>
  51.   
  52.   <xsl:template name="myImproveGenerator" match="*[namespace-uri()='myImproveGenerator']">
  53.      <xsl:param name="pList" select="/.."/>
  54.      <xsl:param name="pParams" select="/.."/>
  55.      
  56.      <xsl:choose>
  57.        <xsl:when test="not($pList)">
  58.          <xsl:call-template name="improve">
  59.             <xsl:with-param name="pList" select="$pParams"/>
  60.          </xsl:call-template>
  61.        </xsl:when>
  62.        <xsl:otherwise>
  63.          <xsl:call-template name="improve">
  64.             <xsl:with-param name="pList" select="$pList[last()]/*"/>
  65.          </xsl:call-template>
  66.        </xsl:otherwise>
  67.      </xsl:choose>
  68.  
  69.   </xsl:template>
  70.   
  71.   <xsl:template name="MyImproveController" match="*[namespace-uri()='myImproveController']">
  72.     <xsl:param name="pList" select="/.."/>
  73.     <xsl:param name="pParams" select="0.01"/>
  74.     
  75.     <xsl:choose>
  76.       <xsl:when test="count($pList) < 2">1</xsl:when>
  77.       <xsl:otherwise>
  78.         <xsl:variable name="vDiff" select="$pList[last()]/*[2] 
  79.                                           - $pList[last() - 1]/*[2]"/>
  80.         <xsl:if test="not($vDiff < $pParams 
  81.                      and $vDiff > (0 - $pParams))
  82.                      and count($pList) <= 5
  83.                      ">1</xsl:if>
  84.       </xsl:otherwise>
  85.     </xsl:choose>
  86.   
  87.   </xsl:template>
  88. </xsl:stylesheet>