callout.xsl 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim" xmlns:xverb="xalan://com.nwalsh.xalan.Verbatim" xmlns:lxslt="http://xml.apache.org/xslt" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="sverb xverb lxslt" version="1.0">
  5. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <lxslt:component prefix="xverb" functions="insertCallouts"/>
  13. <xsl:template match="programlistingco|screenco">
  14. <xsl:variable name="verbatim" select="programlisting|screen"/>
  15. <xsl:choose>
  16. <xsl:when test="$use.extensions != '0' and $callouts.extension != '0'">
  17. <xsl:variable name="rtf">
  18. <xsl:apply-templates select="$verbatim">
  19. <xsl:with-param name="suppress-numbers" select="'1'"/>
  20. </xsl:apply-templates>
  21. </xsl:variable>
  22. <xsl:variable name="rtf-with-callouts">
  23. <xsl:choose>
  24. <xsl:when test="function-available('sverb:insertCallouts')">
  25. <xsl:copy-of select="sverb:insertCallouts(areaspec,$rtf)"/>
  26. </xsl:when>
  27. <xsl:when test="function-available('xverb:insertCallouts')">
  28. <xsl:copy-of select="xverb:insertCallouts(areaspec,$rtf)"/>
  29. </xsl:when>
  30. <xsl:otherwise>
  31. <xsl:message terminate="yes">
  32. <xsl:text>No insertCallouts function is available.</xsl:text>
  33. </xsl:message>
  34. </xsl:otherwise>
  35. </xsl:choose>
  36. </xsl:variable>
  37. <xsl:choose>
  38. <xsl:when test="$verbatim/@linenumbering = 'numbered' and $linenumbering.extension != '0'">
  39. <div>
  40. <xsl:apply-templates select="." mode="class.attribute"/>
  41. <xsl:call-template name="number.rtf.lines">
  42. <xsl:with-param name="rtf" select="$rtf-with-callouts"/>
  43. <xsl:with-param name="pi.context" select="programlisting|screen"/>
  44. </xsl:call-template>
  45. <xsl:apply-templates select="calloutlist"/>
  46. </div>
  47. </xsl:when>
  48. <xsl:otherwise>
  49. <div>
  50. <xsl:apply-templates select="." mode="class.attribute"/>
  51. <xsl:copy-of select="$rtf-with-callouts"/>
  52. <xsl:apply-templates select="calloutlist"/>
  53. </div>
  54. </xsl:otherwise>
  55. </xsl:choose>
  56. </xsl:when>
  57. <xsl:otherwise>
  58. <div>
  59. <xsl:apply-templates select="." mode="class.attribute"/>
  60. <xsl:apply-templates/>
  61. </div>
  62. </xsl:otherwise>
  63. </xsl:choose>
  64. </xsl:template>
  65. <xsl:template match="areaspec|areaset|area">
  66. </xsl:template>
  67. <xsl:template match="areaset" mode="conumber">
  68. <xsl:number count="area|areaset" format="1"/>
  69. </xsl:template>
  70. <xsl:template match="area" mode="conumber">
  71. <xsl:number count="area|areaset" format="1"/>
  72. </xsl:template>
  73. <xsl:template match="co" name="co">
  74. <!-- Support a single linkend in HTML -->
  75. <xsl:variable name="targets" select="key('id', @linkends)"/>
  76. <xsl:variable name="target" select="$targets[1]"/>
  77. <xsl:choose>
  78. <xsl:when test="$target">
  79. <a>
  80. <xsl:apply-templates select="." mode="class.attribute"/>
  81. <xsl:if test="@id or @xml:id">
  82. <xsl:attribute name="id">
  83. <xsl:value-of select="(@id|@xml:id)[1]"/>
  84. </xsl:attribute>
  85. </xsl:if>
  86. <xsl:attribute name="href">
  87. <xsl:call-template name="href.target">
  88. <xsl:with-param name="object" select="$target"/>
  89. </xsl:call-template>
  90. </xsl:attribute>
  91. <xsl:apply-templates select="." mode="callout-bug"/>
  92. </a>
  93. </xsl:when>
  94. <xsl:otherwise>
  95. <xsl:call-template name="anchor"/>
  96. <xsl:apply-templates select="." mode="callout-bug"/>
  97. </xsl:otherwise>
  98. </xsl:choose>
  99. </xsl:template>
  100. <xsl:template match="coref">
  101. <!-- tricky; this relies on the fact that we can process the "co" that's -->
  102. <!-- "over there" as if it were "right here" -->
  103. <xsl:variable name="co" select="key('id', @linkend)"/>
  104. <xsl:choose>
  105. <xsl:when test="not($co)">
  106. <xsl:message>
  107. <xsl:text>Error: coref link is broken: </xsl:text>
  108. <xsl:value-of select="@linkend"/>
  109. </xsl:message>
  110. </xsl:when>
  111. <xsl:when test="local-name($co) != 'co'">
  112. <xsl:message>
  113. <xsl:text>Error: coref doesn't point to a co: </xsl:text>
  114. <xsl:value-of select="@linkend"/>
  115. </xsl:message>
  116. </xsl:when>
  117. <xsl:otherwise>
  118. <xsl:apply-templates select="$co"/>
  119. </xsl:otherwise>
  120. </xsl:choose>
  121. </xsl:template>
  122. <xsl:template match="co" mode="callout-bug">
  123. <xsl:call-template name="callout-bug">
  124. <xsl:with-param name="conum">
  125. <xsl:number count="co" level="any" from="programlisting|screen|literallayout|synopsis" format="1"/>
  126. </xsl:with-param>
  127. </xsl:call-template>
  128. </xsl:template>
  129. <xsl:template name="callout-bug">
  130. <xsl:param name="conum" select="1"/>
  131. <xsl:choose>
  132. <xsl:when test="$callout.graphics != 0 and $conum &lt;= $callout.graphics.number.limit">
  133. <img src="{$callout.graphics.path}{$conum}{$callout.graphics.extension}" alt="{$conum}" border="0"/>
  134. </xsl:when>
  135. <xsl:when test="$callout.unicode != 0 and $conum &lt;= $callout.unicode.number.limit">
  136. <xsl:choose>
  137. <xsl:when test="$callout.unicode.start.character = 10102">
  138. <xsl:choose>
  139. <xsl:when test="$conum = 1">&#10102;</xsl:when>
  140. <xsl:when test="$conum = 2">&#10103;</xsl:when>
  141. <xsl:when test="$conum = 3">&#10104;</xsl:when>
  142. <xsl:when test="$conum = 4">&#10105;</xsl:when>
  143. <xsl:when test="$conum = 5">&#10106;</xsl:when>
  144. <xsl:when test="$conum = 6">&#10107;</xsl:when>
  145. <xsl:when test="$conum = 7">&#10108;</xsl:when>
  146. <xsl:when test="$conum = 8">&#10109;</xsl:when>
  147. <xsl:when test="$conum = 9">&#10110;</xsl:when>
  148. <xsl:when test="$conum = 10">&#10111;</xsl:when>
  149. </xsl:choose>
  150. </xsl:when>
  151. <xsl:otherwise>
  152. <xsl:message>
  153. <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
  154. <xsl:text>when $callout.unicode.start.character is </xsl:text>
  155. <xsl:value-of select="$callout.unicode.start.character"/>
  156. </xsl:message>
  157. <xsl:text>(</xsl:text>
  158. <xsl:value-of select="$conum"/>
  159. <xsl:text>)</xsl:text>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. </xsl:when>
  163. <xsl:otherwise>
  164. <xsl:text>(</xsl:text>
  165. <xsl:value-of select="$conum"/>
  166. <xsl:text>)</xsl:text>
  167. </xsl:otherwise>
  168. </xsl:choose>
  169. </xsl:template>
  170. </xsl:stylesheet>