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

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
  4.                 xmlns:xverb="com.nwalsh.xalan.Verbatim"
  5.                 xmlns:lxslt="http://xml.apache.org/xslt"
  6.                 xmlns:exsl="http://exslt.org/common"
  7.                 exclude-result-prefixes="sverb xverb lxslt exsl"
  8.                 version='1.0'>
  9.  
  10. <!-- ********************************************************************
  11.      $Id: verbatim.xsl,v 1.1.2.1 2002/09/04 13:51:10 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">
  26.     <xsl:call-template name="object.id"/>
  27.   </xsl:variable>
  28.  
  29.   <xsl:call-template name="anchor"/>
  30.  
  31.   <xsl:variable name="content">
  32.     <xsl:choose>
  33.       <xsl:when test="$suppress-numbers = '0'
  34.                       and @linenumbering = 'numbered'
  35.                       and $use.extensions != '0'
  36.                       and $linenumbering.extension != '0'">
  37.         <xsl:variable name="rtf">
  38.           <xsl:apply-templates/>
  39.         </xsl:variable>
  40.         <pre class="{name(.)}">
  41.           <xsl:call-template name="number.rtf.lines">
  42.             <xsl:with-param name="rtf" select="$rtf"/>
  43.           </xsl:call-template>
  44.         </pre>
  45.       </xsl:when>
  46.       <xsl:otherwise>
  47.         <pre class="{name(.)}">
  48.           <xsl:apply-templates/>
  49.         </pre>
  50.       </xsl:otherwise>
  51.     </xsl:choose>
  52.   </xsl:variable>
  53.  
  54.   <xsl:choose>
  55.     <xsl:when test="$shade.verbatim != 0">
  56.       <table xsl:use-attribute-sets="shade.verbatim.style">
  57.         <tr>
  58.           <td>
  59.             <xsl:copy-of select="$content"/>
  60.           </td>
  61.         </tr>
  62.       </table>
  63.     </xsl:when>
  64.     <xsl:otherwise>
  65.       <xsl:copy-of select="$content"/>
  66.     </xsl:otherwise>
  67.   </xsl:choose>
  68. </xsl:template>
  69.  
  70. <xsl:template match="literallayout">
  71.   <xsl:param name="suppress-numbers" select="'0'"/>
  72.  
  73.   <xsl:variable name="rtf">
  74.     <xsl:apply-templates/>
  75.   </xsl:variable>
  76.  
  77.   <xsl:variable name="content">
  78.     <xsl:choose>
  79.       <xsl:when test="$suppress-numbers = '0'
  80.                       and @linenumbering = 'numbered'
  81.                       and $use.extensions != '0'
  82.                       and $linenumbering.extension != '0'">
  83.         <xsl:choose>
  84.           <xsl:when test="@class='monospaced'">
  85.             <pre class="{name(.)}">
  86.               <xsl:call-template name="number.rtf.lines">
  87.                 <xsl:with-param name="rtf" select="$rtf"/>
  88.               </xsl:call-template>
  89.             </pre>
  90.           </xsl:when>
  91.           <xsl:otherwise>
  92.             <div class="{name(.)}">
  93.               <p>
  94.                 <xsl:call-template name="number.rtf.lines">
  95.                   <xsl:with-param name="rtf" select="$rtf"/>
  96.                 </xsl:call-template>
  97.               </p>
  98.             </div>
  99.           </xsl:otherwise>
  100.         </xsl:choose>
  101.       </xsl:when>
  102.  
  103.       <xsl:otherwise>
  104.         <xsl:choose>
  105.           <xsl:when test="@class='monospaced'">
  106.             <pre class="{name(.)}">
  107.               <xsl:copy-of select="$rtf"/>
  108.             </pre>
  109.           </xsl:when>
  110.           <xsl:otherwise>
  111.             <div class="{name(.)}">
  112.               <p>
  113.                 <xsl:call-template name="make-verbatim">
  114.                   <xsl:with-param name="rtf" select="$rtf"/>
  115.                 </xsl:call-template>
  116.               </p>
  117.             </div>
  118.           </xsl:otherwise>
  119.         </xsl:choose>
  120.       </xsl:otherwise>
  121.     </xsl:choose>
  122.   </xsl:variable>
  123.  
  124.   <xsl:choose>
  125.     <xsl:when test="$shade.verbatim != 0 and @class='monospaced'">
  126.       <table xsl:use-attribute-sets="shade.verbatim.style">
  127.         <tr>
  128.           <td>
  129.             <xsl:copy-of select="$content"/>
  130.           </td>
  131.         </tr>
  132.       </table>
  133.     </xsl:when>
  134.     <xsl:otherwise>
  135.       <xsl:copy-of select="$content"/>
  136.     </xsl:otherwise>
  137.   </xsl:choose>
  138. </xsl:template>
  139.  
  140. <xsl:template match="address">
  141.   <xsl:param name="suppress-numbers" select="'0'"/>
  142.  
  143.   <xsl:variable name="rtf">
  144.     <xsl:apply-templates/>
  145.   </xsl:variable>
  146.  
  147.   <xsl:choose>
  148.     <xsl:when test="$suppress-numbers = '0'
  149.                     and @linenumbering = 'numbered'
  150.                     and $use.extensions != '0'
  151.                     and $linenumbering.extension != '0'">
  152.       <div class="{name(.)}">
  153.         <p>
  154.           <xsl:call-template name="number.rtf.lines">
  155.             <xsl:with-param name="rtf" select="$rtf"/>
  156.           </xsl:call-template>
  157.         </p>
  158.       </div>
  159.     </xsl:when>
  160.  
  161.     <xsl:otherwise>
  162.       <div class="{name(.)}">
  163.         <p>
  164.           <xsl:call-template name="make-verbatim">
  165.             <xsl:with-param name="rtf" select="$rtf"/>
  166.           </xsl:call-template>
  167.         </p>
  168.       </div>
  169.     </xsl:otherwise>
  170.   </xsl:choose>
  171. </xsl:template>
  172.  
  173. <xsl:template name="number.rtf.lines">
  174.   <xsl:param name="rtf" select="''"/>
  175.   <xsl:param name="pi.context" select="."/>
  176.  
  177.   <!-- Save the global values -->
  178.   <xsl:variable name="global.linenumbering.everyNth"
  179.                 select="$linenumbering.everyNth"/>
  180.  
  181.   <xsl:variable name="global.linenumbering.separator"
  182.                 select="$linenumbering.separator"/>
  183.  
  184.   <xsl:variable name="global.linenumbering.width"
  185.                 select="$linenumbering.width"/>
  186.  
  187.   <!-- Extract the <?dbhtml linenumbering.*?> PI values -->
  188.   <xsl:variable name="pi.linenumbering.everyNth">
  189.     <xsl:call-template name="dbhtml-attribute">
  190.       <xsl:with-param name="pis"
  191.                       select="$pi.context/processing-instruction('dbhtml')"/>
  192.       <xsl:with-param name="attribute" select="'linenumbering.everyNth'"/>
  193.     </xsl:call-template>
  194.   </xsl:variable>
  195.  
  196.   <xsl:variable name="pi.linenumbering.separator">
  197.     <xsl:call-template name="dbhtml-attribute">
  198.       <xsl:with-param name="pis"
  199.                       select="$pi.context/processing-instruction('dbhtml')"/>
  200.       <xsl:with-param name="attribute" select="'linenumbering.separator'"/>
  201.     </xsl:call-template>
  202.   </xsl:variable>
  203.  
  204.   <xsl:variable name="pi.linenumbering.width">
  205.     <xsl:call-template name="dbhtml-attribute">
  206.       <xsl:with-param name="pis"
  207.                       select="$pi.context/processing-instruction('dbhtml')"/>
  208.       <xsl:with-param name="attribute" select="'linenumbering.width'"/>
  209.     </xsl:call-template>
  210.   </xsl:variable>
  211.  
  212.   <!-- Construct the 'in-context' values -->
  213.   <xsl:variable name="linenumbering.everyNth">
  214.     <xsl:choose>
  215.       <xsl:when test="$pi.linenumbering.everyNth != ''">
  216.         <xsl:value-of select="$pi.linenumbering.everyNth"/>
  217.       </xsl:when>
  218.       <xsl:otherwise>
  219.         <xsl:value-of select="$global.linenumbering.everyNth"/>
  220.       </xsl:otherwise>
  221.     </xsl:choose>
  222.   </xsl:variable>
  223.  
  224.   <xsl:variable name="linenumbering.separator">
  225.     <xsl:choose>
  226.       <xsl:when test="$pi.linenumbering.separator != ''">
  227.         <xsl:value-of select="$pi.linenumbering.separator"/>
  228.       </xsl:when>
  229.       <xsl:otherwise>
  230.         <xsl:value-of select="$global.linenumbering.separator"/>
  231.       </xsl:otherwise>
  232.     </xsl:choose>
  233.   </xsl:variable>
  234.  
  235.   <xsl:variable name="linenumbering.width">
  236.     <xsl:choose>
  237.       <xsl:when test="$pi.linenumbering.width != ''">
  238.         <xsl:value-of select="$pi.linenumbering.width"/>
  239.       </xsl:when>
  240.       <xsl:otherwise>
  241.         <xsl:value-of select="$global.linenumbering.width"/>
  242.       </xsl:otherwise>
  243.     </xsl:choose>
  244.   </xsl:variable>
  245.  
  246.   <xsl:choose>
  247.     <xsl:when test="function-available('sverb:numberLines')">
  248.       <xsl:copy-of select="sverb:numberLines($rtf)"/>
  249.     </xsl:when>
  250.     <xsl:when test="function-available('xverb:numberLines')">
  251.       <xsl:copy-of select="xverb:numberLines($rtf)"/>
  252.     </xsl:when>
  253.     <xsl:otherwise>
  254.       <xsl:message terminate="yes">
  255.         <xsl:text>No numberLines function available.</xsl:text>
  256.       </xsl:message>
  257.     </xsl:otherwise>
  258.   </xsl:choose>
  259. </xsl:template>
  260.  
  261. <xsl:template name="make-verbatim">
  262.   <xsl:param name="rtf"/>
  263.  
  264.   <!-- I want to make this RTF verbatim. There are two possibilities: either
  265.        I have access to the exsl:node-set extension function and I can "do it right"
  266.        or I have to rely on CSS. -->
  267.  
  268.   <xsl:choose>
  269.     <xsl:when test="function-available('exsl:node-set')">
  270.       <xsl:apply-templates select="exsl:node-set($rtf)" mode="make.verbatim.mode"/>
  271.     </xsl:when>
  272.     <xsl:otherwise>
  273.       <span style="white-space: pre;">
  274.         <xsl:copy-of select="$rtf"/>
  275.       </span>
  276.     </xsl:otherwise>
  277.   </xsl:choose>
  278. </xsl:template>
  279.  
  280. </xsl:stylesheet>
  281.  
  282.  
  283.  
  284.  
  285.  
  286.