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 / F31370_teststrMap2.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-11-28  |  3.1 KB  |  95 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:testmap="testmap"
  5. exclude-result-prefixes="xsl testmap map-foldl-func"
  6. xmlns:map-foldl-func="map-foldl-func"
  7. >
  8.    <!-- <xsl:import href="str-map.xsl"/> -->
  9.  
  10.    <map-foldl-func:map-foldl-func/>
  11.  
  12.    <testmap:testmap/>
  13.  
  14.    <xsl:output omit-xml-declaration="yes" indent="yes"/>
  15.    
  16.    <xsl:template match="/">
  17.      <xsl:variable name="vTestMap" select="document('')/*/testmap:*[1]"/>
  18.      <xsl:call-template name="str-map">
  19.        <xsl:with-param name="pFun" select="$vTestMap"/>
  20.        <xsl:with-param name="pStr" select="'0123456789'"/>
  21.      </xsl:call-template>
  22.    </xsl:template>
  23.  
  24.     <xsl:template name="double" match="*[namespace-uri() = 'testmap']">
  25.       <xsl:param name="arg1"/>
  26.       
  27.       <xsl:value-of select="2 * $arg1"/>
  28.     </xsl:template>
  29.  
  30.      <xsl:template name="str-map">
  31.       <xsl:param name="pFun" select="/.."/>
  32.       <xsl:param name="pStr" select="/.."/>
  33.  
  34.        <xsl:variable name="vFoldlFun" select="document('')/*/map-foldl-func:*[1]"/>
  35.  
  36.        <xsl:variable name="vFuncComposition">
  37.          <xsl:copy-of select="$vFoldlFun"/>
  38.          <xsl:copy-of select="$pFun"/>
  39.        </xsl:variable>
  40.  
  41.        <xsl:variable name="vFComposition"
  42.                      select="msxsl:node-set($vFuncComposition)/*"/>
  43.  
  44.       <xsl:call-template name="str-foldl">
  45.         <xsl:with-param name="pFunc" select="$vFComposition"/>
  46.         <xsl:with-param name="pStr" select="$pStr"/>
  47.         <xsl:with-param name="pA0" select="/.."/>
  48.       </xsl:call-template>
  49.     </xsl:template>
  50.  
  51.  
  52.     <xsl:template name="mapL" match="*[namespace-uri() = 'map-foldl-func']">
  53.          <xsl:param name="arg0" select="/.."/>
  54.          <xsl:param name="arg1" select="/.."/>
  55.          <xsl:param name="arg2" select="/.."/>
  56.  
  57.          <!-- $arg1 must be A0 -->
  58.          <xsl:copy-of select="$arg1"/>
  59.  
  60.            <xsl:apply-templates select="$arg0[1]">
  61.              <xsl:with-param name="arg1" select="substring($arg2,1,1)"/>
  62.            </xsl:apply-templates>
  63.     </xsl:template>
  64.  
  65.     <xsl:template name="str-foldl">
  66.       <xsl:param name="pFunc" select="/.."/>
  67.       <xsl:param name="pA0"/>
  68.       <xsl:param name="pStr"/>
  69.  
  70.       <xsl:choose>
  71.          <xsl:when test="not(string($pStr))">
  72.             <xsl:copy-of select="$pA0"/>
  73.          </xsl:when>
  74.          <xsl:otherwise>
  75.             <xsl:variable name="vFunResult">
  76.               <xsl:apply-templates select="$pFunc[1]">
  77.                 <xsl:with-param name="arg0" select="$pFunc[position() > 1]"/>
  78.                 <xsl:with-param name="arg1" select="$pA0"/>
  79.                 <xsl:with-param name="arg2" select="substring($pStr,1,1)"/>
  80.               </xsl:apply-templates>
  81.             </xsl:variable>
  82.  
  83.             <xsl:call-template name="str-foldl">
  84.                 <xsl:with-param name="pFunc" select="$pFunc"/>
  85.                 <xsl:with-param name="pStr" select="substring($pStr,2)"/>
  86.                 <xsl:with-param name="pA0" select="$vFunResult"/>
  87.             </xsl:call-template>
  88.          </xsl:otherwise>
  89.       </xsl:choose>
  90.  
  91.     </xsl:template>
  92.  
  93.  
  94.  
  95. </xsl:stylesheet>