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 / F33170_testTake.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  3.9 KB  |  119 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:DropWhileController="DropWhileController"
  5. xmlns:MyRepeatGenerator="MyRepeatGenerator" 
  6. xmlns:MyRepeatableFunction="MyRepeatableFunction"
  7. exclude-result-prefixes="xsl msxsl pGenerator DropWhileController 
  8.                          MyRepeatGenerator MyRepeatableFunction"
  9. >
  10.  
  11.   <xsl:import href="take.xsl"/> 
  12.   <xsl:import href="drop.xsl"/>
  13.   <xsl:import href="dropWhile.xsl"/>
  14.   
  15.   <!-- To be applied on any xml source. -->
  16.  
  17.   <xsl:output indent="yes" omit-xml-declaration="yes"/>
  18.   
  19.   <pGenerator:pGenerator/>
  20.   <DropWhileController:DropWhileController/>
  21.   <MyRepeatGenerator:MyRepeatGenerator/>
  22.   <MyRepeatableFunction:MyRepeatableFunction/>
  23.   
  24.    <xsl:variable name="vMyGenerator" select="document('')/*/pGenerator:*[1]"/>
  25.    <xsl:variable name="vDropWhileController" select="document('')/*/DropWhileController:*[1]"/>
  26.    <xsl:variable name="vMyRepeat" select="document('')/*/MyRepeatGenerator:*[1]"/>
  27.    <xsl:variable name="vMyFunction" select="document('')/*/MyRepeatableFunction:*[1]"/>
  28.   
  29.   <xsl:template match="/">
  30.  
  31.     <xsl:variable name="vTake8">
  32.         <xsl:call-template name="take">
  33.           <xsl:with-param name="pGenerator" select="$vMyGenerator"/>
  34.           <xsl:with-param name="pN" select="8"/>
  35.         </xsl:call-template>
  36.     </xsl:variable>
  37.     
  38.     <xsl:copy-of select="msxsl:node-set($vTake8)/*"/>
  39.    
  40.     <xsl:text> </xsl:text>
  41.     <xsl:text> </xsl:text>
  42.       
  43.     <xsl:call-template name="take">
  44.       <xsl:with-param name="pList" select="msxsl:node-set($vTake8)/*"/>
  45.       <xsl:with-param name="pN" select="3"/>
  46.     </xsl:call-template>
  47.  
  48.     <xsl:text> </xsl:text>
  49.     <xsl:text> </xsl:text>
  50.   
  51.     <xsl:call-template name="drop">
  52.       <xsl:with-param name="pList" select="msxsl:node-set($vTake8)/*"/>
  53.       <xsl:with-param name="pN" select="3"/>
  54.     </xsl:call-template>
  55.  
  56.     <xsl:text> </xsl:text>
  57.     <xsl:text> </xsl:text>
  58.    
  59.     <xsl:call-template name="dropWhile">
  60.         <xsl:with-param name="pList" select="msxsl:node-set($vTake8)/*"/>
  61.         <xsl:with-param name="pController" select="$vDropWhileController"/>
  62.     </xsl:call-template>
  63.  
  64.  
  65.     <xsl:text> </xsl:text>
  66.     <xsl:text> </xsl:text>
  67.   <xsl:call-template name="take">
  68.     <xsl:with-param name="pN" select="10"/>
  69.     <xsl:with-param name="pGenerator" select="$vMyRepeat"/>
  70.     <xsl:with-param name="pParam0" select="5"/>
  71.     <xsl:with-param name="pParamGenerator" select="$vMyFunction"/>
  72.   </xsl:call-template>
  73.  
  74.  
  75.  
  76.   </xsl:template>
  77.   
  78.   <xsl:template name="listGenerator" match="*[namespace-uri()='pGenerator']">
  79.      <xsl:param name="pList" select="/.."/>
  80.      <xsl:param name="pParams"/>
  81.      
  82.      <xsl:value-of select="(count($pList) + 1) * 2"/>
  83.   </xsl:template>
  84.    
  85.    <xsl:template name="myDWController" match="*[namespace-uri()='DropWhileController']">
  86.      <xsl:param name="pList" select="/.."/>
  87.      <xsl:param name="pParams"/>
  88.      
  89.      <xsl:if test="$pList <= 10">1</xsl:if>
  90.   </xsl:template>
  91.  
  92.   <xsl:template name="myRepeater" match="*[namespace-uri()='MyRepeatGenerator']">
  93.      <xsl:param name="pList" select="/.."/>
  94.      <xsl:param name="pParams"/>
  95.      <xsl:param name="pParamGenerator" select="/.."/>
  96.      
  97.      <xsl:choose>
  98.          <xsl:when test="not($pList)">
  99.             <xsl:copy-of select="$pParams"/>
  100.          </xsl:when>
  101.          <xsl:otherwise>
  102.            <xsl:apply-templates select="$pParamGenerator[1]">
  103.              <xsl:with-param name="X" select="$pList[last()]"/>
  104.              <xsl:with-param name="N" select="9"/>
  105.            </xsl:apply-templates>
  106.          </xsl:otherwise>
  107.      </xsl:choose>
  108.   </xsl:template>
  109.  
  110.   <xsl:template name="myRptFn" match="*[namespace-uri()='MyRepeatableFunction']">
  111.      <xsl:param name="X"/>
  112.      <xsl:param name="N"/>
  113.      
  114.      <xsl:value-of select="($X + ($N div $X)) div 2"/>
  115.   </xsl:template>
  116.   
  117.  
  118.  
  119. </xsl:stylesheet>