lfs-mixed.xsl 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. <!-- screen -->
  6. <xsl:template match="screen">
  7. <xsl:choose>
  8. <xsl:when test="child::* = userinput">
  9. <pre class="userinput">
  10. <xsl:apply-templates/>
  11. </pre>
  12. </xsl:when>
  13. <xsl:otherwise>
  14. <pre class="{name(.)}">
  15. <xsl:apply-templates/>
  16. </pre>
  17. </xsl:otherwise>
  18. </xsl:choose>
  19. </xsl:template>
  20. <xsl:template match="userinput">
  21. <xsl:choose>
  22. <xsl:when test="ancestor::screen">
  23. <kbd class="command">
  24. <xsl:apply-templates/>
  25. </kbd>
  26. </xsl:when>
  27. <xsl:otherwise>
  28. <xsl:apply-imports/>
  29. </xsl:otherwise>
  30. </xsl:choose>
  31. </xsl:template>
  32. <!-- variablelist -->
  33. <xsl:template match="variablelist">
  34. <div class="{name(.)}">
  35. <xsl:if test="title | bridgehead">
  36. <xsl:choose>
  37. <xsl:when test="@role = 'materials'">
  38. <h2>
  39. <xsl:value-of select="title | bridgehead"/>
  40. </h2>
  41. </xsl:when>
  42. <xsl:otherwise>
  43. <h3>
  44. <xsl:value-of select="title | bridgehead"/>
  45. </h3>
  46. </xsl:otherwise>
  47. </xsl:choose>
  48. </xsl:if>
  49. <dl>
  50. <xsl:if test="@role">
  51. <xsl:attribute name="class">
  52. <xsl:value-of select="@role"/>
  53. </xsl:attribute>
  54. </xsl:if>
  55. <xsl:apply-templates select="varlistentry"/>
  56. </dl>
  57. </div>
  58. </xsl:template>
  59. <!-- segementedlist -->
  60. <xsl:template match="seg">
  61. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  62. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  63. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  64. <!-- Note: segtitle is only going to be the right thing in a well formed
  65. SegmentedList. If there are too many Segs or too few SegTitles,
  66. you'll get something odd...maybe an error -->
  67. <div class="seg">
  68. <strong>
  69. <span class="segtitle">
  70. <xsl:apply-templates select="$segtitles[$segnum=position()]" mode="segtitle-in-seg"/>
  71. <xsl:text>: </xsl:text>
  72. </span>
  73. </strong>
  74. <span class="seg">
  75. <xsl:apply-templates/>
  76. </span>
  77. </div>
  78. </xsl:template>
  79. <!-- Body attributes -->
  80. <xsl:template name="body.attributes">
  81. <xsl:attribute name="id">
  82. <xsl:text>lfs</xsl:text>
  83. </xsl:attribute>
  84. <xsl:attribute name="class">
  85. <xsl:value-of select="substring-after(/book/bookinfo/subtitle, ' ')"/>
  86. </xsl:attribute>
  87. </xsl:template>
  88. <!-- External URLs in italic font -->
  89. <xsl:template match="ulink" name="ulink">
  90. <a>
  91. <xsl:if test="@id">
  92. <xsl:attribute name="id">
  93. <xsl:value-of select="@id"/>
  94. </xsl:attribute>
  95. </xsl:if>
  96. <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
  97. <i>
  98. <xsl:choose>
  99. <xsl:when test="count(child::node())=0">
  100. <xsl:value-of select="@url"/>
  101. </xsl:when>
  102. <xsl:otherwise>
  103. <xsl:apply-templates/>
  104. </xsl:otherwise>
  105. </xsl:choose>
  106. </i>
  107. </a>
  108. </xsl:template>
  109. <!-- The <code> xhtml tag have look issues in some browsers, like Konqueror and.
  110. isn't semantically correct (a filename isn't a code fragment) We will use <tt> for now. -->
  111. <xsl:template name="inline.monoseq">
  112. <xsl:param name="content">
  113. <xsl:call-template name="anchor"/>
  114. <xsl:call-template name="simple.xlink">
  115. <xsl:with-param name="content">
  116. <xsl:apply-templates/>
  117. </xsl:with-param>
  118. </xsl:call-template>
  119. </xsl:param>
  120. <tt class="{local-name(.)}">
  121. <xsl:if test="@dir">
  122. <xsl:attribute name="dir">
  123. <xsl:value-of select="@dir"/>
  124. </xsl:attribute>
  125. </xsl:if>
  126. <xsl:copy-of select="$content"/>
  127. </tt>
  128. </xsl:template>
  129. <xsl:template name="inline.boldmonoseq">
  130. <xsl:param name="content">
  131. <xsl:call-template name="anchor"/>
  132. <xsl:call-template name="simple.xlink">
  133. <xsl:with-param name="content">
  134. <xsl:apply-templates/>
  135. </xsl:with-param>
  136. </xsl:call-template>
  137. </xsl:param>
  138. <!-- don't put <strong> inside figure, example, or table titles -->
  139. <!-- or other titles that may already be represented with <strong>'s. -->
  140. <xsl:choose>
  141. <xsl:when test="local-name(..) = 'title' and (local-name(../..) = 'figure'
  142. or local-name(../..) = 'example' or local-name(../..) = 'table' or local-name(../..) = 'formalpara')">
  143. <tt class="{local-name(.)}">
  144. <xsl:if test="@dir">
  145. <xsl:attribute name="dir">
  146. <xsl:value-of select="@dir"/>
  147. </xsl:attribute>
  148. </xsl:if>
  149. <xsl:copy-of select="$content"/>
  150. </tt>
  151. </xsl:when>
  152. <xsl:otherwise>
  153. <strong class="{local-name(.)}">
  154. <tt>
  155. <xsl:if test="@dir">
  156. <xsl:attribute name="dir">
  157. <xsl:value-of select="@dir"/>
  158. </xsl:attribute>
  159. </xsl:if>
  160. <xsl:copy-of select="$content"/>
  161. </tt>
  162. </strong>
  163. </xsl:otherwise>
  164. </xsl:choose>
  165. </xsl:template>
  166. <xsl:template name="inline.italicmonoseq">
  167. <xsl:param name="content">
  168. <xsl:call-template name="anchor"/>
  169. <xsl:call-template name="simple.xlink">
  170. <xsl:with-param name="content">
  171. <xsl:apply-templates/>
  172. </xsl:with-param>
  173. </xsl:call-template>
  174. </xsl:param>
  175. <em class="{local-name(.)}">
  176. <tt>
  177. <xsl:if test="@dir">
  178. <xsl:attribute name="dir">
  179. <xsl:value-of select="@dir"/>
  180. </xsl:attribute>
  181. </xsl:if>
  182. <xsl:copy-of select="$content"/>
  183. </tt>
  184. </em>
  185. </xsl:template>
  186. </xsl:stylesheet>