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