source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/xhtml/verbatim.xsl@ 15c7d39

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 15c7d39 was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 13.8 KB
RevLine 
[c873d807]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">
5
6<!-- ********************************************************************
[15c7d39]7 $Id: verbatim.xsl 9589 2012-09-02 20:52:15Z tom_schr $
[c873d807]8 ********************************************************************
9
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.
13
14 ******************************************************************** -->
15
[15c7d39]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/>
20</xsl:template>
[c873d807]21
22<lxslt:component prefix="xverb" functions="numberLines"/>
23
24<xsl:template match="programlisting|screen|synopsis">
25 <xsl:param name="suppress-numbers" select="'0'"/>
26
27 <xsl:call-template name="anchor"/>
28
[15c7d39]29 <xsl:variable name="div.element">pre</xsl:variable>
30
[c873d807]31 <xsl:if test="$shade.verbatim != 0">
32 <xsl:message>
33 <xsl:text>The shade.verbatim parameter is deprecated. </xsl:text>
34 <xsl:text>Use CSS instead,</xsl:text>
35 </xsl:message>
36 <xsl:message>
37 <xsl:text>for example: pre.</xsl:text>
38 <xsl:value-of select="local-name(.)"/>
39 <xsl:text> { background-color: #E0E0E0; }</xsl:text>
40 </xsl:message>
41 </xsl:if>
42
43 <xsl:choose>
[15c7d39]44 <xsl:when test="$suppress-numbers = '0' and @linenumbering = 'numbered' and $use.extensions != '0' and $linenumbering.extension != '0'">
[c873d807]45 <xsl:variable name="rtf">
[15c7d39]46 <xsl:choose>
47 <xsl:when test="$highlight.source != 0">
48 <xsl:call-template name="apply-highlighting"/>
49 </xsl:when>
50 <xsl:otherwise>
51 <xsl:apply-templates/>
52 </xsl:otherwise>
53 </xsl:choose>
[c873d807]54 </xsl:variable>
[15c7d39]55 <xsl:element name="{$div.element}" namespace="http://www.w3.org/1999/xhtml">
56 <xsl:apply-templates select="." mode="common.html.attributes"/>
57 <xsl:call-template name="id.attribute"/>
58 <xsl:if test="@width != ''">
59 <xsl:attribute name="width">
60 <xsl:value-of select="@width"/>
61 </xsl:attribute>
62 </xsl:if>
63 <xsl:call-template name="number.rtf.lines">
64 <xsl:with-param name="rtf" select="$rtf"/>
65 </xsl:call-template>
66 </xsl:element>
[c873d807]67 </xsl:when>
68 <xsl:otherwise>
[15c7d39]69 <xsl:element name="{$div.element}" namespace="http://www.w3.org/1999/xhtml">
70 <xsl:apply-templates select="." mode="common.html.attributes"/>
71 <xsl:call-template name="id.attribute"/>
72 <xsl:if test="@width != ''">
73 <xsl:attribute name="width">
74 <xsl:value-of select="@width"/>
75 </xsl:attribute>
76 </xsl:if>
77 <xsl:choose>
78 <xsl:when test="$highlight.source != 0">
79 <xsl:call-template name="apply-highlighting"/>
80 </xsl:when>
81 <xsl:otherwise>
82 <xsl:apply-templates/>
83 </xsl:otherwise>
84 </xsl:choose>
85 </xsl:element>
[c873d807]86 </xsl:otherwise>
87 </xsl:choose>
88</xsl:template>
89
90<xsl:template match="literallayout">
91 <xsl:param name="suppress-numbers" select="'0'"/>
92
93 <xsl:variable name="rtf">
94 <xsl:apply-templates/>
95 </xsl:variable>
96
97 <xsl:if test="$shade.verbatim != 0 and @class='monospaced'">
98 <xsl:message>
99 <xsl:text>The shade.verbatim parameter is deprecated. </xsl:text>
100 <xsl:text>Use CSS instead,</xsl:text>
101 </xsl:message>
102 <xsl:message>
103 <xsl:text>for example: pre.</xsl:text>
104 <xsl:value-of select="local-name(.)"/>
105 <xsl:text> { background-color: #E0E0E0; }</xsl:text>
106 </xsl:message>
107 </xsl:if>
108
109 <xsl:choose>
[15c7d39]110 <xsl:when test="$suppress-numbers = '0' and @linenumbering = 'numbered' and $use.extensions != '0' and $linenumbering.extension != '0'">
[c873d807]111 <xsl:choose>
[15c7d39]112 <xsl:when test="@class='monospaced'">
[c873d807]113 <pre>
[15c7d39]114 <xsl:apply-templates select="." mode="common.html.attributes"/>
115 <xsl:call-template name="id.attribute"/>
116 <xsl:call-template name="number.rtf.lines">
117 <xsl:with-param name="rtf" select="$rtf"/>
118 </xsl:call-template>
119 </pre>
120 </xsl:when>
121 <xsl:otherwise>
[c873d807]122 <div>
[15c7d39]123 <xsl:apply-templates select="." mode="common.html.attributes"/>
124 <xsl:call-template name="id.attribute"/>
125 <p>
126 <xsl:call-template name="number.rtf.lines">
127 <xsl:with-param name="rtf" select="$rtf"/>
128 </xsl:call-template>
129 </p>
130 </div>
131 </xsl:otherwise>
[c873d807]132 </xsl:choose>
133 </xsl:when>
134 <xsl:otherwise>
135 <xsl:choose>
[15c7d39]136 <xsl:when test="@class='monospaced'">
[c873d807]137 <pre>
[15c7d39]138 <xsl:apply-templates select="." mode="common.html.attributes"/>
139 <xsl:call-template name="id.attribute"/>
140 <xsl:copy-of select="$rtf"/>
141 </pre>
142 </xsl:when>
143 <xsl:otherwise>
[c873d807]144 <div>
[15c7d39]145 <xsl:apply-templates select="." mode="common.html.attributes"/>
146 <xsl:call-template name="id.attribute"/>
147 <p>
148 <xsl:call-template name="make-verbatim">
149 <xsl:with-param name="rtf" select="$rtf"/>
150 </xsl:call-template>
151 </p>
152 </div>
153 </xsl:otherwise>
[c873d807]154 </xsl:choose>
155 </xsl:otherwise>
156 </xsl:choose>
157</xsl:template>
158
159<xsl:template match="address">
160 <xsl:param name="suppress-numbers" select="'0'"/>
161
162 <xsl:variable name="rtf">
163 <xsl:apply-templates/>
164 </xsl:variable>
165
166 <xsl:choose>
167 <xsl:when test="$suppress-numbers = '0' and @linenumbering = 'numbered' and $use.extensions != '0' and $linenumbering.extension != '0'">
168 <div>
[15c7d39]169 <xsl:apply-templates select="." mode="common.html.attributes"/>
170 <xsl:call-template name="id.attribute"/>
[c873d807]171 <p>
172 <xsl:call-template name="number.rtf.lines">
173 <xsl:with-param name="rtf" select="$rtf"/>
174 </xsl:call-template>
175 </p>
176 </div>
177 </xsl:when>
178
179 <xsl:otherwise>
180 <div>
[15c7d39]181 <xsl:apply-templates select="." mode="common.html.attributes"/>
182 <xsl:call-template name="id.attribute"/>
[c873d807]183 <p>
184 <xsl:call-template name="make-verbatim">
185 <xsl:with-param name="rtf" select="$rtf"/>
186 </xsl:call-template>
187 </p>
188 </div>
189 </xsl:otherwise>
190 </xsl:choose>
191</xsl:template>
192
193<xsl:template name="number.rtf.lines">
194 <xsl:param name="rtf" select="''"/>
195 <xsl:param name="pi.context" select="."/>
196
197 <!-- Save the global values -->
198 <xsl:variable name="global.linenumbering.everyNth" select="$linenumbering.everyNth"/>
199
200 <xsl:variable name="global.linenumbering.separator" select="$linenumbering.separator"/>
201
202 <xsl:variable name="global.linenumbering.width" select="$linenumbering.width"/>
203
204 <!-- Extract the <?dbhtml linenumbering.*?> PI values -->
205 <xsl:variable name="pi.linenumbering.everyNth">
[60a5a938]206 <xsl:call-template name="pi.dbhtml_linenumbering.everyNth">
207 <xsl:with-param name="node" select="$pi.context"/>
[c873d807]208 </xsl:call-template>
209 </xsl:variable>
210
211 <xsl:variable name="pi.linenumbering.separator">
[60a5a938]212 <xsl:call-template name="pi.dbhtml_linenumbering.separator">
213 <xsl:with-param name="node" select="$pi.context"/>
[c873d807]214 </xsl:call-template>
215 </xsl:variable>
216
217 <xsl:variable name="pi.linenumbering.width">
[60a5a938]218 <xsl:call-template name="pi.dbhtml_linenumbering.width">
219 <xsl:with-param name="node" select="$pi.context"/>
[c873d807]220 </xsl:call-template>
221 </xsl:variable>
222
223 <!-- Construct the 'in-context' values -->
224 <xsl:variable name="linenumbering.everyNth">
225 <xsl:choose>
226 <xsl:when test="$pi.linenumbering.everyNth != ''">
227 <xsl:value-of select="$pi.linenumbering.everyNth"/>
228 </xsl:when>
229 <xsl:otherwise>
230 <xsl:value-of select="$global.linenumbering.everyNth"/>
231 </xsl:otherwise>
232 </xsl:choose>
233 </xsl:variable>
234
235 <xsl:variable name="linenumbering.separator">
236 <xsl:choose>
237 <xsl:when test="$pi.linenumbering.separator != ''">
238 <xsl:value-of select="$pi.linenumbering.separator"/>
239 </xsl:when>
240 <xsl:otherwise>
241 <xsl:value-of select="$global.linenumbering.separator"/>
242 </xsl:otherwise>
243 </xsl:choose>
244 </xsl:variable>
245
246 <xsl:variable name="linenumbering.width">
247 <xsl:choose>
248 <xsl:when test="$pi.linenumbering.width != ''">
249 <xsl:value-of select="$pi.linenumbering.width"/>
250 </xsl:when>
251 <xsl:otherwise>
252 <xsl:value-of select="$global.linenumbering.width"/>
253 </xsl:otherwise>
254 </xsl:choose>
255 </xsl:variable>
256
257 <xsl:variable name="linenumbering.startinglinenumber">
258 <xsl:choose>
259 <xsl:when test="$pi.context/@startinglinenumber">
260 <xsl:value-of select="$pi.context/@startinglinenumber"/>
261 </xsl:when>
262 <xsl:when test="$pi.context/@continuation='continues'">
263 <xsl:variable name="lastLine">
264 <xsl:choose>
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']"/>
268 </xsl:call-template>
269 </xsl:when>
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']"/>
273 </xsl:call-template>
274 </xsl:when>
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']"/>
278 </xsl:call-template>
279 </xsl:when>
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']"/>
283 </xsl:call-template>
284 </xsl:when>
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']"/>
288 </xsl:call-template>
289 </xsl:when>
290 <xsl:otherwise>
291 <xsl:message>
292 <xsl:text>Unexpected verbatim environment: </xsl:text>
293 <xsl:value-of select="local-name($pi.context)"/>
294 </xsl:message>
295 <xsl:value-of select="0"/>
296 </xsl:otherwise>
297 </xsl:choose>
298 </xsl:variable>
299
300 <xsl:value-of select="$lastLine + 1"/>
301 </xsl:when>
302 <xsl:otherwise>1</xsl:otherwise>
303 </xsl:choose>
304 </xsl:variable>
305
306 <xsl:choose>
307 <xsl:when test="function-available('sverb:numberLines')">
308 <xsl:copy-of select="sverb:numberLines($rtf)"/>
309 </xsl:when>
310 <xsl:when test="function-available('xverb:numberLines')">
311 <xsl:copy-of select="xverb:numberLines($rtf)"/>
312 </xsl:when>
313 <xsl:otherwise>
314 <xsl:message terminate="yes">
315 <xsl:text>No numberLines function available.</xsl:text>
316 </xsl:message>
317 </xsl:otherwise>
318 </xsl:choose>
319</xsl:template>
320
321<xsl:template name="make-verbatim">
322 <xsl:param name="rtf"/>
323
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. -->
327
328 <xsl:choose>
[15c7d39]329 <xsl:when test="$exsl.node.set.available != 0">
[c873d807]330 <xsl:apply-templates select="exsl:node-set($rtf)" mode="make.verbatim.mode"/>
331 </xsl:when>
332 <xsl:otherwise>
333 <span style="white-space: pre;">
334 <xsl:copy-of select="$rtf"/>
335 </span>
336 </xsl:otherwise>
337 </xsl:choose>
338</xsl:template>
339
340<!-- ======================================================================== -->
341
342<xsl:template name="lastLineNumber">
343 <xsl:param name="listings"/>
344 <xsl:param name="number" select="0"/>
345
346 <xsl:variable name="lines">
347 <xsl:call-template name="countLines">
348 <xsl:with-param name="listing" select="string($listings[1])"/>
349 </xsl:call-template>
350 </xsl:variable>
351
352 <xsl:choose>
353 <xsl:when test="not($listings)">
354 <xsl:value-of select="$number"/>
355 </xsl:when>
356 <xsl:when test="$listings[1]/@startinglinenumber">
357 <xsl:value-of select="$number + $listings[1]/@startinglinenumber + $lines - 1"/>
358 </xsl:when>
359 <xsl:when test="$listings[1]/@continuation='continues'">
360 <xsl:call-template name="lastLineNumber">
[15c7d39]361 <xsl:with-param name="listings" select="$listings[position() &gt; 1]"/>
[c873d807]362 <xsl:with-param name="number" select="$number + $lines"/>
363 </xsl:call-template>
364 </xsl:when>
365 <xsl:otherwise>
366 <xsl:value-of select="$lines"/>
367 </xsl:otherwise>
368 </xsl:choose>
369</xsl:template>
370
371<xsl:template name="countLines">
372 <xsl:param name="listing"/>
373 <xsl:param name="count" select="1"/>
374
375 <xsl:choose>
376 <xsl:when test="contains($listing, '&#10;')">
377 <xsl:call-template name="countLines">
378 <xsl:with-param name="listing" select="substring-after($listing, '&#10;')"/>
379 <xsl:with-param name="count" select="$count + 1"/>
380 </xsl:call-template>
381 </xsl:when>
382 <xsl:otherwise>
383 <xsl:value-of select="$count"/>
384 </xsl:otherwise>
385 </xsl:choose>
386</xsl:template>
387
388</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.