lfs-titles.xsl 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. <!-- appendix.titlepage:
  40. Uses h1 and removed a lot of unneeded code.
  41. When sections are not labeled, we want the appendix label in TOC
  42. but not in titlepage. -->
  43. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  44. <xsl:template name="appendix.titlepage">
  45. <div class="titlepage">
  46. <xsl:if test="@id">
  47. <a id="{@id}" name="{@id}"/>
  48. </xsl:if>
  49. <h1 class="{name(.)}">
  50. <xsl:if test="$section.autolabel != 0">
  51. <xsl:apply-templates select="." mode="label.markup"/>
  52. <xsl:text>. </xsl:text>
  53. </xsl:if>
  54. <xsl:value-of select="title"/>
  55. </h1>
  56. </div>
  57. </xsl:template>
  58. <!-- chapter.titlepage:
  59. Uses h1 and removed a lot of unneeded code.
  60. When sections are not labeled, we want the chapter label in TOC
  61. but not in titlepage. -->
  62. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  63. <xsl:template name="chapter.titlepage">
  64. <div class="titlepage">
  65. <xsl:if test="@id">
  66. <a id="{@id}" name="{@id}"/>
  67. </xsl:if>
  68. <h1 class="{name(.)}">
  69. <xsl:if test="$section.autolabel != 0">
  70. <xsl:apply-templates select="." mode="label.markup"/>
  71. <xsl:text>. </xsl:text>
  72. </xsl:if>
  73. <xsl:value-of select="title"/>
  74. </h1>
  75. </div>
  76. </xsl:template>
  77. <!-- sect1.titlepage:
  78. Uses h1 and removed a lot of unneeded code. -->
  79. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  80. <xsl:template name="sect1.titlepage">
  81. <div class="titlepage">
  82. <xsl:if test="@id">
  83. <a id="{@id}" name="{@id}"/>
  84. </xsl:if>
  85. <h1 class="{name(.)}">
  86. <xsl:if test="$section.autolabel != 0">
  87. <xsl:apply-templates select="." mode="label.markup"/>
  88. <xsl:text>. </xsl:text>
  89. </xsl:if>
  90. <xsl:value-of select="title"/>
  91. </h1>
  92. </div>
  93. </xsl:template>
  94. <!-- sect2.titlepage:
  95. Uses h2 and removed a lot of unneeded code.
  96. Skip empty titles.
  97. No label in preface (actualy, skip the hardcoded dot). -->
  98. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  99. <xsl:template name="sect2.titlepage">
  100. <xsl:choose>
  101. <xsl:when test="string-length(title) = 0"/>
  102. <xsl:otherwise>
  103. <div class="titlepage">
  104. <xsl:if test="@id">
  105. <a id="{@id}" name="{@id}"/>
  106. </xsl:if>
  107. <h2 class="{name(.)}">
  108. <xsl:if test="not(ancestor::preface) and $section.autolabel != 0">
  109. <xsl:apply-templates select="." mode="label.markup"/>
  110. <xsl:text>. </xsl:text>
  111. </xsl:if>
  112. <xsl:value-of select="title"/>
  113. </h2>
  114. </div>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:template>
  118. <!-- dedication.titlepage:
  119. Uses h2 and removed a lot of unneeded code. -->
  120. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  121. <xsl:template name="dedication.titlepage">
  122. <div class="titlepage">
  123. <h2 class="{name(.)}">
  124. <xsl:value-of select="title"/>
  125. </h2>
  126. </div>
  127. </xsl:template>
  128. <!-- bridgehead:
  129. When use always renderas attributes and want the output h* level
  130. matching the defined sect* level.
  131. Create the anchor only if there is an @id. -->
  132. <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
  133. <xsl:template match="bridgehead">
  134. <xsl:variable name="hlevel">
  135. <xsl:choose>
  136. <xsl:when test="@renderas = 'sect1'">1</xsl:when>
  137. <xsl:when test="@renderas = 'sect2'">2</xsl:when>
  138. <xsl:when test="@renderas = 'sect3'">3</xsl:when>
  139. <xsl:when test="@renderas = 'sect4'">4</xsl:when>
  140. <xsl:when test="@renderas = 'sect5'">5</xsl:when>
  141. </xsl:choose>
  142. </xsl:variable>
  143. <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
  144. <xsl:if test="@id">
  145. <a id="{@id}" name="{@id}"/>
  146. </xsl:if>
  147. <xsl:apply-templates/>
  148. </xsl:element>
  149. </xsl:template>
  150. </xsl:stylesheet>