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