lfs-mixed.xsl 5.4 KB

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