1
0

lfs-mixed.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!--
  3. $LastChangedBy$
  4. $Date$
  5. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns="http://www.w3.org/1999/xhtml"
  8. version="1.0">
  9. <!-- This stylesheet contains misc templates for output formating.
  10. This file is for that templates that don't fit in other files
  11. and that not afect the chunk algorithm. -->
  12. <!-- Individual elements templates -->
  13. <!-- para:
  14. Added a choose to skip empty "Home page" in packages.xml.
  15. Added an if for HLFS features. -->
  16. <!-- The original template is in {docbook-xsl}/xhtml/block.xsl -->
  17. <xsl:template match="para">
  18. <xsl:choose>
  19. <xsl:when test="child::ulink[@url=' ']"/>
  20. <xsl:otherwise>
  21. <xsl:call-template name="paragraph">
  22. <xsl:with-param name="class">
  23. <xsl:if test="@role">
  24. <xsl:if test="$book-type = 'hlfs'">
  25. <xsl:if test="contains($hlfs-features,concat(',',@role,','))">
  26. <xsl:text>feature-</xsl:text>
  27. </xsl:if>
  28. </xsl:if>
  29. <xsl:value-of select="@role"/>
  30. </xsl:if>
  31. </xsl:with-param>
  32. <xsl:with-param name="content">
  33. <xsl:if test="position() = 1 and parent::listitem">
  34. <xsl:call-template name="anchor">
  35. <xsl:with-param name="node" select="parent::listitem"/>
  36. </xsl:call-template>
  37. </xsl:if>
  38. <xsl:call-template name="anchor"/>
  39. <xsl:apply-templates/>
  40. </xsl:with-param>
  41. </xsl:call-template>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </xsl:template>
  45. <!-- screen:
  46. Changed class attribute asignament to fit our look needs.
  47. Removed unused line numbering support. -->
  48. <!-- The original template is in {docbook-xsl}/xhtml/verbatim.xsl
  49. It match also programlisting and synopsis. The code for that tags
  50. is unchanged. -->
  51. <xsl:template match="screen">
  52. <pre>
  53. <xsl:attribute name="class">
  54. <xsl:choose>
  55. <xsl:when test="@role and not(@role = 'nodump')">
  56. <xsl:if test="$book-type = 'hlfs'">
  57. <xsl:if test="contains($hlfs-features,concat(',',@role,','))">
  58. <xsl:text>feature-</xsl:text>
  59. </xsl:if>
  60. </xsl:if>
  61. <xsl:value-of select="@role"/>
  62. </xsl:when>
  63. <xsl:when test="child::* = userinput">userinput</xsl:when>
  64. <xsl:otherwise>
  65. <xsl:value-of select="name(.)"/>
  66. </xsl:otherwise>
  67. </xsl:choose>
  68. </xsl:attribute>
  69. <xsl:apply-templates/>
  70. </pre>
  71. </xsl:template>
  72. <!-- userinput:
  73. Using a customized output when inside screen.
  74. In other cases, use the original template. -->
  75. <!-- The original template is in {docbook-xsl}/xhtml/inline.xsl -->
  76. <xsl:template match="userinput">
  77. <xsl:choose>
  78. <xsl:when test="ancestor::screen">
  79. <kbd class="command">
  80. <xsl:apply-templates/>
  81. </kbd>
  82. </xsl:when>
  83. <xsl:otherwise>
  84. <xsl:apply-imports/>
  85. </xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:template>
  88. <!-- itemizadlist:
  89. @compact is not allowed in XHTML 1.0 Strict DTD. Changing it
  90. to @class. -->
  91. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  92. <xsl:template match="itemizedlist">
  93. <div>
  94. <xsl:apply-templates select="." mode="class.attribute"/>
  95. <xsl:call-template name="anchor"/>
  96. <xsl:if test="title">
  97. <xsl:call-template name="formal.object.heading"/>
  98. </xsl:if>
  99. <xsl:apply-templates select="*[not(self::listitem or self::title
  100. or self::titleabbrev)]
  101. |comment()[not(preceding-sibling::listitem)]
  102. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  103. <ul>
  104. <xsl:if test="@spacing='compact'">
  105. <xsl:attribute name="class">
  106. <xsl:value-of select="@spacing"/>
  107. </xsl:attribute>
  108. </xsl:if>
  109. <xsl:apply-templates select="listitem |comment()[preceding-sibling::listitem]
  110. |processing-instruction()[preceding-sibling::listitem]"/>
  111. </ul>
  112. </div>
  113. </xsl:template>
  114. <!-- orderedlist:
  115. @start, @type, and @compact sre not allowed in XHTML 1.0 Strict DTD.
  116. @start and @type can be replaced by CSS code.
  117. Changing @compact to @class. -->
  118. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  119. <xsl:template match="orderedlist">
  120. <div>
  121. <xsl:apply-templates select="." mode="class.attribute"/>
  122. <xsl:call-template name="anchor"/>
  123. <xsl:if test="title">
  124. <xsl:call-template name="formal.object.heading"/>
  125. </xsl:if>
  126. <xsl:apply-templates select="*[not(self::listitem or self::title
  127. or self::titleabbrev)]
  128. |comment()[not(preceding-sibling::listitem)]
  129. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  130. <ol>
  131. <xsl:if test="@spacing='compact'">
  132. <xsl:attribute name="class">
  133. <xsl:value-of select="@spacing"/>
  134. </xsl:attribute>
  135. </xsl:if>
  136. <xsl:apply-templates select="listitem |comment()[preceding-sibling::listitem]
  137. |processing-instruction()[preceding-sibling::listitem]"/>
  138. </ol>
  139. </div>
  140. </xsl:template>
  141. <!-- seg in segementedlist:
  142. Added a span around seg text to can match it with CSS code. -->
  143. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  144. <xsl:template match="seg">
  145. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  146. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  147. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  148. <!-- Note: segtitle is only going to be the right thing in a well formed
  149. SegmentedList. If there are too many Segs or too few SegTitles,
  150. you'll get something odd...maybe an error -->
  151. <div class="seg">
  152. <strong class="segtitle">
  153. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  154. mode="segtitle-in-seg"/>
  155. <xsl:text>: </xsl:text>
  156. </strong>
  157. <span class="segbody">
  158. <xsl:if test="@id">
  159. <a id="{@id}" name="{@id}"/>
  160. </xsl:if>
  161. <xsl:apply-templates/>
  162. </span>
  163. </div>
  164. </xsl:template>
  165. <!-- variablelist:
  166. If it have a role attribute, wrap the default output into a div with
  167. a class attribute matching that role attribute.
  168. Apply the original template in all cases. -->
  169. <!-- The original template is in {docbook-xsl}/xhtml/lists.xsl -->
  170. <xsl:template match="variablelist">
  171. <xsl:choose>
  172. <xsl:when test="@role">
  173. <div class="{@role}">
  174. <xsl:apply-imports/>
  175. </div>
  176. </xsl:when>
  177. <xsl:otherwise>
  178. <xsl:apply-imports/>
  179. </xsl:otherwise>
  180. </xsl:choose>
  181. </xsl:template>
  182. <!-- para/simplelist:
  183. Self-made template. Add a line break and process the childs.
  184. If @type is specified, the original templates should be used,
  185. but not tested. -->
  186. <xsl:template match="para/simplelist">
  187. <br/>
  188. <xsl:apply-templates mode="condensed"/>
  189. </xsl:template>
  190. <!-- member:
  191. Self-made template to process it and add a line break. -->
  192. <xsl:template match="member" mode="condensed">
  193. <xsl:call-template name="anchor"/>
  194. <xsl:call-template name="simple.xlink">
  195. <xsl:with-param name="content">
  196. <xsl:apply-templates/>
  197. </xsl:with-param>
  198. </xsl:call-template>
  199. <br/>
  200. </xsl:template>
  201. <!-- Named formating templates -->
  202. <!-- Body attributes:
  203. Add to the body XHTML output tag a class attribute with the book type
  204. and a id attribute with the book type and version. -->
  205. <!-- The original template is in {docbook-xsl}/xhtml/docbook.xsl -->
  206. <xsl:template name="body.attributes">
  207. <xsl:attribute name="class">
  208. <xsl:value-of select="$book-type"/>
  209. </xsl:attribute>
  210. <xsl:attribute name="id">
  211. <xsl:value-of select="$book-type"/>
  212. <xsl:text>-</xsl:text>
  213. <xsl:value-of select="substring-after(/book/bookinfo/subtitle, ' ')"/>
  214. </xsl:attribute>
  215. </xsl:template>
  216. <!-- Revision History -->
  217. <!-- revhistory mode titlepage.mode:
  218. Removed hardcoded style attributes.
  219. Removed support for separate revhistory file. -->
  220. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  221. <xsl:template match="revhistory" mode="titlepage.mode">
  222. <xsl:variable name="numcols">
  223. <xsl:choose>
  224. <xsl:when test="//authorinitials">4</xsl:when>
  225. <xsl:otherwise>3</xsl:otherwise>
  226. </xsl:choose>
  227. </xsl:variable>
  228. <xsl:variable name="title">
  229. <xsl:call-template name="gentext">
  230. <xsl:with-param name="key">RevHistory</xsl:with-param>
  231. </xsl:call-template>
  232. </xsl:variable>
  233. <xsl:variable name="contents">
  234. <table summary="{$title}" class="{name(.)}">
  235. <tr>
  236. <th colspan="{$numcols}">
  237. <b>
  238. <xsl:value-of select="$title"/>
  239. </b>
  240. </th>
  241. </tr>
  242. <xsl:apply-templates mode="titlepage.mode">
  243. <xsl:with-param name="numcols" select="$numcols"/>
  244. </xsl:apply-templates>
  245. </table>
  246. </xsl:variable>
  247. <xsl:copy-of select="$contents"/>
  248. </xsl:template>
  249. <!-- revhistory/revision mode titlepage.mode:
  250. Removed hardcoded style attributes. -->
  251. <!-- The original template is in {docbook-xsl}/xhtml/titlepage.xsl -->
  252. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  253. <xsl:param name="numcols" select="'3'"/>
  254. <xsl:variable name="revnumber" select="revnumber"/>
  255. <xsl:variable name="revdate" select="date"/>
  256. <xsl:variable name="revauthor" select="authorinitials|author"/>
  257. <xsl:variable name="revremark" select="revremark|revdescription"/>
  258. <tr>
  259. <td>
  260. <xsl:if test="$revnumber">
  261. <xsl:call-template name="gentext">
  262. <xsl:with-param name="key" select="'Revision'"/>
  263. </xsl:call-template>
  264. <xsl:call-template name="gentext.space"/>
  265. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  266. </xsl:if>
  267. </td>
  268. <td>
  269. <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/>
  270. </td>
  271. <xsl:choose>
  272. <xsl:when test="$revauthor">
  273. <td>
  274. <xsl:for-each select="$revauthor">
  275. <xsl:apply-templates select="." mode="titlepage.mode"/>
  276. <xsl:if test="position() != last()">
  277. <xsl:text>, </xsl:text>
  278. </xsl:if>
  279. </xsl:for-each>
  280. </td>
  281. </xsl:when>
  282. <xsl:when test="$numcols &gt; 3">
  283. <td>&#160;</td>
  284. </xsl:when>
  285. <xsl:otherwise/>
  286. </xsl:choose>
  287. <td>
  288. <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/>
  289. </td>
  290. </tr>
  291. </xsl:template>
  292. </xsl:stylesheet>