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 / F41116_splittolines.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-02-06  |  2.1 KB  |  59 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:xalan="http://xml.apache.org/xalan"
  3. xmlns:pGenerator="f:pGenerator"
  4. xmlns:pController="f:pController" 
  5. exclude-result-prefixes="xsl xalan pGenerator pController" 
  6. >
  7.   <xsl:import href="buildListWhile.xsl"/> 
  8.  
  9.   <!-- To be applied on text.xml -->
  10.   
  11.   <xsl:output indent="yes" omit-xml-declaration="yes"/>
  12.   
  13.   <pGenerator:pGenerator/>
  14.   <pController:pController/>
  15.  
  16.   <xsl:variable name="vMyGenerator" select="document('')/*/pGenerator:*[1]"/>
  17.   <xsl:variable name="vMyController" select="document('')/*/pController:*[1]"/>
  18.   
  19.   <xsl:template match="/">
  20.   
  21.     <xsl:variable name="prtfSplitParams">
  22.         <lineLength>64</lineLength>
  23.         <text><xsl:value-of select="/*"/></text>
  24.     </xsl:variable>
  25.     
  26.     <xsl:variable name="pSplitParams" select="xalan:nodeset($prtfSplitParams)"/>
  27.     
  28.     <xsl:variable name="vNumLines" 
  29.                   select="ceiling(string-length($pSplitParams/text) 
  30.                                 div 
  31.                                    $pSplitParams/lineLength
  32.                                    )"
  33.     />
  34.     <xsl:call-template name="buildListWhile">
  35.       <xsl:with-param name="pParam0" select="$pSplitParams"/>
  36.       <xsl:with-param name="pGenerator" select="$vMyGenerator"/>
  37.       <xsl:with-param name="pController" select="$vMyController"/>
  38.       <xsl:with-param name="pContollerParam" select="$vNumLines"/>
  39.       <xsl:with-param name="pElementName" select="'line'"/>
  40.     </xsl:call-template>
  41.   </xsl:template>
  42.  
  43.   <xsl:template name="listGenerator" match="pGenerator:*">
  44.      <xsl:param name="pList" select="/.."/>
  45.      <xsl:param name="pParams"/>
  46.      
  47.      <xsl:variable name="vLineLength" select="$pParams/lineLength"/>
  48.      <xsl:variable name="vText" select="$pParams/text"/>
  49.      <xsl:value-of select="substring($vText, count($pList) * $vLineLength, $vLineLength)"/>
  50.   </xsl:template>
  51.   
  52.   <xsl:template name="listController" match="pController:*">
  53.      <xsl:param name="pList" select="/.."/>
  54.      <xsl:param name="pParams"/>
  55.      
  56.      <xsl:if test="count($pList) <= $pParams">1</xsl:if>
  57.   </xsl:template>
  58.  
  59. </xsl:stylesheet>