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 / F30050_runningTotal.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-03-09  |  2.7 KB  |  85 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:myAdd ="f:myAdd"
  5. xmlns:myMult="f:myMult"
  6. >
  7.   <xsl:import href="zipWithDVC.xsl"/>
  8.   <xsl:import href="scanlDVC.xsl"/>
  9.  
  10.   <!-- To be applied on booklist.xml -->
  11.   <myAdd:myAdd/>
  12.   <myMult:myMult/>
  13.  
  14.   <xsl:output omit-xml-declaration="yes"/>
  15.   <xsl:template match="/">
  16.     <xsl:variable name="vList">
  17.       <xsl:for-each select="booklist/book">
  18.         <xsl:copy-of select="."/>
  19.       </xsl:for-each>
  20.     </xsl:variable>
  21.         <html>
  22.           <table border="2">
  23.            <tr><th>Title</th><th>Author</th><th>Price</th>
  24.                <th>Sales</th><th>Current Total</th>
  25.            </tr>
  26.            <xsl:call-template name="myRunningTotal">
  27.              <xsl:with-param name="vNodes"
  28.                              select="msxsl:node-set($vList)/*"/>
  29.            </xsl:call-template>
  30.           </table>
  31.         </html>
  32.   </xsl:template>
  33.   <xsl:template name="myRunningTotal">
  34.     <xsl:param name="vNodes" select="/.."/>
  35.     
  36.     <xsl:variable name="vFunAdd" select="document('')/*/myAdd:*[1]"/>
  37.     <xsl:variable name="vFunMult" select="document('')/*/myMult:*[1]"/>
  38.  
  39.     <xsl:variable name="vrtfSingleBookAmounts">
  40.       <xsl:call-template name="zipWith">
  41.         <xsl:with-param name="pFun" select="$vFunMult"/>
  42.         <xsl:with-param name="pList1" select="$vNodes/price"/>
  43.         <xsl:with-param name="pList2" select="$vNodes/sales"/>
  44.       </xsl:call-template>
  45.     </xsl:variable>
  46.     
  47.     <xsl:variable name="vrtfRunningTotal">
  48.       <xsl:call-template name="scanl1">
  49.         <xsl:with-param name="pFun" select="$vFunAdd"/>
  50.         <xsl:with-param name="pList"
  51.                 select="msxsl:node-set($vrtfSingleBookAmounts)/*"/>
  52.       </xsl:call-template>
  53.     </xsl:variable>
  54.     
  55.     <xsl:variable name="vRunningTotal"
  56.     select="msxsl:node-set($vrtfRunningTotal)/*"/>
  57.     
  58.     <xsl:for-each select="$vNodes">
  59.         <xsl:variable name="vThisPosition" select="position()"/>
  60.         <tr>
  61.            <td><xsl:value-of select="title"/></td>
  62.            <td><xsl:value-of select="price"/></td>
  63.            <td><xsl:value-of select="sales"/></td>
  64.            <td><xsl:value-of select="sales * price"/></td>
  65.            <td><xsl:value-of select="$vRunningTotal
  66.                                          [$vThisPosition]"/>
  67.            </td>
  68.         </tr>
  69.     </xsl:for-each>
  70.   </xsl:template>
  71.   
  72.   <xsl:template match="myAdd:*">
  73.     <xsl:param name="pArg1"/>
  74.     <xsl:param name="pArg2"/>
  75.  
  76.     <xsl:value-of select="$pArg1 + $pArg2"/>
  77.   </xsl:template>
  78.  
  79.   <xsl:template match="myMult:*">
  80.     <xsl:param name="pArg1"/>
  81.     <xsl:param name="pArg2"/>
  82.  
  83.     <xsl:value-of select="$pArg1 * $pArg2"/>
  84.   </xsl:template>
  85. </xsl:stylesheet>