]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - docbook-xsl/patches/docbook-xsl-newmethods.patch
grep: Update to 3.0
[people/arne_f/ipfire-3.x.git] / docbook-xsl / patches / docbook-xsl-newmethods.patch
1 diff -ruNp docbook-xsl-1.74.0.orig/html/docbook.xsl docbook-xsl-1.74.0/html/docbook.xsl
2 --- docbook-xsl-1.74.0.orig/html/docbook.xsl 2008-06-01 23:36:39.000000000 +0200
3 +++ docbook-xsl-1.74.0/html/docbook.xsl 2008-08-06 13:37:35.000000000 +0200
4 @@ -26,6 +26,7 @@
5 <xsl:include href="../VERSION"/>
6 <xsl:include href="param.xsl"/>
7 <xsl:include href="../lib/lib.xsl"/>
8 +<xsl:include href="../lib/dumpfragment.xsl"/>
9 <xsl:include href="../common/l10n.xsl"/>
10 <xsl:include href="../common/common.xsl"/>
11 <xsl:include href="../common/utility.xsl"/>
12 @@ -44,6 +45,7 @@
13 <xsl:include href="graphics.xsl"/>
14 <xsl:include href="xref.xsl"/>
15 <xsl:include href="formal.xsl"/>
16 +<xsl:include href="dtbl.xsl"/>
17 <xsl:include href="table.xsl"/>
18 <xsl:include href="htmltbl.xsl"/>
19 <xsl:include href="sections.xsl"/>
20 diff -ruNp docbook-xsl-1.74.0.orig/html/dtbl.xsl docbook-xsl-1.74.0/html/dtbl.xsl
21 --- docbook-xsl-1.74.0.orig/html/dtbl.xsl 1970-01-01 01:00:00.000000000 +0100
22 +++ docbook-xsl-1.74.0/html/dtbl.xsl 2008-08-06 13:37:35.000000000 +0200
23 @@ -0,0 +1,293 @@
24 +<?xml version="1.0" encoding="US-ASCII"?>
25 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
26 + xmlns:exsl="http://exslt.org/common"
27 + xmlns:func="http://exslt.org/functions"
28 + xmlns:dtbl="http://docbook.sourceforge.net/dtbl"
29 + extension-element-prefixes="func"
30 + exclude-result-prefixes="exsl func dtbl"
31 + version="1.0">
32 +
33 +<func:function name="dtbl:convertLength">
34 + <xsl:param name="arbitrary.length"/>
35 +
36 + <xsl:variable name="pixels.per.inch" select="96"/>
37 +
38 + <xsl:variable name="unscaled.length"
39 + select="translate($arbitrary.length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ', '')"/>
40 +
41 + <xsl:variable name="units"
42 + select="translate($arbitrary.length,'+-0123456789. ', '')"/>
43 +
44 + <xsl:variable name="scaled.length">
45 + <xsl:choose>
46 + <xsl:when test="$units='in'">
47 + <xsl:value-of select="$unscaled.length * $pixels.per.inch"/>
48 + </xsl:when>
49 + <xsl:when test="$units='cm'">
50 + <xsl:value-of select="$unscaled.length * ($pixels.per.inch div 2.54)"/>
51 + </xsl:when>
52 + <xsl:when test="$units='mm'">
53 + <xsl:value-of select="$unscaled.length * ($pixels.per.inch div 25.4)"/>
54 + </xsl:when>
55 + <xsl:when test="$units='pc'">
56 + <xsl:value-of select="$unscaled.length * (($pixels.per.inch div 72) * 12)"/>
57 + </xsl:when>
58 + <xsl:when test="$units='pt'">
59 + <xsl:value-of select="$unscaled.length * ($pixels.per.inch div 72)"/>
60 + </xsl:when>
61 + <xsl:when test="$units='px' or $units=''">
62 + <xsl:value-of select="$unscaled.length"/>
63 + </xsl:when>
64 + <xsl:otherwise>
65 + <xsl:message terminate="no">
66 + <xsl:text>"</xsl:text>
67 + <xsl:value-of select="$units"/>
68 + <xsl:text>" is not a known unit. Applying scaling factor of 1 instead.</xsl:text>
69 + </xsl:message>
70 + <xsl:value-of select="$unscaled.length"/>
71 + </xsl:otherwise>
72 + </xsl:choose>
73 + </xsl:variable>
74 +
75 + <func:result select="round($scaled.length)"/>
76 +</func:function>
77 +
78 +<func:function name="dtbl:adjustColumnWidths">
79 + <xsl:param name="colgroup"/>
80 +
81 + <xsl:if test="$adjustColumnWidths.debug">
82 + <xsl:message>
83 + <xsl:text>entering adjustColumnWidths(</xsl:text>
84 + <xsl:call-template name="dump-fragment">
85 + <xsl:with-param name="fragment" select="$colgroup"/>
86 + </xsl:call-template>
87 + <xsl:text>)</xsl:text>
88 + </xsl:message>
89 + </xsl:if>
90 +
91 + <xsl:variable name="expanded.colgroup">
92 + <xsl:apply-templates select="exsl:node-set($colgroup)/*" mode="dtbl-split-widths"/>
93 + </xsl:variable>
94 +
95 + <xsl:variable name="absolute.widths.total">
96 + <xsl:value-of select="sum(exsl:node-set($expanded.colgroup)//col/@abswidth)"/>
97 + </xsl:variable>
98 +
99 + <xsl:variable name="relative.widths.total">
100 + <xsl:value-of select="sum(exsl:node-set($expanded.colgroup)//col/@relwidth)"/>
101 + </xsl:variable>
102 +
103 + <xsl:if test="$adjustColumnWidths.debug">
104 + <xsl:message>
105 + <xsl:text>total relative widths = (</xsl:text>
106 + <xsl:value-of select="$relative.widths.total"/>
107 + <xsl:text>)</xsl:text>
108 + </xsl:message>
109 + <xsl:message>
110 + <xsl:text>total absolute widths = (</xsl:text>
111 + <xsl:value-of select="$absolute.widths.total"/>
112 + <xsl:text>)</xsl:text>
113 + </xsl:message>
114 + </xsl:if>
115 +
116 + <xsl:variable name="adjusted.colgroup">
117 + <xsl:choose>
118 + <xsl:when test="$relative.widths.total = 0">
119 + <xsl:if test="$adjustColumnWidths.debug">
120 + <xsl:message>all widths are absolute</xsl:message>
121 + </xsl:if>
122 + <xsl:apply-templates select="exsl:node-set($expanded.colgroup)/*"
123 + mode="dtbl-use-absolute-widths"/>
124 + </xsl:when>
125 + <xsl:when test="$absolute.widths.total = 0">
126 + <xsl:if test="$adjustColumnWidths.debug">
127 + <xsl:message>all widths are relative</xsl:message>
128 + </xsl:if>
129 + <xsl:apply-templates select="exsl:node-set($expanded.colgroup)/*"
130 + mode="dtbl-use-relative-widths">
131 + <xsl:with-param name="relative.widths.total"
132 + select="$relative.widths.total"/>
133 + </xsl:apply-templates>
134 + </xsl:when>
135 + </xsl:choose>
136 + </xsl:variable>
137 +
138 + <xsl:variable name="corrected.adjusted.colgroup">
139 + <xsl:choose>
140 + <xsl:when test="$relative.widths.total = 0">
141 + <xsl:copy-of select="$adjusted.colgroup"/>
142 + </xsl:when>
143 + <xsl:otherwise>
144 + <xsl:variable name="widths.total"
145 + select="sum(exsl:node-set($adjusted.colgroup)//col/@width)"/>
146 + <xsl:variable name="n.columns"
147 + select="count(exsl:node-set($adjusted.colgroup)//col)"/>
148 + <xsl:variable name="error"
149 + select="100 - $widths.total"/>
150 + <xsl:variable name="first.bad.column"
151 + select="($n.columns - $error) + 1"/>
152 + <xsl:apply-templates select="exsl:node-set($adjusted.colgroup)/*"
153 + mode="dtbl-correct-rounding-error">
154 + <xsl:with-param name="first.bad.column"
155 + select="$first.bad.column"/>
156 + </xsl:apply-templates>
157 + </xsl:otherwise>
158 + </xsl:choose>
159 + </xsl:variable>
160 +
161 + <xsl:if test="$adjustColumnWidths.debug">
162 + <xsl:message>
163 + <xsl:text>result = (</xsl:text>
164 + <xsl:call-template name="dump-fragment">
165 + <xsl:with-param name="fragment" select="$corrected.adjusted.colgroup"/>
166 + </xsl:call-template>
167 + <xsl:text>)</xsl:text>
168 + </xsl:message>
169 + </xsl:if>
170 +
171 + <func:result select="$corrected.adjusted.colgroup"/>
172 +</func:function>
173 +
174 +<xsl:template match="colgroup" mode="dtbl-correct-rounding-error">
175 + <xsl:param name="first.bad.column"/>
176 +
177 + <xsl:if test="$adjustColumnWidths.debug">
178 + <xsl:message>
179 + <xsl:text>first.bad.column = (</xsl:text>
180 + <xsl:value-of select="$first.bad.column"/>
181 + <xsl:text>)</xsl:text>
182 + </xsl:message>
183 + </xsl:if>
184 +
185 + <colgroup>
186 + <xsl:for-each select="col[position() &lt; $first.bad.column]">
187 + <xsl:element name="col">
188 + <xsl:attribute name="width">
189 + <xsl:value-of select="concat(@width, '%')"/>
190 + </xsl:attribute>
191 + </xsl:element>
192 + </xsl:for-each>
193 + <xsl:for-each select="col[position() >= $first.bad.column]">
194 + <xsl:element name="col">
195 + <xsl:attribute name="width">
196 + <xsl:value-of select="concat(@width + 1, '%')"/>
197 + </xsl:attribute>
198 + </xsl:element>
199 + </xsl:for-each>
200 + </colgroup>
201 +</xsl:template>
202 +
203 +<xsl:template match="col" mode="dtbl-correct-rounding-error">
204 + <xsl:param name="relative.widths.total"/>
205 + <xsl:param name="error"/>
206 +
207 + <xsl:element name="col">
208 + <xsl:attribute name="width">
209 + <xsl:value-of select="concat('', round((@relwidth div $relative.widths.total) * 100))"/>
210 + </xsl:attribute>
211 + <xsl:apply-templates mode="dtbl-use-absolute-widths"/>
212 + </xsl:element>
213 +</xsl:template>
214 +
215 +<xsl:template match="colgroup" mode="dtbl-use-relative-widths">
216 + <xsl:param name="relative.widths.total"/>
217 +
218 + <colgroup>
219 + <xsl:apply-templates mode="dtbl-use-relative-widths">
220 + <xsl:with-param name="relative.widths.total"
221 + select="$relative.widths.total"/>
222 + </xsl:apply-templates>
223 + </colgroup>
224 +</xsl:template>
225 +
226 +<xsl:template match="col" mode="dtbl-use-relative-widths">
227 + <xsl:param name="relative.widths.total"/>
228 +
229 + <xsl:element name="col">
230 + <xsl:attribute name="width">
231 + <xsl:value-of select="round((@relwidth div $relative.widths.total) * 100)"/>
232 + </xsl:attribute>
233 + <xsl:apply-templates mode="dtbl-use-absolute-widths"/>
234 + </xsl:element>
235 +</xsl:template>
236 +
237 +<xsl:template match="colgroup" mode="dtbl-use-absolute-widths">
238 + <colgroup>
239 + <xsl:apply-templates mode="dtbl-use-absolute-widths"/>
240 + </colgroup>
241 +</xsl:template>
242 +
243 +<xsl:template match="col" mode="dtbl-use-absolute-widths">
244 + <xsl:element name="col">
245 + <xsl:attribute name="width">
246 + <xsl:value-of select="@abswidth"/>
247 + </xsl:attribute>
248 + <xsl:apply-templates mode="dtbl-use-absolute-widths"/>
249 + </xsl:element>
250 +</xsl:template>
251 +
252 +<xsl:template match="colgroup" mode="dtbl-split-widths">
253 + <colgroup>
254 + <xsl:apply-templates mode="dtbl-split-widths"/>
255 + </colgroup>
256 +</xsl:template>
257 +
258 +<xsl:template match="col" mode="dtbl-split-widths">
259 +
260 + <!-- width = @width ? @width : '1*' -->
261 + <xsl:variable name="width">
262 + <xsl:choose>
263 + <xsl:when test="@width != ''">
264 + <xsl:value-of select="@width"/>
265 + </xsl:when>
266 + <xsl:otherwise>
267 + <xsl:text>1*</xsl:text>
268 + </xsl:otherwise>
269 + </xsl:choose>
270 + </xsl:variable>
271 +
272 + <!-- absolute.width = contains($width,'*') ? substring-after($width, '*') : $width -->
273 + <xsl:variable name="absolute.width">
274 + <xsl:choose>
275 + <xsl:when test="contains($width, '*')">
276 + <xsl:value-of select="substring-after($width, '*')"/>
277 + </xsl:when>
278 + <xsl:otherwise>
279 + <xsl:value-of select="$width"/>
280 + </xsl:otherwise>
281 + </xsl:choose>
282 + </xsl:variable>
283 +
284 + <xsl:variable name="converted.absolute.width">
285 + <xsl:choose>
286 + <xsl:when test="$absolute.width != ''">
287 + <xsl:value-of select="dtbl:convertLength($absolute.width)"/>
288 + </xsl:when>
289 + <xsl:otherwise>0</xsl:otherwise>
290 + </xsl:choose>
291 + </xsl:variable>
292 +
293 + <xsl:variable name="relative.width">
294 + <xsl:choose>
295 + <xsl:when test="substring-before($width, '*') != ''">
296 + <xsl:value-of select="substring-before($width, '*')"/>
297 + </xsl:when>
298 + <xsl:otherwise>0</xsl:otherwise>
299 + </xsl:choose>
300 + </xsl:variable>
301 +
302 + <xsl:element name="col">
303 + <xsl:attribute name="width">
304 + <xsl:value-of select="$width"/>
305 + </xsl:attribute>
306 + <xsl:attribute name="relwidth">
307 + <xsl:value-of select="$relative.width"/>
308 + </xsl:attribute>
309 + <xsl:attribute name="abswidth">
310 + <xsl:value-of select="$converted.absolute.width"/>
311 + </xsl:attribute>
312 + <xsl:apply-templates mode="dtbl-split-widths"/>
313 + </xsl:element>
314 +</xsl:template>
315 +
316 +</xsl:stylesheet>
317 diff -ruNp docbook-xsl-1.74.0.orig/html/table.xsl docbook-xsl-1.74.0/html/table.xsl
318 --- docbook-xsl-1.74.0.orig/html/table.xsl 2008-06-01 23:36:39.000000000 +0200
319 +++ docbook-xsl-1.74.0/html/table.xsl 2008-08-06 13:37:35.000000000 +0200
320 @@ -5,7 +5,8 @@
321 xmlns:xtbl="xalan://com.nwalsh.xalan.Table"
322 xmlns:lxslt="http://xml.apache.org/xslt"
323 xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table"
324 - exclude-result-prefixes="doc stbl xtbl lxslt ptbl"
325 + xmlns:dtbl="http://docbook.sourceforge.net/dtbl"
326 + exclude-result-prefixes="doc stbl xtbl lxslt ptbl dtbl"
327 version='1.0'>
328
329 <xsl:include href="../common/table.xsl"/>
330 @@ -365,6 +366,9 @@
331 <xsl:when test="$use.extensions != 0
332 and $tablecolumns.extension != 0">
333 <xsl:choose>
334 + <xsl:when test="function-available('dtbl:convertLength')">
335 + <xsl:value-of select="dtbl:convertLength($table.width)"/>
336 + </xsl:when>
337 <xsl:when test="function-available('stbl:convertLength')">
338 <xsl:value-of select="stbl:convertLength($table.width)"/>
339 </xsl:when>
340 @@ -389,6 +393,9 @@
341 <xsl:when test="$use.extensions != 0
342 and $tablecolumns.extension != 0">
343 <xsl:choose>
344 + <xsl:when test="function-available('dtbl:adjustColumnWidths')">
345 + <xsl:copy-of select="dtbl:adjustColumnWidths($colgroup)"/>
346 + </xsl:when>
347 <xsl:when test="function-available('stbl:adjustColumnWidths')">
348 <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
349 </xsl:when>
350 diff -ruNp docbook-xsl-1.74.0.orig/lib/dumpfragment.xsl docbook-xsl-1.74.0/lib/dumpfragment.xsl
351 --- docbook-xsl-1.74.0.orig/lib/dumpfragment.xsl 1970-01-01 01:00:00.000000000 +0100
352 +++ docbook-xsl-1.74.0/lib/dumpfragment.xsl 2008-08-06 13:37:35.000000000 +0200
353 @@ -0,0 +1,30 @@
354 +<?xml version="1.0" encoding="US-ASCII"?>
355 +<xsl:stylesheet version="1.0"
356 + xmlns:exsl="http://exslt.org/common"
357 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
358 + xmlns="http://www.w3.org/1999/xhtml"
359 + exclude-result-prefixes="exsl">
360 +
361 +<xsl:template name="dump-fragment">
362 + <xsl:param name="fragment"/>
363 + <xsl:apply-templates select="exsl:node-set($fragment)/*" mode="dump-fragment"/>
364 +</xsl:template>
365 +
366 +<xsl:template match="@*" mode="dump-fragment">
367 + <xsl:text> </xsl:text>
368 + <xsl:value-of select="local-name(.)"/>
369 + <xsl:text>="</xsl:text>
370 + <xsl:value-of select="."/>
371 + <xsl:text>"</xsl:text>
372 +</xsl:template>
373 +
374 +<xsl:template match="*" mode="dump-fragment">
375 + <xsl:text>&lt;</xsl:text><xsl:value-of select="local-name(.)"/>
376 + <xsl:apply-templates select="@*" mode="dump-fragment"/>
377 + <xsl:text>></xsl:text>
378 + <xsl:apply-templates mode="dump-fragment"/>
379 + <xsl:text>&lt;/</xsl:text><xsl:value-of select="local-name(.)"/>
380 + <xsl:text>></xsl:text>
381 +</xsl:template>
382 +
383 +</xsl:stylesheet>
384 diff -urNp docbook-xsl-1.76.0-orig/html/param.xsl docbook-xsl-1.76.0/html/param.xsl
385 --- docbook-xsl-1.76.0-orig/html/param.xsl 2010-08-31 09:27:22.000000000 +0200
386 +++ docbook-xsl-1.76.0/html/param.xsl 2010-09-06 11:01:07.916914161 +0200
387 @@ -68,6 +68,7 @@ div.annotation-close { position: absolut
388 http://docbook.sourceforge.net/release/images/annot-close.png</xsl:param>
389 <xsl:param name="annotation.graphic.open">http://docbook.sourceforge.net/release/images/annot-open.png</xsl:param>
390
391 +<xsl:param name="adjustColumnWidths.debug" select="false()"/>
392 <xsl:param name="annotation.js">
393 <xsl:text>http://docbook.sourceforge.net/release/script/AnchorPosition.js http://docbook.sourceforge.net/release/script/PopupWindow.js</xsl:text></xsl:param>
394