lfs-titles.xsl 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns="http://www.w3.org/1999/xhtml"
  4. version="1.0">
  5. <!-- REVISED -->
  6. <!-- This stylesheet controls the h* xhtml tags used for several titles -->
  7. <!-- preface.titlepage:
  8. Uses h1 and removed a lot of unneeded code.
  9. No label in preface. -->
  10. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  11. <xsl:template name="preface.titlepage">
  12. <div class="titlepage">
  13. <h1 class="{name(.)}">
  14. <xsl:value-of select="title"/>
  15. </h1>
  16. </div>
  17. </xsl:template>
  18. <!-- part.titlepage:
  19. Uses h1 and removed a lot of unneeded code. -->
  20. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  21. <xsl:template name="part.titlepage">
  22. <div class="titlepage">
  23. <h1 class="{name(.)}">
  24. <xsl:apply-templates select="." mode="label.markup"/>
  25. <xsl:text>. </xsl:text>
  26. <xsl:value-of select="title"/>
  27. </h1>
  28. </div>
  29. </xsl:template>
  30. <!-- appendix.titlepage:
  31. Uses h1 and removed a lot of unneeded code. -->
  32. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  33. <xsl:template name="appendix.titlepage">
  34. <div class="titlepage">
  35. <h1 class="{name(.)}">
  36. <xsl:apply-templates select="." mode="label.markup"/>
  37. <xsl:text>. </xsl:text>
  38. <xsl:value-of select="title"/>
  39. </h1>
  40. </div>
  41. </xsl:template>
  42. <!-- chapter.titlepage:
  43. Uses h1 and removed a lot of unneeded code. -->
  44. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  45. <xsl:template name="chapter.titlepage">
  46. <div class="titlepage">
  47. <h1 class="{name(.)}">
  48. <xsl:apply-templates select="." mode="label.markup"/>
  49. <xsl:text>. </xsl:text>
  50. <xsl:value-of select="title"/>
  51. </h1>
  52. </div>
  53. </xsl:template>
  54. <!-- sect1.titlepage:
  55. Uses h1 except for the first section, and removed a lot of unneeded code. -->
  56. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  57. <xsl:template name="sect1.titlepage">
  58. <xsl:choose>
  59. <!-- I should find a better test, but if chapter TOC is readded
  60. h1 will be used always, thus no need to worry for now. -->
  61. <xsl:when test="position() = 4">
  62. <div class="titlepage">
  63. <xsl:if test="@id">
  64. <a id="{@id}" name="{@id}"/>
  65. </xsl:if>
  66. <h2 class="{name(.)}">
  67. <xsl:apply-templates select="." mode="label.markup"/>
  68. <xsl:text>. </xsl:text>
  69. <xsl:value-of select="title"/>
  70. </h2>
  71. </div>
  72. </xsl:when>
  73. <xsl:otherwise>
  74. <div class="titlepage">
  75. <h1 class="{name(.)}">
  76. <xsl:apply-templates select="." mode="label.markup"/>
  77. <xsl:text>. </xsl:text>
  78. <xsl:value-of select="title"/>
  79. </h1>
  80. </div>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:template>
  84. <!-- sect2.titlepage:
  85. Uses h2 and removed a lot of unneeded code.
  86. Skip empty titles.
  87. No label in preface. -->
  88. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  89. <xsl:template name="sect2.titlepage">
  90. <xsl:choose>
  91. <xsl:when test="string-length(title) = 0"/>
  92. <xsl:otherwise>
  93. <div class="titlepage">
  94. <xsl:if test="@id">
  95. <a id="{@id}" name="{@id}"/>
  96. </xsl:if>
  97. <h2 class="{name(.)}">
  98. <xsl:if test="not(ancestor::preface)">
  99. <xsl:apply-templates select="." mode="label.markup"/>
  100. <xsl:text>. </xsl:text>
  101. </xsl:if>
  102. <xsl:value-of select="title"/>
  103. </h2>
  104. </div>
  105. </xsl:otherwise>
  106. </xsl:choose>
  107. </xsl:template>
  108. <!-- bridgehead:
  109. When use always renderas attributes and want the output h* level
  110. matching the defined sect* level. -->
  111. <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
  112. <xsl:template match="bridgehead">
  113. <xsl:variable name="hlevel">
  114. <xsl:choose>
  115. <xsl:when test="@renderas = 'sect1'">1</xsl:when>
  116. <xsl:when test="@renderas = 'sect2'">2</xsl:when>
  117. <xsl:when test="@renderas = 'sect3'">3</xsl:when>
  118. <xsl:when test="@renderas = 'sect4'">4</xsl:when>
  119. <xsl:when test="@renderas = 'sect5'">5</xsl:when>
  120. </xsl:choose>
  121. </xsl:variable>
  122. <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
  123. <xsl:call-template name="anchor">
  124. <xsl:with-param name="conditional" select="0"/>
  125. </xsl:call-template>
  126. <xsl:apply-templates/>
  127. </xsl:element>
  128. </xsl:template>
  129. </xsl:stylesheet>