source: clfs-embedded/BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/htmltbl.xsl@ 138fbc4

Last change on this file since 138fbc4 was 9882b55, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added the new lfs-xsl stylesheets.

  • Property mode set to 100644
File size: 7.4 KB
RevLine 
[9882b55]1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 version="1.0">
5
6<!-- ********************************************************************
7 $Id$
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
16<!-- ==================================================================== -->
17
18<xsl:attribute-set name="th.style">
19 <xsl:attribute name="font-weight">bold</xsl:attribute>
20</xsl:attribute-set>
21
22<!-- Outputs an fo:table only, not the caption -->
23<xsl:template match="table|informaltable" mode="htmlTable">
24
25 <xsl:variable name="numcols">
26 <xsl:call-template name="widest-html-row">
27 <xsl:with-param name="rows" select=".//tr"/>
28 </xsl:call-template>
29 </xsl:variable>
30
31 <xsl:variable name="prop-columns"
32 select=".//col[contains(@width, '%')] |
33 .//colgroup[contains(@width, '%')]"/>
34
35 <xsl:variable name="table.width">
36 <xsl:call-template name="table.width"/>
37 </xsl:variable>
38
39 <fo:table xsl:use-attribute-sets="table.table.properties">
40 <xsl:choose>
41 <xsl:when test="$fop.extensions != 0 or
42 $passivetex.extensions != 0">
43 <xsl:attribute name="table-layout">fixed</xsl:attribute>
44 </xsl:when>
45 </xsl:choose>
46 <xsl:attribute name="width">
47 <xsl:choose>
48 <xsl:when test="@width">
49 <xsl:value-of select="@width"/>
50 </xsl:when>
51 <xsl:when test="$table.width">
52 <xsl:value-of select="$table.width"/>
53 </xsl:when>
54 <xsl:otherwise>100%</xsl:otherwise>
55 </xsl:choose>
56 </xsl:attribute>
57 <xsl:call-template name="make-html-table-columns">
58 <xsl:with-param name="count" select="$numcols"/>
59 </xsl:call-template>
60 <xsl:apply-templates select="thead" mode="htmlTable"/>
61 <xsl:apply-templates select="tfoot" mode="htmlTable"/>
62 <xsl:choose>
63 <xsl:when test="tbody">
64 <xsl:apply-templates select="tbody" mode="htmlTable"/>
65 </xsl:when>
66 <xsl:otherwise>
67 <fo:table-body start-indent="0pt" end-indent="0pt">
68 <xsl:apply-templates select="tr" mode="htmlTable"/>
69 </fo:table-body>
70 </xsl:otherwise>
71 </xsl:choose>
72 </fo:table>
73
74</xsl:template>
75
76<xsl:template match="caption" mode="htmlTable">
77 <!-- Handled by formal.object.heading -->
78</xsl:template>
79
80<xsl:template name="widest-html-row">
81 <xsl:param name="rows" select="''"/>
82 <xsl:param name="count" select="0"/>
83 <xsl:choose>
84 <xsl:when test="count($rows) = 0">
85 <xsl:value-of select="$count"/>
86 </xsl:when>
87 <xsl:otherwise>
88 <xsl:choose>
89 <xsl:when test="$count &gt; count($rows[1]/*)">
90 <xsl:call-template name="widest-html-row">
91 <xsl:with-param name="rows" select="$rows[position() &gt; 1]"/>
92 <xsl:with-param name="count" select="$count"/>
93 </xsl:call-template>
94 </xsl:when>
95 <xsl:otherwise>
96 <xsl:call-template name="widest-html-row">
97 <xsl:with-param name="rows" select="$rows[position() &gt; 1]"/>
98 <xsl:with-param name="count" select="count($rows[1]/*)"/>
99 </xsl:call-template>
100 </xsl:otherwise>
101 </xsl:choose>
102 </xsl:otherwise>
103 </xsl:choose>
104</xsl:template>
105
106<xsl:template name="make-html-table-columns">
107 <xsl:param name="count" select="0"/>
108 <xsl:param name="number" select="1"/>
109
110 <xsl:choose>
111 <xsl:when test="col|colgroup/col">
112 <xsl:for-each select="col|colgroup/col">
113 <fo:table-column>
114 <xsl:attribute name="column-number">
115 <xsl:number from="table|informaltable" level="any" format="1"/>
116 </xsl:attribute>
117 <xsl:if test="@width">
118 <xsl:attribute name="column-width">
119 <xsl:choose>
120 <xsl:when test="$fop.extensions != 0 and
121 contains(@width, '%')">
122 <xsl:value-of select="concat('proportional-column-width(',
123 substring-before(@width, '%'),
124 ')')"/>
125 </xsl:when>
126 <xsl:otherwise>
127 <xsl:value-of select="@width"/>
128 </xsl:otherwise>
129 </xsl:choose>
130 </xsl:attribute>
131 </xsl:if>
132 </fo:table-column>
133 </xsl:for-each>
134 </xsl:when>
135 <xsl:when test="$fop.extensions != 0">
136 <xsl:if test="$number &lt;= $count">
137 <fo:table-column column-number="{$number}"
138 column-width="{6.5 div $count}in"/>
139 <xsl:call-template name="make-html-table-columns">
140 <xsl:with-param name="count" select="$count"/>
141 <xsl:with-param name="number" select="$number + 1"/>
142 </xsl:call-template>
143 </xsl:if>
144 </xsl:when>
145 </xsl:choose>
146</xsl:template>
147
148<xsl:template match="tbody" mode="htmlTable">
149 <fo:table-body border-bottom-width="0.25pt"
150 border-bottom-style="solid"
151 border-bottom-color="black"
152 start-indent="0pt"
153 end-indent="0pt">
154 <xsl:apply-templates mode="htmlTable"/>
155 </fo:table-body>
156</xsl:template>
157
158<xsl:template match="td" mode="htmlTable">
159 <xsl:variable name="bgcolor">
160 <xsl:call-template name="pi.dbfo_bgcolor"/>
161 </xsl:variable>
162 <fo:table-cell xsl:use-attribute-sets="table.cell.padding">
163 <xsl:call-template name="table.cell.properties">
164 <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
165 <xsl:with-param name="rowsep.inherit" select="0"/>
166 <xsl:with-param name="colsep.inherit" select="0"/>
167 </xsl:call-template>
168 <fo:block>
169 <xsl:call-template name="table.cell.block.properties"/>
170 <xsl:apply-templates/>
171 </fo:block>
172 </fo:table-cell>
173</xsl:template>
174
175<xsl:template match="tfoot" mode="htmlTable">
176 <fo:table-footer start-indent="0pt"
177 end-indent="0pt">
178 <xsl:apply-templates mode="htmlTable"/>
179 </fo:table-footer>
180</xsl:template>
181
182<xsl:template match="th" mode="htmlTable">
183 <xsl:variable name="bgcolor">
184 <xsl:call-template name="pi.dbfo_bgcolor"/>
185 </xsl:variable>
186 <fo:table-cell xsl:use-attribute-sets="th.style table.cell.padding">
187 <xsl:call-template name="table.cell.properties">
188 <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
189 <xsl:with-param name="rowsep.inherit" select="0"/>
190 <xsl:with-param name="colsep.inherit" select="0"/>
191 </xsl:call-template>
192 <fo:block>
193 <xsl:call-template name="table.cell.block.properties"/>
194 <xsl:apply-templates/>
195 </fo:block>
196 </fo:table-cell>
197</xsl:template>
198
199<xsl:template match="thead" mode="htmlTable">
200 <fo:table-header border-bottom-width="0.25pt"
201 border-bottom-style="solid"
202 border-bottom-color="black"
203 start-indent="0pt"
204 end-indent="0pt"
205 font-weight="bold">
206 <xsl:apply-templates mode="htmlTable"/>
207 </fo:table-header>
208</xsl:template>
209
210<xsl:template match="tr" mode="htmlTable">
211 <fo:table-row>
212 <xsl:call-template name="table.row.properties"/>
213 <xsl:apply-templates mode="htmlTable"/>
214 </fo:table-row>
215</xsl:template>
216
217</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.