Imported Upstream version 1.77.1
[platform/upstream/docbook-xsl.git] / fo / inline.xsl
1 <?xml version='1.0'?>
2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % common.entities SYSTEM "../common/entities.ent">
4 %common.entities;
5 ]>
6 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
8                 xmlns:xlink='http://www.w3.org/1999/xlink'
9                 exclude-result-prefixes="xlink"
10                 version='1.0'>
11
12 <!-- ********************************************************************
13      $Id: inline.xsl 9228 2012-02-01 21:50:25Z bobstayton $
14      ********************************************************************
15
16      This file is part of the XSL DocBook Stylesheet distribution.
17      See ../README or http://docbook.sf.net/release/xsl/current/ for
18      copyright and other information.
19
20      ******************************************************************** -->
21
22 <xsl:key name="glossentries" match="glossentry" use="normalize-space(glossterm)"/>
23 <xsl:key name="glossentries" match="glossentry" use="normalize-space(glossterm/@baseform)"/>
24
25 <xsl:template name="simple.xlink">
26   <xsl:param name="node" select="."/>
27   <xsl:param name="content">
28     <xsl:apply-templates/>
29   </xsl:param>
30   <xsl:param name="linkend" select="$node/@linkend"/>
31   <xsl:param name="xhref" select="$node/@xlink:href"/>
32
33   <xsl:choose>
34     <xsl:when test="$xhref
35                     and (not($node/@xlink:type) or 
36                          $node/@xlink:type='simple')">
37
38       <!-- Is it a local idref? -->
39       <xsl:variable name="is.idref">
40         <xsl:choose>
41           <!-- if the href starts with # and does not contain an "(" -->
42           <!-- or if the href starts with #xpointer(id(, it's just an ID -->
43           <xsl:when test="starts-with($xhref,'#')
44                           and (not(contains($xhref,'&#40;'))
45                           or starts-with($xhref,
46                                      '#xpointer&#40;id&#40;'))">1</xsl:when>
47           <xsl:otherwise>0</xsl:otherwise>
48         </xsl:choose>
49       </xsl:variable>
50
51       <!-- Is it an olink ? -->
52       <xsl:variable name="is.olink">
53         <xsl:choose>
54           <!-- If xlink:role="http://docbook.org/xlink/role/olink" -->
55           <!-- and if the href contains # -->
56           <xsl:when test="contains($xhref,'#') and
57                @xlink:role = $xolink.role">1</xsl:when>
58           <xsl:otherwise>0</xsl:otherwise>
59         </xsl:choose>
60       </xsl:variable>
61
62       <xsl:choose>
63         <xsl:when test="$is.olink = 1">
64           <xsl:call-template name="olink">
65             <xsl:with-param name="content" select="$content"/>
66           </xsl:call-template>
67         </xsl:when>
68
69         <xsl:when test="$is.idref = 1">
70
71           <xsl:variable name="idref">
72             <xsl:call-template name="xpointer.idref">
73               <xsl:with-param name="xpointer" select="$xhref"/>
74             </xsl:call-template>
75           </xsl:variable>
76
77           <xsl:variable name="targets" select="key('id',$idref)"/>
78           <xsl:variable name="target" select="$targets[1]"/>
79
80           <xsl:call-template name="check.id.unique">
81             <xsl:with-param name="linkend" select="$idref"/>
82           </xsl:call-template>
83
84           <xsl:choose>
85             <xsl:when test="count($target) = 0">
86               <xsl:message>
87                 <xsl:text>XLink to nonexistent id: </xsl:text>
88                 <xsl:value-of select="$idref"/>
89               </xsl:message>
90               <xsl:copy-of select="$content"/>
91             </xsl:when>
92
93             <xsl:otherwise>
94               <fo:basic-link internal-destination="{$idref}">
95                 <xsl:apply-templates select="." mode="simple.xlink.properties"/>
96                 <xsl:copy-of select="$content"/>
97               </fo:basic-link>
98             </xsl:otherwise>
99           </xsl:choose>
100         </xsl:when>
101
102         <!-- otherwise it's a URI -->
103         <xsl:otherwise>
104           <fo:basic-link external-destination="url({$xhref})">
105             <xsl:apply-templates select="." mode="simple.xlink.properties"/>
106             <xsl:copy-of select="$content"/>
107           </fo:basic-link>
108           <!-- * Call the template for determining whether the URL for this -->
109           <!-- * hyperlink is displayed, and how to display it (either inline or -->
110           <!-- * as a numbered footnote). -->
111           <xsl:call-template name="hyperlink.url.display">
112             <xsl:with-param name="url" select="$xhref"/>
113           </xsl:call-template>
114         </xsl:otherwise>
115       </xsl:choose>
116     </xsl:when>
117
118     <xsl:when test="$linkend">
119       <xsl:variable name="targets" select="key('id',$linkend)"/>
120       <xsl:variable name="target" select="$targets[1]"/>
121
122       <xsl:call-template name="check.id.unique">
123         <xsl:with-param name="linkend" select="$linkend"/>
124       </xsl:call-template>
125
126       <xsl:choose>
127         <xsl:when test="count($target) = 0">
128           <xsl:message>
129             <xsl:text>XLink to nonexistent id: </xsl:text>
130             <xsl:value-of select="$linkend"/>
131           </xsl:message>
132           <xsl:copy-of select="$content"/>
133         </xsl:when>
134
135         <xsl:otherwise>
136           <fo:basic-link internal-destination="{$linkend}">
137             <xsl:apply-templates select="." mode="simple.xlink.properties"/>
138             <xsl:copy-of select="$content"/>
139           </fo:basic-link>
140         </xsl:otherwise>
141       </xsl:choose>
142     </xsl:when>
143
144     <xsl:otherwise>
145       <xsl:copy-of select="$content"/>
146     </xsl:otherwise>
147   </xsl:choose>
148
149 </xsl:template>
150
151 <xsl:template name="inline.charseq">
152   <xsl:param name="content">
153     <xsl:call-template name="simple.xlink">
154       <xsl:with-param name="content">
155         <xsl:apply-templates/>
156       </xsl:with-param>
157     </xsl:call-template>
158   </xsl:param>
159
160   <xsl:choose>
161     <xsl:when test="@dir">
162       <fo:inline>
163         <xsl:attribute name="direction">
164           <xsl:choose>
165             <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
166             <xsl:otherwise>rtl</xsl:otherwise>
167           </xsl:choose>
168         </xsl:attribute>
169         <xsl:copy-of select="$content"/>
170       </fo:inline>
171     </xsl:when>
172     <xsl:otherwise>
173       <xsl:copy-of select="$content"/>
174     </xsl:otherwise>
175   </xsl:choose>
176 </xsl:template>
177
178 <xsl:template name="inline.monoseq">
179   <xsl:param name="content">
180     <xsl:call-template name="simple.xlink">
181       <xsl:with-param name="content">
182         <xsl:apply-templates/>
183       </xsl:with-param>
184     </xsl:call-template>
185   </xsl:param>
186
187   <fo:inline xsl:use-attribute-sets="monospace.properties">
188     <xsl:call-template name="anchor"/>
189     <xsl:if test="@dir">
190       <xsl:attribute name="direction">
191         <xsl:choose>
192           <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
193           <xsl:otherwise>rtl</xsl:otherwise>
194         </xsl:choose>
195       </xsl:attribute>
196     </xsl:if>
197     <xsl:copy-of select="$content"/>
198   </fo:inline>
199 </xsl:template>
200
201 <xsl:template name="inline.boldseq">
202   <xsl:param name="content">
203     <xsl:call-template name="simple.xlink">
204       <xsl:with-param name="content">
205         <xsl:apply-templates/>
206       </xsl:with-param>
207     </xsl:call-template>
208   </xsl:param>
209
210   <fo:inline font-weight="bold">
211     <xsl:if test="@dir">
212       <xsl:attribute name="direction">
213         <xsl:choose>
214           <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
215           <xsl:otherwise>rtl</xsl:otherwise>
216         </xsl:choose>
217       </xsl:attribute>
218     </xsl:if>
219     <xsl:copy-of select="$content"/>
220   </fo:inline>
221 </xsl:template>
222
223 <xsl:template name="inline.italicseq">
224   <xsl:param name="content">
225     <xsl:call-template name="simple.xlink">
226       <xsl:with-param name="content">
227         <xsl:apply-templates/>
228       </xsl:with-param>
229     </xsl:call-template>
230   </xsl:param>
231
232   <fo:inline font-style="italic">
233     <xsl:call-template name="anchor"/>
234     <xsl:if test="@dir">
235       <xsl:attribute name="direction">
236         <xsl:choose>
237           <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
238           <xsl:otherwise>rtl</xsl:otherwise>
239         </xsl:choose>
240       </xsl:attribute>
241     </xsl:if>
242     <xsl:copy-of select="$content"/>
243   </fo:inline>
244 </xsl:template>
245
246 <xsl:template name="inline.boldmonoseq">
247   <xsl:param name="content">
248     <xsl:call-template name="simple.xlink">
249       <xsl:with-param name="content">
250         <xsl:apply-templates/>
251       </xsl:with-param>
252     </xsl:call-template>
253   </xsl:param>
254
255   <fo:inline font-weight="bold" xsl:use-attribute-sets="monospace.properties">
256     <xsl:call-template name="anchor"/>
257     <xsl:if test="@dir">
258       <xsl:attribute name="direction">
259         <xsl:choose>
260           <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
261           <xsl:otherwise>rtl</xsl:otherwise>
262         </xsl:choose>
263       </xsl:attribute>
264     </xsl:if>
265     <xsl:copy-of select="$content"/>
266   </fo:inline>
267 </xsl:template>
268
269 <xsl:template name="inline.italicmonoseq">
270   <xsl:param name="content">
271     <xsl:call-template name="simple.xlink">
272       <xsl:with-param name="content">
273         <xsl:apply-templates/>
274       </xsl:with-param>
275     </xsl:call-template>
276   </xsl:param>
277
278   <fo:inline font-style="italic" xsl:use-attribute-sets="monospace.properties">
279     <xsl:call-template name="anchor"/>
280     <xsl:if test="@dir">
281       <xsl:attribute name="direction">
282         <xsl:choose>
283           <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
284           <xsl:otherwise>rtl</xsl:otherwise>
285         </xsl:choose>
286       </xsl:attribute>
287     </xsl:if>
288     <xsl:copy-of select="$content"/>
289   </fo:inline>
290 </xsl:template>
291
292 <xsl:template name="inline.superscriptseq">
293   <xsl:param name="content">
294     <xsl:call-template name="simple.xlink">
295       <xsl:with-param name="content">
296         <xsl:apply-templates/>
297       </xsl:with-param>
298     </xsl:call-template>
299   </xsl:param>
300
301   <fo:inline xsl:use-attribute-sets="superscript.properties">
302     <xsl:call-template name="anchor"/>
303     <xsl:if test="@dir">
304       <xsl:attribute name="direction">
305         <xsl:choose>
306           <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
307           <xsl:otherwise>rtl</xsl:otherwise>
308         </xsl:choose>
309       </xsl:attribute>
310     </xsl:if>
311     <xsl:choose>
312       <xsl:when test="$fop.extensions != 0">
313         <xsl:attribute name="vertical-align">super</xsl:attribute>
314       </xsl:when>
315       <xsl:otherwise>
316         <xsl:attribute name="baseline-shift">super</xsl:attribute>
317       </xsl:otherwise>
318     </xsl:choose>
319     <xsl:copy-of select="$content"/>
320   </fo:inline>
321 </xsl:template>
322
323 <xsl:template name="inline.subscriptseq">
324   <xsl:param name="content">
325     <xsl:call-template name="simple.xlink">
326       <xsl:with-param name="content">
327         <xsl:apply-templates/>
328       </xsl:with-param>
329     </xsl:call-template>
330   </xsl:param>
331
332   <fo:inline xsl:use-attribute-sets="subscript.properties">
333     <xsl:call-template name="anchor"/>
334     <xsl:if test="@dir">
335       <xsl:attribute name="direction">
336         <xsl:choose>
337           <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
338           <xsl:otherwise>rtl</xsl:otherwise>
339         </xsl:choose>
340       </xsl:attribute>
341     </xsl:if>
342     <xsl:choose>
343       <xsl:when test="$fop.extensions != 0">
344         <xsl:attribute name="vertical-align">sub</xsl:attribute>
345       </xsl:when>
346       <xsl:otherwise>
347         <xsl:attribute name="baseline-shift">sub</xsl:attribute>
348       </xsl:otherwise>
349     </xsl:choose>
350     <xsl:copy-of select="$content"/>
351   </fo:inline>
352 </xsl:template>
353
354 <!-- ==================================================================== -->
355 <!-- some special cases -->
356
357 <xsl:template match="author">
358   <xsl:call-template name="simple.xlink">
359     <xsl:with-param name="content">
360       <xsl:call-template name="person.name"/>
361     </xsl:with-param>
362   </xsl:call-template>
363 </xsl:template>
364
365 <xsl:template match="editor">
366   <xsl:call-template name="simple.xlink">
367     <xsl:with-param name="content">
368       <xsl:call-template name="person.name"/>
369     </xsl:with-param>
370   </xsl:call-template>
371 </xsl:template>
372
373 <xsl:template match="othercredit">
374   <xsl:call-template name="simple.xlink">
375     <xsl:with-param name="content">
376       <xsl:call-template name="person.name"/>
377     </xsl:with-param>
378   </xsl:call-template>
379 </xsl:template>
380
381 <xsl:template match="authorinitials">
382   <xsl:call-template name="inline.charseq"/>
383 </xsl:template>
384
385 <!-- ==================================================================== -->
386
387 <xsl:template match="accel">
388   <xsl:call-template name="inline.charseq"/>
389 </xsl:template>
390
391 <xsl:template match="action">
392   <xsl:call-template name="inline.charseq"/>
393 </xsl:template>
394
395 <xsl:template match="application">
396   <xsl:call-template name="inline.charseq"/>
397 </xsl:template>
398
399 <xsl:template match="classname">
400   <xsl:call-template name="inline.monoseq"/>
401 </xsl:template>
402
403 <xsl:template match="exceptionname">
404   <xsl:call-template name="inline.monoseq"/>
405 </xsl:template>
406
407 <xsl:template match="interfacename">
408   <xsl:call-template name="inline.monoseq"/>
409 </xsl:template>
410
411 <xsl:template match="methodname">
412   <xsl:call-template name="inline.monoseq"/>
413 </xsl:template>
414
415 <xsl:template match="command">
416   <xsl:call-template name="inline.boldseq"/>
417 </xsl:template>
418
419 <xsl:template match="computeroutput">
420   <xsl:call-template name="inline.monoseq"/>
421 </xsl:template>
422
423 <xsl:template match="constant">
424   <xsl:call-template name="inline.monoseq"/>
425 </xsl:template>
426
427 <xsl:template match="database">
428   <xsl:call-template name="inline.charseq"/>
429 </xsl:template>
430
431 <xsl:template match="date">
432   <!-- should this support locale-specific formatting? how? -->
433   <xsl:call-template name="inline.charseq"/>
434 </xsl:template>
435
436 <xsl:template match="errorcode">
437   <xsl:call-template name="inline.charseq"/>
438 </xsl:template>
439
440 <xsl:template match="errorname">
441   <xsl:call-template name="inline.charseq"/>
442 </xsl:template>
443
444 <xsl:template match="errortype">
445   <xsl:call-template name="inline.charseq"/>
446 </xsl:template>
447
448 <xsl:template match="errortext">
449   <xsl:call-template name="inline.charseq"/>
450 </xsl:template>
451
452 <xsl:template match="envar">
453   <xsl:call-template name="inline.monoseq"/>
454 </xsl:template>
455
456 <xsl:template match="filename">
457   <xsl:call-template name="inline.monoseq"/>
458 </xsl:template>
459
460 <xsl:template match="function">
461   <xsl:choose>
462     <xsl:when test="$function.parens != '0'
463                     and (parameter or function or replaceable)">
464       <xsl:variable name="nodes" select="text()|*"/>
465       <xsl:call-template name="inline.monoseq">
466         <xsl:with-param name="content">
467           <xsl:call-template name="simple.xlink">
468             <xsl:with-param name="content">
469               <xsl:apply-templates select="$nodes[1]"/>
470             </xsl:with-param>
471           </xsl:call-template>
472         </xsl:with-param>
473       </xsl:call-template>
474       <xsl:text>(</xsl:text>
475       <xsl:apply-templates select="$nodes[position()>1]"/>
476       <xsl:text>)</xsl:text>
477     </xsl:when>
478     <xsl:otherwise>
479      <xsl:call-template name="inline.monoseq"/>
480     </xsl:otherwise>
481   </xsl:choose>
482 </xsl:template>
483
484 <xsl:template match="function/parameter" priority="2">
485   <xsl:call-template name="inline.italicmonoseq"/>
486   <xsl:if test="following-sibling::*">
487     <xsl:text>, </xsl:text>
488   </xsl:if>
489 </xsl:template>
490
491 <xsl:template match="function/replaceable" priority="2">
492   <xsl:call-template name="inline.italicmonoseq"/>
493   <xsl:if test="following-sibling::*">
494     <xsl:text>, </xsl:text>
495   </xsl:if>
496 </xsl:template>
497
498 <xsl:template match="guibutton">
499   <xsl:call-template name="inline.charseq"/>
500 </xsl:template>
501
502 <xsl:template match="guiicon">
503   <xsl:call-template name="inline.charseq"/>
504 </xsl:template>
505
506 <xsl:template match="guilabel">
507   <xsl:call-template name="inline.charseq"/>
508 </xsl:template>
509
510 <xsl:template match="guimenu">
511   <xsl:call-template name="inline.charseq"/>
512 </xsl:template>
513
514 <xsl:template match="guimenuitem">
515   <xsl:call-template name="inline.charseq"/>
516 </xsl:template>
517
518 <xsl:template match="guisubmenu">
519   <xsl:call-template name="inline.charseq"/>
520 </xsl:template>
521
522 <xsl:template match="hardware">
523   <xsl:call-template name="inline.charseq"/>
524 </xsl:template>
525
526 <xsl:template match="interface">
527   <xsl:call-template name="inline.charseq"/>
528 </xsl:template>
529
530 <xsl:template match="interfacedefinition">
531   <xsl:call-template name="inline.charseq"/>
532 </xsl:template>
533
534 <xsl:template match="keycap">
535   <xsl:call-template name="inline.boldseq"/>
536 </xsl:template>
537
538 <xsl:template match="keycode">
539   <xsl:call-template name="inline.charseq"/>
540 </xsl:template>
541
542 <xsl:template match="keysym">
543   <xsl:call-template name="inline.charseq"/>
544 </xsl:template>
545
546 <xsl:template match="literal">
547   <xsl:call-template name="inline.monoseq"/>
548 </xsl:template>
549
550 <xsl:template match="code">
551   <xsl:call-template name="inline.monoseq"/>
552 </xsl:template>
553
554 <xsl:template match="medialabel">
555   <xsl:call-template name="inline.italicseq"/>
556 </xsl:template>
557
558 <xsl:template match="shortcut">
559   <xsl:call-template name="inline.boldseq"/>
560 </xsl:template>
561
562 <xsl:template match="mousebutton">
563   <xsl:call-template name="inline.charseq"/>
564 </xsl:template>
565
566 <xsl:template match="option">
567   <xsl:call-template name="inline.monoseq"/>
568 </xsl:template>
569
570 <xsl:template match="package">
571   <xsl:call-template name="inline.charseq"/>
572 </xsl:template>
573
574 <xsl:template match="parameter">
575   <xsl:call-template name="inline.italicmonoseq"/>
576 </xsl:template>
577
578 <xsl:template match="property">
579   <xsl:call-template name="inline.charseq"/>
580 </xsl:template>
581
582 <xsl:template match="prompt">
583   <xsl:call-template name="inline.monoseq"/>
584 </xsl:template>
585
586 <xsl:template match="replaceable">
587   <xsl:call-template name="inline.italicmonoseq"/>
588 </xsl:template>
589
590 <xsl:template match="returnvalue">
591   <xsl:call-template name="inline.charseq"/>
592 </xsl:template>
593
594 <xsl:template match="structfield">
595   <xsl:call-template name="inline.italicmonoseq"/>
596 </xsl:template>
597
598 <xsl:template match="structname">
599   <xsl:call-template name="inline.charseq"/>
600 </xsl:template>
601
602 <xsl:template match="symbol">
603   <xsl:call-template name="inline.charseq"/>
604 </xsl:template>
605
606 <xsl:template match="systemitem">
607   <xsl:call-template name="inline.monoseq"/>
608 </xsl:template>
609
610 <xsl:template match="token">
611   <xsl:call-template name="inline.charseq"/>
612 </xsl:template>
613
614 <xsl:template match="type">
615   <xsl:call-template name="inline.charseq"/>
616 </xsl:template>
617
618 <xsl:template match="userinput">
619   <xsl:call-template name="inline.boldmonoseq"/>
620 </xsl:template>
621
622 <xsl:template match="abbrev">
623   <xsl:call-template name="inline.charseq"/>
624 </xsl:template>
625
626 <xsl:template match="acronym">
627   <xsl:call-template name="inline.charseq"/>
628 </xsl:template>
629
630 <xsl:template match="citerefentry">
631   <xsl:call-template name="inline.charseq"/>
632 </xsl:template>
633
634 <xsl:template match="citetitle">
635   <xsl:choose>
636     <xsl:when test="@pubwork = 'article'">
637       <xsl:call-template name="gentext.startquote"/>
638       <xsl:call-template name="inline.charseq"/>
639       <xsl:call-template name="gentext.endquote"/>
640     </xsl:when>
641     <xsl:otherwise>
642       <xsl:call-template name="inline.italicseq"/>
643     </xsl:otherwise>
644   </xsl:choose>
645 </xsl:template>
646
647 <xsl:template match="emphasis">
648   <xsl:variable name="depth">
649     <xsl:call-template name="dot.count">
650       <xsl:with-param name="string">
651         <xsl:number level="multiple"/>
652       </xsl:with-param>
653     </xsl:call-template>
654   </xsl:variable>
655
656   <xsl:choose>
657     <xsl:when test="@role='bold' or @role='strong'">
658       <xsl:call-template name="inline.boldseq"/>
659     </xsl:when>
660     <xsl:when test="@role='underline'">
661       <fo:inline text-decoration="underline">
662         <xsl:call-template name="inline.charseq"/>
663       </fo:inline>
664     </xsl:when>
665     <xsl:when test="@role='strikethrough'">
666       <fo:inline text-decoration="line-through">
667         <xsl:call-template name="inline.charseq"/>
668       </fo:inline>
669     </xsl:when>
670     <xsl:otherwise>
671       <xsl:choose>
672         <xsl:when test="$depth mod 2 = 1">
673           <fo:inline font-style="normal">
674             <xsl:apply-templates/>
675           </fo:inline>
676         </xsl:when>
677         <xsl:otherwise>
678           <xsl:call-template name="inline.italicseq"/>
679         </xsl:otherwise>
680       </xsl:choose>
681     </xsl:otherwise>
682   </xsl:choose>
683 </xsl:template>
684
685 <xsl:template match="foreignphrase">
686   <xsl:call-template name="inline.italicseq"/>
687 </xsl:template>
688
689 <xsl:template match="markup">
690   <xsl:call-template name="inline.charseq"/>
691 </xsl:template>
692
693 <xsl:template match="phrase">
694   <fo:inline>
695     <xsl:call-template name="anchor"/>
696     <xsl:call-template name="inline.charseq"/>
697   </fo:inline>
698 </xsl:template>
699
700 <xsl:template match="quote">
701   <xsl:variable name="depth">
702     <xsl:call-template name="dot.count">
703       <xsl:with-param name="string"><xsl:number level="multiple"/></xsl:with-param>
704     </xsl:call-template>
705   </xsl:variable>
706   <xsl:variable name="content">
707     <xsl:choose>
708       <xsl:when test="$depth mod 2 = 0">
709         <xsl:call-template name="gentext.startquote"/>
710         <xsl:call-template name="inline.charseq"/>
711         <xsl:call-template name="gentext.endquote"/>
712       </xsl:when>
713       <xsl:otherwise>
714         <xsl:call-template name="gentext.nestedstartquote"/>
715         <xsl:call-template name="inline.charseq"/>
716         <xsl:call-template name="gentext.nestedendquote"/>
717       </xsl:otherwise>
718     </xsl:choose>
719   </xsl:variable>
720
721   <fo:inline>
722     <xsl:call-template name="anchor"/>
723     <xsl:copy-of select="$content"/>
724   </fo:inline>
725
726 </xsl:template>
727
728 <xsl:template match="varname">
729   <xsl:call-template name="inline.monoseq"/>
730 </xsl:template>
731
732 <xsl:template match="wordasword">
733   <xsl:call-template name="inline.italicseq"/>
734 </xsl:template>
735
736 <xsl:template match="lineannotation">
737   <fo:inline font-style="italic">
738     <xsl:call-template name="inline.charseq"/>
739   </fo:inline>
740 </xsl:template>
741
742 <xsl:template match="superscript">
743   <xsl:call-template name="inline.superscriptseq"/>
744 </xsl:template>
745
746 <xsl:template match="subscript">
747   <xsl:call-template name="inline.subscriptseq"/>
748 </xsl:template>
749
750 <xsl:template match="trademark">
751   <xsl:call-template name="inline.charseq"/>
752   <xsl:choose>
753     <xsl:when test="@class = 'copyright'
754                     or @class = 'registered'">
755       <xsl:call-template name="dingbat">
756         <xsl:with-param name="dingbat" select="@class"/>
757       </xsl:call-template>
758     </xsl:when>
759     <xsl:when test="@class = 'service'">
760       <xsl:call-template name="inline.superscriptseq">
761         <xsl:with-param name="content" select="'SM'"/>
762       </xsl:call-template>
763     </xsl:when>
764     <xsl:otherwise>
765       <xsl:call-template name="dingbat">
766         <xsl:with-param name="dingbat" select="'trademark'"/>
767       </xsl:call-template>
768     </xsl:otherwise>
769   </xsl:choose>
770 </xsl:template>
771
772 <xsl:template match="firstterm">
773   <xsl:call-template name="glossterm">
774     <xsl:with-param name="firstterm" select="1"/>
775   </xsl:call-template>
776 </xsl:template>
777
778 <xsl:template match="glossterm" name="glossterm">
779   <xsl:param name="firstterm" select="0"/>
780
781   <xsl:choose>
782     <xsl:when test="($firstterm.only.link = 0 or $firstterm = 1) and @linkend">
783       <xsl:variable name="targets" select="key('id',@linkend)"/>
784       <xsl:variable name="target" select="$targets[1]"/>
785
786       <xsl:choose>
787         <xsl:when test="$target">
788           <fo:basic-link internal-destination="{@linkend}" 
789                          xsl:use-attribute-sets="xref.properties">
790             <xsl:call-template name="inline.italicseq"/>
791           </fo:basic-link>
792         </xsl:when>
793         <xsl:otherwise>
794           <xsl:call-template name="inline.italicseq"/>
795         </xsl:otherwise>
796       </xsl:choose>
797     </xsl:when>
798
799     <xsl:when test="not(@linkend)
800                     and ($firstterm.only.link = 0 or $firstterm = 1)
801                     and ($glossterm.auto.link != 0)
802                     and $glossary.collection != ''">
803       <xsl:variable name="term">
804         <xsl:choose>
805           <xsl:when test="@baseform"><xsl:value-of select="@baseform"/></xsl:when>
806           <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
807         </xsl:choose>
808       </xsl:variable>
809       <xsl:variable name="cterm"
810            select="(document($glossary.collection,.)//glossentry[glossterm=$term])[1]"/>
811
812       <xsl:choose>
813         <xsl:when test="not($cterm)">
814           <xsl:message>
815             <xsl:text>There's no entry for </xsl:text>
816             <xsl:value-of select="$term"/>
817             <xsl:text> in </xsl:text>
818             <xsl:value-of select="$glossary.collection"/>
819           </xsl:message>
820           <xsl:call-template name="inline.italicseq"/>
821         </xsl:when>
822         <xsl:otherwise>
823           <xsl:variable name="id">
824             <xsl:call-template name="object.id">
825               <xsl:with-param name="object" select="$cterm"/>
826             </xsl:call-template>
827           </xsl:variable>
828           <fo:basic-link internal-destination="{$id}"
829                          xsl:use-attribute-sets="xref.properties">
830             <xsl:call-template name="inline.italicseq"/>
831           </fo:basic-link>
832         </xsl:otherwise>
833       </xsl:choose>
834     </xsl:when>
835
836     <xsl:when test="not(@linkend)
837                     and ($firstterm.only.link = 0 or $firstterm = 1)
838                     and $glossterm.auto.link != 0">
839       <xsl:variable name="term">
840         <xsl:choose>
841           <xsl:when test="@baseform">
842             <xsl:value-of select="normalize-space(@baseform)"/>
843           </xsl:when>
844           <xsl:otherwise>
845             <xsl:value-of select="normalize-space(.)"/>
846           </xsl:otherwise>
847         </xsl:choose>
848       </xsl:variable>
849
850       <xsl:variable name="targets"
851                     select="key('glossentries', $term)"/>
852       <xsl:variable name="target" select="$targets[1]"/>
853
854       <xsl:choose>
855         <xsl:when test="count($targets)=0">
856           <xsl:message>
857             <xsl:text>Error: no glossentry for glossterm: </xsl:text>
858             <xsl:value-of select="."/>
859             <xsl:text>.</xsl:text>
860           </xsl:message>
861           <xsl:call-template name="inline.italicseq"/>
862         </xsl:when>
863         <xsl:otherwise>
864           <xsl:variable name="termid">
865             <xsl:call-template name="object.id">
866               <xsl:with-param name="object" select="$target"/>
867             </xsl:call-template>
868           </xsl:variable>
869
870           <fo:basic-link internal-destination="{$termid}"
871                          xsl:use-attribute-sets="xref.properties">
872             <xsl:call-template name="inline.charseq"/>
873           </fo:basic-link>
874         </xsl:otherwise>
875       </xsl:choose>
876     </xsl:when>
877     <xsl:otherwise>
878       <xsl:call-template name="inline.italicseq"/>
879     </xsl:otherwise>
880   </xsl:choose>
881 </xsl:template>
882
883 <xsl:template match="termdef">
884   <fo:inline>
885     <xsl:call-template name="gentext.template">
886       <xsl:with-param name="context" select="'termdef'"/>
887       <xsl:with-param name="name" select="'prefix'"/>
888     </xsl:call-template>
889     <xsl:apply-templates/>
890     <xsl:call-template name="gentext.template">
891       <xsl:with-param name="context" select="'termdef'"/>
892       <xsl:with-param name="name" select="'suffix'"/>
893     </xsl:call-template>
894   </fo:inline>
895 </xsl:template>
896
897 <xsl:template match="sgmltag|tag">
898   <xsl:variable name="class">
899     <xsl:choose>
900       <xsl:when test="@class">
901         <xsl:value-of select="@class"/>
902       </xsl:when>
903       <xsl:otherwise>element</xsl:otherwise>
904     </xsl:choose>
905   </xsl:variable>
906
907   <xsl:choose>
908     <xsl:when test="$class='attribute'">
909       <xsl:call-template name="inline.monoseq"/>
910     </xsl:when>
911     <xsl:when test="$class='attvalue'">
912       <xsl:call-template name="inline.monoseq"/>
913     </xsl:when>
914     <xsl:when test="$class='element'">
915       <xsl:call-template name="inline.monoseq"/>
916     </xsl:when>
917     <xsl:when test="$class='endtag'">
918       <xsl:call-template name="inline.monoseq">
919         <xsl:with-param name="content">
920           <xsl:text>&lt;/</xsl:text>
921           <xsl:apply-templates/>
922           <xsl:text>&gt;</xsl:text>
923         </xsl:with-param>
924       </xsl:call-template>
925     </xsl:when>
926     <xsl:when test="$class='genentity'">
927       <xsl:call-template name="inline.monoseq">
928         <xsl:with-param name="content">
929           <xsl:text>&amp;</xsl:text>
930           <xsl:apply-templates/>
931           <xsl:text>;</xsl:text>
932         </xsl:with-param>
933       </xsl:call-template>
934     </xsl:when>
935     <xsl:when test="$class='numcharref'">
936       <xsl:call-template name="inline.monoseq">
937         <xsl:with-param name="content">
938           <xsl:text>&amp;#</xsl:text>
939           <xsl:apply-templates/>
940           <xsl:text>;</xsl:text>
941         </xsl:with-param>
942       </xsl:call-template>
943     </xsl:when>
944     <xsl:when test="$class='paramentity'">
945       <xsl:call-template name="inline.monoseq">
946         <xsl:with-param name="content">
947           <xsl:text>%</xsl:text>
948           <xsl:apply-templates/>
949           <xsl:text>;</xsl:text>
950         </xsl:with-param>
951       </xsl:call-template>
952     </xsl:when>
953     <xsl:when test="$class='pi'">
954       <xsl:call-template name="inline.monoseq">
955         <xsl:with-param name="content">
956           <xsl:text>&lt;?</xsl:text>
957           <xsl:apply-templates/>
958           <xsl:text>&gt;</xsl:text>
959         </xsl:with-param>
960       </xsl:call-template>
961     </xsl:when>
962     <xsl:when test="$class='xmlpi'">
963       <xsl:call-template name="inline.monoseq">
964         <xsl:with-param name="content">
965           <xsl:text>&lt;?</xsl:text>
966           <xsl:apply-templates/>
967           <xsl:text>?&gt;</xsl:text>
968         </xsl:with-param>
969       </xsl:call-template>
970     </xsl:when>
971     <xsl:when test="$class='starttag'">
972       <xsl:call-template name="inline.monoseq">
973         <xsl:with-param name="content">
974           <xsl:text>&lt;</xsl:text>
975           <xsl:apply-templates/>
976           <xsl:text>&gt;</xsl:text>
977         </xsl:with-param>
978       </xsl:call-template>
979     </xsl:when>
980     <xsl:when test="$class='emptytag'">
981       <xsl:call-template name="inline.monoseq">
982         <xsl:with-param name="content">
983           <xsl:text>&lt;</xsl:text>
984           <xsl:apply-templates/>
985           <xsl:text>/&gt;</xsl:text>
986         </xsl:with-param>
987       </xsl:call-template>
988     </xsl:when>
989     <xsl:when test="$class='sgmlcomment' or $class='comment'">
990       <xsl:call-template name="inline.monoseq">
991         <xsl:with-param name="content">
992           <xsl:text>&lt;!--</xsl:text>
993           <xsl:apply-templates/>
994           <xsl:text>--&gt;</xsl:text>
995         </xsl:with-param>
996       </xsl:call-template>
997     </xsl:when>
998     <xsl:otherwise>
999       <xsl:call-template name="inline.charseq"/>
1000     </xsl:otherwise>
1001   </xsl:choose>
1002 </xsl:template>
1003
1004 <xsl:template match="email">
1005   <xsl:call-template name="inline.monoseq">
1006     <xsl:with-param name="content">
1007       <fo:inline keep-together.within-line="always" hyphenate="false">
1008         <xsl:if test="not($email.delimiters.enabled = 0)">
1009           <xsl:text>&lt;</xsl:text>
1010         </xsl:if>
1011         <xsl:choose>
1012           <xsl:when test="not($email.mailto.enabled = 0)">
1013             <fo:basic-link xsl:use-attribute-sets="xref.properties"
1014                            keep-together.within-line="always" hyphenate="false">
1015               <xsl:attribute name="external-destination">
1016                 mailto:<xsl:value-of select="string(.)" />
1017               </xsl:attribute>
1018               <xsl:apply-templates/>
1019             </fo:basic-link>
1020           </xsl:when>
1021           <xsl:otherwise>
1022             <xsl:apply-templates/>
1023           </xsl:otherwise>
1024         </xsl:choose>
1025         <xsl:if test="not($email.delimiters.enabled = 0)">
1026           <xsl:text>&gt;</xsl:text>
1027         </xsl:if>
1028       </fo:inline>
1029     </xsl:with-param>
1030   </xsl:call-template>
1031 </xsl:template>
1032
1033 <xsl:template match="keycombo">
1034   <xsl:variable name="action" select="@action"/>
1035   <xsl:variable name="joinchar">
1036     <xsl:choose>
1037       <xsl:when test="$action='seq'"><xsl:text> </xsl:text></xsl:when>
1038       <xsl:when test="$action='simul'">+</xsl:when>
1039       <xsl:when test="$action='press'">-</xsl:when>
1040       <xsl:when test="$action='click'">-</xsl:when>
1041       <xsl:when test="$action='double-click'">-</xsl:when>
1042       <xsl:when test="$action='other'"></xsl:when>
1043       <xsl:otherwise>+</xsl:otherwise>
1044     </xsl:choose>
1045   </xsl:variable>
1046   <xsl:for-each select="*">
1047     <xsl:if test="position()>1"><xsl:value-of select="$joinchar"/></xsl:if>
1048     <xsl:apply-templates select="."/>
1049   </xsl:for-each>
1050 </xsl:template>
1051
1052 <xsl:template match="uri">
1053   <xsl:call-template name="inline.monoseq"/>
1054 </xsl:template>
1055
1056 <!-- ==================================================================== -->
1057
1058 <xsl:template match="menuchoice">
1059   <xsl:variable name="shortcut" select="./shortcut"/>
1060   <xsl:call-template name="process.menuchoice"/>
1061   <xsl:if test="$shortcut">
1062     <xsl:text> (</xsl:text>
1063     <xsl:apply-templates select="$shortcut"/>
1064     <xsl:text>)</xsl:text>
1065   </xsl:if>
1066 </xsl:template>
1067
1068 <xsl:template name="process.menuchoice">
1069   <xsl:param name="nodelist" select="guibutton|guiicon|guilabel|guimenu|guimenuitem|guisubmenu|interface"/><!-- not(shortcut) -->
1070   <xsl:param name="count" select="1"/>
1071
1072   <xsl:variable name="mm.separator">
1073     <xsl:choose>
1074       <xsl:when test="($fop.extensions != 0 or $fop1.extensions != 0 ) and
1075                 contains($menuchoice.menu.separator, '&#x2192;')">
1076         <fo:inline font-family="Symbol">
1077           <xsl:copy-of select="$menuchoice.menu.separator"/>
1078         </fo:inline>
1079       </xsl:when>
1080       <xsl:otherwise>
1081         <xsl:copy-of select="$menuchoice.menu.separator"/>
1082       </xsl:otherwise>
1083     </xsl:choose>
1084   </xsl:variable>
1085
1086   <xsl:choose>
1087     <xsl:when test="$count>count($nodelist)"></xsl:when>
1088     <xsl:when test="$count=1">
1089       <xsl:apply-templates select="$nodelist[$count=position()]"/>
1090       <xsl:call-template name="process.menuchoice">
1091         <xsl:with-param name="nodelist" select="$nodelist"/>
1092         <xsl:with-param name="count" select="$count+1"/>
1093       </xsl:call-template>
1094     </xsl:when>
1095     <xsl:otherwise>
1096       <xsl:variable name="node" select="$nodelist[$count=position()]"/>
1097       <xsl:choose>
1098         <xsl:when test="local-name($node)='guimenuitem'
1099                         or local-name($node)='guisubmenu'">
1100           <xsl:copy-of select="$mm.separator"/>
1101         </xsl:when>
1102         <xsl:otherwise>
1103           <xsl:copy-of select="$menuchoice.separator"/>
1104         </xsl:otherwise>
1105       </xsl:choose>
1106       <xsl:apply-templates select="$node"/>
1107       <xsl:call-template name="process.menuchoice">
1108         <xsl:with-param name="nodelist" select="$nodelist"/>
1109         <xsl:with-param name="count" select="$count+1"/>
1110       </xsl:call-template>
1111     </xsl:otherwise>
1112   </xsl:choose>
1113 </xsl:template>
1114
1115 <!-- ==================================================================== -->
1116
1117 <xsl:template match="optional">
1118   <xsl:value-of select="$arg.choice.opt.open.str"/>
1119   <xsl:call-template name="inline.charseq"/>
1120   <xsl:value-of select="$arg.choice.opt.close.str"/>
1121 </xsl:template>
1122
1123 <xsl:template match="citation">
1124   <!-- todo: integrate with bibliography collection -->
1125   <xsl:variable name="targets" select="(//biblioentry | //bibliomixed)[abbrev = string(current())]"/>
1126   <xsl:variable name="target" select="$targets[1]"/>
1127
1128   <xsl:choose>
1129     <!-- try automatic linking based on match to abbrev -->
1130     <xsl:when test="$target and not(xref) and not(link)">
1131
1132       <xsl:text>[</xsl:text>
1133       <fo:basic-link>
1134         <xsl:attribute name="internal-destination">
1135           <xsl:call-template name="object.id">
1136             <xsl:with-param name="object" select="$target"/>
1137           </xsl:call-template>
1138         </xsl:attribute>
1139
1140         <xsl:choose>
1141           <xsl:when test="$bibliography.numbered != 0">
1142             <xsl:apply-templates select="$target" mode="citation"/>
1143           </xsl:when>
1144           <xsl:otherwise>
1145             <xsl:call-template name="inline.charseq"/>
1146           </xsl:otherwise>
1147         </xsl:choose>
1148      
1149       </fo:basic-link>
1150       <xsl:text>]</xsl:text>
1151     </xsl:when>
1152
1153     <xsl:otherwise>
1154       <xsl:text>[</xsl:text>
1155       <xsl:call-template name="inline.charseq"/>
1156       <xsl:text>]</xsl:text>
1157     </xsl:otherwise>
1158   </xsl:choose>
1159 </xsl:template>
1160
1161 <xsl:template match="citebiblioid">
1162   <xsl:variable name="targets" select="//*[biblioid = string(current())]"/>
1163   <xsl:variable name="target" select="$targets[1]"/>
1164
1165   <xsl:choose>
1166     <!-- try automatic linking based on match to parent of biblioid -->
1167     <xsl:when test="$target and not(xref) and not(link)">
1168
1169       <xsl:text>[</xsl:text>
1170       <fo:basic-link>
1171         <xsl:attribute name="internal-destination">
1172           <xsl:call-template name="object.id">
1173             <xsl:with-param name="object" select="$target"/>
1174           </xsl:call-template>
1175         </xsl:attribute>
1176
1177         <xsl:call-template name="inline.charseq"/>
1178             
1179       </fo:basic-link>
1180       <xsl:text>]</xsl:text>
1181     </xsl:when>
1182
1183     <xsl:otherwise>
1184       <xsl:text>[</xsl:text>
1185       <xsl:call-template name="inline.charseq"/>
1186       <xsl:text>]</xsl:text>
1187     </xsl:otherwise>
1188   </xsl:choose>
1189 </xsl:template>
1190
1191 <xsl:template match="biblioentry|bibliomixed" mode="citation">
1192   <xsl:number from="bibliography" count="biblioentry|bibliomixed"
1193               level="any" format="1"/>
1194 </xsl:template>
1195
1196 <!-- ==================================================================== -->
1197
1198 <xsl:template match="comment[&comment.block.parents;]|remark[&comment.block.parents;]">
1199   <xsl:if test="$show.comments != 0">
1200     <fo:block font-style="italic">
1201       <xsl:call-template name="inline.charseq"/>
1202     </fo:block>
1203   </xsl:if>
1204 </xsl:template>
1205
1206 <xsl:template match="comment|remark">
1207   <xsl:if test="$show.comments != 0">
1208     <fo:inline font-style="italic">
1209       <xsl:call-template name="inline.charseq"/>
1210     </fo:inline>
1211   </xsl:if>
1212 </xsl:template>
1213
1214 <!-- ==================================================================== -->
1215
1216 <xsl:template match="productname">
1217   <xsl:call-template name="inline.charseq"/>
1218   <xsl:if test="@class">
1219     <xsl:call-template name="dingbat">
1220       <xsl:with-param name="dingbat" select="@class"/>
1221     </xsl:call-template>
1222   </xsl:if>
1223 </xsl:template>
1224
1225 <xsl:template match="productnumber">
1226   <xsl:call-template name="inline.charseq"/>
1227 </xsl:template>
1228
1229 <!-- ==================================================================== -->
1230
1231 <xsl:template match="pob|street|city|state|postcode|country|otheraddr">
1232   <xsl:call-template name="inline.charseq"/>
1233 </xsl:template>
1234
1235 <xsl:template match="phone|fax">
1236   <xsl:call-template name="inline.charseq"/>
1237 </xsl:template>
1238
1239 <!-- in Addresses, for example -->
1240 <xsl:template match="honorific|firstname|surname|lineage|othername">
1241   <xsl:call-template name="inline.charseq"/>
1242 </xsl:template>
1243
1244 <!-- ==================================================================== -->
1245
1246 <xsl:template match="person">
1247   <xsl:apply-templates select="personname"/>
1248 </xsl:template>
1249
1250 <xsl:template match="personname">
1251   <xsl:call-template name="simple.xlink">
1252     <xsl:with-param name="content">
1253       <xsl:call-template name="person.name"/>
1254     </xsl:with-param>
1255   </xsl:call-template>
1256 </xsl:template>
1257
1258 <xsl:template match="jobtitle">
1259   <xsl:call-template name="simple.xlink">
1260     <xsl:with-param name="content">
1261       <xsl:apply-templates/>
1262     </xsl:with-param>
1263   </xsl:call-template>
1264 </xsl:template>
1265
1266 <!-- ==================================================================== -->
1267
1268 <xsl:template match="org">
1269   <xsl:call-template name="inline.charseq"/>
1270 </xsl:template>
1271
1272 <xsl:template match="orgname">
1273   <xsl:call-template name="inline.charseq"/>
1274 </xsl:template>
1275
1276 <xsl:template match="orgdiv">
1277   <xsl:call-template name="inline.charseq"/>
1278 </xsl:template>
1279
1280 <xsl:template match="affiliation">
1281   <xsl:call-template name="inline.charseq"/>
1282 </xsl:template>
1283
1284 <!-- ==================================================================== -->
1285
1286 <xsl:template match="beginpage">
1287   <!-- does nothing; this *is not* markup to force a page break. -->
1288 </xsl:template>
1289
1290 <xsl:template match="*" mode="simple.xlink.properties">
1291   <!-- Placeholder template to apply properties to links made from
1292        elements other than xref, link, and olink.
1293        This template should generate attributes only, as it is
1294        applied right after the opening <fo:basic-link> tag.
1295        -->
1296   <!-- for example
1297   <xsl:attribute name="color">blue</xsl:attribute>
1298   -->
1299   <!-- Since this is a mode, you can create different
1300        templates with different properties for different linking elements -->
1301 </xsl:template>
1302
1303 </xsl:stylesheet>
1304