lfs-mixed.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. <!-- itemizadlist:
  77. @compact is not allowed in XHTML 1.0 Strict DTD. Changing it
  78. to @class. -->
  79. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  80. <xsl:template match="itemizedlist">
  81. <div>
  82. <xsl:apply-templates select="." mode="class.attribute"/>
  83. <xsl:call-template name="anchor"/>
  84. <xsl:if test="title">
  85. <xsl:call-template name="formal.object.heading"/>
  86. </xsl:if>
  87. <xsl:apply-templates select="*[not(self::listitem or self::title
  88. or self::titleabbrev)]
  89. |comment()[not(preceding-sibling::listitem)]
  90. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  91. <ul>
  92. <xsl:if test="@spacing='compact'">
  93. <xsl:attribute name="class">
  94. <xsl:value-of select="@spacing"/>
  95. </xsl:attribute>
  96. </xsl:if>
  97. <xsl:apply-templates select="listitem |comment()[preceding-sibling::listitem]
  98. |processing-instruction()[preceding-sibling::listitem]"/>
  99. </ul>
  100. </div>
  101. </xsl:template>
  102. <!-- orderedlist:
  103. @start, @type, and @compact sre not allowed in XHTML 1.0 Strict DTD.
  104. @start and @type can be replaced by CSS code.
  105. Changing @compact to @class. -->
  106. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  107. <xsl:template match="orderedlist">
  108. <div>
  109. <xsl:apply-templates select="." mode="class.attribute"/>
  110. <xsl:call-template name="anchor"/>
  111. <xsl:if test="title">
  112. <xsl:call-template name="formal.object.heading"/>
  113. </xsl:if>
  114. <xsl:apply-templates select="*[not(self::listitem or self::title
  115. or self::titleabbrev)]
  116. |comment()[not(preceding-sibling::listitem)]
  117. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  118. <ol>
  119. <xsl:if test="@spacing='compact'">
  120. <xsl:attribute name="class">
  121. <xsl:value-of select="@spacing"/>
  122. </xsl:attribute>
  123. </xsl:if>
  124. <xsl:apply-templates select="listitem |comment()[preceding-sibling::listitem]
  125. |processing-instruction()[preceding-sibling::listitem]"/>
  126. </ol>
  127. </div>
  128. </xsl:template>
  129. <!-- seg in segementedlist:
  130. Added a span around seg text to can match it with CSS code. -->
  131. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  132. <xsl:template match="seg">
  133. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  134. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  135. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  136. <!-- Note: segtitle is only going to be the right thing in a well formed
  137. SegmentedList. If there are too many Segs or too few SegTitles,
  138. you'll get something odd...maybe an error -->
  139. <div class="seg">
  140. <strong>
  141. <span class="segtitle">
  142. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  143. mode="segtitle-in-seg"/>
  144. <xsl:text>: </xsl:text>
  145. </span>
  146. </strong>
  147. <span class="segbody">
  148. <xsl:if test="@id">
  149. <a id="{@id}" name="{@id}"/>
  150. </xsl:if>
  151. <xsl:apply-templates/>
  152. </span>
  153. </div>
  154. </xsl:template>
  155. <!-- variablelist:
  156. If it have a role attribute, wrap the default output into a div with
  157. a class attribute matching that role attribute.
  158. Apply the original template in all cases. -->
  159. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  160. <xsl:template match="variablelist">
  161. <xsl:choose>
  162. <xsl:when test="@role">
  163. <div class="{@role}">
  164. <xsl:apply-imports/>
  165. </div>
  166. </xsl:when>
  167. <xsl:otherwise>
  168. <xsl:apply-imports/>
  169. </xsl:otherwise>
  170. </xsl:choose>
  171. </xsl:template>
  172. <!-- para/simplelist:
  173. Self-made template. Add a line break and process the childs.
  174. If @type is specified, the original templates should be used,
  175. but not tested. -->
  176. <xsl:template match="para/simplelist">
  177. <br/>
  178. <xsl:apply-templates mode="condensed"/>
  179. </xsl:template>
  180. <!-- member:
  181. Self-made template to process it and add a line break. -->
  182. <xsl:template match="member" mode="condensed">
  183. <xsl:call-template name="anchor"/>
  184. <xsl:call-template name="simple.xlink">
  185. <xsl:with-param name="content">
  186. <xsl:apply-templates/>
  187. </xsl:with-param>
  188. </xsl:call-template>
  189. <br/>
  190. </xsl:template>
  191. <!-- Named formating templates -->
  192. <!-- Body attributes:
  193. Add to the body XHTML output tag a class attribute with the book type
  194. and a id atribute with the book type and version. -->
  195. <!-- The original template is in {docbook-xsl}/xhtml/docbook.xsl -->
  196. <xsl:template name="body.attributes">
  197. <xsl:attribute name="class">
  198. <xsl:value-of select="$book-type"/>
  199. </xsl:attribute>
  200. <xsl:attribute name="id">
  201. <xsl:value-of select="$book-type"/>
  202. <xsl:text>-</xsl:text>
  203. <xsl:value-of select="substring-after(/book/bookinfo/subtitle, ' ')"/>
  204. </xsl:attribute>
  205. </xsl:template>
  206. <!-- Revision History -->
  207. <!-- revhistory mode titlepage.mode:
  208. Removed hardcoded style attributes.
  209. Removed support for separate revhistory file. -->
  210. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  211. <xsl:template match="revhistory" mode="titlepage.mode">
  212. <xsl:variable name="numcols">
  213. <xsl:choose>
  214. <xsl:when test="//authorinitials">4</xsl:when>
  215. <xsl:otherwise>3</xsl:otherwise>
  216. </xsl:choose>
  217. </xsl:variable>
  218. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  219. <xsl:variable name="title">
  220. <xsl:call-template name="gentext">
  221. <xsl:with-param name="key">RevHistory</xsl:with-param>
  222. </xsl:call-template>
  223. </xsl:variable>
  224. <xsl:variable name="contents">
  225. <div class="{name(.)}">
  226. <table summary="Revision history">
  227. <tr>
  228. <th colspan="{$numcols}">
  229. <b>
  230. <xsl:call-template name="gentext">
  231. <xsl:with-param name="key" select="'RevHistory'"/>
  232. </xsl:call-template>
  233. </b>
  234. </th>
  235. </tr>
  236. <xsl:apply-templates mode="titlepage.mode">
  237. <xsl:with-param name="numcols" select="$numcols"/>
  238. </xsl:apply-templates>
  239. </table>
  240. </div>
  241. </xsl:variable>
  242. <xsl:copy-of select="$contents"/>
  243. </xsl:template>
  244. <!-- revhistory/revision mode titlepage.mode:
  245. Removed hardcoded style attributes. -->
  246. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  247. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  248. <xsl:param name="numcols" select="'3'"/>
  249. <xsl:variable name="revnumber" select="revnumber"/>
  250. <xsl:variable name="revdate" select="date"/>
  251. <xsl:variable name="revauthor" select="authorinitials|author"/>
  252. <xsl:variable name="revremark" select="revremark|revdescription"/>
  253. <tr>
  254. <td>
  255. <xsl:if test="$revnumber">
  256. <xsl:call-template name="gentext">
  257. <xsl:with-param name="key" select="'Revision'"/>
  258. </xsl:call-template>
  259. <xsl:call-template name="gentext.space"/>
  260. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  261. </xsl:if>
  262. </td>
  263. <td>
  264. <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/>
  265. </td>
  266. <xsl:choose>
  267. <xsl:when test="$revauthor">
  268. <td>
  269. <xsl:for-each select="$revauthor">
  270. <xsl:apply-templates select="." mode="titlepage.mode"/>
  271. <xsl:if test="position() != last()">
  272. <xsl:text>, </xsl:text>
  273. </xsl:if>
  274. </xsl:for-each>
  275. </td>
  276. </xsl:when>
  277. <xsl:when test="$numcols &gt; 3">
  278. <td>&#160;</td>
  279. </xsl:when>
  280. <xsl:otherwise/>
  281. </xsl:choose>
  282. <td>
  283. <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/>
  284. </td>
  285. </tr>
  286. </xsl:template>
  287. </xsl:stylesheet>