summaryrefslogtreecommitdiff
path: root/gtk-doc.xsl
blob: 7d6530b13804bb2de6249a369d748e4c7e6769a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
<?xml version='1.0'?> <!--*- mode: xml -*-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
                exclude-result-prefixes="l"
                version="1.0">

  <!-- import the chunked XSL stylesheet -->
  <!-- http://www.sagehill.net/docbookxsl/Chunking.html#FastChunking says we should use
       "chunkfast.xsl", but I can't see a difference. Also it is not clear whether
       one should still set "chunk.fast". Again, no meassuable difference. -->
  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
  <xsl:include href="devhelp2.xsl"/>
  <xsl:include href="version-greater-or-equal.xsl"/>

  <xsl:key name="acronym.key" match="glossentry/glossterm" use="."/>
  <xsl:key name="gallery.key" match="para[@role='gallery']/link" use="@linkend"/>

  <!-- change some parameters -->
  <!-- http://docbook.sourceforge.net/release/xsl/current/doc/html/index.html -->
  <xsl:param name="admon.style"/>
  <xsl:param name="toc.section.depth">2</xsl:param>
  <xsl:param name="generate.toc">
    book	toc
    chapter toc
    glossary toc
    index toc
    part	toc
    reference toc
  </xsl:param>
  <xsl:param name="process.empty.source.toc">1</xsl:param>

  <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
  <xsl:param name="chunker.output.indent" select="'yes'"/>
  <xsl:param name="chunker.output.doctype-public" select="'-//W3C//DTD HTML 4.01 Transitional//EN'"/>
  <xsl:param name="chunk.fast" select="1"/>

  <xsl:param name="default.encoding" select="'UTF-8'"/>
  <xsl:param name="chapter.autolabel" select="0"/>
  <xsl:param name="use.id.as.filename" select="1"/>
  <xsl:param name="generate.consistent.ids" select="1"/>
  <xsl:param name="html.ext" select="'.html'"/>
  <xsl:param name="refentry.generate.name" select="0"/>
  <xsl:param name="refentry.generate.title" select="1"/>
  <xsl:param name="abstract.notitle.enabled" select="1"/>
  <!-- don't generate all those link tags (very slow and hardly used)
       it does not show much effect as we have a user.head.content template
  <xsl:param name="html.extra.head.links" select="0" />
   -->

  <!-- use index filtering (if available) -->
  <xsl:param name="index.on.role" select="1"/>

  <!-- display variablelists as tables -->
  <xsl:param name="variablelist.as.table" select="1"/>

  <!-- new things to consider
  <xsl:param name="glossterm.auto.link" select="0"></xsl:param>
  -->

  <!-- this gets set on the command line ... -->
  <xsl:param name="gtkdoc.version" select="''"/>
  <xsl:param name="gtkdoc.bookname" select="''"/>

  <!-- Override the typical template to prevent showing titles -->
  <xsl:param name="admon.textlabel" select="0"/>

  <!-- ========================================================= -->

  <!-- l10n is slow, we don't ue it, so we'd like to turn it off
       this at least avoid the re-evaluation -->
  <xsl:template name="l10n.language">en</xsl:template>

  <xsl:param name="gtkdoc.l10n.xml" select="document('http://docbook.sourceforge.net/release/xsl/current/common/en.xml')"/>

  <xsl:key name="gtkdoc.gentext.key" match="l:gentext[@key]" use="@key"/>
  <xsl:key name="gtkdoc.context.key" match="l:context[@name]" use="@name"/>

  <xsl:template name="gentext">
    <xsl:param name="key" select="local-name(.)"/>

    <xsl:for-each select="$gtkdoc.l10n.xml">
    <xsl:variable name="l10n.gentext" select="key('gtkdoc.gentext.key', $key)"/>

    <xsl:choose>
      <xsl:when test="$l10n.gentext">
        <xsl:value-of select="$l10n.gentext/@text"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>
          <xsl:text>No "en" localization of "</xsl:text>
          <xsl:value-of select="$key"/>
          <xsl:text>" exists.</xsl:text>
        </xsl:message>
      </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="gentext.dingbat">
    <xsl:param name="dingbat">bullet</xsl:param>

    <xsl:variable name="l10n.dingbat"
                  select="($gtkdoc.l10n.xml/l:l10n/l:dingbat[@key=$dingbat])[1]"/>

    <xsl:choose>
      <xsl:when test="$l10n.dingbat">
        <xsl:value-of select="$l10n.dingbat/@text"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>
          <xsl:text>No "en" localization of dingbat </xsl:text>
          <xsl:value-of select="$dingbat"/>
          <xsl:text> exists; using "en".</xsl:text>
        </xsl:message>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="gentext.template">
    <xsl:param name="context" select="'default'"/>
    <xsl:param name="name" select="'default'"/>
    <xsl:param name="origname" select="$name"/>

    <!-- cut leading / if any to avoid one recursion -->
    <xsl:variable name="rname">
      <xsl:choose>
        <xsl:when test="starts-with($name, '/')">
          <xsl:value-of select="substring-after($name, '/')"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$name"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <!-- this is called with context="title|title-numbered|title-unnumbered>
    <xsl:message>
      <xsl:text>context:</xsl:text><xsl:value-of select="$context"/>
      <xsl:text>;name:</xsl:text><xsl:value-of select="$rname"/>
      <xsl:text>;origname:</xsl:text><xsl:value-of select="$origname"/>
    </xsl:message>

    see html/html.xsl:<xsl:template match="*" mode="html.title.attribute">
    -->

    <xsl:for-each select="$gtkdoc.l10n.xml">
    <xsl:variable name="context.node" select="key('gtkdoc.context.key', $context)"/>
    <xsl:variable name="template.node"
                  select="($context.node/l:template[@name=$rname])[1]"/>

    <xsl:choose>
      <xsl:when test="$template.node/@text">
        <xsl:value-of select="$template.node/@text"/>
        <!-- debug
        <xsl:message>
          <xsl:text>=</xsl:text><xsl:value-of select="$template.node/@text"/>
        </xsl:message>
        -->
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="contains($rname, '/')">
            <xsl:call-template name="gentext.template">
              <xsl:with-param name="context" select="$context"/>
              <xsl:with-param name="name" select="substring-after($rname, '/')"/>
              <xsl:with-param name="origname" select="$origname"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
  </xsl:template>

  <!-- silently test whether a gentext template exists -->
  <xsl:template name="gentext.template.exists">
    <xsl:param name="context" select="'default'"/>
    <xsl:param name="name" select="'default'"/>
    <xsl:param name="origname" select="$name"/>

    <xsl:variable name="template">
      <xsl:call-template name="gentext.template">
        <xsl:with-param name="context" select="$context"/>
        <xsl:with-param name="name" select="$name"/>
        <xsl:with-param name="origname" select="$origname"/>
      </xsl:call-template>
    </xsl:variable>

    <xsl:choose>
      <xsl:when test="string-length($template) != 0">1</xsl:when>
      <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- shortcut version -->
  <!-- @bug: https://bugzilla.gnome.org/show_bug.cgi?id=617478 -->
  <xsl:template name="generate.html.title"/>
  <!--xsl:template name="generate.html.title">
    <xsl:variable name="has.title.markup">
      <xsl:apply-templates select="." mode="title.markup">
        <xsl:with-param name="verbose" select="0"/>
      </xsl:apply-templates>
    </xsl:variable>
    <xsl:if test="$has.title.markup != '???TITLE???'">
      <xsl:variable name="gentext.title">
        <xsl:apply-templates select="."  mode="object.title.markup.textonly"/>
      </xsl:variable>
      <xsl:choose>
        <xsl:when test="string-length($gentext.title) != 0">
          <xsl:attribute name="title">
            <xsl:value-of select="$gentext.title"/>
          </xsl:attribute>
        </xsl:when>
        <xsl:when test="alt">
          <xsl:attribute name="title">
            <xsl:value-of select="normalize-space(alt)"/>
          </xsl:attribute>
        </xsl:when>
      </xsl:choose>
    </xsl:if>
  </xsl:template-->

  <!-- Generate a title attribute for the context node (e.g. links) -->
  <xsl:template match="*" mode="html.title.attribute">
    <xsl:variable name="has.title.markup">
      <xsl:apply-templates select="." mode="title.markup">
        <xsl:with-param name="verbose" select="0"/>
      </xsl:apply-templates>
    </xsl:variable>
    <xsl:if test="$has.title.markup != '???TITLE???'">
      <xsl:variable name="is.title">
        <xsl:call-template name="gentext.template.exists">
          <xsl:with-param name="context" select="'title'"/>
          <xsl:with-param name="name" select="local-name(.)"/>
          <xsl:with-param name="lang">
            <xsl:call-template name="l10n.language"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>

      <xsl:variable name="is.title-numbered">
        <xsl:if test="$is.title = 0">
          <xsl:call-template name="gentext.template.exists">
            <xsl:with-param name="context" select="'title-numbered'"/>
            <xsl:with-param name="name" select="local-name(.)"/>
            <xsl:with-param name="lang">
              <xsl:call-template name="l10n.language"/>
            </xsl:with-param>
          </xsl:call-template>
        </xsl:if>
      </xsl:variable>

      <xsl:variable name="is.title-unnumbered">
        <xsl:if test="$is.title = 0 and $is.title-numbered = 0">
          <xsl:call-template name="gentext.template.exists">
            <xsl:with-param name="context" select="'title-unnumbered'"/>
            <xsl:with-param name="name" select="local-name(.)"/>
            <xsl:with-param name="lang">
              <xsl:call-template name="l10n.language"/>
            </xsl:with-param>
          </xsl:call-template>
        </xsl:if>
      </xsl:variable>

      <xsl:variable name="gentext.title">
        <xsl:if test="$is.title != 0 or
                      $is.title-numbered != 0 or
                      $is.title-unnumbered != 0">
          <xsl:apply-templates select="."
                               mode="object.title.markup.textonly"/>
        </xsl:if>
      </xsl:variable>

      <xsl:choose>
        <xsl:when test="string-length($gentext.title) != 0">
          <xsl:attribute name="title">
            <xsl:value-of select="$gentext.title"/>
          </xsl:attribute>
        </xsl:when>
        <xsl:when test="alt">
          <xsl:attribute name="title">
            <xsl:value-of select="normalize-space(alt)"/>
          </xsl:attribute>
        </xsl:when>
      </xsl:choose>
    </xsl:if>
  </xsl:template>




  <!-- ========================================================= -->
  <!-- template to create the index.sgml anchor index -->

  <xsl:template match="book|article">
    <xsl:variable name="tooldver">
      <xsl:call-template name="version-greater-or-equal">
        <xsl:with-param name="ver1" select="$VERSION" />
        <xsl:with-param name="ver2">1.36</xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:if test="$tooldver = 0">
      <xsl:message terminate="yes">
