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 / F30170_scanlDVC.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-03-09  |  2.7 KB  |  74 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. >
  5.   <xsl:template name="scanl">
  6.     <xsl:param name="pFun" select="/.."/>
  7.     <xsl:param name="pQ0" select="/.."/>
  8.     <xsl:param name="pList" select="/.."/>
  9.     <xsl:param name="pElName" select="'el'"/>
  10.     <xsl:param name="pStarting" select="1"/>
  11.     
  12.     <xsl:variable name="vLength" select="count($pList)"/>
  13.  
  14.     <xsl:choose>
  15.       <xsl:when test="$vLength > 1">
  16.         <xsl:variable name="vHalf" select="floor($vLength div 2)"/>
  17.           
  18.         <xsl:variable name="vrtfResult1">
  19.               <xsl:call-template name="scanl">
  20.                     <xsl:with-param name="pFun" select="$pFun"/>
  21.                     <xsl:with-param name="pQ0" select="$pQ0" />
  22.                     <xsl:with-param name="pList" select="$pList[position() <= $vHalf]"/>
  23.                     <xsl:with-param name="pElName" select="$pElName"/>
  24.             <xsl:with-param name="pStarting" select="$pStarting"/>
  25.               </xsl:call-template>
  26.           </xsl:variable>
  27.           
  28.           <xsl:variable name="vResult1" select="msxsl:node-set($vrtfResult1)/*"/>
  29.           
  30.           <xsl:copy-of select="$vResult1"/>
  31.           
  32.           <xsl:call-template name="scanl">
  33.                 <xsl:with-param name="pFun" select="$pFun"/>
  34.                 <xsl:with-param name="pQ0" select="$vResult1[last()]" />
  35.                 <xsl:with-param name="pList" select="$pList[position() > $vHalf]"/>
  36.                 <xsl:with-param name="pElName" select="$pElName"/>
  37.           <xsl:with-param name="pStarting" select="0"/>
  38.           </xsl:call-template>
  39.       </xsl:when>
  40.  
  41.       <xsl:otherwise>
  42.             <xsl:if test="$pStarting">
  43.                 <xsl:element name="{$pElName}">
  44.                   <xsl:copy-of select="msxsl:node-set($pQ0)/node()"/>
  45.                 </xsl:element>
  46.             </xsl:if>
  47.     
  48.         <xsl:if test="$pList">
  49.                 <xsl:element name="{$pElName}">
  50.                   <xsl:apply-templates select="$pFun">
  51.                     <xsl:with-param name="pArg1" select="$pQ0"/>
  52.                     <xsl:with-param name="pArg2" select="$pList[1]"/>
  53.                   </xsl:apply-templates>
  54.                 </xsl:element>
  55.         </xsl:if>
  56.       </xsl:otherwise>
  57.     </xsl:choose>
  58.   </xsl:template>
  59.   
  60.   <xsl:template name="scanl1">
  61.     <xsl:param name="pFun" select="/.."/>
  62.     <xsl:param name="pList" select="/.."/>
  63.     <xsl:param name="pElName" select="'el'"/>
  64.     
  65.     <xsl:if test="$pList">
  66.       <xsl:call-template name="scanl">
  67.         <xsl:with-param name="pFun" select="$pFun"/>
  68.         <xsl:with-param name="pQ0" select="$pList[1]" />
  69.         <xsl:with-param name="pList" select="$pList[position() > 1]"/>
  70.         <xsl:with-param name="pElName" select="$pElName"/>
  71.       </xsl:call-template>
  72.     </xsl:if>
  73.   </xsl:template>
  74. </xsl:stylesheet>