lfs-mixed.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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="seg">
  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 ty 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. <!-- inline.monoseq:
  132. The code xhtml tag have look issues in some browsers.
  133. We will use tt instead. -->
  134. <!-- The original template is in {docbook-xsl}/xhtml/inline.xsl -->
  135. <xsl:template name="inline.monoseq">
  136. <xsl:param name="content">
  137. <xsl:call-template name="anchor"/>
  138. <xsl:call-template name="simple.xlink">
  139. <xsl:with-param name="content">
  140. <xsl:apply-templates/>
  141. </xsl:with-param>
  142. </xsl:call-template>
  143. </xsl:param>
  144. <tt>
  145. <xsl:apply-templates select="." mode="class.attribute"/>
  146. <xsl:call-template name="dir"/>
  147. <xsl:call-template name="generate.html.title"/>
  148. <xsl:copy-of select="$content"/>
  149. <xsl:call-template name="apply-annotations"/>
  150. </tt>
  151. </xsl:template>
  152. <!-- inline.boldmonoseq:
  153. The code xhtml tag have look issues in some browsers.
  154. We will use tt instead. -->
  155. <!-- The original template is in {docbook-xsl}/xhtml/inline.xsl -->
  156. <xsl:template name="inline.boldmonoseq">
  157. <xsl:param name="content">
  158. <xsl:call-template name="anchor"/>
  159. <xsl:call-template name="simple.xlink">
  160. <xsl:with-param name="content">
  161. <xsl:apply-templates/>
  162. </xsl:with-param>
  163. </xsl:call-template>
  164. </xsl:param>
  165. <!-- don't put <strong> inside figure, example, or table titles
  166. or other titles that may already be represented with <strong>'s. -->
  167. <xsl:choose>
  168. <xsl:when test="local-name(..)='title' and (local-name(../..)='figure'
  169. or local-name(../..)='example' or local-name(../..)='table'
  170. or local-name(../..)='formalpara')">
  171. <tt>
  172. <xsl:apply-templates select="." mode="class.attribute"/>
  173. <xsl:call-template name="generate.html.title"/>
  174. <xsl:call-template name="dir"/>
  175. <xsl:copy-of select="$content"/>
  176. <xsl:call-template name="apply-annotations"/>
  177. </tt>
  178. </xsl:when>
  179. <xsl:otherwise>
  180. <strong>
  181. <xsl:apply-templates select="." mode="class.attribute"/>
  182. <tt>
  183. <xsl:call-template name="generate.html.title"/>
  184. <xsl:call-template name="dir"/>
  185. <xsl:copy-of select="$content"/>
  186. </tt>
  187. </strong>
  188. </xsl:otherwise>
  189. </xsl:choose>
  190. </xsl:template>
  191. <!-- inline.italicmonoseq:
  192. The code xhtml tag have look issues in some browsers.
  193. We will use tt instead. -->
  194. <!-- The original template is in {docbook-xsl}/xhtml/inline.xsl -->
  195. <xsl:template name="inline.italicmonoseq">
  196. <xsl:param name="content">
  197. <xsl:call-template name="anchor"/>
  198. <xsl:call-template name="simple.xlink">
  199. <xsl:with-param name="content">
  200. <xsl:apply-templates/>
  201. </xsl:with-param>
  202. </xsl:call-template>
  203. </xsl:param>
  204. <em>
  205. <xsl:apply-templates select="." mode="class.attribute"/>
  206. <tt>
  207. <xsl:call-template name="generate.html.title"/>
  208. <xsl:call-template name="dir"/>
  209. <xsl:copy-of select="$content"/>
  210. <xsl:call-template name="apply-annotations"/>
  211. </tt>
  212. </em>
  213. </xsl:template>
  214. <!-- Revision History -->
  215. <!-- revhistory mode titlepage.mode:
  216. Removed hardcoded style attributes.
  217. Removed support for separate revhistory file. -->
  218. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  219. <xsl:template match="revhistory" mode="titlepage.mode">
  220. <xsl:variable name="numcols">
  221. <xsl:choose>
  222. <xsl:when test="//authorinitials">4</xsl:when>
  223. <xsl:otherwise>3</xsl:otherwise>
  224. </xsl:choose>
  225. </xsl:variable>
  226. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  227. <xsl:variable name="title">
  228. <xsl:call-template name="gentext">
  229. <xsl:with-param name="key">RevHistory</xsl:with-param>
  230. </xsl:call-template>
  231. </xsl:variable>
  232. <xsl:variable name="contents">
  233. <div class="{name(.)}">
  234. <table summary="Revision history">
  235. <tr>
  236. <th colspan="{$numcols}">
  237. <b>
  238. <xsl:call-template name="gentext">
  239. <xsl:with-param name="key" select="'RevHistory'"/>
  240. </xsl:call-template>
  241. </b>
  242. </th>
  243. </tr>
  244. <xsl:apply-templates mode="titlepage.mode">
  245. <xsl:with-param name="numcols" select="$numcols"/>
  246. </xsl:apply-templates>
  247. </table>
  248. </div>
  249. </xsl:variable>
  250. <xsl:copy-of select="$contents"/>
  251. </xsl:template>
  252. <!-- revhistory/revision mode titlepage.mode:
  253. Removed hardcoded style attributes. -->
  254. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  255. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  256. <xsl:param name="numcols" select="'3'"/>
  257. <xsl:variable name="revnumber" select="revnumber"/>
  258. <xsl:variable name="revdate" select="date"/>
  259. <xsl:variable name="revauthor" select="authorinitials|author"/>
  260. <xsl:variable name="revremark" select="revremark|revdescription"/>
  261. <tr>
  262. <td>
  263. <xsl:if test="$revnumber">
  264. <xsl:call-template name="gentext">
  265. <xsl:with-param name="key" select="'Revision'"/>
  266. </xsl:call-template>
  267. <xsl:call-template name="gentext.space"/>
  268. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  269. </xsl:if>
  270. </td>
  271. <td>
  272. <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/>
  273. </td>
  274. <xsl:choose>
  275. <xsl:when test="$revauthor">
  276. <td>
  277. <xsl:for-each select="$revauthor">
  278. <xsl:apply-templates select="." mode="titlepage.mode"/>
  279. <xsl:if test="position() != last()">
  280. <xsl:text>, </xsl:text>
  281. </xsl:if>
  282. </xsl:for-each>
  283. </td>
  284. </xsl:when>
  285. <xsl:when test="$numcols &gt; 3">
  286. <td>&#160;</td>
  287. </xsl:when>
  288. <xsl:otherwise/>
  289. </xsl:choose>
  290. <td>
  291. <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/>
  292. </td>
  293. </tr>
  294. </xsl:template>
  295. </xsl:stylesheet>