1 <?xml version = "1.0" encoding = "utf-8"?>
3 Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
10 <xsl:stylesheet version = "1.0"
11 xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
14 <!-- needed for calsTable template -->
17 href="http://docbook.sourceforge.net/release/xsl/current/html/formal.xsl"/>
19 <!-- Optionally add the section id to each section's class.
20 This is useful if you want to style individual sections differently. -->
21 <xsl:param name="boost.section.class.add.id" select="0"/>
24 Override the behaviour of some DocBook elements for better
25 integration with the new look & feel.
28 <xsl:template match = "programlisting[ancestor::informaltable]">
29 <pre class = "table-{name(.)}"><xsl:apply-templates/></pre>
32 <xsl:template match = "refsynopsisdiv">
33 <h2 class = "{name(.)}-title">Synopsis</h2>
34 <div class = "{name(.)}"><xsl:apply-templates/></div>
37 <!-- table: remove border = '1' -->
39 <xsl:template match = "table|informaltable">
41 <xsl:when test = "self::table and tgroup|mediaobject|graphic">
43 </xsl:when><xsl:when test = "self::informaltable and tgroup|mediaobject|graphic">
44 <xsl:call-template name = "informal.object">
45 <xsl:with-param name = "class"><xsl:choose>
46 <xsl:when test = "@tabstyle">
47 <xsl:value-of select = "@tabstyle"/>
48 </xsl:when><xsl:otherwise>
49 <xsl:value-of select = "local-name(.)"/>
51 </xsl:choose></xsl:with-param>
53 </xsl:when><xsl:otherwise>
54 <table class = "table"><xsl:copy-of select = "@*[not(local-name(.)='border')]"/>
55 <xsl:call-template name = "htmlTable"/>
61 <xsl:template match = "tgroup" name = "tgroup">
62 <xsl:variable name="summary"><xsl:call-template name="dbhtml-attribute">
63 <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
64 <xsl:with-param name="attribute" select="'table-summary'"/>
65 </xsl:call-template></xsl:variable>
67 <xsl:variable name="cellspacing"><xsl:call-template name="dbhtml-attribute">
68 <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
69 <xsl:with-param name="attribute" select="'cellspacing'"/>
70 </xsl:call-template></xsl:variable>
72 <xsl:variable name="cellpadding"><xsl:call-template name="dbhtml-attribute">
73 <xsl:with-param name="pis" select="processing-instruction('dbhtml')[1]"/>
74 <xsl:with-param name="attribute" select="'cellpadding'"/>
75 </xsl:call-template></xsl:variable>
77 <table class = "table">
79 <xsl:when test="../textobject/phrase">
80 <xsl:attribute name="summary">
81 <xsl:value-of select="../textobject/phrase"/>
83 </xsl:when><xsl:when test="$summary != ''">
84 <xsl:attribute name="summary">
85 <xsl:value-of select="$summary"/>
87 </xsl:when><xsl:when test="../title">
88 <xsl:attribute name="summary">
89 <xsl:value-of select="string(../title)"/>
93 </xsl:choose><xsl:if test="$cellspacing != '' or $html.cellspacing != ''">
94 <xsl:attribute name="cellspacing"><xsl:choose>
95 <xsl:when test="$cellspacing != ''"><xsl:value-of select="$cellspacing"/></xsl:when>
96 <xsl:otherwise><xsl:value-of select="$html.cellspacing"/></xsl:otherwise>
97 </xsl:choose></xsl:attribute>
98 </xsl:if><xsl:if test="$cellpadding != '' or $html.cellpadding != ''">
99 <xsl:attribute name="cellpadding"><xsl:choose>
100 <xsl:when test="$cellpadding != ''"><xsl:value-of select="$cellpadding"/></xsl:when>
101 <xsl:otherwise><xsl:value-of select="$html.cellpadding"/></xsl:otherwise>
102 </xsl:choose></xsl:attribute>
103 </xsl:if><xsl:if test="../@pgwide=1">
104 <xsl:attribute name="width">100%</xsl:attribute>
107 <xsl:variable name="colgroup">
108 <colgroup><xsl:call-template name="generate.colgroup">
109 <xsl:with-param name="cols" select="@cols"/>
110 </xsl:call-template></colgroup>
113 <xsl:variable name="explicit.table.width"><xsl:call-template name="dbhtml-attribute">
114 <xsl:with-param name="pis" select="../processing-instruction('dbhtml')[1]"/>
115 <xsl:with-param name="attribute" select="'table-width'"/>
116 </xsl:call-template></xsl:variable>
118 <xsl:variable name="table.width"><xsl:choose>
119 <xsl:when test="$explicit.table.width != ''">
120 <xsl:value-of select="$explicit.table.width"/>
121 </xsl:when><xsl:when test="$default.table.width = ''">
122 <xsl:text>100%</xsl:text>
123 </xsl:when><xsl:otherwise>
124 <xsl:value-of select="$default.table.width"/>
126 </xsl:choose></xsl:variable>
128 <xsl:if test="$default.table.width != '' or $explicit.table.width != ''">
129 <xsl:attribute name="width"><xsl:choose>
130 <xsl:when test="contains($table.width, '%')">
131 <xsl:value-of select="$table.width"/>
132 </xsl:when><xsl:when test="$use.extensions != 0 and $tablecolumns.extension != 0">
134 <xsl:when test="function-available('stbl:convertLength')">
135 <xsl:value-of select="stbl:convertLength($table.width)"/>
136 </xsl:when><xsl:when test="function-available('xtbl:convertLength')">
137 <xsl:value-of select="xtbl:convertLength($table.width)"/>
138 </xsl:when><xsl:otherwise>
139 <xsl:message terminate="yes">
140 <xsl:text>No convertLength function available.</xsl:text>
144 </xsl:when><xsl:otherwise>
145 <xsl:value-of select="$table.width"/>
147 </xsl:choose></xsl:attribute>
151 <xsl:when test="$use.extensions != 0 and $tablecolumns.extension != 0">
153 <xsl:when test="function-available('stbl:adjustColumnWidths')">
154 <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
155 </xsl:when><xsl:when test="function-available('xtbl:adjustColumnWidths')">
156 <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
157 </xsl:when><xsl:when test="function-available('ptbl:adjustColumnWidths')">
158 <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>
159 </xsl:when><xsl:otherwise>
160 <xsl:message terminate="yes">
161 <xsl:text>No adjustColumnWidths function available.</xsl:text>
165 </xsl:when><xsl:otherwise>
166 <xsl:copy-of select="$colgroup"/>
170 <xsl:apply-templates select="thead"/>
171 <xsl:apply-templates select="tfoot"/>
172 <xsl:apply-templates select="tbody"/>
174 <xsl:if test=".//footnote"><tbody class="footnotes">
175 <tr><td colspan="{@cols}">
176 <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
182 <!-- table of contents
184 The standard Docbook template selects, amoung others,
185 the 'refentry' element for inclusion in TOC. In some
186 cases, this creates empty TOC. The most possible reason
187 is that there's 'refentry' element without 'refentrytitle',
188 but it's a mistery why it occurs. Even if we fix that
189 problem, we'll get non-empty TOC where no TOC is desired
190 (e.g. for section corresponding to each header file in
191 library doc). So, don't bother for now.
194 <xsl:template name="section.toc">
195 <xsl:param name="toc-context" select="."/>
196 <xsl:param name="toc.title.p" select="true()"/>
198 <xsl:call-template name="make.toc">
199 <xsl:with-param name="toc-context" select="$toc-context"/>
200 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
201 <xsl:with-param name="nodes" select="
202 section|sect1|sect2|sect3|sect4|sect5|
203 bridgehead[$bridgehead.in.toc != 0]
208 <!-- When there is both a title and a caption for a table, only use the
210 <xsl:template match="table" mode="title.markup">
211 <xsl:param name="allow-anchors" select="0"/>
212 <xsl:apply-templates select="(title|caption)[1]" mode="title.markup">
213 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
214 </xsl:apply-templates>
218 <!-- Adds role class for section element resulting div. So that
219 we can style them in the resulting HTML.
220 Also, add the section id, if boost.section.class.add.id = 1.
221 This can be used to style individual sections differently. -->
222 <xsl:template match="section" mode="class.value">
223 <xsl:param name="class" select="local-name(.)"/>
224 <xsl:param name="node" select="."/>
225 <xsl:variable name="id">
226 <xsl:if test="$boost.section.class.add.id">
227 <xsl:call-template name="object.id">
228 <xsl:with-param name="object" select="$node"/>
232 <xsl:value-of select="normalize-space(concat($class, ' ',
233 @role, ' ', translate($id, '.', '_')))"/>
236 <!-- Adds role class for simplesect element resulting div. So that
237 we can style them in the resulting HTML. -->
238 <xsl:template match="simplesect" mode="class.value">
239 <xsl:param name="class" select="local-name(.)"/>
240 <xsl:param name="node" select="."/>
241 <xsl:value-of select="normalize-space(concat($class,' ',@role))"/>
244 <!-- Allow for specifying that a section should not include the parents
245 labeling. This allows us to start clean numering of a sub-section. -->
246 <xsl:template match="section[@label-style='no-parent']" mode="label.markup">
248 <xsl:when test="@label">
249 <xsl:value-of select="@label"/>
251 <xsl:when test="$label != 0">
252 <xsl:variable name="format">
253 <xsl:call-template name="autolabel.format">
254 <xsl:with-param name="format" select="$section.autolabel"/>
257 <xsl:number format="{$format}" count="section"/>