lfs-mixed.xsl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. <!-- Body attributes -->
  60. <xsl:template name="body.attributes">
  61. <xsl:attribute name="id">
  62. <xsl:text>lfs</xsl:text>
  63. </xsl:attribute>
  64. <xsl:attribute name="class">
  65. <xsl:value-of select="substring-after(/book/bookinfo/subtitle, ' ')"/>
  66. </xsl:attribute>
  67. </xsl:template>
  68. <!-- External URLs in italic font -->
  69. <xsl:template match="ulink" name="ulink">
  70. <a>
  71. <xsl:if test="@id">
  72. <xsl:attribute name="id">
  73. <xsl:value-of select="@id"/>
  74. </xsl:attribute>
  75. </xsl:if>
  76. <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
  77. <i>
  78. <xsl:choose>
  79. <xsl:when test="count(child::node())=0">
  80. <xsl:value-of select="@url"/>
  81. </xsl:when>
  82. <xsl:otherwise>
  83. <xsl:apply-templates/>
  84. </xsl:otherwise>
  85. </xsl:choose>
  86. </i>
  87. </a>
  88. </xsl:template>
  89. <!-- The <code> xhtml tag have look issues in some browsers, like Konqueror and.
  90. isn't semantically correct (a filename isn't a code fragment) We will use <tt> for now. -->
  91. <xsl:template name="inline.monoseq">
  92. <xsl:param name="content">
  93. <xsl:call-template name="anchor"/>
  94. <xsl:call-template name="simple.xlink">
  95. <xsl:with-param name="content">
  96. <xsl:apply-templates/>
  97. </xsl:with-param>
  98. </xsl:call-template>
  99. </xsl:param>
  100. <tt class="{local-name(.)}">
  101. <xsl:if test="@dir">
  102. <xsl:attribute name="dir">
  103. <xsl:value-of select="@dir"/>
  104. </xsl:attribute>
  105. </xsl:if>
  106. <xsl:copy-of select="$content"/>
  107. </tt>
  108. </xsl:template>
  109. <xsl:template name="inline.boldmonoseq">
  110. <xsl:param name="content">
  111. <xsl:call-template name="anchor"/>
  112. <xsl:call-template name="simple.xlink">
  113. <xsl:with-param name="content">
  114. <xsl:apply-templates/>
  115. </xsl:with-param>
  116. </xsl:call-template>
  117. </xsl:param>
  118. <!-- don't put <strong> inside figure, example, or table titles -->
  119. <!-- or other titles that may already be represented with <strong>'s. -->
  120. <xsl:choose>
  121. <xsl:when test="local-name(..) = 'title' and (local-name(../..) = 'figure'
  122. or local-name(../..) = 'example' or local-name(../..) = 'table' or local-name(../..) = 'formalpara')">
  123. <tt class="{local-name(.)}">
  124. <xsl:if test="@dir">
  125. <xsl:attribute name="dir">
  126. <xsl:value-of select="@dir"/>
  127. </xsl:attribute>
  128. </xsl:if>
  129. <xsl:copy-of select="$content"/>
  130. </tt>
  131. </xsl:when>
  132. <xsl:otherwise>
  133. <strong class="{local-name(.)}">
  134. <tt>
  135. <xsl:if test="@dir">
  136. <xsl:attribute name="dir">
  137. <xsl:value-of select="@dir"/>
  138. </xsl:attribute>
  139. </xsl:if>
  140. <xsl:copy-of select="$content"/>
  141. </tt>
  142. </strong>
  143. </xsl:otherwise>
  144. </xsl:choose>
  145. </xsl:template>
  146. <xsl:template name="inline.italicmonoseq">
  147. <xsl:param name="content">
  148. <xsl:call-template name="anchor"/>
  149. <xsl:call-template name="simple.xlink">
  150. <xsl:with-param name="content">
  151. <xsl:apply-templates/>
  152. </xsl:with-param>
  153. </xsl:call-template>
  154. </xsl:param>
  155. <em class="{local-name(.)}">
  156. <tt>
  157. <xsl:if test="@dir">
  158. <xsl:attribute name="dir">
  159. <xsl:value-of select="@dir"/>
  160. </xsl:attribute>
  161. </xsl:if>
  162. <xsl:copy-of select="$content"/>
  163. </tt>
  164. </em>
  165. </xsl:template>
  166. </xsl:stylesheet>