lfs-titles.xsl 6.6 KB

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