lfs-mixed.xsl 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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:if test="@id">
  96. <a id="{@id}" name="{@id}"/>
  97. </xsl:if>
  98. <xsl:apply-templates/>
  99. </span>
  100. </div>
  101. </xsl:template>
  102. <!-- variablelist:
  103. If it have a role attribute, wrap the default output into a div with
  104. a class attribute matching that role attribute.
  105. Apply the original template in all cases. -->
  106. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  107. <xsl:template match="variablelist">
  108. <xsl:choose>
  109. <xsl:when test="@role">
  110. <div class="{@role}">
  111. <xsl:apply-imports/>
  112. </div>
  113. </xsl:when>
  114. <xsl:otherwise>
  115. <xsl:apply-imports/>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. </xsl:template>
  119. <!-- para/simplelist:
  120. Self-made template. Add a line break and process the childs.
  121. If @type is specified, the original templates should be used,
  122. but not tested. -->
  123. <xsl:template match="para/simplelist">
  124. <br/>
  125. <xsl:apply-templates mode="condensed"/>
  126. </xsl:template>
  127. <!-- member:
  128. Self-made template to process it and add a line break. -->
  129. <xsl:template match="member" mode="condensed">
  130. <xsl:call-template name="anchor"/>
  131. <xsl:call-template name="simple.xlink">
  132. <xsl:with-param name="content">
  133. <xsl:apply-templates/>
  134. </xsl:with-param>
  135. </xsl:call-template>
  136. <br/>
  137. </xsl:template>
  138. <!-- Named formating templates -->
  139. <!-- Body attributes:
  140. Add to the body XHTML output tag a class attribute with the book type
  141. and a id atribute with the book type and version. -->
  142. <!-- The original template is in {docbook-xsl}/xhtml/docbook.xsl -->
  143. <xsl:template name="body.attributes">
  144. <xsl:attribute name="class">
  145. <xsl:value-of select="$book-type"/>
  146. </xsl:attribute>
  147. <xsl:attribute name="id">
  148. <xsl:value-of select="$book-type"/>
  149. <xsl:text>-</xsl:text>
  150. <xsl:value-of select="substring-after(/book/bookinfo/subtitle, ' ')"/>
  151. </xsl:attribute>
  152. </xsl:template>
  153. <!-- Revision History -->
  154. <!-- revhistory mode titlepage.mode:
  155. Removed hardcoded style attributes.
  156. Removed support for separate revhistory file. -->
  157. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  158. <xsl:template match="revhistory" mode="titlepage.mode">
  159. <xsl:variable name="numcols">
  160. <xsl:choose>
  161. <xsl:when test="//authorinitials">4</xsl:when>
  162. <xsl:otherwise>3</xsl:otherwise>
  163. </xsl:choose>
  164. </xsl:variable>
  165. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  166. <xsl:variable name="title">
  167. <xsl:call-template name="gentext">
  168. <xsl:with-param name="key">RevHistory</xsl:with-param>
  169. </xsl:call-template>
  170. </xsl:variable>
  171. <xsl:variable name="contents">
  172. <div class="{name(.)}">
  173. <table summary="Revision history">
  174. <tr>
  175. <th colspan="{$numcols}">
  176. <b>
  177. <xsl:call-template name="gentext">
  178. <xsl:with-param name="key" select="'RevHistory'"/>
  179. </xsl:call-template>
  180. </b>
  181. </th>
  182. </tr>
  183. <xsl:apply-templates mode="titlepage.mode">
  184. <xsl:with-param name="numcols" select="$numcols"/>
  185. </xsl:apply-templates>
  186. </table>
  187. </div>
  188. </xsl:variable>
  189. <xsl:copy-of select="$contents"/>
  190. </xsl:template>
  191. <!-- revhistory/revision mode titlepage.mode:
  192. Removed hardcoded style attributes. -->
  193. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  194. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  195. <xsl:param name="numcols" select="'3'"/>
  196. <xsl:variable name="revnumber" select="revnumber"/>
  197. <xsl:variable name="revdate" select="date"/>
  198. <xsl:variable name="revauthor" select="authorinitials|author"/>
  199. <xsl:variable name="revremark" select="revremark|revdescription"/>
  200. <tr>
  201. <td>
  202. <xsl:if test="$revnumber">
  203. <xsl:call-template name="gentext">
  204. <xsl:with-param name="key" select="'Revision'"/>
  205. </xsl:call-template>
  206. <xsl:call-template name="gentext.space"/>
  207. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  208. </xsl:if>
  209. </td>
  210. <td>
  211. <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/>
  212. </td>
  213. <xsl:choose>
  214. <xsl:when test="$revauthor">
  215. <td>
  216. <xsl:for-each select="$revauthor">
  217. <xsl:apply-templates select="." mode="titlepage.mode"/>
  218. <xsl:if test="position() != last()">
  219. <xsl:text>, </xsl:text>
  220. </xsl:if>
  221. </xsl:for-each>
  222. </td>
  223. </xsl:when>
  224. <xsl:when test="$numcols &gt; 3">
  225. <td>&#160;</td>
  226. </xsl:when>
  227. <xsl:otherwise/>
  228. </xsl:choose>
  229. <td>
  230. <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/>
  231. </td>
  232. </tr>
  233. </xsl:template>
  234. </xsl:stylesheet>