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 / F31790_testBuildListWhileIntervals3.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  6.5 KB  |  178 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:pGenerator="pGenerator"
  4. xmlns:pController="pController"
  5. xmlns:IntervalParams="IntervalParams"
  6. xmlns:IntegralFunction="IntegralFunction"
  7. xmlns:mapEasyIntegrate="mapEasyIntegrate"
  8. xmlns:easy-integrate="easy-integrate"
  9. exclude-result-prefixes="xsl msxsl pGenerator pController IntervalParams IntegralFunction"
  10. >
  11.   <xsl:import href="buildListWhileMap.xsl"/>
  12.   <xsl:import href="foldl.xsl"/>
  13.  
  14.   
  15.   <xsl:output indent="yes" omit-xml-declaration="yes"/>
  16.   
  17.   <pGenerator:pGenerator/>
  18.   <pController:pController/>
  19.   <mapEasyIntegrate:mapEasyIntegrate/>
  20.   <easy-integrate:easy-integrate/>
  21.   
  22.   <IntervalParams:IntervalParams>
  23.     <Interval>
  24.         <el>0</el>
  25.         <el>1</el>
  26.     </Interval>
  27.     <IntegralFunction:IntegralFunction/>
  28.   </IntervalParams:IntervalParams>
  29.   
  30.   <xsl:variable name="vMyGenerator" select="document('')/*/pGenerator:*[1]"/>
  31.   <xsl:variable name="vMyController" select="document('')/*/pController:*[1]"/>
  32.   <xsl:variable name="vmyEasyIntegrateMap" select="document('')/*/mapEasyIntegrate:*[1]"/>
  33.   <xsl:variable name="vIntervalParams" select="document('')/*/IntervalParams:*[1]"/>
  34.  
  35.   <xsl:template match="/">
  36.     <xsl:variable name="vrtfResultIntervalList">
  37.       <xsl:call-template name="buildListWhileMap">
  38.         <xsl:with-param name="pGenerator" select="$vMyGenerator"/>
  39.         <xsl:with-param name="pController" select="$vMyController"/>
  40.         <xsl:with-param name="pParam0" select="$vIntervalParams"/>
  41.         <xsl:with-param name="pContollerParam" select="0.001"/>
  42.         <xsl:with-param name="pMap" select="$vmyEasyIntegrateMap"/>
  43.       </xsl:call-template>
  44.     </xsl:variable>
  45.     
  46.     <xsl:copy-of select="msxsl:node-set($vrtfResultIntervalList)"/>
  47.  
  48.     <xsl:variable name="vResultIntervalList"
  49.        select="msxsl:node-set($vrtfResultIntervalList)/*[last()]/*"/>
  50.        
  51.     <xsl:for-each select="$vResultIntervalList">
  52.      <xsl:copy-of select="."/>
  53.     </xsl:for-each>
  54.     
  55.   </xsl:template>
  56.  
  57.   <xsl:template name="listGenerator" match="*[namespace-uri()='pGenerator']">
  58.      <xsl:param name="pList" select="/.."/>
  59.      <xsl:param name="pParams"/>
  60.  
  61.      <xsl:variable name="pA0" select="string($pParams/*[1]/*[1])"/>
  62.      <xsl:variable name="pB0" select="string($pParams/*[1]/*[2])"/>
  63.      <xsl:variable name="pFun" select="$pParams/*[2]"/>
  64.      
  65.      <xsl:choose>
  66.        <xsl:when test="not($pList)">
  67.          <xsl:variable name="vFa">
  68.            <xsl:apply-templates select="$pFun">
  69.              <xsl:with-param name="pX" select="$pA0"/>
  70.            </xsl:apply-templates>
  71.          </xsl:variable>
  72.        
  73.          <xsl:variable name="vFb">
  74.            <xsl:apply-templates select="$pFun">
  75.              <xsl:with-param name="pX" select="$pB0"/>
  76.            </xsl:apply-templates>
  77.          </xsl:variable>
  78.          
  79.          <e><xsl:value-of select="$pB0 - $pA0"/></e>
  80.          <e><xsl:value-of select="$vFa"/></e>
  81.          <e><xsl:value-of select="$vFb"/></e>
  82.        </xsl:when>
  83.        <xsl:otherwise>
  84.           <xsl:variable name="vprevH" select="$pList[last()]/*[1]"/>
  85.           <xsl:variable name="vH" select="$vprevH div 2"/>
  86.           <e><xsl:value-of select="$vH"/></e>
  87.           <xsl:for-each select="$pList[last()]/*[position() > 1 
  88.                                              and position() != last()]">
  89.            <xsl:variable name="vA" select="$pA0 + (position() - 1) * $vprevH"/>
  90.            
  91.            <xsl:variable name="vMid" select="$vA + $vH"/>
  92.            
  93.            <xsl:variable name="vF_mid">
  94.              <xsl:apply-templates select="$pFun">
  95.                <xsl:with-param name="pX" select="$vMid"/>
  96.              </xsl:apply-templates>
  97.            </xsl:variable>
  98.            
  99.            
  100.            
  101.            <xsl:copy-of select="."/>
  102.            <e><xsl:value-of select="$vF_mid"/></e>
  103.          </xsl:for-each>
  104.          <xsl:copy-of select="$pList[last()]/*[last()]"/>
  105.        </xsl:otherwise>
  106.      </xsl:choose>
  107.      
  108.   </xsl:template>
  109.  
  110.   <xsl:template name="listController" match="*[namespace-uri()='pController']">
  111.      <xsl:param name="pList" select="/.."/>
  112.      <xsl:param name="pParams"/>
  113.      
  114.      <xsl:choose>
  115.          <xsl:when test="count($pList) < 2">1</xsl:when>
  116.          <xsl:otherwise>
  117.              <xsl:variable name="vLastDiff" select="$pList[last()]
  118.                                                   - $pList[last() - 1]"/>
  119.  
  120.              <xsl:if test="not($vLastDiff < $pParams
  121.                        and $vLastDiff > (0 - $pParams))">1</xsl:if>
  122.              <!-- <xsl:if test="count($pList[last()]/*) <= $pParams">1</xsl:if> -->
  123.              <!-- <xsl:if test="count($pList) <= $pParams">1</xsl:if> -->
  124.          </xsl:otherwise>
  125.      </xsl:choose>
  126.      
  127.   </xsl:template>
  128.   
  129.   <xsl:template name="mapEasyIntegrate" match="*[namespace-uri()='mapEasyIntegrate']">
  130.      <xsl:param name="pParams" select="/.."/> <!-- pMapParams -->
  131.      <xsl:param name="pDynParams" select="/.."/> <!-- NewBaseListElement -->
  132.      <xsl:param name="pList" select="/.."/>
  133.      
  134.      <xsl:variable name="vResult">
  135.          <xsl:call-template name="multiIntegrate">
  136.           <xsl:with-param name="pList" select="$pDynParams/*"/>
  137.         </xsl:call-template>
  138.      </xsl:variable>
  139.      
  140.      <xsl:copy-of select="msxsl:node-set($vResult)"/>
  141.   </xsl:template>
  142.  
  143.   
  144.   <xsl:template name="myIntegralFn" match="*[namespace-uri()='IntegralFunction']">
  145.     <xsl:param name="pX"/>
  146.     
  147.     <xsl:value-of select="$pX * $pX"/>
  148.   </xsl:template>
  149.  
  150.   <xsl:template name="multiIntegrate">
  151.     <xsl:param name="pList" select="/*/*"/>
  152.  
  153.     <xsl:variable name="vmyeasyIntegrateFn" select="document('')/*/easy-integrate:*[1]"/>
  154.  
  155.       <xsl:call-template name="foldl">
  156.         <xsl:with-param name="pFunc" select="$vmyeasyIntegrateFn"/>
  157.         <xsl:with-param name="pList" select="$pList[position() > 1
  158.                                               and position() < last()]"/>
  159.         <xsl:with-param name="pA0" select="0"/>
  160.       </xsl:call-template>
  161.  
  162.   </xsl:template>
  163.  
  164.   <xsl:template name="myEasyIntegrateFn" match="*[namespace-uri()='easy-integrate']">
  165.     <xsl:param name="arg1" select="0"/> <!-- pA0 -->
  166.     <xsl:param name="arg2" select="0"/> <!-- node -->
  167.  
  168.     <xsl:value-of
  169.        select="$arg1
  170.              +
  171.                (($arg2 + $arg2/following-sibling::*[1])
  172.                  div 2
  173.                 ) * $arg2/../*[1]"/>
  174.  
  175.   </xsl:template>
  176.  
  177.      
  178. </xsl:stylesheet>