1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim" xmlns:xverb="xalan://com.nwalsh.xalan.Verbatim" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="sverb xverb lxslt exsl" version="1.0">
6 <!-- ********************************************************************
7 $Id: verbatim.xsl 8807 2010-08-09 18:57:41Z bobstayton $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- XSLTHL highlighting is turned off by default. See highlighting/README
17 for instructions on how to turn on XSLTHL -->
18 <xsl:template name="apply-highlighting">
19 <xsl:apply-templates/>
22 <lxslt:component prefix="xverb" functions="numberLines"/>
24 <xsl:template match="programlisting|screen|synopsis">
25 <xsl:param name="suppress-numbers" select="'0'"/>
26 <xsl:variable name="id">
27 <xsl:call-template name="object.id"/>
30 <xsl:call-template name="anchor"/>
32 <xsl:variable name="div.element">
34 <xsl:when test="$make.clean.html != 0">div</xsl:when>
35 <xsl:otherwise>pre</xsl:otherwise>
39 <xsl:if test="$shade.verbatim != 0">
41 <xsl:text>The shade.verbatim parameter is deprecated. </xsl:text>
42 <xsl:text>Use CSS instead,</xsl:text>
45 <xsl:text>for example: pre.</xsl:text>
46 <xsl:value-of select="local-name(.)"/>
47 <xsl:text> { background-color: #E0E0E0; }</xsl:text>
52 <xsl:when test="$suppress-numbers = '0' and @linenumbering = 'numbered' and $use.extensions != '0' and $linenumbering.extension != '0'">
53 <xsl:variable name="rtf">
55 <xsl:when test="$highlight.source != 0">
56 <xsl:call-template name="apply-highlighting"/>
59 <xsl:apply-templates/>
63 <xsl:element name="{$div.element}" namespace="http://www.w3.org/1999/xhtml">
64 <xsl:apply-templates select="." mode="common.html.attributes"/>
65 <xsl:if test="@width != ''">
66 <xsl:attribute name="width">
67 <xsl:value-of select="@width"/>
70 <xsl:call-template name="number.rtf.lines">
71 <xsl:with-param name="rtf" select="$rtf"/>
76 <xsl:element name="{$div.element}" namespace="http://www.w3.org/1999/xhtml">
77 <xsl:apply-templates select="." mode="common.html.attributes"/>
78 <xsl:if test="@width != ''">
79 <xsl:attribute name="width">
80 <xsl:value-of select="@width"/>
84 <xsl:when test="$highlight.source != 0">
85 <xsl:call-template name="apply-highlighting"/>
88 <xsl:apply-templates/>
96 <xsl:template match="literallayout">
97 <xsl:param name="suppress-numbers" select="'0'"/>
99 <xsl:variable name="rtf">
100 <xsl:apply-templates/>
103 <xsl:if test="$shade.verbatim != 0 and @class='monospaced'">
105 <xsl:text>The shade.verbatim parameter is deprecated. </xsl:text>
106 <xsl:text>Use CSS instead,</xsl:text>
109 <xsl:text>for example: pre.</xsl:text>
110 <xsl:value-of select="local-name(.)"/>
111 <xsl:text> { background-color: #E0E0E0; }</xsl:text>
116 <xsl:when test="$suppress-numbers = '0' and @linenumbering = 'numbered' and $use.extensions != '0' and $linenumbering.extension != '0'">
118 <xsl:when test="@class='monospaced'">
120 <xsl:apply-templates select="." mode="common.html.attributes"/>
121 <xsl:call-template name="number.rtf.lines">
122 <xsl:with-param name="rtf" select="$rtf"/>
128 <xsl:apply-templates select="." mode="common.html.attributes"/>
130 <xsl:call-template name="number.rtf.lines">
131 <xsl:with-param name="rtf" select="$rtf"/>
140 <xsl:when test="@class='monospaced'">
142 <xsl:apply-templates select="." mode="common.html.attributes"/>
143 <xsl:copy-of select="$rtf"/>
148 <xsl:apply-templates select="." mode="common.html.attributes"/>
150 <xsl:call-template name="make-verbatim">
151 <xsl:with-param name="rtf" select="$rtf"/>
161 <xsl:template match="address">
162 <xsl:param name="suppress-numbers" select="'0'"/>
164 <xsl:variable name="rtf">
165 <xsl:apply-templates/>
169 <xsl:when test="$suppress-numbers = '0' and @linenumbering = 'numbered' and $use.extensions != '0' and $linenumbering.extension != '0'">
171 <xsl:apply-templates select="." mode="common.html.attributes"/>
173 <xsl:call-template name="number.rtf.lines">
174 <xsl:with-param name="rtf" select="$rtf"/>
182 <xsl:apply-templates select="." mode="common.html.attributes"/>
184 <xsl:call-template name="make-verbatim">
185 <xsl:with-param name="rtf" select="$rtf"/>
193 <xsl:template name="number.rtf.lines">
194 <xsl:param name="rtf" select="''"/>
195 <xsl:param name="pi.context" select="."/>
197 <!-- Save the global values -->
198 <xsl:variable name="global.linenumbering.everyNth" select="$linenumbering.everyNth"/>
200 <xsl:variable name="global.linenumbering.separator" select="$linenumbering.separator"/>
202 <xsl:variable name="global.linenumbering.width" select="$linenumbering.width"/>
204 <!-- Extract the <?dbhtml linenumbering.*?> PI values -->
205 <xsl:variable name="pi.linenumbering.everyNth">
206 <xsl:call-template name="pi.dbhtml_linenumbering.everyNth">
207 <xsl:with-param name="node" select="$pi.context"/>
211 <xsl:variable name="pi.linenumbering.separator">
212 <xsl:call-template name="pi.dbhtml_linenumbering.separator">
213 <xsl:with-param name="node" select="$pi.context"/>
217 <xsl:variable name="pi.linenumbering.width">
218 <xsl:call-template name="pi.dbhtml_linenumbering.width">
219 <xsl:with-param name="node" select="$pi.context"/>
223 <!-- Construct the 'in-context' values -->
224 <xsl:variable name="linenumbering.everyNth">
226 <xsl:when test="$pi.linenumbering.everyNth != ''">
227 <xsl:value-of select="$pi.linenumbering.everyNth"/>
230 <xsl:value-of select="$global.linenumbering.everyNth"/>
235 <xsl:variable name="linenumbering.separator">
237 <xsl:when test="$pi.linenumbering.separator != ''">
238 <xsl:value-of select="$pi.linenumbering.separator"/>
241 <xsl:value-of select="$global.linenumbering.separator"/>
246 <xsl:variable name="linenumbering.width">
248 <xsl:when test="$pi.linenumbering.width != ''">
249 <xsl:value-of select="$pi.linenumbering.width"/>
252 <xsl:value-of select="$global.linenumbering.width"/>
257 <xsl:variable name="linenumbering.startinglinenumber">
259 <xsl:when test="$pi.context/@startinglinenumber">
260 <xsl:value-of select="$pi.context/@startinglinenumber"/>
262 <xsl:when test="$pi.context/@continuation='continues'">
263 <xsl:variable name="lastLine">
265 <xsl:when test="$pi.context/self::programlisting">
266 <xsl:call-template name="lastLineNumber">
267 <xsl:with-param name="listings" select="preceding::programlisting[@linenumbering='numbered']"/>
270 <xsl:when test="$pi.context/self::screen">
271 <xsl:call-template name="lastLineNumber">
272 <xsl:with-param name="listings" select="preceding::screen[@linenumbering='numbered']"/>
275 <xsl:when test="$pi.context/self::literallayout">
276 <xsl:call-template name="lastLineNumber">
277 <xsl:with-param name="listings" select="preceding::literallayout[@linenumbering='numbered']"/>
280 <xsl:when test="$pi.context/self::address">
281 <xsl:call-template name="lastLineNumber">
282 <xsl:with-param name="listings" select="preceding::address[@linenumbering='numbered']"/>
285 <xsl:when test="$pi.context/self::synopsis">
286 <xsl:call-template name="lastLineNumber">
287 <xsl:with-param name="listings" select="preceding::synopsis[@linenumbering='numbered']"/>
292 <xsl:text>Unexpected verbatim environment: </xsl:text>
293 <xsl:value-of select="local-name($pi.context)"/>
295 <xsl:value-of select="0"/>
300 <xsl:value-of select="$lastLine + 1"/>
302 <xsl:otherwise>1</xsl:otherwise>
307 <xsl:when test="function-available('sverb:numberLines')">
308 <xsl:copy-of select="sverb:numberLines($rtf)"/>
310 <xsl:when test="function-available('xverb:numberLines')">
311 <xsl:copy-of select="xverb:numberLines($rtf)"/>
314 <xsl:message terminate="yes">
315 <xsl:text>No numberLines function available.</xsl:text>
321 <xsl:template name="make-verbatim">
322 <xsl:param name="rtf"/>
324 <!-- I want to make this RTF verbatim. There are two possibilities: either
325 I have access to the exsl:node-set extension function and I can "do it right"
326 or I have to rely on CSS. -->
329 <xsl:when test="$exsl.node.set.available != 0">
330 <xsl:apply-templates select="exsl:node-set($rtf)" mode="make.verbatim.mode"/>
333 <span style="white-space: pre;">
334 <xsl:copy-of select="$rtf"/>
340 <!-- ======================================================================== -->
342 <xsl:template name="lastLineNumber">
343 <xsl:param name="listings"/>
344 <xsl:param name="number" select="0"/>
346 <xsl:variable name="lines">
347 <xsl:call-template name="countLines">
348 <xsl:with-param name="listing" select="string($listings[1])"/>
353 <xsl:when test="not($listings)">
354 <xsl:value-of select="$number"/>
356 <xsl:when test="$listings[1]/@startinglinenumber">
357 <xsl:value-of select="$number + $listings[1]/@startinglinenumber + $lines - 1"/>
359 <xsl:when test="$listings[1]/@continuation='continues'">
360 <xsl:call-template name="lastLineNumber">
361 <xsl:with-param name="listings" select="listings[position() > 1]"/>
362 <xsl:with-param name="number" select="$number + $lines"/>
366 <xsl:value-of select="$lines"/>
371 <xsl:template name="countLines">
372 <xsl:param name="listing"/>
373 <xsl:param name="count" select="1"/>
376 <xsl:when test="contains($listing, ' ')">
377 <xsl:call-template name="countLines">
378 <xsl:with-param name="listing" select="substring-after($listing, ' ')"/>
379 <xsl:with-param name="count" select="$count + 1"/>
383 <xsl:value-of select="$count"/>