lfs-sections.xsl 5.8 KB

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