2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:d="http://docbook.org/ns/docbook"
4 xmlns:fo="http://www.w3.org/1999/XSL/Format"
5 xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
6 xmlns:xverb="com.nwalsh.xalan.Verbatim"
7 xmlns:lxslt="http://xml.apache.org/xslt"
8 exclude-result-prefixes="sverb xverb lxslt d"
11 <!-- ********************************************************************
13 This file is part of the XSL DocBook Stylesheet distribution.
14 See ../README or http://cdn.docbook.org/release/xsl/current/ for
15 copyright and other information.
17 ******************************************************************** -->
19 <lxslt:component prefix="xverb"
20 functions="insertCallouts"/>
22 <xsl:template match="d:programlistingco|d:screenco">
23 <xsl:variable name="verbatim" select="d:programlisting|d:screen"/>
24 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
27 <xsl:when test="$use.extensions != '0'
28 and $callouts.extension != '0'">
29 <xsl:variable name="rtf">
30 <xsl:apply-templates select="$verbatim">
31 <xsl:with-param name="suppress-numbers" select="'1'"/>
32 </xsl:apply-templates>
35 <xsl:variable name="rtf-with-callouts">
37 <xsl:when test="contains($vendor, 'SAXON ')">
38 <xsl:copy-of select="sverb:insertCallouts(d:areaspec,$rtf)"/>
40 <xsl:when test="contains($vendor, 'Apache Software Foundation')">
41 <xsl:copy-of select="xverb:insertCallouts(d:areaspec,$rtf)"/>
44 <xsl:message terminate="yes">
45 <xsl:text>Don't know how to do callouts with </xsl:text>
46 <xsl:value-of select="$vendor"/>
53 <xsl:when test="$verbatim/@linenumbering = 'numbered'
54 and $linenumbering.extension != '0'">
55 <xsl:call-template name="number.rtf.lines">
56 <xsl:with-param name="rtf" select="$rtf-with-callouts"/>
57 <xsl:with-param name="pi.context"
58 select="d:programlisting|d:screen"/>
60 <xsl:apply-templates select="d:calloutlist"/>
63 <xsl:copy-of select="$rtf-with-callouts"/>
64 <xsl:apply-templates select="d:calloutlist"/>
69 <xsl:apply-templates/>
74 <xsl:template match="d:areaspec|d:areaset|d:area">
77 <xsl:template match="d:areaset" mode="conumber">
78 <xsl:number count="d:area|d:areaset" format="1"/>
81 <xsl:template match="d:area" mode="conumber">
82 <xsl:number count="d:area|d:areaset" format="1"/>
85 <xsl:template match="d:co">
86 <xsl:param name="coref"/>
87 <!-- link to the callout? -->
88 <xsl:variable name="linkend">
90 <!-- if more than one target, choose the first -->
91 <xsl:when test="contains(normalize-space(@linkends), ' ')">
92 <xsl:value-of select="substring-before(normalize-space(@linkends), ' ')"/>
94 <xsl:when test="string-length(normalize-space(@linkends)) != 0">
95 <xsl:value-of select="normalize-space(@linkends)"/>
103 <xsl:when test="string-length($linkend) != 0">
104 <fo:basic-link internal-destination="{$linkend}">
106 <xsl:when test="$coref">
107 <xsl:call-template name="anchor">
108 <xsl:with-param name="node" select="$coref"/>
109 <xsl:with-param name="conditional" select="0"/>
113 <xsl:call-template name="anchor">
114 <xsl:with-param name="conditional" select="0"/>
118 <xsl:apply-templates select="." mode="callout-bug"/>
124 <xsl:when test="$coref">
125 <xsl:call-template name="anchor">
126 <xsl:with-param name="node" select="$coref"/>
127 <xsl:with-param name="conditional" select="0"/>
131 <xsl:call-template name="anchor">
132 <xsl:with-param name="conditional" select="0"/>
136 <xsl:apply-templates select="." mode="callout-bug"/>
142 <xsl:template match="d:coref">
143 <!-- this relies on the fact that we can process the "co" that's -->
144 <!-- "over there" as if it were "right here" -->
146 <xsl:variable name="co" select="key('id', @linkend)"/>
148 <xsl:when test="not($co)">
150 <xsl:text>Error: coref link is broken: </xsl:text>
151 <xsl:value-of select="@linkend"/>
154 <xsl:when test="local-name($co) != 'co'">
156 <xsl:text>Error: coref doesn't point to a co: </xsl:text>
157 <xsl:value-of select="@linkend"/>
161 <!-- process it as if it were the co itself -->
162 <xsl:apply-templates select="$co">
163 <xsl:with-param name="coref" select="."/>
164 </xsl:apply-templates>
169 <xsl:template match="d:co" mode="callout-bug">
170 <xsl:call-template name="callout-bug">
171 <xsl:with-param name="conum">
172 <xsl:number count="d:co"
174 from="d:programlisting|d:screen|d:literallayout|d:synopsis"
180 <xsl:template name="callout-bug">
181 <xsl:param name="conum" select='1'/>
184 <!-- Draw callouts as images -->
185 <xsl:when test="$callout.graphics != '0'
186 and $conum <= $callout.graphics.number.limit">
187 <xsl:variable name="filename"
188 select="concat($callout.graphics.path, $conum,
189 $callout.graphics.extension)"/>
191 <fo:external-graphic content-width="{$callout.icon.size}"
192 width="{$callout.icon.size}">
193 <xsl:attribute name="src">
195 <xsl:when test="$fop.extensions != 0
196 or $arbortext.extensions != 0">
197 <xsl:value-of select="$filename"/>
200 <xsl:text>url(</xsl:text>
201 <xsl:value-of select="$filename"/>
202 <xsl:text>)</xsl:text>
206 </fo:external-graphic>
209 <xsl:when test="$callout.unicode != 0
210 and $conum <= $callout.unicode.number.limit">
211 <xsl:variable name="comarkup">
213 <xsl:when test="$callout.unicode.start.character = 10102">
215 <xsl:when test="$conum = 1">❶</xsl:when>
216 <xsl:when test="$conum = 2">❷</xsl:when>
217 <xsl:when test="$conum = 3">❸</xsl:when>
218 <xsl:when test="$conum = 4">❹</xsl:when>
219 <xsl:when test="$conum = 5">❺</xsl:when>
220 <xsl:when test="$conum = 6">❻</xsl:when>
221 <xsl:when test="$conum = 7">❼</xsl:when>
222 <xsl:when test="$conum = 8">❽</xsl:when>
223 <xsl:when test="$conum = 9">❾</xsl:when>
224 <xsl:when test="$conum = 10">❿</xsl:when>
225 <xsl:when test="$conum = 11">⓫</xsl:when>
226 <xsl:when test="$conum = 12">⓬</xsl:when>
227 <xsl:when test="$conum = 13">⓭</xsl:when>
228 <xsl:when test="$conum = 14">⓮</xsl:when>
229 <xsl:when test="$conum = 15">⓯</xsl:when>
230 <xsl:when test="$conum = 16">⓰</xsl:when>
231 <xsl:when test="$conum = 17">⓱</xsl:when>
232 <xsl:when test="$conum = 18">⓲</xsl:when>
233 <xsl:when test="$conum = 19">⓳</xsl:when>
234 <xsl:when test="$conum = 20">⓴</xsl:when>
237 <xsl:when test="$callout.unicode.start.character = 9312">
239 <xsl:when test="$conum = 1">①</xsl:when>
240 <xsl:when test="$conum = 2">②</xsl:when>
241 <xsl:when test="$conum = 3">③</xsl:when>
242 <xsl:when test="$conum = 4">④</xsl:when>
243 <xsl:when test="$conum = 5">⑤</xsl:when>
244 <xsl:when test="$conum = 6">⑥</xsl:when>
245 <xsl:when test="$conum = 7">⑦</xsl:when>
246 <xsl:when test="$conum = 8">⑧</xsl:when>
247 <xsl:when test="$conum = 9">⑨</xsl:when>
248 <xsl:when test="$conum = 10">⑩</xsl:when>
249 <xsl:when test="$conum = 11">⑪</xsl:when>
250 <xsl:when test="$conum = 12">⑫</xsl:when>
251 <xsl:when test="$conum = 13">⑬</xsl:when>
252 <xsl:when test="$conum = 14">⑭</xsl:when>
253 <xsl:when test="$conum = 15">⑮</xsl:when>
254 <xsl:when test="$conum = 16">⑯</xsl:when>
255 <xsl:when test="$conum = 17">⑰</xsl:when>
256 <xsl:when test="$conum = 18">⑱</xsl:when>
257 <xsl:when test="$conum = 19">⑲</xsl:when>
258 <xsl:when test="$conum = 20">⑳</xsl:when>
263 <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
264 <xsl:text>when $callout.unicode.start.character is </xsl:text>
265 <xsl:value-of select="$callout.unicode.start.character"/>
267 <fo:inline background-color="#404040"
270 padding-bottom="0.1em"
271 padding-start="0.2em"
273 baseline-shift="0.1em"
274 font-family="{$body.fontset}"
277 <xsl:value-of select="$conum"/>
284 <xsl:when test="$callout.unicode.font != ''">
285 <fo:inline font-family="{$callout.unicode.font}">
286 <xsl:copy-of select="$comarkup"/>
290 <xsl:copy-of select="$comarkup"/>
295 <!-- Most safe: draw a dark gray square with a white number inside -->
297 <fo:inline background-color="#404040"
300 padding-bottom="0.1em"
301 padding-start="0.2em"
303 baseline-shift="0.1em"
304 font-family="{$body.fontset}"
307 <xsl:value-of select="$conum"/>