callout.xsl 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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: callout.xsl 9305 2012-04-27 21:50:53Z bobstayton $
  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:call-template name="common.html.attributes"/>
  41. <xsl:call-template name="id.attribute"/>
  42. <xsl:call-template name="number.rtf.lines">
  43. <xsl:with-param name="rtf" select="$rtf-with-callouts"/>
  44. <xsl:with-param name="pi.context" select="programlisting|screen"/>
  45. </xsl:call-template>
  46. <xsl:apply-templates select="calloutlist"/>
  47. </div>
  48. </xsl:when>
  49. <xsl:otherwise>
  50. <div>
  51. <xsl:call-template name="common.html.attributes"/>
  52. <xsl:call-template name="id.attribute"/>
  53. <xsl:copy-of select="$rtf-with-callouts"/>
  54. <xsl:apply-templates select="calloutlist"/>
  55. </div>
  56. </xsl:otherwise>
  57. </xsl:choose>
  58. </xsl:when>
  59. <xsl:otherwise>
  60. <div>
  61. <xsl:apply-templates select="." mode="common.html.attributes"/>
  62. <xsl:call-template name="id.attribute"/>
  63. <xsl:apply-templates/>
  64. </div>
  65. </xsl:otherwise>
  66. </xsl:choose>
  67. </xsl:template>
  68. <xsl:template match="areaspec|areaset|area">
  69. </xsl:template>
  70. <xsl:template match="areaset" mode="conumber">
  71. <xsl:number count="area|areaset" format="1"/>
  72. </xsl:template>
  73. <xsl:template match="area" mode="conumber">
  74. <xsl:number count="area|areaset" format="1"/>
  75. </xsl:template>
  76. <xsl:template match="co" name="co">
  77. <!-- Support a single linkend in HTML -->
  78. <xsl:variable name="targets" select="key('id', @linkends)"/>
  79. <xsl:variable name="target" select="$targets[1]"/>
  80. <xsl:choose>
  81. <xsl:when test="$target">
  82. <a>
  83. <xsl:apply-templates select="." mode="common.html.attributes"/>
  84. <xsl:choose>
  85. <xsl:when test="$generate.id.attributes = 0">
  86. <!-- force an id attribute here -->
  87. <xsl:if test="@id or @xml:id">
  88. <xsl:attribute name="id">
  89. <xsl:value-of select="(@id|@xml:id)[1]"/>
  90. </xsl:attribute>
  91. </xsl:if>
  92. </xsl:when>
  93. <xsl:otherwise>
  94. <xsl:call-template name="id.attribute"/>
  95. </xsl:otherwise>
  96. </xsl:choose>
  97. <xsl:attribute name="href">
  98. <xsl:call-template name="href.target">
  99. <xsl:with-param name="object" select="$target"/>
  100. </xsl:call-template>
  101. </xsl:attribute>
  102. <xsl:apply-templates select="." mode="callout-bug"/>
  103. </a>
  104. </xsl:when>
  105. <xsl:otherwise>
  106. <xsl:if test="$generate.id.attributes != 0">
  107. <xsl:if test="@id or @xml:id">
  108. <span>
  109. <xsl:attribute name="id">
  110. <xsl:value-of select="(@id|@xml:id)[1]"/>
  111. </xsl:attribute>
  112. </span>
  113. </xsl:if>
  114. </xsl:if>
  115. <xsl:call-template name="anchor"/>
  116. <xsl:apply-templates select="." mode="callout-bug"/>
  117. </xsl:otherwise>
  118. </xsl:choose>
  119. </xsl:template>
  120. <xsl:template match="coref">
  121. <!-- tricky; this relies on the fact that we can process the "co" that's -->
  122. <!-- "over there" as if it were "right here" -->
  123. <xsl:variable name="co" select="key('id', @linkend)"/>
  124. <xsl:choose>
  125. <xsl:when test="not($co)">
  126. <xsl:message>
  127. <xsl:text>Error: coref link is broken: </xsl:text>
  128. <xsl:value-of select="@linkend"/>
  129. </xsl:message>
  130. </xsl:when>
  131. <xsl:when test="local-name($co) != 'co'">
  132. <xsl:message>
  133. <xsl:text>Error: coref doesn't point to a co: </xsl:text>
  134. <xsl:value-of select="@linkend"/>
  135. </xsl:message>
  136. </xsl:when>
  137. <xsl:otherwise>
  138. <xsl:apply-templates select="$co"/>
  139. </xsl:otherwise>
  140. </xsl:choose>
  141. </xsl:template>
  142. <xsl:template match="co" mode="callout-bug">
  143. <xsl:call-template name="callout-bug">
  144. <xsl:with-param name="conum">
  145. <xsl:number count="co" level="any" from="programlisting|screen|literallayout|synopsis" format="1"/>
  146. </xsl:with-param>
  147. </xsl:call-template>
  148. </xsl:template>
  149. <xsl:template name="callout-bug">
  150. <xsl:param name="conum" select="1"/>
  151. <xsl:choose>
  152. <xsl:when test="$callout.graphics != 0 and $conum &lt;= $callout.graphics.number.limit">
  153. <!-- Added span to make valid in XHTML 1 -->
  154. <span><img src="{$callout.graphics.path}{$conum}{$callout.graphics.extension}" alt="{$conum}"/></span>
  155. </xsl:when>
  156. <xsl:when test="$callout.unicode != 0 and $conum &lt;= $callout.unicode.number.limit">
  157. <xsl:choose>
  158. <xsl:when test="$callout.unicode.start.character = 10102">
  159. <xsl:choose>
  160. <xsl:when test="$conum = 1">&#10102;</xsl:when>
  161. <xsl:when test="$conum = 2">&#10103;</xsl:when>
  162. <xsl:when test="$conum = 3">&#10104;</xsl:when>
  163. <xsl:when test="$conum = 4">&#10105;</xsl:when>
  164. <xsl:when test="$conum = 5">&#10106;</xsl:when>
  165. <xsl:when test="$conum = 6">&#10107;</xsl:when>
  166. <xsl:when test="$conum = 7">&#10108;</xsl:when>
  167. <xsl:when test="$conum = 8">&#10109;</xsl:when>
  168. <xsl:when test="$conum = 9">&#10110;</xsl:when>
  169. <xsl:when test="$conum = 10">&#10111;</xsl:when>
  170. </xsl:choose>
  171. </xsl:when>
  172. <xsl:otherwise>
  173. <xsl:message>
  174. <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
  175. <xsl:text>when $callout.unicode.start.character is </xsl:text>
  176. <xsl:value-of select="$callout.unicode.start.character"/>
  177. </xsl:message>
  178. <xsl:text>(</xsl:text>
  179. <xsl:value-of select="$conum"/>
  180. <xsl:text>)</xsl:text>
  181. </xsl:otherwise>
  182. </xsl:choose>
  183. </xsl:when>
  184. <xsl:otherwise>
  185. <xsl:text>(</xsl:text>
  186. <xsl:value-of select="$conum"/>
  187. <xsl:text>)</xsl:text>
  188. </xsl:otherwise>
  189. </xsl:choose>
  190. </xsl:template>
  191. </xsl:stylesheet>