lfs-mixed.xsl 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 contains misc templates for output formating.
  6. This file is for that templates that don't fit in other files
  7. and that not afect the chunk algorithm. -->
  8. <!-- Individual elements templates -->
  9. <!-- para:
  10. Added a choose to skip empty "Home page" in packages.xml -->
  11. <!-- The original template is in {docbook-xsl}/xhtml/block.xsl -->
  12. <xsl:template match="para">
  13. <xsl:choose>
  14. <xsl:when test="child::ulink[@url=' ']"/>
  15. <xsl:otherwise>
  16. <xsl:call-template name="paragraph">
  17. <xsl:with-param name="class">
  18. <xsl:if test="@role and $para.propagates.style != 0">
  19. <xsl:value-of select="@role"/>
  20. </xsl:if>
  21. </xsl:with-param>
  22. <xsl:with-param name="content">
  23. <xsl:if test="position() = 1 and parent::listitem">
  24. <xsl:call-template name="anchor">
  25. <xsl:with-param name="node" select="parent::listitem"/>
  26. </xsl:call-template>
  27. </xsl:if>
  28. <xsl:call-template name="anchor"/>
  29. <xsl:apply-templates/>
  30. </xsl:with-param>
  31. </xsl:call-template>
  32. </xsl:otherwise>
  33. </xsl:choose>
  34. </xsl:template>
  35. <!-- screen:
  36. Changed class attribute asignament to fit our look needs.
  37. Removed unused line numbering support. -->
  38. <!-- The original template is in {docbook-xsl}/xhtml/verbatim.xsl
  39. It match also programlisting and synopsis. The code for that tags
  40. is unchanged. -->
  41. <xsl:template match="screen">
  42. <xsl:choose>
  43. <xsl:when test="@role = 'root'">
  44. <pre class="root">
  45. <xsl:apply-templates/>
  46. </pre>
  47. </xsl:when>
  48. <xsl:when test="child::* = userinput">
  49. <pre class="userinput">
  50. <xsl:apply-templates/>
  51. </pre>
  52. </xsl:when>
  53. <xsl:otherwise>
  54. <pre class="{name(.)}">
  55. <xsl:apply-templates/>
  56. </pre>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:template>
  60. <!-- userinput:
  61. Using a customized output when inside screen.
  62. In other cases, use the original template. -->
  63. <!-- The original template is in {docbook-xsl}/xhtml/inline.xsl -->
  64. <xsl:template match="userinput">
  65. <xsl:choose>
  66. <xsl:when test="ancestor::screen">
  67. <kbd class="command">
  68. <xsl:apply-templates/>
  69. </kbd>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <xsl:apply-imports/>
  73. </xsl:otherwise>
  74. </xsl:choose>
  75. </xsl:template>
  76. <!-- seg in segementedlist:
  77. Added a span around seg text to can match it with CSS code. -->
  78. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  79. <xsl:template match="seg">
  80. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  81. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  82. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  83. <!-- Note: segtitle is only going to be the right thing in a well formed
  84. SegmentedList. If there are too many Segs or too few SegTitles,
  85. you'll get something odd...maybe an error -->
  86. <div class="seg">
  87. <strong>
  88. <span class="segtitle">
  89. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  90. mode="segtitle-in-seg"/>
  91. <xsl:text>: </xsl:text>
  92. </span>
  93. </strong>
  94. <span class="segbody">
  95. <xsl:apply-templates/>
  96. </span>
  97. </div>
  98. </xsl:template>
  99. <!-- variablelist:
  100. If it have a role attribute, wrap the default output into a div with
  101. a class attribute matching that role attribute.
  102. Apply the original template in all cases. -->
  103. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  104. <xsl:template match="variablelist">
  105. <xsl:choose>
  106. <xsl:when test="@role">
  107. <div class="{@role}">
  108. <xsl:apply-imports/>
  109. </div>
  110. </xsl:when>
  111. <xsl:otherwise>
  112. <xsl:apply-imports/>
  113. </xsl:otherwise>
  114. </xsl:choose>
  115. </xsl:template>
  116. <!-- Named formating templates -->
  117. <!-- Body attributes:
  118. Add to the body XHTML output tag a class attribute with the book type
  119. and a id atribute with the book type and version. -->
  120. <!-- The original template is in {docbook-xsl}/xhtml/docbook.xsl -->
  121. <xsl:template name="body.attributes">
  122. <xsl:attribute name="class">
  123. <xsl:value-of select="$book-type"/>
  124. </xsl:attribute>
  125. <xsl:attribute name="id">
  126. <xsl:value-of select="$book-type"/>
  127. <xsl:text>-</xsl:text>
  128. <xsl:value-of select="substring-after(/book/bookinfo/subtitle, ' ')"/>
  129. </xsl:attribute>
  130. </xsl:template>
  131. <!-- Revision History -->
  132. <!-- revhistory mode titlepage.mode:
  133. Removed hardcoded style attributes.
  134. Removed support for separate revhistory file. -->
  135. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  136. <xsl:template match="revhistory" mode="titlepage.mode">
  137. <xsl:variable name="numcols">
  138. <xsl:choose>
  139. <xsl:when test="//authorinitials">4</xsl:when>
  140. <xsl:otherwise>3</xsl:otherwise>
  141. </xsl:choose>
  142. </xsl:variable>
  143. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  144. <xsl:variable name="title">
  145. <xsl:call-template name="gentext">
  146. <xsl:with-param name="key">RevHistory</xsl:with-param>
  147. </xsl:call-template>
  148. </xsl:variable>
  149. <xsl:variable name="contents">
  150. <div class="{name(.)}">
  151. <table summary="Revision history">
  152. <tr>
  153. <th colspan="{$numcols}">
  154. <b>
  155. <xsl:call-template name="gentext">
  156. <xsl:with-param name="key" select="'RevHistory'"/>
  157. </xsl:call-template>
  158. </b>
  159. </th>
  160. </tr>
  161. <xsl:apply-templates mode="titlepage.mode">
  162. <xsl:with-param name="numcols" select="$numcols"/>
  163. </xsl:apply-templates>
  164. </table>
  165. </div>
  166. </xsl:variable>
  167. <xsl:copy-of select="$contents"/>
  168. </xsl:template>
  169. <!-- revhistory/revision mode titlepage.mode:
  170. Removed hardcoded style attributes. -->
  171. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  172. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  173. <xsl:param name="numcols" select="'3'"/>
  174. <xsl:variable name="revnumber" select="revnumber"/>
  175. <xsl:variable name="revdate" select="date"/>
  176. <xsl:variable name="revauthor" select="authorinitials|author"/>
  177. <xsl:variable name="revremark" select="revremark|revdescription"/>
  178. <tr>
  179. <td>
  180. <xsl:if test="$revnumber">
  181. <xsl:call-template name="gentext">
  182. <xsl:with-param name="key" select="'Revision'"/>
  183. </xsl:call-template>
  184. <xsl:call-template name="gentext.space"/>
  185. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  186. </xsl:if>
  187. </td>
  188. <td>
  189. <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/>
  190. </td>
  191. <xsl:choose>
  192. <xsl:when test="$revauthor">
  193. <td>
  194. <xsl:for-each select="$revauthor">
  195. <xsl:apply-templates select="." mode="titlepage.mode"/>
  196. <xsl:if test="position() != last()">
  197. <xsl:text>, </xsl:text>
  198. </xsl:if>
  199. </xsl:for-each>
  200. </td>
  201. </xsl:when>
  202. <xsl:when test="$numcols &gt; 3">
  203. <td>&#160;</td>
  204. </xsl:when>
  205. <xsl:otherwise/>
  206. </xsl:choose>
  207. <td>
  208. <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/>
  209. </td>
  210. </tr>
  211. </xsl:template>
  212. </xsl:stylesheet>