lfs-titles.xsl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. <!-- This stylesheet controls the h* xhtml tags used for several titles -->
  6. <!-- preface.titlepage:
  7. Uses h1 and removed a lot of unneeded code.
  8. No label in preface. -->
  9. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  10. <xsl:template name="preface.titlepage">
  11. <div class="titlepage">
  12. <xsl:if test="@id">
  13. <a id="{@id}" name="{@id}"/>
  14. </xsl:if>
  15. <h1 class="{name(.)}">
  16. <xsl:value-of select="title"/>
  17. </h1>
  18. </div>
  19. </xsl:template>
  20. <!-- part.titlepage:
  21. Uses h1 and removed a lot of unneeded code.
  22. When sections are not labeled, we want the part label in TOC
  23. but not in titlepage. -->
  24. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  25. <xsl:template name="part.titlepage">
  26. <div class="titlepage">
  27. <xsl:if test="@id">
  28. <a id="{@id}" name="{@id}"/>
  29. </xsl:if>
  30. <h1 class="{name(.)}">
  31. <xsl:if test="$section.autolabel != 0">
  32. <xsl:apply-templates select="." mode="label.markup"/>
  33. <xsl:text>. </xsl:text>
  34. </xsl:if>
  35. <xsl:value-of select="title"/>
  36. </h1>
  37. </div>
  38. </xsl:template>
  39. <!-- partintro.titlepage:
  40. Uses h2 and removed a lot of unneeded code. -->
  41. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  42. <xsl:template name="partintro.titlepage">
  43. <xsl:if test="title">
  44. <div class="partintrotitle">
  45. <xsl:if test="@id">
  46. <a id="{@id}" name="{@id}"/>
  47. </xsl:if>
  48. <h2 class="{name(.)}">
  49. <xsl:value-of select="title"/>
  50. </h2>
  51. </div>
  52. </xsl:if>
  53. </xsl:template>
  54. <!-- appendix.titlepage:
  55. Uses h1 and removed a lot of unneeded code.
  56. When sections are not labeled, we want the appendix label in TOC
  57. but not in titlepage. -->
  58. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  59. <xsl:template name="appendix.titlepage">
  60. <div class="titlepage">
  61. <xsl:if test="@id">
  62. <a id="{@id}" name="{@id}"/>
  63. </xsl:if>
  64. <h1 class="{name(.)}">
  65. <xsl:if test="$section.autolabel != 0">
  66. <xsl:apply-templates select="." mode="label.markup"/>
  67. <xsl:text>. </xsl:text>
  68. </xsl:if>
  69. <xsl:value-of select="title"/>
  70. </h1>
  71. </div>
  72. </xsl:template>
  73. <!-- chapter.titlepage:
  74. Uses h1 and removed a lot of unneeded code.
  75. When sections are not labeled, we want the chapter label in TOC
  76. but not in titlepage. -->
  77. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  78. <xsl:template name="chapter.titlepage">
  79. <div class="titlepage">
  80. <xsl:if test="@id">
  81. <a id="{@id}" name="{@id}"/>
  82. </xsl:if>
  83. <h1 class="{name(.)}">
  84. <xsl:if test="$section.autolabel != 0">
  85. <xsl:apply-templates select="." mode="label.markup"/>
  86. <xsl:text>. </xsl:text>
  87. </xsl:if>
  88. <xsl:value-of select="title"/>
  89. </h1>
  90. </div>
  91. </xsl:template>
  92. <!-- sect1.titlepage:
  93. Uses h1 and removed a lot of unneeded code. -->
  94. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  95. <xsl:template name="sect1.titlepage">
  96. <div class="titlepage">
  97. <xsl:if test="@id">
  98. <a id="{@id}" name="{@id}"/>
  99. </xsl:if>
  100. <h1 class="{name(.)}">
  101. <xsl:if test="$section.autolabel != 0">
  102. <xsl:apply-templates select="." mode="label.markup"/>
  103. <xsl:text>. </xsl:text>
  104. </xsl:if>
  105. <xsl:value-of select="title"/>
  106. </h1>
  107. </div>
  108. </xsl:template>
  109. <!-- sect2.titlepage:
  110. Uses h2 and removed a lot of unneeded code.
  111. Skip empty titles.
  112. No label in preface. -->
  113. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  114. <xsl:template name="sect2.titlepage">
  115. <xsl:choose>
  116. <xsl:when test="string-length(title) = 0"/>
  117. <xsl:otherwise>
  118. <div class="titlepage">
  119. <xsl:if test="@id">
  120. <a id="{@id}" name="{@id}"/>
  121. </xsl:if>
  122. <h2 class="{name(.)}">
  123. <xsl:if test="not(ancestor::preface) and $section.autolabel != 0">
  124. <xsl:apply-templates select="." mode="label.markup"/>
  125. <xsl:text>. </xsl:text>
  126. </xsl:if>
  127. <xsl:value-of select="title"/>
  128. </h2>
  129. </div>
  130. </xsl:otherwise>
  131. </xsl:choose>
  132. </xsl:template>
  133. <!-- sect3.titlepage:
  134. Uses h3 and removed a lot of unneeded code. -->
  135. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  136. <xsl:template name="sect3.titlepage">
  137. <div class="titlepage">
  138. <xsl:if test="@id">
  139. <a id="{@id}" name="{@id}"/>
  140. </xsl:if>
  141. <h3 class="{name(.)}">
  142. <xsl:if test="$section.autolabel != 0">
  143. <xsl:apply-templates select="." mode="label.markup"/>
  144. <xsl:text>. </xsl:text>
  145. </xsl:if>
  146. <xsl:value-of select="title"/>
  147. </h3>
  148. </div>
  149. </xsl:template>
  150. <!-- dedication.titlepage:
  151. Uses h2 and removed a lot of unneeded code. -->
  152. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  153. <xsl:template name="dedication.titlepage">
  154. <div class="titlepage">
  155. <h2 class="{name(.)}">
  156. <xsl:value-of select="title"/>
  157. </h2>
  158. </div>
  159. </xsl:template>
  160. <!-- bridgehead:
  161. We use always renderas attributes and want the output h* level
  162. matching the defined sect* level.
  163. Create the anchor only if there is an @id. -->
  164. <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
  165. <xsl:template match="bridgehead">
  166. <xsl:variable name="hlevel">
  167. <xsl:choose>
  168. <xsl:when test="@renderas = 'sect1'">1</xsl:when>
  169. <xsl:when test="@renderas = 'sect2'">2</xsl:when>
  170. <xsl:when test="@renderas = 'sect3'">3</xsl:when>
  171. <xsl:when test="@renderas = 'sect4'">4</xsl:when>
  172. <xsl:when test="@renderas = 'sect5'">5</xsl:when>
  173. </xsl:choose>
  174. </xsl:variable>
  175. <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
  176. <xsl:if test="@id">
  177. <a id="{@id}" name="{@id}"/>
  178. </xsl:if>
  179. <xsl:apply-templates/>
  180. </xsl:element>
  181. </xsl:template>
  182. </xsl:stylesheet>