lfs-titles.xsl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. <h1 class="{name(.)}">
  13. <xsl:value-of select="title"/>
  14. </h1>
  15. </div>
  16. </xsl:template>
  17. <!-- part.titlepage:
  18. Uses h1 and removed a lot of unneeded code. -->
  19. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  20. <xsl:template name="part.titlepage">
  21. <div class="titlepage">
  22. <h1 class="{name(.)}">
  23. <xsl:apply-templates select="." mode="label.markup"/>
  24. <xsl:text>. </xsl:text>
  25. <xsl:value-of select="title"/>
  26. </h1>
  27. </div>
  28. </xsl:template>
  29. <!-- appendix.titlepage:
  30. Uses h1 and removed a lot of unneeded code. -->
  31. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  32. <xsl:template name="appendix.titlepage">
  33. <div class="titlepage">
  34. <h1 class="{name(.)}">
  35. <xsl:apply-templates select="." mode="label.markup"/>
  36. <xsl:text>. </xsl:text>
  37. <xsl:value-of select="title"/>
  38. </h1>
  39. </div>
  40. </xsl:template>
  41. <!-- chapter.titlepage:
  42. Uses h1 and removed a lot of unneeded code. -->
  43. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  44. <xsl:template name="chapter.titlepage">
  45. <div class="titlepage">
  46. <h1 class="{name(.)}">
  47. <xsl:apply-templates select="." mode="label.markup"/>
  48. <xsl:text>. </xsl:text>
  49. <xsl:value-of select="title"/>
  50. </h1>
  51. </div>
  52. </xsl:template>
  53. <!-- sect1.titlepage:
  54. Select the proper template depending on if chapters TOC are
  55. generated or not. -->
  56. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  57. <!-- Version for when there is no chapters TOC:
  58. Uses h1 except for the first section, and removed a lot of unneeded code. -->
  59. <!--
  60. <xsl:template name="sect1.titlepage">
  61. <xsl:choose>
  62. <xsl:when test="position() = 4">
  63. <div class="titlepage">
  64. <xsl:if test="@id">
  65. <a id="{@id}" name="{@id}"/>
  66. </xsl:if>
  67. <h2 class="{name(.)}">
  68. <xsl:apply-templates select="." mode="label.markup"/>
  69. <xsl:text>. </xsl:text>
  70. <xsl:value-of select="title"/>
  71. </h2>
  72. </div>
  73. </xsl:when>
  74. <xsl:otherwise>
  75. <div class="titlepage">
  76. <h1 class="{name(.)}">
  77. <xsl:apply-templates select="." mode="label.markup"/>
  78. <xsl:text>. </xsl:text>
  79. <xsl:value-of select="title"/>
  80. </h1>
  81. </div>
  82. </xsl:otherwise>
  83. </xsl:choose>
  84. </xsl:template>
  85. -->
  86. <!-- Version for when chapters TOC are generated:
  87. Uses h1 and removed a lot of unneeded code. -->
  88. <xsl:template name="sect1.titlepage">
  89. <div class="titlepage">
  90. <h1 class="{name(.)}">
  91. <xsl:apply-templates select="." mode="label.markup"/>
  92. <xsl:text>. </xsl:text>
  93. <xsl:value-of select="title"/>
  94. </h1>
  95. </div>
  96. </xsl:template>
  97. <!-- sect2.titlepage:
  98. Uses h2 and removed a lot of unneeded code.
  99. Skip empty titles.
  100. No label in preface (actualy, skip the hardcoded dot). -->
  101. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
  102. <xsl:template name="sect2.titlepage">
  103. <xsl:choose>
  104. <xsl:when test="string-length(title) = 0"/>
  105. <xsl:otherwise>
  106. <div class="titlepage">
  107. <xsl:if test="@id">
  108. <a id="{@id}" name="{@id}"/>
  109. </xsl:if>
  110. <h2 class="{name(.)}">
  111. <xsl:if test="not(ancestor::preface)">
  112. <xsl:apply-templates select="." mode="label.markup"/>
  113. <xsl:text>. </xsl:text>
  114. </xsl:if>
  115. <xsl:value-of select="title"/>
  116. </h2>
  117. </div>
  118. </xsl:otherwise>
  119. </xsl:choose>
  120. </xsl:template>
  121. <!-- bridgehead:
  122. When use always renderas attributes and want the output h* level
  123. matching the defined sect* level. -->
  124. <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
  125. <xsl:template match="bridgehead">
  126. <xsl:variable name="hlevel">
  127. <xsl:choose>
  128. <xsl:when test="@renderas = 'sect1'">1</xsl:when>
  129. <xsl:when test="@renderas = 'sect2'">2</xsl:when>
  130. <xsl:when test="@renderas = 'sect3'">3</xsl:when>
  131. <xsl:when test="@renderas = 'sect4'">4</xsl:when>
  132. <xsl:when test="@renderas = 'sect5'">5</xsl:when>
  133. </xsl:choose>
  134. </xsl:variable>
  135. <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
  136. <xsl:call-template name="anchor">
  137. <xsl:with-param name="conditional" select="0"/>
  138. </xsl:call-template>
  139. <xsl:apply-templates/>
  140. </xsl:element>
  141. </xsl:template>
  142. </xsl:stylesheet>