VirtualBox

source: vbox/trunk/src/libs/dita-ot-1.8.5/plugins/legacypdf/xslfo/dita2fo-calstable.xsl@ 99507

最後變更 在這個檔案從99507是 98584,由 vboxsync 提交於 2 年 前

Docs: bugref:10302. Setting svn properties of DITA-OT library.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 17.2 KB
 
1<?xml version='1.0'?>
2<!-- This file is part of the DITA Open Toolkit project hosted on
3 Sourceforge.net. See the accompanying license.txt file for
4 applicable licenses.-->
5<!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
6
7<!DOCTYPE xsl:transform [
8<!-- entities for use in the generated output (must produce correctly in FO) -->
9 <!ENTITY rbl "&#160;">
10]>
11<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12 xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
13 <!-- CALS (OASIS) TABLE -->
14 <!-- adapted from sample code in the XSL FO spec; extended considerably! -->
15 <!-- table formatting properties -->
16 <xsl:attribute-set name="table.data">
17 <!-- use for overall table default characteristics -->
18 <xsl:attribute name="table-layout">fixed</xsl:attribute>
19 <xsl:attribute name="width">100%</xsl:attribute>
20 <!--xsl:attribute name="inline-progression-dimension">auto</xsl:attribute-->
21 <xsl:attribute name="space-before">10pt</xsl:attribute>
22 <xsl:attribute name="space-after">10pt</xsl:attribute>
23 <xsl:attribute name="background-color">white</xsl:attribute>
24 <!--xsl:attribute name="start-indent">inherit</xsl:attribute-->
25 </xsl:attribute-set>
26 <xsl:attribute-set name="table.data.caption">
27 <xsl:attribute name="start-indent">inherit</xsl:attribute>
28 <xsl:attribute name="font-weight">bold</xsl:attribute>
29 </xsl:attribute-set>
30 <xsl:attribute-set name="table.data.tbody">
31 <xsl:attribute name="background-color">white</xsl:attribute>
32 </xsl:attribute-set>
33 <xsl:attribute-set name="table.data.th">
34 <xsl:attribute name="color">black</xsl:attribute>
35 <!--xsl:attribute name="background-color">silver</xsl:attribute-->
36 <xsl:attribute name="padding">2pt</xsl:attribute>
37 <xsl:attribute name="text-align">center</xsl:attribute>
38 <xsl:attribute name="font-weight">bold</xsl:attribute>
39 </xsl:attribute-set>
40 <xsl:attribute-set name="table.data.tf">
41 <xsl:attribute name="color">blue</xsl:attribute>
42 <xsl:attribute name="padding">2pt</xsl:attribute>
43 </xsl:attribute-set>
44 <xsl:attribute-set name="table.data.td">
45 <!--xsl:attribute name="background-color">grey</xsl:attribute-->
46 <xsl:attribute name="padding">2pt</xsl:attribute>
47 </xsl:attribute-set>
48 <xsl:template
49 match="*[contains(@class,' topic/table ')]/*[contains(@class,' topic/xtitle ')]" priority="2"/>
50 <xsl:template match="*[contains(@class,' topic/table ')]">
51 <fo:block>
52 <xsl:if test="@id">
53 <xsl:apply-templates select="@id"/>
54 </xsl:if>
55 <xsl:apply-templates/>
56 </fo:block>
57 </xsl:template>
58 <xsl:template name="default-colwidth">
59 <!--fo:table-column column-width="150pt"/-->
60 <xsl:for-each select="row[1]/entry">
61 <fo:table-column>
62 <!-- compute even columns (creates valid processing, but all columns are even width) -->
63 <xsl:attribute name="column-width">
64 <xsl:value-of select="floor(@width div 72)"/>in</xsl:attribute>
65 </fo:table-column>
66 </xsl:for-each>
67 </xsl:template>
68 <xsl:template match="*[contains(@class,' topic/spanspec ')]">
69 <!-- <xsl:call-template name="att-align"/> -->
70 </xsl:template>
71 <xsl:template match="*[contains(@class,' topic/colspec ')]">
72 <fo:table-column>
73 <xsl:call-template name="att-align"/>
74 <xsl:attribute name="column-number">
75 <xsl:number count="colspec"/>
76 </xsl:attribute>
77 <xsl:attribute name="column-width">
78 <xsl:call-template name="xcalc.column.width">
79 <xsl:with-param name="colwidth">
80 <xsl:value-of select="@colwidth"/>
81 </xsl:with-param>
82 </xsl:call-template>
83 </xsl:attribute>
84 </fo:table-column>
85 </xsl:template>
86 <xsl:template match="*[contains(@class,' topic/tgroup ')]">
87 <!--
88 <xsl:call-template name="att-align"/>
89-->
90 <xsl:choose>
91 <xsl:when test="xtitle">
92 <!-- renamed for now to NOT trigger on title; testing the "otherwise" code -->
93 <fo:table-and-caption xsl:use-attribute-sets="table.data frameall">
94 <fo:table-caption>
95 <fo:block xsl:use-attribute-sets="table.data.caption">
96 <xsl:value-of select="title"/>
97 </fo:block>
98 </fo:table-caption>
99 <fo:table xsl:use-attribute-sets="table.data frameall" space-before="12pt">
100 <xsl:if test="string(@id)">
101 <xsl:attribute name="id">
102 <xsl:value-of select="@id"/>
103 </xsl:attribute>
104 </xsl:if>
105 <xsl:apply-templates/>
106 </fo:table>
107 </fo:table-and-caption>
108 </xsl:when>
109 <xsl:otherwise>
110 <fo:table xsl:use-attribute-sets="table.data frameall" space-before="12pt">
111 <!--xsl:if test="string(@id)"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute></xsl:if-->
112 <xsl:call-template name="default-colwidth"/>
113 <xsl:apply-templates/>
114 </fo:table>
115 </xsl:otherwise>
116 </xsl:choose>
117 </xsl:template>
118 <xsl:template match="*[contains(@class,' topic/thead ')]">
119 <fo:table-header>
120 <xsl:call-template name="att-valign"/>
121 <xsl:apply-templates/>
122 </fo:table-header>
123 </xsl:template>
124 <xsl:template match="*[contains(@class,' topic/tfoot ')]">
125 <fo:table-footer>
126 <xsl:call-template name="att-valign"/>
127 <xsl:apply-templates/>
128 </fo:table-footer>
129 </xsl:template>
130 <xsl:template match="*[contains(@class,' topic/tbody ')]">
131 <fo:table-body>
132 <xsl:call-template name="att-valign"/>
133 <xsl:apply-templates/>
134 </fo:table-body>
135 </xsl:template>
136 <xsl:template match="*[contains(@class,' topic/tnote ')]">
137 <fo:table-row>
138 <fo:table-cell start-indent="2pt" background-color="#E0E0F0" xsl:use-attribute-sets="table.data.td">
139 <fo:block>
140 <fo:inline font-weight="bold">
141 <xsl:call-template name="getString">
142 <xsl:with-param name="stringName" select="'Note'"/>
143 </xsl:call-template>
144 <xsl:text>: </xsl:text>
145 </fo:inline>
146 <xsl:apply-templates/>
147 </fo:block>
148 </fo:table-cell>
149 </fo:table-row>
150 </xsl:template>
151 <xsl:template match="*[contains(@class,' topic/row ')]">
152 <fo:table-row>
153 <xsl:call-template name="att-valign"/>
154 <xsl:apply-templates/>
155 </fo:table-row>
156 </xsl:template>
157 <xsl:template match="*[contains(@class,' topic/thead ')]/*[contains(@class,' topic/row ')]/*[contains(@class,' topic/entry ')]">
158 <xsl:variable name="colnumval">
159 <xsl:choose>
160 <xsl:when test="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum">
161 <xsl:value-of select="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum"/>
162 </xsl:when>
163 <xsl:when test="@colnum">
164 <xsl:value-of select="@colnum"/>
165 </xsl:when>
166 <xsl:otherwise>
167 <xsl:number count="entry"/>
168 </xsl:otherwise>
169 </xsl:choose>
170 </xsl:variable>
171 <fo:table-cell column-number="{$colnumval}" start-indent="2pt"
172 background-color="silver" padding="2pt" text-align="center"
173 font-weight="bold" xsl:use-attribute-sets="frameall">
174 <!-- xsl:use-attribute-sets="table.data.th"-->
175 <xsl:call-template name="entryatts"/>
176 <fo:block>
177 <xsl:call-template name="fillit"/>
178 </fo:block>
179 </fo:table-cell>
180 </xsl:template>
181 <xsl:template match="*[contains(@class,' topic/tfoot ')]/*[contains(@class,' topic/row ')]/*[contains(@class,' topic/entry ')]">
182 <xsl:variable name="colnumval">
183 <xsl:choose>
184 <xsl:when test="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum">
185 <xsl:value-of select="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum"/>
186 </xsl:when>
187 <xsl:when test="@colnum">
188 <xsl:value-of select="@colnum"/>
189 </xsl:when>
190 <xsl:otherwise>
191 <xsl:number count="entry"/>
192 </xsl:otherwise>
193 </xsl:choose>
194 </xsl:variable>
195 <fo:table-cell start-indent="2pt" column-number="{$colnumval}" xsl:use-attribute-sets="table.data.tf frameall">
196 <xsl:call-template name="entryatts"/>
197 <fo:block>
198 <xsl:call-template name="fillit"/>
199 </fo:block>
200 </fo:table-cell>
201 </xsl:template>
202 <xsl:template name="get-colnumval">
203 <xsl:variable name="colnumval">
204 <xsl:choose>
205 <xsl:when test="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum">
206 <xsl:value-of select="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum"/>
207 </xsl:when>
208 <xsl:when test="@colnum">
209 <xsl:value-of select="@colnum"/>
210 </xsl:when>
211 <xsl:otherwise>
212 <xsl:number count="entry"/>
213 </xsl:otherwise>
214 </xsl:choose>
215 </xsl:variable>
216 </xsl:template>
217 <xsl:template match="*[contains(@class,' topic/tbody ')]/*[contains(@class,' topic/row ')]/*[contains(@class,' topic/entry ')]">
218 <xsl:variable name="colnumval">
219 <xsl:choose>
220 <xsl:when test="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum">
221 <xsl:value-of select="ancestor::tgroup/colspec[@colname=current()/@colname]/@colnum"/>
222 </xsl:when>
223 <xsl:when test="@colnum">
224 <xsl:value-of select="@colnum"/>
225 </xsl:when>
226 <xsl:otherwise>
227 <xsl:number count="entry"/>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:variable>
231 <fo:table-cell column-number="{$colnumval}" start-indent="2pt"
232 background-color="#faf4fa" padding="2pt" xsl:use-attribute-sets="frameall">
233 <xsl:call-template name="entryatts"/>
234 <fo:block>
235 <xsl:call-template name="fillit"/>
236 </fo:block>
237 </fo:table-cell>
238 </xsl:template>
239 <!-- named templates -->
240 <xsl:template name="fillit">
241 <xsl:choose>
242 <!-- test to see if the cell contains any sensible text or other element... -->
243 <xsl:when test="not(text()[normalize-space(.)] | *)">
244 <fo:inline>&rbl;</fo:inline>
245 </xsl:when>
246 <xsl:otherwise>
247 <xsl:apply-templates/>
248 </xsl:otherwise>
249 </xsl:choose>
250 </xsl:template>
251 <!-- table "macros" -->
252 <xsl:template name="entryatts">
253 <xsl:call-template name="att-valign"/>
254 <xsl:call-template name="att-align"/>
255 <!-- SF 1553905: remove invalid cellpadding attribute -->
256 <!--
257 <xsl:if test="string(@colsep)">
258 <xsl:if test="@colsep='1'">
259 <xsl:attribute name="cellpadding">10</xsl:attribute>
260 </xsl:if>
261 </xsl:if>
262 -->
263 <!-- IPL start -->
264 <xsl:if test="string(@namest)">
265 <xsl:variable name="colst" select="substring-after(@namest,'col')"/>
266 <xsl:variable name="colend" select="substring-after(@nameend,'col')"/>
267 <xsl:attribute name="number-columns-spanned">
268 <xsl:value-of select="$colend - $colst + 1"/>
269 </xsl:attribute>
270 </xsl:if>
271 <!-- IPL end -->
272 <xsl:if test="@morerows">
273 <xsl:attribute name="number-rows-spanned">
274 <xsl:value-of select="@morerows+1"/>
275 </xsl:attribute>
276 </xsl:if>
277 </xsl:template>
278 <xsl:template name="att-valign">
279 <xsl:if test="string(@valign)">
280 <xsl:choose>
281 <xsl:when test="@valign='middle'">
282 <xsl:attribute name="display-align">center</xsl:attribute>
283 </xsl:when>
284 <xsl:when test="@valign='top'">
285 <xsl:attribute name="display-align">before</xsl:attribute>
286 </xsl:when>
287 <xsl:when test="@valign='bottom'">
288 <xsl:attribute name="display-align">after</xsl:attribute>
289 </xsl:when>
290 <xsl:otherwise>
291 <xsl:attribute name="display-align">
292 <xsl:value-of select="@valign"/>
293 </xsl:attribute>
294 </xsl:otherwise>
295 </xsl:choose>
296 </xsl:if>
297 </xsl:template>
298 <xsl:template name="att-align">
299 <xsl:if test="string(@align)">
300 <xsl:attribute name="text-align">
301 <xsl:value-of select="normalize-space(@align)"/>
302 </xsl:attribute>
303 </xsl:if>
304 </xsl:template>
305 <!-- table support based on examples in the XSL spec -->
306 <!-- see original support comments in the XSL spec, source of this fragment -->
307 <xsl:template name="calc.column.width">
308 <xsl:param name="colwidth">1*</xsl:param>
309 <!-- Ok, the colwidth could have any one of the following forms: -->
310 <!-- 1* = proportional width -->
311 <!-- 1unit = 1.0 units wide -->
312 <!-- 1 = 1pt wide -->
313 <!-- 1*+1unit = proportional width + some fixed width -->
314 <!-- 1*+1 = proportional width + some fixed width -->
315 <!-- If it has a proportional width, translate it to XSL -->
316 <xsl:if test="contains($colwidth, '*')">
317 <!-- modified to handle "*" as input -->
318 <xsl:variable name="colfactor">
319 <xsl:value-of select="substring-before($colwidth, '*')"/>
320 </xsl:variable>
321 <xsl:text>proportional-column-width(</xsl:text>
322 <xsl:choose>
323 <xsl:when test="not($colfactor = '')">
324 <xsl:value-of select="$colfactor"/>
325 </xsl:when>
326 <xsl:otherwise>1</xsl:otherwise>
327 </xsl:choose>
328 <xsl:text>)</xsl:text>
329 </xsl:if>
330 <!-- Now get the non-proportional part of the specification -->
331 <xsl:variable name="width-units">
332 <xsl:choose>
333 <xsl:when test="contains($colwidth, '*')">
334 <xsl:value-of select="normalize-space(substring-after($colwidth, '*'))"/>
335 </xsl:when>
336 <xsl:otherwise>
337 <xsl:value-of select="normalize-space($colwidth)"/>
338 </xsl:otherwise>
339 </xsl:choose>
340 </xsl:variable>
341 <!-- Now the width-units could have any one of the following forms: -->
342 <!-- = <empty string> -->
343 <!-- 1unit = 1.0 units wide -->
344 <!-- 1 = 1pt wide -->
345 <!-- with an optional leading sign -->
346 <!-- Get the width part by blanking out the units part and discarding -->
347 <!-- white space. -->
348 <xsl:variable name="width" select="normalize-space(translate($width-units, '+-0123456789.abcdefghijklmnopqrstuvwxyz', '+-0123456789.'))"/>
349 <!-- Get the units part by blanking out the width part and discarding -->
350 <!-- white space. -->
351 <xsl:variable name="units" select="normalize-space(translate($width-units, 'abcdefghijklmnopqrstuvwxyz+-0123456789.', 'abcdefghijklmnopqrstuvwxyz'))"/>
352 <!-- Output the width -->
353 <xsl:value-of select="$width"/>
354 <!-- Output the units, translated appropriately -->
355 <xsl:choose>
356 <xsl:when test="$units = 'pi'">pc</xsl:when>
357 <xsl:when test="$units = '' and $width != ''">pt</xsl:when>
358 <xsl:otherwise>
359 <xsl:value-of select="$units"/>
360 </xsl:otherwise>
361 </xsl:choose>
362 </xsl:template>
363 <xsl:template name="xcalc.column.width">
364 <!-- see original support comments in the XSL spec, source of this fragment -->
365 <xsl:param name="colwidth">1*</xsl:param>
366 <!-- Ok, the colwidth could have any one of the following forms: -->
367 <!-- 1* = proportional width -->
368 <!-- 1unit = 1.0 units wide -->
369 <!-- 1 = 1pt wide -->
370 <!-- 1*+1unit = proportional width + some fixed width -->
371 <!-- 1*+1 = proportional width + some fixed width -->
372 <!-- If it has a proportional width, translate it to XSL -->
373 <xsl:if test="contains($colwidth, '*')">
374 <xsl:variable name="colfactor">
375 <xsl:value-of select="substring-before($colwidth, '*')"/>
376 </xsl:variable>
377 <xsl:text>proportional-column-width(</xsl:text>
378 <xsl:choose>
379 <xsl:when test="not($colfactor = '')">
380 <xsl:value-of select="$colfactor"/>
381 </xsl:when>
382 <xsl:otherwise>1</xsl:otherwise>
383 </xsl:choose>
384 <xsl:text>)</xsl:text>
385 </xsl:if>
386 <!-- Now get the non-proportional part of the specification -->
387 <xsl:variable name="width-units">
388 <xsl:choose>
389 <xsl:when test="contains($colwidth, '*')">
390 <xsl:value-of select="normalize-space(substring-after($colwidth, '*'))"/>
391 </xsl:when>
392 <xsl:otherwise>
393 <xsl:value-of select="normalize-space($colwidth)"/>
394 </xsl:otherwise>
395 </xsl:choose>
396 </xsl:variable>
397 <!-- Now the width-units could have any one of the following forms: -->
398 <!-- = <empty string> -->
399 <!-- 1unit = 1.0 units wide -->
400 <!-- 1 = 1pt wide -->
401 <!-- with an optional leading sign -->
402 <!-- Get the width part by blanking out the units part and discarding -->
403 <!-- whitespace. -->
404 <xsl:variable name="width" select="normalize-space(translate($width-units, '+-0123456789.abcdefghijklmnopqrstuvwxyz', '+-0123456789.'))"/>
405 <!-- Get the units part by blanking out the width part and discarding -->
406 <!-- whitespace. -->
407 <xsl:variable name="units" select="normalize-space(translate($width-units, 'abcdefghijklmnopqrstuvwxyz+-0123456789.', 'abcdefghijklmnopqrstuvwxyz'))"/>
408 <!-- Output the width -->
409 <xsl:value-of select="$width"/>
410 <!-- Output the units, translated appropriately -->
411 <xsl:choose>
412 <xsl:when test="$units = 'pi'">pc</xsl:when>
413 <xsl:when test="$units = '' and $width != ''">pt</xsl:when>
414 <xsl:otherwise>
415 <xsl:value-of select="$units"/>
416 </xsl:otherwise>
417 </xsl:choose>
418 </xsl:template>
419 <!-- end of table section -->
420</xsl:stylesheet>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette