lfs-sections.xsl 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!--
  3. $LastChangedBy$
  4. $Date$
  5. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns="http://www.w3.org/1999/xhtml"
  8. version="1.0">
  9. <!-- This stylesheet controls how preface, chapter, and sections are handled -->
  10. <!-- Chunk the first top-level section? 1 = yes, 0 = no
  11. If preface and chapters TOC are generated, this must be 1. -->
  12. <xsl:param name="chunk.first.sections" select="1"/>
  13. <!-- preface:
  14. Output non sect1 child elements before the TOC -->
  15. <!-- The original template is in {docbook-xsl}/xhtml/components.xsl -->
  16. <xsl:template match="preface">
  17. <xsl:call-template name="id.warning"/>
  18. <div>
  19. <xsl:apply-templates select="." mode="class.attribute"/>
  20. <xsl:call-template name="dir">
  21. <xsl:with-param name="inherit" select="1"/>
  22. </xsl:call-template>
  23. <xsl:call-template name="language.attribute"/>
  24. <xsl:if test="$generate.id.attributes != 0">
  25. <xsl:attribute name="id">
  26. <xsl:call-template name="object.id"/>
  27. </xsl:attribute>
  28. </xsl:if>
  29. <xsl:call-template name="component.separator"/>
  30. <xsl:call-template name="preface.titlepage"/>
  31. <xsl:apply-templates/>
  32. <xsl:variable name="toc.params">
  33. <xsl:call-template name="find.path.params">
  34. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  35. </xsl:call-template>
  36. </xsl:variable>
  37. <xsl:if test="contains($toc.params, 'toc')">
  38. <xsl:call-template name="component.toc">
  39. <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
  40. </xsl:call-template>
  41. <xsl:call-template name="component.toc.separator"/>
  42. </xsl:if>
  43. <xsl:call-template name="process.footnotes"/>
  44. </div>
  45. </xsl:template>
  46. <!-- chapter:
  47. Output non sect1 child elements before the TOC -->
  48. <!-- The original template is in {docbook-xsl}/xhtml/components.xsl -->
  49. <xsl:template match="chapter">
  50. <xsl:call-template name="id.warning"/>
  51. <div>
  52. <xsl:apply-templates select="." mode="class.attribute"/>
  53. <xsl:call-template name="dir">
  54. <xsl:with-param name="inherit" select="1"/>
  55. </xsl:call-template>
  56. <xsl:call-template name="language.attribute"/>
  57. <xsl:if test="$generate.id.attributes != 0">
  58. <xsl:attribute name="id">
  59. <xsl:call-template name="object.id"/>
  60. </xsl:attribute>
  61. </xsl:if>
  62. <xsl:call-template name="component.separator"/>
  63. <xsl:call-template name="chapter.titlepage"/>
  64. <xsl:apply-templates/>
  65. <xsl:variable name="toc.params">
  66. <xsl:call-template name="find.path.params">
  67. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  68. </xsl:call-template>
  69. </xsl:variable>
  70. <xsl:if test="contains($toc.params, 'toc')">
  71. <xsl:call-template name="component.toc">
  72. <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
  73. </xsl:call-template>
  74. <xsl:call-template name="component.toc.separator"/>
  75. </xsl:if>
  76. <xsl:call-template name="process.footnotes"/>
  77. </div>
  78. </xsl:template>
  79. <!-- sect1:
  80. When there is a role attibute, use it as the class value.
  81. Process the SVN keywords found in sect1info as a footnote.
  82. Removed unused code. -->
  83. <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
  84. <xsl:template match="sect1">
  85. <div>
  86. <xsl:choose>
  87. <xsl:when test="@role">
  88. <xsl:attribute name="class">
  89. <xsl:value-of select="@role"/>
  90. </xsl:attribute>
  91. </xsl:when>
  92. <xsl:otherwise>
  93. <xsl:apply-templates select="." mode="class.attribute"/>
  94. </xsl:otherwise>
  95. </xsl:choose>
  96. <xsl:call-template name="language.attribute"/>
  97. <xsl:call-template name="sect1.titlepage"/>
  98. <xsl:apply-templates/>
  99. <xsl:apply-templates select="sect1info" mode="svn-keys"/>
  100. </div>
  101. </xsl:template>
  102. <!-- sect2:
  103. When there is a role attibute, use it as the class value.
  104. Removed unused code. -->
  105. <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
  106. <xsl:template match="sect2">
  107. <div>
  108. <xsl:choose>
  109. <xsl:when test="@role">
  110. <xsl:attribute name="class">
  111. <xsl:value-of select="@role"/>
  112. </xsl:attribute>
  113. </xsl:when>
  114. <xsl:otherwise>
  115. <xsl:attribute name="class">
  116. <xsl:value-of select="name(.)"/>
  117. </xsl:attribute>
  118. </xsl:otherwise>
  119. </xsl:choose>
  120. <xsl:call-template name="language.attribute"/>
  121. <xsl:call-template name="sect2.titlepage"/>
  122. <xsl:apply-templates/>
  123. </div>
  124. </xsl:template>
  125. <!-- sect1info mode svn-keys:
  126. Self-made template to process SVN keywords found in sect1info. -->
  127. <xsl:template match="sect1info" mode="svn-keys">
  128. <p class="updated">Last updated <!-- by
  129. <xsl:apply-templates select="othername" mode="svn-keys"/> -->
  130. on
  131. <xsl:apply-templates select="date" mode="svn-keys"/>
  132. </p>
  133. </xsl:template>
  134. <!-- othername mode svn-keys:
  135. Self-made template to process the $LastChangedBy SVN keyword. -->
  136. <xsl:template match="othername" mode="svn-keys">
  137. <xsl:variable name="author">
  138. <xsl:value-of select="."/>
  139. </xsl:variable>
  140. <xsl:variable name="nameonly">
  141. <xsl:value-of select="substring($author,16)"/>
  142. </xsl:variable>
  143. <xsl:value-of select="substring-before($nameonly,'$')"/>
  144. </xsl:template>
  145. <!-- date mode svn-keys:
  146. Self-made template to process the $Date SVN keyword. -->
  147. <xsl:template match="date" mode="svn-keys">
  148. <xsl:variable name="date">
  149. <xsl:value-of select="."/>
  150. </xsl:variable>
  151. <xsl:value-of select="substring($date,7,26)"/>
  152. </xsl:template>
  153. </xsl:stylesheet>