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 / F33800_zipWithDVC.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-03-09  |  1.9 KB  |  52 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="zipWith">
  6.     <xsl:param name="pFun" select="/.."/>
  7.     <xsl:param name="pList1" select="/.."/>
  8.     <xsl:param name="pList2" select="/.."/>
  9.     <xsl:param name="pElName" select="'el'"/>
  10.  
  11.     <xsl:if test="$pList1 and $pList2">
  12.       <xsl:variable name="vLength" select="count($pList1)"/>
  13.       <xsl:choose>
  14.           <xsl:when test="$vLength > 1">
  15.             <xsl:variable name="vHalf" select="floor($vLength div 2)"/>
  16.           
  17.               <xsl:call-template name="zipWith">
  18.                 <xsl:with-param name="pFun" select="$pFun"/>
  19.                 <xsl:with-param name="pList1" 
  20.                                 select="$pList1[position() <= $vHalf]"/>
  21.                 <xsl:with-param name="pList2" 
  22.                                 select="$pList2[position() <= $vHalf]"/>
  23.                 <xsl:with-param name="pElName" select="'el'"/>
  24.               </xsl:call-template>
  25.           
  26.               <xsl:call-template name="zipWith">
  27.                 <xsl:with-param name="pFun" select="$pFun"/>
  28.                 <xsl:with-param name="pList1" 
  29.                                 select="$pList1[position() > $vHalf]"/>
  30.                 <xsl:with-param name="pList2" 
  31.                                 select="$pList2[position() > $vHalf]"/>
  32.                 <xsl:with-param name="pElName" select="'el'"/>
  33.               </xsl:call-template>
  34.           </xsl:when>
  35.  
  36.           <xsl:otherwise>
  37.               <xsl:variable name="vFunResult">
  38.                 <xsl:apply-templates select="$pFun">
  39.                   <xsl:with-param name="pArg1" select="$pList1[1]"/>
  40.                   <xsl:with-param name="pArg2" select="$pList2[1]"/>
  41.                 </xsl:apply-templates>
  42.               </xsl:variable>
  43.         
  44.               <xsl:element name="{$pElName}">
  45.                 <xsl:copy-of select="$vFunResult"/>
  46.               </xsl:element>
  47.           </xsl:otherwise>
  48.       </xsl:choose>
  49.     </xsl:if>
  50.   </xsl:template>
  51. </xsl:stylesheet>
  52.