home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _CAA273EB1B5D48CD9B02A7AB5BFF4488 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  8.1 KB  |  236 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4.                 xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
  5.                 xmlns:xverb="com.nwalsh.xalan.Verbatim"
  6.                 xmlns:lxslt="http://xml.apache.org/xslt"
  7.                 exclude-result-prefixes="sverb xverb lxslt"
  8.                 version='1.0'>
  9.  
  10. <!-- ********************************************************************
  11.      $Id: verbatim.xsl,v 1.1.2.1 2002/09/04 14:25:49 jdj Exp $
  12.      ********************************************************************
  13.  
  14.      This file is part of the XSL DocBook Stylesheet distribution.
  15.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  16.      and other information.
  17.  
  18.      ******************************************************************** -->
  19.  
  20. <lxslt:component prefix="xverb"
  21.                  functions="numberLines"/>
  22.  
  23. <xsl:template match="programlisting|screen|synopsis">
  24.   <xsl:param name="suppress-numbers" select="'0'"/>
  25.   <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  26.  
  27.   <xsl:variable name="content">
  28.     <xsl:choose>
  29.       <xsl:when test="$suppress-numbers = '0'
  30.                       and @linenumbering = 'numbered'
  31.                       and $use.extensions != '0'
  32.                       and $linenumbering.extension != '0'">
  33.         <xsl:call-template name="number.rtf.lines">
  34.           <xsl:with-param name="rtf">
  35.             <xsl:apply-templates/>
  36.           </xsl:with-param>
  37.         </xsl:call-template>
  38.       </xsl:when>
  39.       <xsl:otherwise>
  40.         <xsl:apply-templates/>
  41.       </xsl:otherwise>
  42.     </xsl:choose>
  43.   </xsl:variable>
  44.  
  45.   <fo:block wrap-option='no-wrap'
  46.             white-space-collapse='false'
  47.             linefeed-treatment="preserve"
  48.             xsl:use-attribute-sets="monospace.verbatim.properties">
  49.     <xsl:choose>
  50.       <xsl:when test="$shade.verbatim != 0">
  51.         <fo:block space-before="0pt" space-after="0pt"
  52.                   xsl:use-attribute-sets="shade.verbatim.style">
  53.           <xsl:copy-of select="$content"/>
  54.         </fo:block>
  55.       </xsl:when>
  56.       <xsl:otherwise>
  57.         <xsl:copy-of select="$content"/>
  58.       </xsl:otherwise>
  59.     </xsl:choose>
  60.   </fo:block>
  61. </xsl:template>
  62.  
  63. <xsl:template match="literallayout">
  64.   <xsl:param name="suppress-numbers" select="'0'"/>
  65.  
  66.   <xsl:variable name="raw.content">
  67.     <xsl:choose>
  68.       <xsl:when test="$suppress-numbers = '0'
  69.                       and @linenumbering = 'numbered'
  70.                       and $use.extensions != '0'
  71.                       and $linenumbering.extension != '0'">
  72.         <xsl:call-template name="number.rtf.lines">
  73.           <xsl:with-param name="rtf">
  74.             <xsl:apply-templates/>
  75.           </xsl:with-param>
  76.         </xsl:call-template>
  77.       </xsl:when>
  78.       <xsl:otherwise>
  79.         <xsl:apply-templates/>
  80.       </xsl:otherwise>
  81.     </xsl:choose>
  82.   </xsl:variable>
  83.  
  84.   <xsl:variable name="content">
  85.     <xsl:choose>
  86.       <xsl:when test="@class='monospaced' and $shade.verbatim != 0">
  87.         <fo:block space-before="0pt" space-after="0pt"
  88.                   xsl:use-attribute-sets="shade.verbatim.style">
  89.           <xsl:copy-of select="$raw.content"/>
  90.         </fo:block>
  91.       </xsl:when>
  92.       <xsl:otherwise>
  93.         <xsl:copy-of select="$raw.content"/>
  94.       </xsl:otherwise>
  95.     </xsl:choose>
  96.   </xsl:variable>
  97.  
  98.   <xsl:choose>
  99.     <xsl:when test="@class='monospaced'">
  100.       <fo:block wrap-option='no-wrap'
  101.                 linefeed-treatment="preserve"
  102.                 white-space-collapse='false'
  103.                 xsl:use-attribute-sets="monospace.verbatim.properties">
  104.         <xsl:copy-of select="$content"/>
  105.       </fo:block>
  106.     </xsl:when>
  107.     <xsl:otherwise>
  108.       <fo:block wrap-option='no-wrap'
  109.                 linefeed-treatment="preserve"
  110.                 white-space-collapse='false'
  111.                 xsl:use-attribute-sets="verbatim.properties">
  112.         <xsl:copy-of select="$content"/>
  113.       </fo:block>
  114.     </xsl:otherwise>
  115.   </xsl:choose>
  116. </xsl:template>
  117.  
  118. <xsl:template match="address">
  119.   <xsl:param name="suppress-numbers" select="'0'"/>
  120.  
  121.   <xsl:variable name="content">
  122.     <xsl:choose>
  123.       <xsl:when test="$suppress-numbers = '0'
  124.                       and @linenumbering = 'numbered'
  125.                       and $use.extensions != '0'
  126.                       and $linenumbering.extension != '0'">
  127.         <xsl:call-template name="number.rtf.lines">
  128.           <xsl:with-param name="rtf">
  129.             <xsl:apply-templates/>
  130.           </xsl:with-param>
  131.         </xsl:call-template>
  132.       </xsl:when>
  133.       <xsl:otherwise>
  134.         <xsl:apply-templates/>
  135.       </xsl:otherwise>
  136.     </xsl:choose>
  137.   </xsl:variable>
  138.  
  139.   <fo:block wrap-option='no-wrap'
  140.             white-space-collapse='false'
  141.             linefeed-treatment="preserve"
  142.             xsl:use-attribute-sets="verbatim.properties">
  143.     <xsl:copy-of select="$content"/>
  144.   </fo:block>
  145. </xsl:template>
  146.  
  147. <xsl:template name="number.rtf.lines">
  148.   <xsl:param name="rtf" select="''"/>
  149.   <xsl:param name="pi.context" select="."/>
  150.  
  151.   <!-- Save the global values -->
  152.   <xsl:variable name="global.linenumbering.everyNth"
  153.                 select="$linenumbering.everyNth"/>
  154.  
  155.   <xsl:variable name="global.linenumbering.separator"
  156.                 select="$linenumbering.separator"/>
  157.  
  158.   <xsl:variable name="global.linenumbering.width"
  159.                 select="$linenumbering.width"/>
  160.  
  161.   <!-- Extract the <?dbfo linenumbering.*?> PI values -->
  162.   <xsl:variable name="pi.linenumbering.everyNth">
  163.     <xsl:call-template name="dbfo-attribute">
  164.       <xsl:with-param name="pis"
  165.                       select="$pi.context/processing-instruction('dbfo')"/>
  166.       <xsl:with-param name="attribute" select="'linenumbering.everyNth'"/>
  167.     </xsl:call-template>
  168.   </xsl:variable>
  169.  
  170.   <xsl:variable name="pi.linenumbering.separator">
  171.     <xsl:call-template name="dbfo-attribute">
  172.       <xsl:with-param name="pis"
  173.                       select="$pi.context/processing-instruction('dbfo')"/>
  174.       <xsl:with-param name="attribute" select="'linenumbering.separator'"/>
  175.     </xsl:call-template>
  176.   </xsl:variable>
  177.  
  178.   <xsl:variable name="pi.linenumbering.width">
  179.     <xsl:call-template name="dbfo-attribute">
  180.       <xsl:with-param name="pis"
  181.                       select="$pi.context/processing-instruction('dbfo')"/>
  182.       <xsl:with-param name="attribute" select="'linenumbering.width'"/>
  183.     </xsl:call-template>
  184.   </xsl:variable>
  185.  
  186.   <!-- Construct the 'in-context' values -->
  187.   <xsl:variable name="linenumbering.everyNth">
  188.     <xsl:choose>
  189.       <xsl:when test="$pi.linenumbering.everyNth != ''">
  190.         <xsl:value-of select="$pi.linenumbering.everyNth"/>
  191.       </xsl:when>
  192.       <xsl:otherwise>
  193.         <xsl:value-of select="$global.linenumbering.everyNth"/>
  194.       </xsl:otherwise>
  195.     </xsl:choose>
  196.   </xsl:variable>
  197.  
  198.   <xsl:variable name="linenumbering.separator">
  199.     <xsl:choose>
  200.       <xsl:when test="$pi.linenumbering.separator != ''">
  201.         <xsl:value-of select="$pi.linenumbering.separator"/>
  202.       </xsl:when>
  203.       <xsl:otherwise>
  204.         <xsl:value-of select="$global.linenumbering.separator"/>
  205.       </xsl:otherwise>
  206.     </xsl:choose>
  207.   </xsl:variable>
  208.  
  209.   <xsl:variable name="linenumbering.width">
  210.     <xsl:choose>
  211.       <xsl:when test="$pi.linenumbering.width != ''">
  212.         <xsl:value-of select="$pi.linenumbering.width"/>
  213.       </xsl:when>
  214.       <xsl:otherwise>
  215.         <xsl:value-of select="$global.linenumbering.width"/>
  216.       </xsl:otherwise>
  217.     </xsl:choose>
  218.   </xsl:variable>
  219.  
  220.   <xsl:choose>
  221.     <xsl:when test="function-available('sverb:numberLines')">
  222.       <xsl:copy-of select="sverb:numberLines($rtf)"/>
  223.     </xsl:when>
  224.     <xsl:when test="function-available('xverb:numberLines')">
  225.       <xsl:copy-of select="xverb:numberLines($rtf)"/>
  226.     </xsl:when>
  227.     <xsl:otherwise>
  228.       <xsl:message terminate="yes">
  229.         <xsl:text>No numberLines function available.</xsl:text>
  230.       </xsl:message>
  231.     </xsl:otherwise>
  232.   </xsl:choose>
  233. </xsl:template>
  234.  
  235. </xsl:stylesheet>
  236.