FATAL-ERROR: You need the DocBook XSL Stylesheets version 1.36 or higher
to build the documentation.
Get a newer version at http://docbook.sourceforge.net/projects/xsl/
      </xsl:message>
    </xsl:if>
    <xsl:apply-imports/>

    <!-- generate $book.devhelp2 -->
    <xsl:call-template name="generate.devhelp2"/>
  </xsl:template>

  <!-- ========================================================= -->
  <!-- template to output gtkdoclink elements for the unknown targets -->

  <xsl:template match="link">
    <xsl:choose>
      <xsl:when test="id(@linkend)">
        <xsl:apply-imports/>
      </xsl:when>
      <xsl:otherwise>
        <GTKDOCLINK HREF="{@linkend}">
          <xsl:apply-templates/>
        </GTKDOCLINK>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- ========================================================= -->
  <!-- Below are the visual portions of the stylesheet.  They provide
       the normal gtk-doc output style. -->

  <xsl:param name="shade.verbatim" select="0"/>
  <xsl:param name="refentry.separator" select="0"/>

  <xsl:template match="refsect2">
    <xsl:if test="preceding-sibling::refsect2">
      <hr/>
    </xsl:if>
    <xsl:apply-imports/>
  </xsl:template>

  <xsl:template name="user.head.title">
   <xsl:param name="node" select="."/>
   <xsl:param name="title"/>
   <xsl:variable name="home" select="/*[1]"/>
   <title>
     <xsl:copy-of select="$title"/>: <xsl:apply-templates select="$home" mode="object.title.markup"/>
   </title>
  </xsl:template>

  <xsl:template name="user.head.content">
    <xsl:if test="$gtkdoc.version">
      <meta name="generator" content="GTK-Doc V{$gtkdoc.version} (XML mode)"/>
    </xsl:if>
    <link rel="stylesheet" href="style.css" type="text/css"/>
  </xsl:template>

  <xsl:template name="user.footer.content">
    <div class="footer">
      <hr />
      <xsl:choose>
        <xsl:when test="$gtkdoc.version">
          <xsl:text>Generated by GTK-Doc V</xsl:text><xsl:copy-of select="$gtkdoc.version" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>Generated by GTK-Doc</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>

  <xsl:template match="title" mode="book.titlepage.recto.mode">
    <table class="navigation" id="top" width="100%"
           cellpadding="2" cellspacing="0">
      <tr>
        <th valign="middle">
          <p class="{name(.)}">
            <xsl:value-of select="."/>
          </p>
        </th>
      </tr>
    </table>
  </xsl:template>

  <xsl:template name="header.navigation">
    <xsl:param name="prev" select="/foo"/>
    <xsl:param name="next" select="/foo"/>
    <xsl:variable name="home" select="/*[1]"/>
    <xsl:variable name="up" select="parent::*"/>
    <xsl:variable name="refsections" select="./refsect1[@role]"/>
    <xsl:variable name="glssections" select="./glossdiv/title"/>
    <xsl:variable name="idxsections" select="./indexdiv/indexdiv/title"/>
    <xsl:variable name="section_id" select="./@id"/>
    <xsl:variable name="sect_object_hierarchy" select="./refsect1[@role='object_hierarchy']"/>
    <xsl:variable name="sect_impl_interfaces" select="./refsect1[@role='impl_interfaces']"/>
    <xsl:variable name="sect_prerequisites" select="./refsect1[@role='prerequisites']"/>
    <xsl:variable name="sect_derived_interfaces" select="./refsect1[@role='derived_interfaces']"/>
    <xsl:variable name="sect_implementations" select="./refsect1[@role='implementations']"/>
    <xsl:variable name="sect_properties" select="./refsect1[@role='properties']"/>
    <xsl:variable name="sect_actions" select="./refsect1[@role='actions']"/>
    <xsl:variable name="sect_child_properties" select="./refsect1[@role='child_properties']"/>
    <xsl:variable name="sect_style_properties" select="./refsect1[@role='style_properties']"/>
    <xsl:variable name="sect_signal_proto" select="./refsect1[@role='signal_proto']"/>
    <xsl:variable name="sect_desc" select="./refsect1[@role='desc']"/>
    <xsl:variable name="sect_synopsis" select="./refsynopsisdiv[@role='synopsis']"/>
    <!--
    <xsl:variable name="sect_details" select="./refsect1[@id='details']"/>
    <xsl:variable name="sect_property_details" select="./refsect1[@id='property_details']"/>
    <xsl:variable name="sect_child_property_details" select="./refsect1[@id='child_property_details']"/>
    <xsl:variable name="sect_style_property_details" select="./refsect1[@id='style_property_details']"/>
    <xsl:variable name="sect_signals" select="./refsect1[@id='signals']"/>
    -->

    <xsl:if test="$suppress.navigation = '0' and $home != .">
      <table class="navigation" id="top" width="100%"
             summary = "Navigation header" cellpadding="2" cellspacing="5">
        <tr valign="middle">
          <td width="100%" align="left" class="shortcuts">
            <!--<xsl:if test="name()='refentry'"-->
            <xsl:choose>
              <xsl:when test="count($refsections) > 0">
                <a href="#" class="shortcut">Top</a>
                <xsl:if test="count($sect_desc) > 0">
                  <span id="nav_description">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.description" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='desc']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_object_hierarchy) > 0">
                  <span id="nav_hierarchy">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.object-hierarchy" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='object_hierarchy']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_impl_interfaces) > 0">
                  <span id="nav_interfaces">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.implemented-interfaces" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='impl_interfaces']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_prerequisites) > 0">
                  <span id="nav_prerequisites">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.prerequisites" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='prerequisites']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_derived_interfaces) > 0">
                  <span id="nav_derived_interfaces">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.derived-interfaces" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='derived_interfaces']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_implementations) > 0">
                  <span id="nav_implementations">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.implementations" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='implementations']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_properties) > 0">
                  <span id="nav_properties">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.properties" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='properties']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_child_properties) > 0">
                  <span id="nav_child_properties">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.child-properties" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='child_properties']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_style_properties) > 0">
                  <span id="nav_style_properties">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.style-properties" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='style_properties']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_signal_proto) > 0">
                  <span id="nav_signals">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.signals" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='signal_proto']/title"/>
                  </a></span>
                </xsl:if>
                <xsl:if test="count($sect_actions) > 0">
                  <span id="nav_properties">&#160;&#160;<span class="dim">|</span>&#160;
                  <a href="#{$section_id}.actions" class="shortcut">
                    <xsl:value-of select="./refsect1[@role='actions']/title"/>
                  </a></span>
                </xsl:if>
              </xsl:when>
              <!-- this is not yet very nice, as it requires all glossdic/indexdiv
                   elements having a anchor element. maybe we can customize the xsl
                   to automatically create local anchors
              -->
              <xsl:when test="count($glssections) > 0">
                <span id="nav_glossary">
                <xsl:for-each select="./glossdiv">
                  <xsl:if test="position() > 1">
                    &#160;<span class="dim">|</span>&#160;
                  </xsl:if>
                  <a class="shortcut">
                    <xsl:attribute name="href">#gls<xsl:value-of select="./title"/></xsl:attribute>
                    <xsl:value-of select="./title"/>
                  </a>
                </xsl:for-each>
                </span>
              </xsl:when>
              <xsl:when test="count($idxsections) > 0">
                <span id="nav_index">
                <xsl:for-each select="./indexdiv/indexdiv">
                  <xsl:if test="position() > 1">
                    &#160;<span class="dim">|</span>&#160;
                  </xsl:if>
                  <a class="shortcut">
                    <xsl:attribute name="href">#idx<xsl:value-of select="./title"/></xsl:attribute>
                    <xsl:value-of select="./title"/>
                  </a>
                </xsl:for-each>
                </span>
              </xsl:when>
            </xsl:choose>
          </td>
          <xsl:choose>
            <xsl:when test="$home != .">
              <td>
                <a accesskey="h">
                  <xsl:attribute name="href">
                    <xsl:call-template name="href.target">
                      <xsl:with-param name="object" select="$home"/>
                    </xsl:call-template>
                  </xsl:attribute>
                  <img src="home.png" width="16" height="16" border="0">
                    <xsl:attribute name="alt">
                      <xsl:call-template name="gentext">
                        <xsl:with-param name="key">nav-home</xsl:with-param>
                      </xsl:call-template>
                    </xsl:attribute>
                  </img>
                </a>
              </td>
            </xsl:when>
            <xsl:otherwise>
              <td>&#160;</td>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="count($up) > 0 and $up != $home">
              <td>
                <a accesskey="u">
                  <xsl:attribute name="href">
                    <xsl:call-template name="href.target">
                      <xsl:with-param name="object" select="$up"/>
                    </xsl:call-template>
                  </xsl:attribute>
                  <img src="up.png" width="16" height="16" border="0">
                    <xsl:attribute name="alt">
                      <xsl:call-template name="gentext">
                        <xsl:with-param name="key">nav-up</xsl:with-param>
                      </xsl:call-template>
                    </xsl:attribute>
                  </img>
                </a>
              </td>
            </xsl:when>
            <xsl:otherwise>
              <td><img src="up-insensitive.png" width="16" height="16" border="0"/></td>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="count($prev) > 0">
              <td>
                <a accesskey="p">
                  <xsl:attribute name="href">
                    <xsl:call-template name="href.target">
                      <xsl:with-param name="object" select="$prev"/>
                    </xsl:call-template>
                  </xsl:attribute>
                  <img src="left.png" width="16" height="16" border="0">
                    <xsl:attribute name="alt">
                      <xsl:call-template name="gentext">
                        <xsl:with-param name="key">nav-prev</xsl:with-param>
                      </xsl:call-template>
                    </xsl:attribute>
                  </img>
                </a>
              </td>
            </xsl:when>
            <xsl:otherwise>
              <td><img src="left-insensitive.png" width="16" height="16" border="0"/></td>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="count($next) > 0">
              <td>
                <a accesskey="n">
                  <xsl:attribute name="href">
                    <xsl:call-template name="href.target">
                      <xsl:with-param name="object" select="$next"/>
                    </xsl:call-template>
                  </xsl:attribute>
                  <img src="right.png" width="16" height="16" border="0">
                    <xsl:attribute name="alt">
                      <xsl:call-template name="gentext">
                        <xsl:with-param name="key">nav-next</xsl:with-param>
                      </xsl:call-template>
                    </xsl:attribute>
                  </img>
                </a>
              </td>
            </xsl:when>
            <xsl:otherwise>
              <td><img src="right-insensitive.png" width="16" height="16" border="0"/></td>
            </xsl:otherwise>
          </xsl:choose>
        </tr>
      </table>
    </xsl:if>
  </xsl:template>

  <xsl:template name="footer.navigation">
  </xsl:template>

  <!-- avoid creating multiple identical indices
       if the stylesheets don't support filtered indices
    -->
  <xsl:template match="index">
    <xsl:variable name="has-filtered-index">
      <xsl:call-template name="version-greater-or-equal">
        <xsl:with-param name="ver1" select="$VERSION" />
        <xsl:with-param name="ver2">1.66</xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
      <xsl:apply-imports/>
    </xsl:if>
  </xsl:template>

  <xsl:template match="index" mode="toc">
    <xsl:variable name="has-filtered-index">
      <xsl:call-template name="version-greater-or-equal">
        <xsl:with-param name="ver1" select="$VERSION" />
        <xsl:with-param name="ver2">1.66</xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
      <xsl:apply-imports/>
    </xsl:if>
  </xsl:template>

  <xsl:template match="para">
    <xsl:choose>
      <xsl:when test="@role = 'gallery'">
         <div class="container">
           <div class="gallery-spacer"> </div>
           <xsl:apply-templates mode="gallery.mode"/>
           <div class="gallery-spacer"> </div>
         </div>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-imports/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!-- FIXME: try if that works too -->
  <!--xsl:template match="para[@role='gallery']">
    <div class="container">
      <div class="gallery-spacer"> </div>
      <xsl:apply-templates mode="gallery.mode"/>
      <div class="gallery-spacer"> </div>
    </div>
  </xsl:template-->



  <xsl:template match="link" mode="gallery.mode">
    <div class="gallery-float">
       <xsl:apply-templates select="."/>
    </div>
  </xsl:template>

  <!-- add gallery handling to refnamediv template -->
  <xsl:template match="refnamediv">
    <div class="{name(.)}">
      <table width="100%">
        <tr><td valign="top">
          <xsl:call-template name="anchor"/>
          <xsl:choose>
            <xsl:when test="$refentry.generate.name != 0">
              <h2>
              <xsl:call-template name="gentext">
                  <xsl:with-param name="key" select="'RefName'"/>
                </xsl:call-template>
              </h2>
            </xsl:when>
            <xsl:when test="$refentry.generate.title != 0">
              <h2>
                <xsl:choose>
                  <xsl:when test="../refmeta/refentrytitle">
                    <xsl:apply-templates select="../refmeta/refentrytitle"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:apply-templates select="refname[1]"/>
                  </xsl:otherwise>
                </xsl:choose>
              </h2>
            </xsl:when>
          </xsl:choose>
          <p>
            <xsl:apply-templates/>
          </p>
        </td>
        <td class="gallery_image" valign="top" align="right">
          <xsl:choose>
            <xsl:when test="../refmeta/refmiscinfo/inlinegraphic">
              <xsl:apply-templates select="../refmeta/refmiscinfo/inlinegraphic"/>
            </xsl:when>
            <xsl:otherwise>
              <!-- find the gallery image to use here
                   - determine the id of the enclosing refentry
                   - look for an inlinegraphic inside a link with linkend == refentryid inside a para with role == gallery
                   - use it here
                -->
              <xsl:variable name="refentryid" select="../@id"/>
              <xsl:apply-templates select="key('gallery.key', $refentryid)/inlinegraphic"/>
            </xsl:otherwise>
          </xsl:choose>
        </td></tr>
       </table>
     </div>
  </xsl:template>

  <!-- a copy from refentry.xsl to add the missing mode attribute,
       see bug/729911, https://sourceforge.net/p/docbook/bugs/1358/
       fixed in: https://sourceforge.net/p/docbook/code/9962/
  -->
  <xsl:template match="refpurpose" mode="no.anchor.mode">
    <xsl:if test="node()">
      <xsl:text> </xsl:text>
      <xsl:call-template name="dingbat">
        <xsl:with-param name="dingbat">em-dash</xsl:with-param>
      </xsl:call-template>
      <xsl:text> </xsl:text>
      <xsl:apply-templates mode="no.anchor.mode"/>
    </xsl:if>
  </xsl:template>

  <!-- add anchors for index sections -->
  <xsl:template match="indexdiv">
    <a><xsl:attribute name="name">idx<xsl:value-of select="./title"/></xsl:attribute></a>
    <xsl:apply-templates/>
  </xsl:template>

  <!-- add anchors for glossary sections -->
  <xsl:template match="glossdiv">
    <a><xsl:attribute name="name">gls<xsl:value-of select="./title"/></xsl:attribute></a>
    <xsl:apply-templates/>
  </xsl:template>

  <!-- Exterminate any trace of indexterms in the main flow -->
  <xsl:template match="indexterm">
  </xsl:template>

  <!-- Extra link on the right side of doc-blobs -->
  <xsl:template name="user.format.extralinks">
    <xsl:if test="../ulink[@role='extralinks']">
      <span class="extralinks">
        <xsl:for-each select="../ulink[@role='extralinks']">
          <xsl:if test="position() = 1">[&#160;</xsl:if>
          <xsl:if test="position() > 1">&#160;&#160;<span class="dim">|</span>&#160;</xsl:if>
          <a>
            <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
            <xsl:copy-of select="text()" />
          </a>
          <xsl:if test="position() = last()">&#160;&#160;]</xsl:if>
        </xsl:for-each>
      </span>
    </xsl:if>
    <!--xsl:copy-of select="text()" /-->
    <xsl:apply-templates/>
  </xsl:template>

  <!-- this is not in use yet (see gtkdoc-mkdb
  <xsl:template match="//refsect2/ulink[@role='extralinks']"/>
  <xsl:template match="//refsect1/ulink[@role='extralinks']"/>

  <xsl:template match="//refsect2/title">
    <h3><xsl:call-template name="user.format.extralinks"/></h3>
  </xsl:template>

  <xsl:template match="//refsect1/title">
    <h2><xsl:call-template name="user.format.extralinks"/></h2>
  </xsl:template>
  -->

  <!-- ==================================================================== -->

  <xsl:template match="acronym">
    <xsl:call-template name="generate.acronym.link"/>
  </xsl:template>

  <xsl:template name="generate.acronym.link">
    <xsl:param name="acronym">
      <xsl:apply-templates/>
    </xsl:param>
    <xsl:param name="value" >
      <xsl:value-of select="key('acronym.key', $acronym)/../glossdef/para[1]" />
    </xsl:param>
    <xsl:choose>
      <xsl:when test="$value=''">
        <!-- debug -->
        <xsl:message>
          In gtk-doc.xsl: For acronym (<xsl:value-of select="$acronym"/>) no value found!
        </xsl:message>
        <a>
          <xsl:attribute name="href">
            <xsl:text>http://foldoc.org/</xsl:text>
	          <xsl:value-of select="$acronym"/>
          </xsl:attribute>
          <xsl:call-template name="inline.charseq"/>
        </a>
      </xsl:when>
      <xsl:otherwise>
        <!-- found -->
        <acronym>
          <xsl:attribute name="title">
            <xsl:value-of select="$value"/>
          </xsl:attribute>
          <xsl:call-template name="inline.charseq"/>
        </acronym>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>