1 | <?xml version='1.0'?>
|
---|
2 | <!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
|
---|
3 | <!--#############################################################################
|
---|
4 | | $Id: callout.mod.xsl,v 1.10 2004/01/14 14:54:32 j-devenish Exp $
|
---|
5 | |- #############################################################################
|
---|
6 | | $Author: j-devenish $
|
---|
7 | + ############################################################################## -->
|
---|
8 |
|
---|
9 | <xsl:stylesheet
|
---|
10 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
11 | xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
|
---|
12 | exclude-result-prefixes="doc" version='1.0'>
|
---|
13 |
|
---|
14 | <doc:reference id="callout" xmlns="">
|
---|
15 | <referenceinfo>
|
---|
16 | <releaseinfo role="meta">
|
---|
17 | $Id: callout.mod.xsl,v 1.10 2004/01/14 14:54:32 j-devenish Exp $
|
---|
18 | </releaseinfo>
|
---|
19 | <authorgroup>
|
---|
20 | &ramon;
|
---|
21 | &james;
|
---|
22 | </authorgroup>
|
---|
23 | <copyright>
|
---|
24 | <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
|
---|
25 | <holder>Ramon Casellas</holder>
|
---|
26 | </copyright>
|
---|
27 | <revhistory>
|
---|
28 | <doc:revision rcasver="1.5">&rev_2003_05;</doc:revision>
|
---|
29 | <doc:revision rcasver="1.6">
|
---|
30 | <date>January 2004</date>
|
---|
31 | <revremark>Added callout support.</revremark>
|
---|
32 | </doc:revision>
|
---|
33 | </revhistory>
|
---|
34 | </referenceinfo>
|
---|
35 | <title>Callouts <filename>callout.mod.xsl</filename></title>
|
---|
36 | <partintro>
|
---|
37 | <para>
|
---|
38 |
|
---|
39 | These template use the concept of an <quote>areamark</quote>, an
|
---|
40 | <quote>arearef</quote> and an <quote>areasymbol</quote>. An areamark
|
---|
41 | is a way of illustrating a callout area as part of an image or
|
---|
42 | listing. An arearef is a way of illustrating a callout area as part of
|
---|
43 | a callout list. By default, the areamark and the arearef are both
|
---|
44 | represented by the areasymbol. (Aside: that the areamark is drawn
|
---|
45 | first.) This system allows opens the possibility for an areamark to
|
---|
46 | draw a box around an area in addition to displaying the areasymbol.
|
---|
47 |
|
---|
48 | </para>
|
---|
49 | </partintro>
|
---|
50 | </doc:reference>
|
---|
51 |
|
---|
52 | <doc:template xmlns="">
|
---|
53 | <refpurpose> Essential preamble for <filename>callout.mod.xsl</filename> support </refpurpose>
|
---|
54 | <doc:description>
|
---|
55 | <para>
|
---|
56 |
|
---|
57 | Loads the <productname>overpic</productname> packages and
|
---|
58 | defines <function condition="latex">calsscale</function>
|
---|
59 | and <function condition="latex">calspair</function> (which
|
---|
60 | are used to convert <quote>calspair</quote> coordinates into
|
---|
61 | <productname>overpic</productname> percent-style coordinates.
|
---|
62 |
|
---|
63 | </para>
|
---|
64 | </doc:description>
|
---|
65 | <doc:variables>
|
---|
66 | <variablelist>
|
---|
67 | <varlistentry>
|
---|
68 | <term><xref linkend="param.latex.use.overpic"/></term>
|
---|
69 | <listitem><simpara>
|
---|
70 | Whether to enable this preamble or not.
|
---|
71 | If 0, callouts will cause &LaTeX; errors.
|
---|
72 | </simpara></listitem>
|
---|
73 | </varlistentry>
|
---|
74 | </variablelist>
|
---|
75 | </doc:variables>
|
---|
76 | <doc:seealso>
|
---|
77 | <itemizedlist>
|
---|
78 | <listitem><simpara>&preamble;</simpara></listitem>
|
---|
79 | </itemizedlist>
|
---|
80 | </doc:seealso>
|
---|
81 | </doc:template>
|
---|
82 | <xsl:template name="latex.preamble.essential.callout">
|
---|
83 | <xsl:if test="$latex.use.overpic=1 and //callout">
|
---|
84 | <xsl:text>
|
---|
85 | <![CDATA[
|
---|
86 | \usepackage[percent]{overpic}
|
---|
87 | \newdimen\dblatex@ascale \newdimen\dblatex@bscale
|
---|
88 | \newdimen\dblatex@adimen \newdimen\dblatex@bdimen
|
---|
89 | \newdimen\dblatex@cdimen \newdimen\dblatex@ddimen
|
---|
90 | \newcommand{\calsscale}{%
|
---|
91 | \ifnum\@tempcnta>\@tempcntb%
|
---|
92 | \dblatex@ascale=1pt%
|
---|
93 | \dblatex@bscale=\@tempcntb pt%
|
---|
94 | \divide\dblatex@bscale by \@tempcnta%
|
---|
95 | \else%
|
---|
96 | \dblatex@bscale=1 pt%
|
---|
97 | \dblatex@ascale=\@tempcnta pt%
|
---|
98 | \divide\dblatex@ascale by \@tempcntb%
|
---|
99 | \fi%
|
---|
100 | }
|
---|
101 | \newcommand{\calspair}[3]{
|
---|
102 | \sbox{\z@}{#3}
|
---|
103 | \settowidth{\dblatex@cdimen}{\usebox{\z@}}
|
---|
104 | \settoheight{\dblatex@ddimen}{\usebox{\z@}}
|
---|
105 | \divide\dblatex@cdimen by 2
|
---|
106 | \divide\dblatex@ddimen by 2
|
---|
107 | \dblatex@adimen=#1 pt \dblatex@adimen=\strip@pt\dblatex@ascale\dblatex@adimen
|
---|
108 | \dblatex@bdimen=#2 pt \dblatex@bdimen=\strip@pt\dblatex@bscale\dblatex@bdimen
|
---|
109 | \put(\strip@pt\dblatex@adimen,\strip@pt\dblatex@bdimen){\hspace{-\dblatex@cdimen}\raisebox{-\dblatex@ddimen}{\usebox{\z@}}}
|
---|
110 | }
|
---|
111 | ]]>
|
---|
112 | </xsl:text>
|
---|
113 | </xsl:if>
|
---|
114 | </xsl:template>
|
---|
115 |
|
---|
116 | <doc:template xmlns="">
|
---|
117 | <refpurpose>Process <doc:db>programlistingco</doc:db> and <doc:db>screenco</doc:db> elements</refpurpose>
|
---|
118 | <doc:description>
|
---|
119 | <para>
|
---|
120 | Applies templates.
|
---|
121 | </para>
|
---|
122 | </doc:description>
|
---|
123 | <doc:variables>
|
---|
124 | &no_var;
|
---|
125 | </doc:variables>
|
---|
126 | </doc:template>
|
---|
127 | <xsl:template match="programlistingco|screenco">
|
---|
128 | <xsl:apply-templates select="programlisting|screen|calloutlist"/>
|
---|
129 | </xsl:template>
|
---|
130 |
|
---|
131 | <doc:template xmlns="">
|
---|
132 | <refpurpose>Process <doc:db>areaset</doc:db>-related elements</refpurpose>
|
---|
133 | <doc:description>
|
---|
134 | <para>
|
---|
135 | Suppressed (<doc:db>area</doc:db> templates are applied by
|
---|
136 | <xref linkend="template.imagedata"/>).
|
---|
137 | </para>
|
---|
138 | </doc:description>
|
---|
139 | <doc:variables>
|
---|
140 | &no_var;
|
---|
141 | </doc:variables>
|
---|
142 | </doc:template>
|
---|
143 | <xsl:template match="areaspec|areaset"/>
|
---|
144 |
|
---|
145 | <doc:template xmlns="">
|
---|
146 | <refpurpose>Process <doc:db>co</doc:db>-related elements</refpurpose>
|
---|
147 | <doc:description>
|
---|
148 | <para>
|
---|
149 | Print a callout number as a parenthesis.
|
---|
150 | </para>
|
---|
151 | </doc:description>
|
---|
152 | <doc:variables>
|
---|
153 | &no_var;
|
---|
154 | </doc:variables>
|
---|
155 | <doc:notes>
|
---|
156 | <para>This template is probably never applied, because
|
---|
157 | we can't yet handled <doc:db basename="co">cos</doc:db>
|
---|
158 | in verbatim environments.</para>
|
---|
159 | </doc:notes>
|
---|
160 | </doc:template>
|
---|
161 | <xsl:template match="co">
|
---|
162 | <xsl:variable name="conum">
|
---|
163 | <xsl:number count="co" format="1"/>
|
---|
164 | </xsl:variable>
|
---|
165 | <xsl:text>(</xsl:text>
|
---|
166 | <xsl:value-of select="$conum"/>
|
---|
167 | <xsl:text>)</xsl:text>
|
---|
168 | </xsl:template>
|
---|
169 |
|
---|
170 | <doc:template xmlns="">
|
---|
171 | <refpurpose>Process <doc:db>calloutlist</doc:db> elements</refpurpose>
|
---|
172 | <doc:description>
|
---|
173 | <para>
|
---|
174 | Applies templates.
|
---|
175 | </para>
|
---|
176 | </doc:description>
|
---|
177 | <doc:variables>
|
---|
178 | &no_var;
|
---|
179 | </doc:variables>
|
---|
180 | </doc:template>
|
---|
181 | <xsl:template match="calloutlist">
|
---|
182 | <xsl:apply-templates select="./title"/>
|
---|
183 | <xsl:text> \begin{description} </xsl:text>
|
---|
184 | <xsl:apply-templates select="callout"/>
|
---|
185 | <xsl:text>\end{description} </xsl:text>
|
---|
186 | </xsl:template>
|
---|
187 |
|
---|
188 | <doc:template xmlns="">
|
---|
189 | <refpurpose>Process titles for <doc:db>calloutlist</doc:db> elements</refpurpose>
|
---|
190 | <doc:description>
|
---|
191 | <para>
|
---|
192 |
|
---|
193 | Formats a title.
|
---|
194 |
|
---|
195 | </para>
|
---|
196 | </doc:description>
|
---|
197 | <doc:variables>
|
---|
198 | <variablelist>
|
---|
199 | <varlistentry>
|
---|
200 | <term><xref linkend="param.latex.list.title.style"/></term>
|
---|
201 | <listitem><simpara>
|
---|
202 | The &LaTeX; command for formatting titles.
|
---|
203 | </simpara></listitem>
|
---|
204 | </varlistentry>
|
---|
205 | </variablelist>
|
---|
206 | </doc:variables>
|
---|
207 | <doc:params>
|
---|
208 | <variablelist>
|
---|
209 | <varlistentry>
|
---|
210 | <term>style</term>
|
---|
211 | <listitem><simpara>The &LaTeX; command to use. Defaults to
|
---|
212 | <xref linkend="param.latex.list.title.style"/>.</simpara></listitem>
|
---|
213 | </varlistentry>
|
---|
214 | </variablelist>
|
---|
215 | </doc:params>
|
---|
216 | <doc:notes>
|
---|
217 | <para>
|
---|
218 | Applies templates as a paragraph, formatted with the specified style.
|
---|
219 | </para>
|
---|
220 | </doc:notes>
|
---|
221 | </doc:template>
|
---|
222 | <xsl:template match="calloutlist/title">
|
---|
223 | <xsl:param name="style" select="$latex.list.title.style"/>
|
---|
224 | <xsl:text> {</xsl:text>
|
---|
225 | <xsl:value-of select="$style"/>
|
---|
226 | <xsl:text>{</xsl:text>
|
---|
227 | <xsl:apply-templates/>
|
---|
228 | <xsl:text>}} </xsl:text>
|
---|
229 | </xsl:template>
|
---|
230 |
|
---|
231 | <doc:template basename="callout" xmlns="">
|
---|
232 | <refpurpose>Process <doc:db>callout</doc:db> elements</refpurpose>
|
---|
233 | <doc:description>
|
---|
234 | <para>
|
---|
235 | Formats arearefs as an <function condition="latex">item</function>,
|
---|
236 | then applies templates. Since there may be multiple IDs specified
|
---|
237 | in the <sgmltag class="attribute">arearefs</sgmltag> attribute,
|
---|
238 | the <xref linkend="template.generate.callout.arearefs"/> template is
|
---|
239 | called recursively to generate the arearefs.
|
---|
240 | </para>
|
---|
241 | </doc:description>
|
---|
242 | <doc:variables>
|
---|
243 | &no_var;
|
---|
244 | </doc:variables>
|
---|
245 | </doc:template>
|
---|
246 | <xsl:template match="callout">
|
---|
247 | <xsl:text>\item[{</xsl:text>
|
---|
248 | <xsl:call-template name="generate.callout.arearefs"/>
|
---|
249 | <xsl:text>}]\null{} </xsl:text>
|
---|
250 | <xsl:apply-templates/>
|
---|
251 | <xsl:text> </xsl:text>
|
---|
252 | </xsl:template>
|
---|
253 |
|
---|
254 | <doc:template xmlns="">
|
---|
255 | <refpurpose>Determine a <doc:db>callout</doc:db>'s arearefs</refpurpose>
|
---|
256 | <doc:description>
|
---|
257 | <para>
|
---|
258 | Splits the arearef attribute on whitespace, then
|
---|
259 | constructs a list of references by applying templates
|
---|
260 | in <quote>generate.callout.arearef</quote> mode.
|
---|
261 | </para>
|
---|
262 | </doc:description>
|
---|
263 | <doc:variables>
|
---|
264 | &no_var;
|
---|
265 | </doc:variables>
|
---|
266 | <doc:notes>
|
---|
267 | <para>
|
---|
268 | The current node must be a <doc:db>callout</doc:db>.
|
---|
269 | </para>
|
---|
270 | </doc:notes>
|
---|
271 | </doc:template>
|
---|
272 | <xsl:template name="generate.callout.arearefs">
|
---|
273 | <xsl:param name="arearefs" select="normalize-space(@arearefs)"/>
|
---|
274 | <xsl:param name="count" select="1"/>
|
---|
275 | <xsl:if test="$arearefs!=''">
|
---|
276 | <xsl:choose>
|
---|
277 | <xsl:when test="substring-before($arearefs,' ')=''">
|
---|
278 | <xsl:apply-templates select="." mode="generate.callout.arearef">
|
---|
279 | <xsl:with-param name="arearef" select="$arearefs"/>
|
---|
280 | <xsl:with-param name="count" select="$count"/>
|
---|
281 | <xsl:with-param name="last" select="true()"/>
|
---|
282 | </xsl:apply-templates>
|
---|
283 | </xsl:when>
|
---|
284 | <xsl:otherwise>
|
---|
285 | <xsl:apply-templates select="." mode="generate.callout.arearef">
|
---|
286 | <xsl:with-param name="arearef" select="substring-before($arearefs,' ')"/>
|
---|
287 | <xsl:with-param name="count" select="$count"/>
|
---|
288 | <xsl:with-param name="last" select="false()"/>
|
---|
289 | </xsl:apply-templates>
|
---|
290 | </xsl:otherwise>
|
---|
291 | </xsl:choose>
|
---|
292 | <xsl:call-template name="generate.callout.arearefs">
|
---|
293 | <xsl:with-param name="arearefs" select="substring-after($arearefs,' ')"/>
|
---|
294 | <xsl:with-param name="count" select="$count + 1"/>
|
---|
295 | </xsl:call-template>
|
---|
296 | </xsl:if>
|
---|
297 | </xsl:template>
|
---|
298 |
|
---|
299 | <doc:template xmlns="">
|
---|
300 | <refpurpose>Format a <doc:db>callout</doc:db>'s arearefs</refpurpose>
|
---|
301 | <doc:description>
|
---|
302 | <para>
|
---|
303 | Applies templates in <quote>generate.callout.arearef</quote> mode.
|
---|
304 | </para>
|
---|
305 | </doc:description>
|
---|
306 | <doc:variables>
|
---|
307 | &no_var;
|
---|
308 | </doc:variables>
|
---|
309 | <doc:params>
|
---|
310 | <variablelist>
|
---|
311 | <varlistentry>
|
---|
312 | <term>arearef</term>
|
---|
313 | <listitem><simpara>
|
---|
314 | The ID of the <doc:db>area</doc:db> to which a <doc:db>callout</doc:db>
|
---|
315 | refers.
|
---|
316 | </simpara></listitem>
|
---|
317 | </varlistentry>
|
---|
318 | <varlistentry>
|
---|
319 | <term>area</term>
|
---|
320 | <listitem><simpara>
|
---|
321 | The <doc:db>area</doc:db> object to which a <doc:db>callout</doc:db>
|
---|
322 | refers. By default, this searches for a area whose <sgmltag
|
---|
323 | class="attribute">id</sgmltag> attribute equals the
|
---|
324 | <literal>arearef</literal> parameter.
|
---|
325 | </simpara></listitem>
|
---|
326 | </varlistentry>
|
---|
327 | <varlistentry>
|
---|
328 | <term>count</term>
|
---|
329 | <listitem><simpara>
|
---|
330 | The position of this reference in the list of references
|
---|
331 | used by a given <doc:db>callout</doc:db>. Influences
|
---|
332 | delimiters for list items.
|
---|
333 | </simpara></listitem>
|
---|
334 | </varlistentry>
|
---|
335 | <varlistentry>
|
---|
336 | <term>last</term>
|
---|
337 | <listitem><simpara>
|
---|
338 | Whether this area reference is the last one for a given
|
---|
339 | <doc:db>callout</doc:db>. Influences delimiters for list
|
---|
340 | items.
|
---|
341 | </simpara></listitem>
|
---|
342 | </varlistentry>
|
---|
343 | </variablelist>
|
---|
344 | </doc:params>
|
---|
345 | <doc:notes>
|
---|
346 | <para>
|
---|
347 | Formats a reference for a single arearef. This is performed by
|
---|
348 | applying templates for the <doc:db>area</doc:db> in
|
---|
349 | <quote>generate.area.arearef</quote> mode.
|
---|
350 | </para>
|
---|
351 | <para>
|
---|
352 | The current node must be a <doc:db>callout</doc:db>.
|
---|
353 | </para>
|
---|
354 | <para>
|
---|
355 | Uses the <quote>naturalinlinelist</quote> localisation context.
|
---|
356 | </para>
|
---|
357 | </doc:notes>
|
---|
358 | </doc:template>
|
---|
359 | <xsl:template match="callout" mode="generate.callout.arearef">
|
---|
360 | <xsl:param name="arearef" select="@arearefs"/>
|
---|
361 | <xsl:param name="area" select="key('id', $arearef)"/>
|
---|
362 | <xsl:param name="last" select="false()"/>
|
---|
363 | <xsl:param name="count" select="1"/>
|
---|
364 | <xsl:variable name="first" select="$count=1"/>
|
---|
365 | <xsl:choose>
|
---|
366 | <xsl:when test="$first">
|
---|
367 | <xsl:call-template name="gentext.template">
|
---|
368 | <xsl:with-param name="context" select="'naturalinlinelist'"/>
|
---|
369 | <xsl:with-param name="name" select="'start'"/>
|
---|
370 | </xsl:call-template>
|
---|
371 | </xsl:when>
|
---|
372 | <xsl:when test="$last">
|
---|
373 | <xsl:call-template name="gentext.template">
|
---|
374 | <xsl:with-param name="context" select="'naturalinlinelist'"/>
|
---|
375 | <xsl:with-param name="name">
|
---|
376 | <xsl:choose>
|
---|
377 | <xsl:when test="$count > 2">
|
---|
378 | <xsl:text>lastofmany</xsl:text>
|
---|
379 | </xsl:when>
|
---|
380 | <xsl:otherwise>
|
---|
381 | <xsl:text>lastoftwo</xsl:text>
|
---|
382 | </xsl:otherwise>
|
---|
383 | </xsl:choose>
|
---|
384 | </xsl:with-param>
|
---|
385 | </xsl:call-template>
|
---|
386 | </xsl:when>
|
---|
387 | <xsl:otherwise>
|
---|
388 | <xsl:call-template name="gentext.template">
|
---|
389 | <xsl:with-param name="context" select="'naturalinlinelist'"/>
|
---|
390 | <xsl:with-param name="name" select="'middle'"/>
|
---|
391 | </xsl:call-template>
|
---|
392 | </xsl:otherwise>
|
---|
393 | </xsl:choose>
|
---|
394 | <xsl:choose>
|
---|
395 | <xsl:when test="$area">
|
---|
396 | <xsl:apply-templates select="$area" mode="generate.area.arearef"/>
|
---|
397 | </xsl:when>
|
---|
398 | <xsl:otherwise>
|
---|
399 | <xsl:text>?</xsl:text>
|
---|
400 | <xsl:message>
|
---|
401 | <xsl:text>Error: no ID for constraint arearefs: </xsl:text>
|
---|
402 | <xsl:value-of select="$arearef"/>
|
---|
403 | <xsl:text>.</xsl:text>
|
---|
404 | </xsl:message>
|
---|
405 | </xsl:otherwise>
|
---|
406 | </xsl:choose>
|
---|
407 | <xsl:if test="$last">
|
---|
408 | <xsl:call-template name="gentext.template">
|
---|
409 | <xsl:with-param name="context" select="'naturalinlinelist'"/>
|
---|
410 | <xsl:with-param name="name" select="'end'"/>
|
---|
411 | </xsl:call-template>
|
---|
412 | </xsl:if>
|
---|
413 | </xsl:template>
|
---|
414 |
|
---|
415 | <doc:template basename="area" xmlns="">
|
---|
416 | <refpurpose>Illustrate a reference to a callout's area</refpurpose>
|
---|
417 | <doc:description>
|
---|
418 | <para>
|
---|
419 | Formats an <doc:db>area</doc:db> as part of a
|
---|
420 | callout list.
|
---|
421 | </para>
|
---|
422 | </doc:description>
|
---|
423 | <doc:variables>
|
---|
424 | &no_var;
|
---|
425 | </doc:variables>
|
---|
426 | <doc:notes>
|
---|
427 | <para>
|
---|
428 | The current node must be an <doc:db>area</doc:db>.
|
---|
429 | </para>
|
---|
430 | <para>
|
---|
431 | Applies templates in the <quote>generate.arearef.calspair</quote>,
|
---|
432 | <quote>generate.arearef.linerange</quote> and
|
---|
433 | <quote>generate.arearef</quote> modes.
|
---|
434 | </para>
|
---|
435 | </doc:notes>
|
---|
436 | </doc:template>
|
---|
437 | <xsl:template match="area" mode="generate.area.arearef">
|
---|
438 | <xsl:variable name="units">
|
---|
439 | <xsl:choose>
|
---|
440 | <xsl:when test="@units!=''">
|
---|
441 | <xsl:value-of select="@units"/>
|
---|
442 | </xsl:when>
|
---|
443 | <xsl:when test="../@units!=''">
|
---|
444 | <xsl:value-of select="../@units"/>
|
---|
445 | </xsl:when>
|
---|
446 | <xsl:when test="../../@units!=''">
|
---|
447 | <xsl:value-of select="../../@units"/>
|
---|
448 | </xsl:when>
|
---|
449 | </xsl:choose>
|
---|
450 | </xsl:variable>
|
---|
451 | <xsl:choose>
|
---|
452 | <xsl:when test="$units='calspair'">
|
---|
453 | <xsl:apply-templates select="." mode="generate.arearef.calspair"/>
|
---|
454 | </xsl:when>
|
---|
455 | <xsl:when test="$units='linerange'">
|
---|
456 | <xsl:apply-templates select="." mode="generate.arearef.linerange"/>
|
---|
457 | </xsl:when>
|
---|
458 | <xsl:otherwise>
|
---|
459 | <xsl:apply-templates select="." mode="generate.arearef">
|
---|
460 | <xsl:with-param name="units" select="$units"/>
|
---|
461 | </xsl:apply-templates>
|
---|
462 | </xsl:otherwise>
|
---|
463 | </xsl:choose>
|
---|
464 | </xsl:template>
|
---|
465 |
|
---|
466 | <doc:template basename="area" xmlns="">
|
---|
467 | <refpurpose>Illustrate a reference to a callout's area</refpurpose>
|
---|
468 | <doc:description>
|
---|
469 | <para>
|
---|
470 | Formats an <doc:db>area</doc:db> as part of a
|
---|
471 | callout list.
|
---|
472 | </para>
|
---|
473 | </doc:description>
|
---|
474 | <doc:variables>
|
---|
475 | &no_var;
|
---|
476 | </doc:variables>
|
---|
477 | <doc:notes>
|
---|
478 | <para>
|
---|
479 | This is a fallback template for unknown units.
|
---|
480 | It does not format an arearef but instead prints
|
---|
481 | an error message.
|
---|
482 | </para>
|
---|
483 | </doc:notes>
|
---|
484 | </doc:template>
|
---|
485 | <xsl:template match="area" mode="generate.arearef">
|
---|
486 | <xsl:param name="units"/>
|
---|
487 | <xsl:message>Error: unsupported arearef units <xsl:value-of select="$units"/>.</xsl:message>
|
---|
488 | </xsl:template>
|
---|
489 |
|
---|
490 | <doc:template basename="area" xmlns="">
|
---|
491 | <refpurpose>Illustrate a reference to a callout's area</refpurpose>
|
---|
492 | <doc:description>
|
---|
493 | <para>
|
---|
494 | Formats calspair units for a callout list.
|
---|
495 | </para>
|
---|
496 | </doc:description>
|
---|
497 | <doc:variables>
|
---|
498 | &no_var;
|
---|
499 | </doc:variables>
|
---|
500 | <doc:notes>
|
---|
501 | <para>
|
---|
502 | Calls <xref linkend="template.area-generate.area.areasymbol"/>.
|
---|
503 | </para>
|
---|
504 | </doc:notes>
|
---|
505 | </doc:template>
|
---|
506 | <xsl:template match="area" mode="generate.arearef.calspair">
|
---|
507 | <xsl:apply-templates select="." mode="generate.area.areasymbol"/>
|
---|
508 | </xsl:template>
|
---|
509 |
|
---|
510 | <doc:template basename="area" xmlns="">
|
---|
511 | <refpurpose>Illustrate a reference to a callout's area</refpurpose>
|
---|
512 | <doc:description>
|
---|
513 | <para>
|
---|
514 | Formats linerange units for a callout list.
|
---|
515 | </para>
|
---|
516 | </doc:description>
|
---|
517 | <doc:variables>
|
---|
518 | &no_var;
|
---|
519 | </doc:variables>
|
---|
520 | <doc:notes>
|
---|
521 | <para>
|
---|
522 | Formats a line range numerically, condensing the line range
|
---|
523 | down to a single line reference if the starting line is the
|
---|
524 | same as the finishing line.
|
---|
525 | </para>
|
---|
526 | </doc:notes>
|
---|
527 | </doc:template>
|
---|
528 | <xsl:template match="area" mode="generate.arearef.linerange">
|
---|
529 | <xsl:choose>
|
---|
530 | <xsl:when test="not(contains(@coords, ' '))">
|
---|
531 | <xsl:value-of select="@coords"/>
|
---|
532 | </xsl:when>
|
---|
533 | <xsl:otherwise>
|
---|
534 | <xsl:variable name="start" select="substring-before(@coords, ' ')"/>
|
---|
535 | <xsl:variable name="finish" select="substring-after(@coords, ' ')"/>
|
---|
536 | <xsl:choose>
|
---|
537 | <xsl:when test="$start=$finish">
|
---|
538 | <xsl:value-of select="$start"/>
|
---|
539 | </xsl:when>
|
---|
540 | <xsl:otherwise>
|
---|
541 | <xsl:call-template name="string-replace">
|
---|
542 | <xsl:with-param name="from" select="' '"/>
|
---|
543 | <xsl:with-param name="to" select="'--'"/>
|
---|
544 | <xsl:with-param name="string" select="@coords"/>
|
---|
545 | </xsl:call-template>
|
---|
546 | </xsl:otherwise>
|
---|
547 | </xsl:choose>
|
---|
548 | </xsl:otherwise>
|
---|
549 | </xsl:choose>
|
---|
550 | </xsl:template>
|
---|
551 |
|
---|
552 | <doc:template basename="area" xmlns="">
|
---|
553 | <refpurpose>Illustrate a callout's area as part of an image or listing</refpurpose>
|
---|
554 | <doc:description>
|
---|
555 | <para>
|
---|
556 | Formats an <doc:db>area</doc:db> as part of a
|
---|
557 | displayed image or listing.
|
---|
558 | </para>
|
---|
559 | </doc:description>
|
---|
560 | <doc:variables>
|
---|
561 | &no_var;
|
---|
562 | </doc:variables>
|
---|
563 | <doc:notes>
|
---|
564 | <para>
|
---|
565 | Applies templates in the <quote>generate.area.areamark</quote> mode.
|
---|
566 | </para>
|
---|
567 | </doc:notes>
|
---|
568 | </doc:template>
|
---|
569 | <xsl:template match="area">
|
---|
570 | <xsl:apply-templates select="." mode="generate.area.areamark"/>
|
---|
571 | </xsl:template>
|
---|
572 |
|
---|
573 | <doc:template basename="area" xmlns="">
|
---|
574 | <refpurpose>Illustrate a callout's area as part of an image or listing</refpurpose>
|
---|
575 | <doc:description>
|
---|
576 | <para>
|
---|
577 | Formats an <doc:db>area</doc:db> as part of a
|
---|
578 | displayed image or listing.
|
---|
579 | </para>
|
---|
580 | </doc:description>
|
---|
581 | <doc:variables>
|
---|
582 | &no_var;
|
---|
583 | </doc:variables>
|
---|
584 | <doc:notes>
|
---|
585 | <para>
|
---|
586 | Applies templates in the <quote>generate.areamark.calspair</quote> or
|
---|
587 | <quote>generate.areamark</quote> modes.
|
---|
588 | </para>
|
---|
589 | </doc:notes>
|
---|
590 | </doc:template>
|
---|
591 | <xsl:template match="area" mode="generate.area.areamark">
|
---|
592 | <xsl:variable name="units">
|
---|
593 | <xsl:choose>
|
---|
594 | <xsl:when test="@units!=''">
|
---|
595 | <xsl:value-of select="@units"/>
|
---|
596 | </xsl:when>
|
---|
597 | <xsl:when test="../@units!=''">
|
---|
598 | <xsl:value-of select="../@units"/>
|
---|
599 | </xsl:when>
|
---|
600 | <xsl:when test="../../@units!=''">
|
---|
601 | <xsl:value-of select="../../@units"/>
|
---|
602 | </xsl:when>
|
---|
603 | </xsl:choose>
|
---|
604 | </xsl:variable>
|
---|
605 | <xsl:choose>
|
---|
606 | <xsl:when test="$units='calspair'">
|
---|
607 | <xsl:apply-templates select="." mode="generate.areamark.calspair"/>
|
---|
608 | </xsl:when>
|
---|
609 | <xsl:otherwise>
|
---|
610 | <xsl:apply-templates select="." mode="generate.areamark">
|
---|
611 | <xsl:with-param name="units" select="$units"/>
|
---|
612 | </xsl:apply-templates>
|
---|
613 | </xsl:otherwise>
|
---|
614 | </xsl:choose>
|
---|
615 | </xsl:template>
|
---|
616 |
|
---|
617 | <doc:template basename="area" xmlns="">
|
---|
618 | <refpurpose>Illustrate a callout's area as part of an image or listing</refpurpose>
|
---|
619 | <doc:description>
|
---|
620 | <para>
|
---|
621 | Formats an <doc:db>area</doc:db> as part of a
|
---|
622 | displayed image or listing.
|
---|
623 | </para>
|
---|
624 | </doc:description>
|
---|
625 | <doc:variables>
|
---|
626 | &no_var;
|
---|
627 | </doc:variables>
|
---|
628 | <doc:notes>
|
---|
629 | <para>
|
---|
630 | This is a fallback template for unknown units.
|
---|
631 | It does not format an areamark but instead prints
|
---|
632 | an error message.
|
---|
633 | </para>
|
---|
634 | </doc:notes>
|
---|
635 | </doc:template>
|
---|
636 | <xsl:template match="area" mode="generate.areamark">
|
---|
637 | <xsl:param name="units"/>
|
---|
638 | <xsl:message>Error: unsupported areamark units <xsl:value-of select="$units"/>.</xsl:message>
|
---|
639 | </xsl:template>
|
---|
640 |
|
---|
641 | <doc:template basename="area" xmlns="">
|
---|
642 | <refpurpose>Illustrate a callout's area as part of an image or listing</refpurpose>
|
---|
643 | <doc:description>
|
---|
644 | <para>
|
---|
645 | Formats calspair units for a displayed image or listing.
|
---|
646 | </para>
|
---|
647 | </doc:description>
|
---|
648 | <doc:variables>
|
---|
649 | &no_var;
|
---|
650 | </doc:variables>
|
---|
651 | <doc:notes>
|
---|
652 | <para>
|
---|
653 | Converts calspair coordinates relative to the width and height of the
|
---|
654 | displayed image area. Will understand "x1,y1 x2,y2" and also "x1 y1".
|
---|
655 | In the former case, the drawing location is moved to the centre of
|
---|
656 | the implied rectangle. Templates are then applied in the
|
---|
657 | <quote>generate.area.areasymbol</quote> mode.
|
---|
658 | </para>
|
---|
659 | </doc:notes>
|
---|
660 | </doc:template>
|
---|
661 | <xsl:template match="area" mode="generate.areamark.calspair">
|
---|
662 | <xsl:choose>
|
---|
663 | <xsl:when test="not(contains(@coords, ' '))">
|
---|
664 | <xsl:message>Error: invalid calspair '<xsl:value-of select="@coords"/>'.</xsl:message>
|
---|
665 | </xsl:when>
|
---|
666 | <xsl:otherwise>
|
---|
667 | <xsl:variable name="x1y1">
|
---|
668 | <xsl:value-of select="substring-before(@coords, ' ')"/>
|
---|
669 | </xsl:variable>
|
---|
670 | <xsl:variable name="x1">
|
---|
671 | <xsl:choose>
|
---|
672 | <xsl:when test="contains($x1y1, ',')">
|
---|
673 | <xsl:value-of select="substring-before($x1y1, ',')"/>
|
---|
674 | </xsl:when>
|
---|
675 | <xsl:otherwise>
|
---|
676 | <xsl:value-of select="$x1y1"/>
|
---|
677 | </xsl:otherwise>
|
---|
678 | </xsl:choose>
|
---|
679 | </xsl:variable>
|
---|
680 | <xsl:variable name="y1">
|
---|
681 | <xsl:choose>
|
---|
682 | <xsl:when test="contains($x1y1, ',')">
|
---|
683 | <xsl:value-of select="substring-after($x1y1, ',')"/>
|
---|
684 | </xsl:when>
|
---|
685 | <xsl:otherwise>
|
---|
686 | <xsl:value-of select="''"/>
|
---|
687 | </xsl:otherwise>
|
---|
688 | </xsl:choose>
|
---|
689 | </xsl:variable>
|
---|
690 | <xsl:variable name="x2y2">
|
---|
691 | <xsl:value-of select="substring-after(@coords, ' ')"/>
|
---|
692 | </xsl:variable>
|
---|
693 | <xsl:variable name="y2">
|
---|
694 | <xsl:choose>
|
---|
695 | <xsl:when test="contains($x2y2, ',')">
|
---|
696 | <xsl:value-of select="substring-after($x2y2, ',')"/>
|
---|
697 | </xsl:when>
|
---|
698 | <xsl:otherwise>
|
---|
699 | <xsl:value-of select="$x2y2"/>
|
---|
700 | </xsl:otherwise>
|
---|
701 | </xsl:choose>
|
---|
702 | </xsl:variable>
|
---|
703 | <xsl:variable name="x2">
|
---|
704 | <xsl:choose>
|
---|
705 | <xsl:when test="contains($x2y2, ',')">
|
---|
706 | <xsl:value-of select="substring-before($x2y2, ',')"/>
|
---|
707 | </xsl:when>
|
---|
708 | <xsl:otherwise>
|
---|
709 | <xsl:value-of select="''"/>
|
---|
710 | </xsl:otherwise>
|
---|
711 | </xsl:choose>
|
---|
712 | </xsl:variable>
|
---|
713 | <xsl:text>\calspair{</xsl:text>
|
---|
714 | <!-- choose horizontal coordinate -->
|
---|
715 | <xsl:choose>
|
---|
716 | <xsl:when test="$x1 != '' and $x2 != ''">
|
---|
717 | <xsl:value-of select="(number($x1)+number($x2)) div 200"/>
|
---|
718 | </xsl:when>
|
---|
719 | <xsl:otherwise>
|
---|
720 | <xsl:value-of select="number(concat($x1, $x2)) div 100"/>
|
---|
721 | </xsl:otherwise>
|
---|
722 | </xsl:choose>
|
---|
723 | <xsl:text>}{</xsl:text>
|
---|
724 | <!-- choose vertical coordinate -->
|
---|
725 | <xsl:choose>
|
---|
726 | <xsl:when test="$y1 != '' and $y2 != ''">
|
---|
727 | <xsl:value-of select="(number($y1)+number($y2)) div 200"/>
|
---|
728 | </xsl:when>
|
---|
729 | <xsl:otherwise>
|
---|
730 | <xsl:value-of select="number(concat($y1, $y2)) div 100"/>
|
---|
731 | </xsl:otherwise>
|
---|
732 | </xsl:choose>
|
---|
733 | <xsl:text>}{</xsl:text>
|
---|
734 | <xsl:apply-templates select="." mode="generate.area.areasymbol"/>
|
---|
735 | <xsl:text>} </xsl:text>
|
---|
736 | </xsl:otherwise>
|
---|
737 | </xsl:choose>
|
---|
738 | </xsl:template>
|
---|
739 |
|
---|
740 | <doc:template basename="area" xmlns="">
|
---|
741 | <refpurpose>Illustrate a callout's area as part of an image or listing</refpurpose>
|
---|
742 | <doc:description>
|
---|
743 | <para>
|
---|
744 | Formats an <doc:db>area</doc:db> as an overlay
|
---|
745 | on an image or listing.
|
---|
746 | </para>
|
---|
747 | </doc:description>
|
---|
748 | <doc:variables>
|
---|
749 | &no_var;
|
---|
750 | </doc:variables>
|
---|
751 | <doc:notes>
|
---|
752 | <para>
|
---|
753 | If the area has a <sgmltag class="attribute">label</sgmltag>
|
---|
754 | attribute, it is used as raw &LaTeX; code.
|
---|
755 | </para>
|
---|
756 | <para>
|
---|
757 | If the area has a linkends attribute, templates are
|
---|
758 | applied for the first linkend using
|
---|
759 | <quote>generate.callout.areasymbol</quote> mode.
|
---|
760 | It is implicit in this scenario that an arearef
|
---|
761 | and an areamark will both consist of an identical
|
---|
762 | icon for an area.
|
---|
763 | </para>
|
---|
764 | <para>
|
---|
765 | If none of the above were performed, an asterisk is printed.
|
---|
766 | </para>
|
---|
767 | </doc:notes>
|
---|
768 | </doc:template>
|
---|
769 | <xsl:template match="area" mode="generate.area.areasymbol">
|
---|
770 | <xsl:param name="linkends" select="normalize-space(@linkends)"/>
|
---|
771 | <xsl:choose>
|
---|
772 | <xsl:when test="@label">
|
---|
773 | <xsl:value-of select="@label"/>
|
---|
774 | </xsl:when>
|
---|
775 | <xsl:when test="$linkends!=''">
|
---|
776 | <xsl:variable name="linkend">
|
---|
777 | <xsl:choose>
|
---|
778 | <xsl:when test="contains($linkends, ' ')">
|
---|
779 | <xsl:value-of select="substring-before($linkends, ' ')"/>
|
---|
780 | </xsl:when>
|
---|
781 | <xsl:otherwise>
|
---|
782 | <xsl:value-of select="$linkends"/>
|
---|
783 | </xsl:otherwise>
|
---|
784 | </xsl:choose>
|
---|
785 | </xsl:variable>
|
---|
786 | <xsl:variable name="target" select="key('id', $linkend)"/>
|
---|
787 | <xsl:choose>
|
---|
788 | <xsl:when test="count($target)>0">
|
---|
789 | <xsl:for-each select="$target">
|
---|
790 | <xsl:apply-templates select="." mode="generate.callout.areasymbol">
|
---|
791 | <xsl:with-param name="arearef" select="generate-id(current())"/>
|
---|
792 | <xsl:with-param name="area" select="current()"/>
|
---|
793 | </xsl:apply-templates>
|
---|
794 | </xsl:for-each>
|
---|
795 | </xsl:when>
|
---|
796 | <xsl:otherwise>
|
---|
797 | <xsl:text>?</xsl:text>
|
---|
798 | <xsl:message>
|
---|
799 | <xsl:text>Error: no ID for constraint linkends: </xsl:text>
|
---|
800 | <xsl:value-of select="$linkends"/>
|
---|
801 | <xsl:text>.</xsl:text>
|
---|
802 | </xsl:message>
|
---|
803 | </xsl:otherwise>
|
---|
804 | </xsl:choose>
|
---|
805 | </xsl:when>
|
---|
806 | <xsl:otherwise>
|
---|
807 | <xsl:text>*</xsl:text>
|
---|
808 | </xsl:otherwise>
|
---|
809 | </xsl:choose>
|
---|
810 | </xsl:template>
|
---|
811 |
|
---|
812 | <doc:template basename="callout" xmlns="">
|
---|
813 | <refpurpose>Illustrate a callout's area as part of an image or listing</refpurpose>
|
---|
814 | <doc:description>
|
---|
815 | <para>
|
---|
816 | Illustrates an <doc:db>area</doc:db> as part of a
|
---|
817 | displayed image or listing.
|
---|
818 | </para>
|
---|
819 | </doc:description>
|
---|
820 | <doc:variables>
|
---|
821 | &no_var;
|
---|
822 | </doc:variables>
|
---|
823 | <doc:notes>
|
---|
824 | <para>
|
---|
825 | Prints the numeric position of the <doc:db>callout</doc:db> within its <doc:db>calloutlist</doc:db>.
|
---|
826 | </para>
|
---|
827 | </doc:notes>
|
---|
828 | </doc:template>
|
---|
829 | <xsl:template match="callout" mode="generate.callout.areasymbol">
|
---|
830 | <xsl:number count="callout" format="1"/>
|
---|
831 | </xsl:template>
|
---|
832 |
|
---|
833 | <doc:template xmlns="">
|
---|
834 | <refpurpose>Process <doc:db>mediaobjectco</doc:db> elements</refpurpose>
|
---|
835 | <doc:description>
|
---|
836 | <para>
|
---|
837 | Applies templates.
|
---|
838 | </para>
|
---|
839 | </doc:description>
|
---|
840 | <doc:variables>
|
---|
841 | &no_var;
|
---|
842 | </doc:variables>
|
---|
843 | </doc:template>
|
---|
844 | <xsl:template match="mediaobjectco">
|
---|
845 | <xsl:text> </xsl:text>
|
---|
846 | <xsl:apply-templates select="imageobjectco"/>
|
---|
847 | <xsl:text> </xsl:text>
|
---|
848 | </xsl:template>
|
---|
849 |
|
---|
850 | <doc:template xmlns="">
|
---|
851 | <refpurpose>Process <doc:db>imageobjectco</doc:db> elements</refpurpose>
|
---|
852 | <doc:description>
|
---|
853 | <para>
|
---|
854 | Applies templates.
|
---|
855 | </para>
|
---|
856 | </doc:description>
|
---|
857 | <doc:variables>
|
---|
858 | &no_var;
|
---|
859 | </doc:variables>
|
---|
860 | </doc:template>
|
---|
861 | <xsl:template match="imageobjectco">
|
---|
862 | <xsl:apply-templates select="imageobject"/>
|
---|
863 | <xsl:text> </xsl:text>
|
---|
864 | <xsl:apply-templates select="calloutlist"/>
|
---|
865 | </xsl:template>
|
---|
866 |
|
---|
867 | <doc:template basename="imageobject" xmlns="">
|
---|
868 | <refpurpose>Process a <doc:db>imageobjectco</doc:db>'s <doc:db>imageobject</doc:db> elements</refpurpose>
|
---|
869 | <doc:description>
|
---|
870 | <para>
|
---|
871 | Applies templates for <doc:db>imagedata</doc:db>.
|
---|
872 | </para>
|
---|
873 | </doc:description>
|
---|
874 | <doc:variables>
|
---|
875 | &no_var;
|
---|
876 | </doc:variables>
|
---|
877 | </doc:template>
|
---|
878 | <xsl:template match="imageobjectco/imageobject">
|
---|
879 | <xsl:apply-templates select="imagedata">
|
---|
880 | <xsl:with-param name="is.imageobjectco" select="true()"/>
|
---|
881 | </xsl:apply-templates>
|
---|
882 | </xsl:template>
|
---|
883 |
|
---|
884 | </xsl:stylesheet>
|
---|