lfs-mixed.xsl 5.1 KB

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