| 1 | <?xml version="1.0"?> |
|---|
| 2 | |
|---|
| 3 | <!-- |
|---|
| 4 | - Customize the generation of HTML from the DocBook sources for the YAML spec. |
|---|
| 5 | --> |
|---|
| 6 | |
|---|
| 7 | <xsl:stylesheet |
|---|
| 8 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 9 | version="1.0"> |
|---|
| 10 | |
|---|
| 11 | <!-- Invoke the DocBook -> HTML conversion stylesheet --> |
|---|
| 12 | <xsl:import href="docbook_xslt/xhtml/docbook.xsl" /> |
|---|
| 13 | |
|---|
| 14 | <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" |
|---|
| 15 | doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" |
|---|
| 16 | doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" /> |
|---|
| 17 | |
|---|
| 18 | <!-- |
|---|
| 19 | - Tweak the generation of a table of contents: |
|---|
| 20 | --> |
|---|
| 21 | |
|---|
| 22 | <!-- Use a CSS stylesheet to customize the HTML file. --> |
|---|
| 23 | <xsl:param name="html.stylesheet" select="'single_html.css'"></xsl:param> |
|---|
| 24 | |
|---|
| 25 | <!-- Supress including all abstracts in the META tag. --> |
|---|
| 26 | <xsl:param name="generate.meta.abstract" select="0"></xsl:param> |
|---|
| 27 | |
|---|
| 28 | <!-- Generate "more valid" HTML. --> |
|---|
| 29 | <xsl:param name="make.valid.html" select="0"></xsl:param> |
|---|
| 30 | |
|---|
| 31 | <!-- Disable EBNF table border (leave it to the CSS). --> |
|---|
| 32 | <xsl:param name="ebnf.table.border" select="0"></xsl:param> |
|---|
| 33 | |
|---|
| 34 | <!-- Disable EBNF table color (leave it to the CSS). --> |
|---|
| 35 | <xsl:param name="ebnf.table.bgcolor" select="''"></xsl:param> |
|---|
| 36 | |
|---|
| 37 | <!-- Auto-number sections. The default doesn't. --> |
|---|
| 38 | <xsl:param name="section.autolabel" select="1" /> |
|---|
| 39 | |
|---|
| 40 | <!-- Include chapter number in section number (1.2 instead of 2). --> |
|---|
| 41 | <xsl:param name="section.label.includes.component.label" select="1" /> |
|---|
| 42 | |
|---|
| 43 | <!-- Include sect4 elements in TOC (the default is just sect2) --> |
|---|
| 44 | <xsl:param name="toc.section.depth">4</xsl:param> |
|---|
| 45 | |
|---|
| 46 | <!-- Supress everything except a single top-level table of contents. --> |
|---|
| 47 | <xsl:param name="generate.toc"> |
|---|
| 48 | set toc,title |
|---|
| 49 | book toc,title,index |
|---|
| 50 | article title |
|---|
| 51 | part nop |
|---|
| 52 | chapter nop |
|---|
| 53 | preface nop |
|---|
| 54 | qandadiv nop |
|---|
| 55 | qandaset nop |
|---|
| 56 | reference nop |
|---|
| 57 | sect1 nop |
|---|
| 58 | sect2 nop |
|---|
| 59 | sect3 nop |
|---|
| 60 | sect4 nop |
|---|
| 61 | sect5 nop |
|---|
| 62 | section nop |
|---|
| 63 | appendix nop |
|---|
| 64 | </xsl:param> |
|---|
| 65 | |
|---|
| 66 | <!-- Ignore fo only --> |
|---|
| 67 | <xsl:template match="fo" |
|---|
| 68 | ></xsl:template> |
|---|
| 69 | |
|---|
| 70 | <!-- Ignore a <pagebreak/> command --> |
|---|
| 71 | <xsl:template match="pagebreak"/> |
|---|
| 72 | |
|---|
| 73 | <!-- Horrible hack for making preferred index entries a different class. --> |
|---|
| 74 | <xsl:template match="indexterm" mode="reference"> |
|---|
| 75 | <xsl:param name="scope" select="."/> |
|---|
| 76 | <xsl:param name="separator" select="', '"/> |
|---|
| 77 | |
|---|
| 78 | <xsl:value-of select="$separator"/> |
|---|
| 79 | <xsl:choose> |
|---|
| 80 | <xsl:when test="@zone and string(@zone)"> |
|---|
| 81 | <xsl:call-template name="reference"> |
|---|
| 82 | <xsl:with-param name="zones" select="normalize-space(@zone)"/> |
|---|
| 83 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 84 | </xsl:call-template> |
|---|
| 85 | </xsl:when> |
|---|
| 86 | <xsl:otherwise> |
|---|
| 87 | <a> |
|---|
| 88 | <xsl:variable name="title"> |
|---|
| 89 | <xsl:apply-templates select="(ancestor-or-self::set |
|---|
| 90 | |ancestor-or-self::book |
|---|
| 91 | |ancestor-or-self::part |
|---|
| 92 | |ancestor-or-self::reference |
|---|
| 93 | |ancestor-or-self::partintro |
|---|
| 94 | |ancestor-or-self::chapter |
|---|
| 95 | |ancestor-or-self::appendix |
|---|
| 96 | |ancestor-or-self::preface |
|---|
| 97 | |ancestor-or-self::article |
|---|
| 98 | |ancestor-or-self::section |
|---|
| 99 | |ancestor-or-self::sect1 |
|---|
| 100 | |ancestor-or-self::sect2 |
|---|
| 101 | |ancestor-or-self::sect3 |
|---|
| 102 | |ancestor-or-self::sect4 |
|---|
| 103 | |ancestor-or-self::sect5 |
|---|
| 104 | |ancestor-or-self::refentry |
|---|
| 105 | |ancestor-or-self::refsect1 |
|---|
| 106 | |ancestor-or-self::refsect2 |
|---|
| 107 | |ancestor-or-self::refsect3 |
|---|
| 108 | |ancestor-or-self::simplesect |
|---|
| 109 | |ancestor-or-self::bibliography |
|---|
| 110 | |ancestor-or-self::glossary |
|---|
| 111 | |ancestor-or-self::index |
|---|
| 112 | |ancestor-or-self::webpage)[last()]" |
|---|
| 113 | mode="title.markup"/> |
|---|
| 114 | </xsl:variable> |
|---|
| 115 | |
|---|
| 116 | <!-- Added from here --> |
|---|
| 117 | <xsl:if test="@significance='preferred'"> |
|---|
| 118 | <xsl:attribute name="class">preferred</xsl:attribute> |
|---|
| 119 | </xsl:if> |
|---|
| 120 | <!-- Added to here --> |
|---|
| 121 | |
|---|
| 122 | <xsl:attribute name="href"> |
|---|
| 123 | <xsl:call-template name="href.target"> |
|---|
| 124 | <xsl:with-param name="object" |
|---|
| 125 | select="(ancestor-or-self::set |
|---|
| 126 | |ancestor-or-self::book |
|---|
| 127 | |ancestor-or-self::part |
|---|
| 128 | |ancestor-or-self::reference |
|---|
| 129 | |ancestor-or-self::partintro |
|---|
| 130 | |ancestor-or-self::chapter |
|---|
| 131 | |ancestor-or-self::appendix |
|---|
| 132 | |ancestor-or-self::preface |
|---|
| 133 | |ancestor-or-self::article |
|---|
| 134 | |ancestor-or-self::section |
|---|
| 135 | |ancestor-or-self::sect1 |
|---|
| 136 | |ancestor-or-self::sect2 |
|---|
| 137 | |ancestor-or-self::sect3 |
|---|
| 138 | |ancestor-or-self::sect4 |
|---|
| 139 | |ancestor-or-self::sect5 |
|---|
| 140 | |ancestor-or-self::refentry |
|---|
| 141 | |ancestor-or-self::refsect1 |
|---|
| 142 | |ancestor-or-self::refsect2 |
|---|
| 143 | |ancestor-or-self::refsect3 |
|---|
| 144 | |ancestor-or-self::simplesect |
|---|
| 145 | |ancestor-or-self::bibliography |
|---|
| 146 | |ancestor-or-self::glossary |
|---|
| 147 | |ancestor-or-self::index |
|---|
| 148 | |ancestor-or-self::webpage)[last()]"/> |
|---|
| 149 | </xsl:call-template> |
|---|
| 150 | </xsl:attribute> |
|---|
| 151 | |
|---|
| 152 | <xsl:value-of select="$title"/> <!-- text only --> |
|---|
| 153 | </a> |
|---|
| 154 | |
|---|
| 155 | <xsl:if test="key('endofrange', @id) |
|---|
| 156 | [count(ancestor::node()|$scope) = count(ancestor::node())]"> |
|---|
| 157 | <xsl:apply-templates select="key('endofrange', @id) |
|---|
| 158 | [count(ancestor::node()|$scope) = count(ancestor::node())][last()]" |
|---|
| 159 | mode="reference"> |
|---|
| 160 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 161 | <xsl:with-param name="separator" select="'-'"/> |
|---|
| 162 | </xsl:apply-templates> |
|---|
| 163 | </xsl:if> |
|---|
| 164 | </xsl:otherwise> |
|---|
| 165 | </xsl:choose> |
|---|
| 166 | </xsl:template> |
|---|
| 167 | |
|---|
| 168 | <!-- Horrid hack for making primary index entries anchored. --> |
|---|
| 169 | <xsl:template match="indexterm" mode="index-primary"> |
|---|
| 170 | <xsl:param name="scope" select="."/> |
|---|
| 171 | <xsl:variable name="key" |
|---|
| 172 | select="normalize-space(concat(primary/@sortas, primary[not(@sortas)]))"/> |
|---|
| 173 | <xsl:variable name="refs" |
|---|
| 174 | select="key('primary', $key)[count(ancestor::node()|$scope) |
|---|
| 175 | = count(ancestor::node())]"/> |
|---|
| 176 | <dt> |
|---|
| 177 | <!-- Added from here --> |
|---|
| 178 | <a><xsl:attribute name="id" |
|---|
| 179 | >index-entry-<xsl:value-of select="primary" |
|---|
| 180 | /></xsl:attribute></a> |
|---|
| 181 | <!-- Added to here --> |
|---|
| 182 | <xsl:value-of select="primary"/> |
|---|
| 183 | <xsl:for-each |
|---|
| 184 | select="$refs[generate-id() |
|---|
| 185 | = generate-id( |
|---|
| 186 | key('primary-section', |
|---|
| 187 | concat($key, " ", |
|---|
| 188 | generate-id((ancestor-or-self::set |
|---|
| 189 | |ancestor-or-self::book |
|---|
| 190 | |ancestor-or-self::part |
|---|
| 191 | |ancestor-or-self::reference |
|---|
| 192 | |ancestor-or-self::partintro |
|---|
| 193 | |ancestor-or-self::chapter |
|---|
| 194 | |ancestor-or-self::appendix |
|---|
| 195 | |ancestor-or-self::preface |
|---|
| 196 | |ancestor-or-self::article |
|---|
| 197 | |ancestor-or-self::section |
|---|
| 198 | |ancestor-or-self::sect1 |
|---|
| 199 | |ancestor-or-self::sect2 |
|---|
| 200 | |ancestor-or-self::sect3 |
|---|
| 201 | |ancestor-or-self::sect4 |
|---|
| 202 | |ancestor-or-self::sect5 |
|---|
| 203 | |ancestor-or-self::refentry |
|---|
| 204 | |ancestor-or-self::refsect1 |
|---|
| 205 | |ancestor-or-self::refsect2 |
|---|
| 206 | |ancestor-or-self::refsect3 |
|---|
| 207 | |ancestor-or-self::simplesect |
|---|
| 208 | |ancestor-or-self::bibliography |
|---|
| 209 | |ancestor-or-self::glossary |
|---|
| 210 | |ancestor-or-self::index |
|---|
| 211 | |ancestor-or-self::webpage) |
|---|
| 212 | [last()] |
|---|
| 213 | ) |
|---|
| 214 | ) |
|---|
| 215 | )[count(ancestor::node()|$scope) |
|---|
| 216 | = count(ancestor::node())][1])]"> |
|---|
| 217 | <xsl:apply-templates select="." mode="reference"> |
|---|
| 218 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 219 | </xsl:apply-templates> |
|---|
| 220 | </xsl:for-each> |
|---|
| 221 | <xsl:if test="$refs[not(secondary)]/*[self::see]"> |
|---|
| 222 | <xsl:apply-templates |
|---|
| 223 | select="$refs[generate-id() |
|---|
| 224 | = generate-id( |
|---|
| 225 | key('see', |
|---|
| 226 | concat( |
|---|
| 227 | normalize-space( |
|---|
| 228 | concat(primary/@sortas, |
|---|
| 229 | primary[not(@sortas)] |
|---|
| 230 | ) |
|---|
| 231 | ), " ", " ", " ", see |
|---|
| 232 | ) |
|---|
| 233 | )[count(ancestor::node()|$scope) |
|---|
| 234 | = count(ancestor::node())][1])]" |
|---|
| 235 | mode="index-see"> |
|---|
| 236 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 237 | <xsl:sort select="translate(see, 'abcdefghijklmnopqrstuvwxyz', |
|---|
| 238 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> |
|---|
| 239 | </xsl:apply-templates> |
|---|
| 240 | </xsl:if> |
|---|
| 241 | </dt> |
|---|
| 242 | <xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]"> |
|---|
| 243 | <dd> |
|---|
| 244 | <dl> |
|---|
| 245 | <xsl:apply-templates |
|---|
| 246 | select="$refs[generate-id() |
|---|
| 247 | = generate-id( |
|---|
| 248 | key('see-also', |
|---|
| 249 | concat( |
|---|
| 250 | normalize-space( |
|---|
| 251 | concat(primary/@sortas, |
|---|
| 252 | primary[not(@sortas)] |
|---|
| 253 | ) |
|---|
| 254 | ), " ", " ", " ", |
|---|
| 255 | seealso |
|---|
| 256 | ) |
|---|
| 257 | )[count(ancestor::node()|$scope) |
|---|
| 258 | = count(ancestor::node())][1])]" |
|---|
| 259 | mode="index-seealso"> |
|---|
| 260 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 261 | <xsl:sort select="translate(seealso, |
|---|
| 262 | 'abcdefghijklmnopqrstuvwxyz', |
|---|
| 263 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> |
|---|
| 264 | </xsl:apply-templates> |
|---|
| 265 | <xsl:apply-templates |
|---|
| 266 | select="$refs[secondary |
|---|
| 267 | and count( |
|---|
| 268 | .|key('secondary', |
|---|
| 269 | concat($key, " ", |
|---|
| 270 | normalize-space( |
|---|
| 271 | concat(secondary/@sortas, |
|---|
| 272 | secondary[not(@sortas)]) |
|---|
| 273 | ) |
|---|
| 274 | ) |
|---|
| 275 | )[count(ancestor::node()|$scope) |
|---|
| 276 | = count(ancestor::node())][1]) = 1]" |
|---|
| 277 | mode="index-secondary"> |
|---|
| 278 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 279 | <xsl:sort |
|---|
| 280 | select="translate( |
|---|
| 281 | normalize-space( |
|---|
| 282 | concat(secondary/@sortas, |
|---|
| 283 | secondary[not(@sortas)]) |
|---|
| 284 | ), |
|---|
| 285 | 'abcdefghijklmnopqrstuvwxyz', |
|---|
| 286 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> |
|---|
| 287 | </xsl:apply-templates> |
|---|
| 288 | </dl> |
|---|
| 289 | </dd> |
|---|
| 290 | </xsl:if> |
|---|
| 291 | </xsl:template> |
|---|
| 292 | |
|---|
| 293 | <!-- Disgusting hack for making secondary index entries anchored. --> |
|---|
| 294 | <xsl:template match="QQQindexterm" mode="index-secondary"> |
|---|
| 295 | <xsl:param name="scope" select="."/> |
|---|
| 296 | <xsl:variable name="key" |
|---|
| 297 | select="concat( |
|---|
| 298 | normalize-space( |
|---|
| 299 | concat(primary/@sortas, primary[not(@sortas)])), |
|---|
| 300 | " ", |
|---|
| 301 | normalize-space( |
|---|
| 302 | concat(secondary/@sortas, secondary[not(@sortas)])))"/> |
|---|
| 303 | <xsl:variable name="refs" |
|---|
| 304 | select="key('secondary', $key)[count(ancestor::node()|$scope) |
|---|
| 305 | = count(ancestor::node())]"/> |
|---|
| 306 | <dt> |
|---|
| 307 | <!-- Added from here --> |
|---|
| 308 | <a><xsl:attribute name="id" |
|---|
| 309 | >index-entry-<xsl:value-of select="primary" |
|---|
| 310 | />/<xsl:value-of select="secondary" |
|---|
| 311 | /></xsl:attribute></a> |
|---|
| 312 | <!-- Added to here --> |
|---|
| 313 | <xsl:value-of select="secondary"/> |
|---|
| 314 | <xsl:for-each |
|---|
| 315 | select="$refs[generate-id() |
|---|
| 316 | = generate-id( |
|---|
| 317 | key('secondary-section', |
|---|
| 318 | concat($key, " ", |
|---|
| 319 | generate-id((ancestor-or-self::set |
|---|
| 320 | |ancestor-or-self::book |
|---|
| 321 | |ancestor-or-self::part |
|---|
| 322 | |ancestor-or-self::reference |
|---|
| 323 | |ancestor-or-self::partintro |
|---|
| 324 | |ancestor-or-self::chapter |
|---|
| 325 | |ancestor-or-self::appendix |
|---|
| 326 | |ancestor-or-self::preface |
|---|
| 327 | |ancestor-or-self::article |
|---|
| 328 | |ancestor-or-self::section |
|---|
| 329 | |ancestor-or-self::sect1 |
|---|
| 330 | |ancestor-or-self::sect2 |
|---|
| 331 | |ancestor-or-self::sect3 |
|---|
| 332 | |ancestor-or-self::sect4 |
|---|
| 333 | |ancestor-or-self::sect5 |
|---|
| 334 | |ancestor-or-self::refentry |
|---|
| 335 | |ancestor-or-self::refsect1 |
|---|
| 336 | |ancestor-or-self::refsect2 |
|---|
| 337 | |ancestor-or-self::refsect3 |
|---|
| 338 | |ancestor-or-self::simplesect |
|---|
| 339 | |ancestor-or-self::bibliography |
|---|
| 340 | |ancestor-or-self::glossary |
|---|
| 341 | |ancestor-or-self::index |
|---|
| 342 | |ancestor-or-self::webpage) |
|---|
| 343 | [last()] |
|---|
| 344 | ) |
|---|
| 345 | ) |
|---|
| 346 | )[count(ancestor::node()|$scope) |
|---|
| 347 | = count(ancestor::node())][1])]"> |
|---|
| 348 | <xsl:apply-templates select="." mode="reference"> |
|---|
| 349 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 350 | </xsl:apply-templates> |
|---|
| 351 | </xsl:for-each> |
|---|
| 352 | <xsl:if test="$refs[not(tertiary)]/*[self::see]"> |
|---|
| 353 | <xsl:apply-templates |
|---|
| 354 | select="$refs[generate-id() |
|---|
| 355 | = generate-id( |
|---|
| 356 | key('see', |
|---|
| 357 | concat( |
|---|
| 358 | normalize-space( |
|---|
| 359 | concat(primary/@sortas, |
|---|
| 360 | primary[not(@sortas)]) |
|---|
| 361 | ), " ", |
|---|
| 362 | normalize-space( |
|---|
| 363 | concat(secondary/@sortas, |
|---|
| 364 | secondary[not(@sortas)]) |
|---|
| 365 | ), " ", " ", see |
|---|
| 366 | ) |
|---|
| 367 | )[count(ancestor::node()|$scope) |
|---|
| 368 | = count(ancestor::node())][1])]" mode="index-see"> |
|---|
| 369 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 370 | <xsl:sort select="translate(see, 'abcdefghijklmnopqrstuvwxyz', |
|---|
| 371 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> |
|---|
| 372 | </xsl:apply-templates> |
|---|
| 373 | </xsl:if> |
|---|
| 374 | </dt> |
|---|
| 375 | <xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::seealso]"> |
|---|
| 376 | <dd> |
|---|
| 377 | <dl> |
|---|
| 378 | <xsl:apply-templates |
|---|
| 379 | select="$refs[generate-id() |
|---|
| 380 | = generate-id( |
|---|
| 381 | key('see-also', |
|---|
| 382 | concat( |
|---|
| 383 | normalize-space( |
|---|
| 384 | concat(primary/@sortas, |
|---|
| 385 | primary[not(@sortas)]) |
|---|
| 386 | ), " ", |
|---|
| 387 | normalize-space( |
|---|
| 388 | concat(secondary/@sortas, |
|---|
| 389 | secondary[not(@sortas)]) |
|---|
| 390 | ), " ", " ", seealso) |
|---|
| 391 | )[count(ancestor::node()|$scope) |
|---|
| 392 | = count(ancestor::node())][1])]" |
|---|
| 393 | mode="index-seealso"> |
|---|
| 394 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 395 | <xsl:sort |
|---|
| 396 | select="translate(seealso, 'abcdefghijklmnopqrstuvwxyz', |
|---|
| 397 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> |
|---|
| 398 | </xsl:apply-templates> |
|---|
| 399 | <xsl:apply-templates |
|---|
| 400 | select="$refs[tertiary |
|---|
| 401 | and count( |
|---|
| 402 | .|key('tertiary', |
|---|
| 403 | concat($key, " ", |
|---|
| 404 | normalize-space( |
|---|
| 405 | concat(tertiary/@sortas, |
|---|
| 406 | tertiary[not(@sortas)]) |
|---|
| 407 | ) |
|---|
| 408 | ) |
|---|
| 409 | )[count(ancestor::node()|$scope) |
|---|
| 410 | = count(ancestor::node())][1]) = 1]" |
|---|
| 411 | mode="index-tertiary"> |
|---|
| 412 | <xsl:with-param name="scope" select="$scope"/> |
|---|
| 413 | <xsl:sort |
|---|
| 414 | select="translate( |
|---|
| 415 | normalize-space( |
|---|
| 416 | concat(tertiary/@sortas, tertiary[not(@sortas)]) |
|---|
| 417 | ), 'abcdefghijklmnopqrstuvwxyz', |
|---|
| 418 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> |
|---|
| 419 | </xsl:apply-templates> |
|---|
| 420 | </dl> |
|---|
| 421 | </dd> |
|---|
| 422 | </xsl:if> |
|---|
| 423 | </xsl:template> |
|---|
| 424 | </xsl:stylesheet> |
|---|