Debian Codegraph @

docbook-xsl-ns/html/callout.xsl

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