1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version='1.0'> 4 5<!-- ******************************************************************** 6 $Id: component.xsl,v 1.27 2005/10/28 12:35:15 nwalsh Exp $ 7 ******************************************************************** 8 9 This file is part of the XSL DocBook Stylesheet distribution. 10 See /README or http://nwalsh.com/docbook/xsl/ for copyright 11 and other information. 12 13 ******************************************************************** --> 14 15<!-- ==================================================================== --> 16 17<xsl:template name="component.title"> 18 <xsl:param name="node" select="."/> 19 20 <xsl:variable name="level"> 21 <xsl:choose> 22 <xsl:when test="ancestor::section"> 23 <xsl:value-of select="count(ancestor::section)+1"/> 24 </xsl:when> 25 <xsl:when test="ancestor::sect5">6</xsl:when> 26 <xsl:when test="ancestor::sect4">5</xsl:when> 27 <xsl:when test="ancestor::sect3">4</xsl:when> 28 <xsl:when test="ancestor::sect2">3</xsl:when> 29 <xsl:when test="ancestor::sect1">2</xsl:when> 30 <xsl:otherwise>1</xsl:otherwise> 31 </xsl:choose> 32 </xsl:variable> 33 34 <!-- Let's handle the case where a component (bibliography, for example) 35 occurs inside a section; will we need parameters for this? --> 36 37 <xsl:element name="h{$level+1}"> 38 <xsl:attribute name="class">title</xsl:attribute> 39 <xsl:call-template name="anchor"> 40 <xsl:with-param name="node" select="$node"/> 41 <xsl:with-param name="conditional" select="0"/> 42 </xsl:call-template> 43 <xsl:apply-templates select="$node" mode="object.title.markup"> 44 <xsl:with-param name="allow-anchors" select="1"/> 45 </xsl:apply-templates> 46 </xsl:element> 47</xsl:template> 48 49<xsl:template name="component.subtitle"> 50 <xsl:param name="node" select="."/> 51 <xsl:variable name="subtitle" 52 select="($node/docinfo/subtitle 53 |$node/info/subtitle 54 |$node/prefaceinfo/subtitle 55 |$node/chapterinfo/subtitle 56 |$node/appendixinfo/subtitle 57 |$node/articleinfo/subtitle 58 |$node/artheader/subtitle 59 |$node/subtitle)[1]"/> 60 61 <xsl:if test="$subtitle"> 62 <h3 class="subtitle"> 63 <i> 64 <xsl:apply-templates select="$node" mode="object.subtitle.markup"/> 65 </i> 66 </h3> 67 </xsl:if> 68</xsl:template> 69 70<xsl:template name="component.separator"> 71</xsl:template> 72 73<!-- ==================================================================== --> 74 75<xsl:template match="dedication" mode="dedication"> 76 <xsl:call-template name="id.warning"/> 77 78 <div class="{name(.)}"> 79 <xsl:call-template name="dir"> 80 <xsl:with-param name="inherit" select="1"/> 81 </xsl:call-template> 82 <xsl:call-template name="language.attribute"/> 83 <xsl:call-template name="dedication.titlepage"/> 84 <xsl:apply-templates/> 85 <xsl:call-template name="process.footnotes"/> 86 </div> 87</xsl:template> 88 89<xsl:template match="dedication/title" mode="titlepage.mode" priority="2"> 90 <xsl:call-template name="component.title"> 91 <xsl:with-param name="node" select="ancestor::dedication[1]"/> 92 </xsl:call-template> 93</xsl:template> 94 95<xsl:template match="dedication/subtitle" mode="titlepage.mode" priority="2"> 96 <xsl:call-template name="component.subtitle"> 97 <xsl:with-param name="node" select="ancestor::dedication[1]"/> 98 </xsl:call-template> 99</xsl:template> 100 101<xsl:template match="dedication"></xsl:template> <!-- see mode="dedication" --> 102<xsl:template match="dedication/title"></xsl:template> 103<xsl:template match="dedication/subtitle"></xsl:template> 104<xsl:template match="dedication/titleabbrev"></xsl:template> 105 106<!-- ==================================================================== --> 107 108<xsl:template match="colophon"> 109 <xsl:call-template name="id.warning"/> 110 111 <div class="{name(.)}"> 112 <xsl:call-template name="dir"> 113 <xsl:with-param name="inherit" select="1"/> 114 </xsl:call-template> 115 <xsl:call-template name="language.attribute"/> 116 <xsl:if test="$generate.id.attributes != 0"> 117 <xsl:attribute name="id"> 118 <xsl:call-template name="object.id"/> 119 </xsl:attribute> 120 </xsl:if> 121 122 <xsl:call-template name="component.separator"/> 123 <xsl:call-template name="component.title"/> 124 <xsl:call-template name="component.subtitle"/> 125 126 <xsl:apply-templates/> 127 <xsl:call-template name="process.footnotes"/> 128 </div> 129</xsl:template> 130 131<xsl:template match="colophon/title"></xsl:template> 132<xsl:template match="colophon/subtitle"></xsl:template> 133<xsl:template match="colophon/titleabbrev"></xsl:template> 134 135<!-- ==================================================================== --> 136 137<xsl:template match="preface"> 138 <xsl:call-template name="id.warning"/> 139 140 <div class="{name(.)}"> 141 <xsl:call-template name="dir"> 142 <xsl:with-param name="inherit" select="1"/> 143 </xsl:call-template> 144 <xsl:call-template name="language.attribute"/> 145 <xsl:if test="$generate.id.attributes != 0"> 146 <xsl:attribute name="id"> 147 <xsl:call-template name="object.id"/> 148 </xsl:attribute> 149 </xsl:if> 150 151 <xsl:call-template name="component.separator"/> 152 <xsl:call-template name="preface.titlepage"/> 153 154 <xsl:variable name="toc.params"> 155 <xsl:call-template name="find.path.params"> 156 <xsl:with-param name="table" select="normalize-space($generate.toc)"/> 157 </xsl:call-template> 158 </xsl:variable> 159 160 <xsl:if test="contains($toc.params, 'toc')"> 161 <xsl:call-template name="component.toc"> 162 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/> 163 </xsl:call-template> 164 <xsl:call-template name="component.toc.separator"/> 165 </xsl:if> 166 <xsl:apply-templates/> 167 <xsl:call-template name="process.footnotes"/> 168 </div> 169</xsl:template> 170 171<xsl:template match="preface/title" mode="titlepage.mode" priority="2"> 172 <xsl:call-template name="component.title"> 173 <xsl:with-param name="node" select="ancestor::preface[1]"/> 174 </xsl:call-template> 175</xsl:template> 176 177<xsl:template match="preface/subtitle 178 |preface/prefaceinfo/subtitle 179 |preface/info/subtitle 180 |preface/docinfo/subtitle" 181 mode="titlepage.mode" priority="2"> 182 <xsl:call-template name="component.subtitle"> 183 <xsl:with-param name="node" select="ancestor::preface[1]"/> 184 </xsl:call-template> 185</xsl:template> 186 187<xsl:template match="preface/docinfo|prefaceinfo"></xsl:template> 188<xsl:template match="preface/title"></xsl:template> 189<xsl:template match="preface/titleabbrev"></xsl:template> 190<xsl:template match="preface/subtitle"></xsl:template> 191 192<!-- ==================================================================== --> 193 194<xsl:template match="chapter"> 195 <xsl:call-template name="id.warning"/> 196 197 <div class="{name(.)}"> 198 <xsl:call-template name="dir"> 199 <xsl:with-param name="inherit" select="1"/> 200 </xsl:call-template> 201 <xsl:call-template name="language.attribute"/> 202 <xsl:if test="$generate.id.attributes != 0"> 203 <xsl:attribute name="id"> 204 <xsl:call-template name="object.id"/> 205 </xsl:attribute> 206 </xsl:if> 207 208 <xsl:call-template name="component.separator"/> 209 <xsl:call-template name="chapter.titlepage"/> 210 211 <xsl:variable name="toc.params"> 212 <xsl:call-template name="find.path.params"> 213 <xsl:with-param name="table" select="normalize-space($generate.toc)"/> 214 </xsl:call-template> 215 </xsl:variable> 216 <xsl:if test="contains($toc.params, 'toc')"> 217 <xsl:call-template name="component.toc"> 218 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/> 219 </xsl:call-template> 220 <xsl:call-template name="component.toc.separator"/> 221 </xsl:if> 222 <xsl:apply-templates/> 223 <xsl:call-template name="process.footnotes"/> 224 </div> 225</xsl:template> 226 227<xsl:template match="chapter/title" mode="titlepage.mode" priority="2"> 228 <xsl:call-template name="component.title"> 229 <xsl:with-param name="node" select="ancestor::chapter[1]"/> 230 </xsl:call-template> 231</xsl:template> 232 233<xsl:template match="chapter/subtitle 234 |chapter/chapterinfo/subtitle 235 |chapter/info/subtitle 236 |chapter/docinfo/subtitle" 237 mode="titlepage.mode" priority="2"> 238 <xsl:call-template name="component.subtitle"> 239 <xsl:with-param name="node" select="ancestor::chapter[1]"/> 240 </xsl:call-template> 241</xsl:template> 242 243<xsl:template match="chapter/docinfo|chapterinfo"></xsl:template> 244<xsl:template match="chapter/title"></xsl:template> 245<xsl:template match="chapter/titleabbrev"></xsl:template> 246<xsl:template match="chapter/subtitle"></xsl:template> 247 248<!-- ==================================================================== --> 249 250<xsl:template match="appendix"> 251 <xsl:variable name="ischunk"> 252 <xsl:call-template name="chunk"/> 253 </xsl:variable> 254 255 <xsl:call-template name="id.warning"/> 256 257 <div class="{name(.)}"> 258 <xsl:call-template name="dir"> 259 <xsl:with-param name="inherit" select="1"/> 260 </xsl:call-template> 261 <xsl:call-template name="language.attribute"/> 262 <xsl:if test="$generate.id.attributes != 0"> 263 <xsl:attribute name="id"> 264 <xsl:call-template name="object.id"/> 265 </xsl:attribute> 266 </xsl:if> 267 268 <xsl:choose> 269 <xsl:when test="parent::article and $ischunk = 0"> 270 <xsl:call-template name="section.heading"> 271 <xsl:with-param name="level" select="1"/> 272 <xsl:with-param name="title"> 273 <xsl:apply-templates select="." mode="object.title.markup"/> 274 </xsl:with-param> 275 </xsl:call-template> 276 </xsl:when> 277 <xsl:otherwise> 278 <xsl:call-template name="component.separator"/> 279 <xsl:call-template name="appendix.titlepage"/> 280 </xsl:otherwise> 281 </xsl:choose> 282 283 <xsl:variable name="toc.params"> 284 <xsl:call-template name="find.path.params"> 285 <xsl:with-param name="table" select="normalize-space($generate.toc)"/> 286 </xsl:call-template> 287 </xsl:variable> 288 289 <xsl:if test="contains($toc.params, 'toc')"> 290 <xsl:call-template name="component.toc"> 291 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/> 292 </xsl:call-template> 293 <xsl:call-template name="component.toc.separator"/> 294 </xsl:if> 295 296 <xsl:apply-templates/> 297 298 <xsl:if test="not(parent::article) or $ischunk != 0"> 299 <xsl:call-template name="process.footnotes"/> 300 </xsl:if> 301 </div> 302</xsl:template> 303 304<xsl:template match="appendix/title" mode="titlepage.mode" priority="2"> 305 <xsl:call-template name="component.title"> 306 <xsl:with-param name="node" select="ancestor::appendix[1]"/> 307 </xsl:call-template> 308</xsl:template> 309 310<xsl:template match="appendix/subtitle 311 |appendix/appendixinfo/subtitle 312 |appendix/info/subtitle 313 |appendix/docinfo/subtitle" 314 mode="titlepage.mode" priority="2"> 315 <xsl:call-template name="component.subtitle"> 316 <xsl:with-param name="node" select="ancestor::appendix[1]"/> 317 </xsl:call-template> 318</xsl:template> 319 320<xsl:template match="appendix/docinfo|appendixinfo"></xsl:template> 321<xsl:template match="appendix/title"></xsl:template> 322<xsl:template match="appendix/titleabbrev"></xsl:template> 323<xsl:template match="appendix/subtitle"></xsl:template> 324 325<!-- ==================================================================== --> 326 327<xsl:template match="article"> 328 <xsl:call-template name="id.warning"/> 329 330 <div class="{name(.)}"> 331 <xsl:call-template name="dir"> 332 <xsl:with-param name="inherit" select="1"/> 333 </xsl:call-template> 334 <xsl:call-template name="language.attribute"/> 335 <xsl:if test="$generate.id.attributes != 0"> 336 <xsl:attribute name="id"> 337 <xsl:call-template name="object.id"/> 338 </xsl:attribute> 339 </xsl:if> 340 341 <xsl:call-template name="article.titlepage"/> 342 343 <xsl:variable name="toc.params"> 344 <xsl:call-template name="find.path.params"> 345 <xsl:with-param name="table" select="normalize-space($generate.toc)"/> 346 </xsl:call-template> 347 </xsl:variable> 348 349 <xsl:call-template name="make.lots"> 350 <xsl:with-param name="toc.params" select="$toc.params"/> 351 <xsl:with-param name="toc"> 352 <xsl:call-template name="component.toc"> 353 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/> 354 </xsl:call-template> 355 </xsl:with-param> 356 </xsl:call-template> 357 358 <xsl:apply-templates/> 359 <xsl:call-template name="process.footnotes"/> 360 </div> 361</xsl:template> 362 363<xsl:template match="article/title" mode="titlepage.mode" priority="2"> 364 <xsl:call-template name="component.title"> 365 <xsl:with-param name="node" select="ancestor::article[1]"/> 366 </xsl:call-template> 367</xsl:template> 368 369<xsl:template match="article/subtitle 370 |article/articleinfo/subtitle 371 |article/info/subtitle 372 |article/artheader/subtitle" 373 mode="titlepage.mode" priority="2"> 374 <xsl:call-template name="component.subtitle"> 375 <xsl:with-param name="node" select="ancestor::article[1]"/> 376 </xsl:call-template> 377</xsl:template> 378 379<xsl:template match="article/artheader|article/articleinfo"></xsl:template> 380<xsl:template match="article/title"></xsl:template> 381<xsl:template match="article/titleabbrev"></xsl:template> 382<xsl:template match="article/subtitle"></xsl:template> 383 384<!-- ==================================================================== --> 385 386</xsl:stylesheet> 387 388