xslt: cache some nodesets to be quicker
[gtk-doc.git] / gtk-doc.xsl
blob983d3f3e5666b780241bf9926f093f06d9839a55
1 <?xml version='1.0'?> <!--*- mode: xml -*-->
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
4 exclude-result-prefixes="l"
5 version="1.0">
7 <!-- import the chunked XSL stylesheet -->
8 <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
9 <xsl:include href="devhelp.xsl"/>
10 <xsl:include href="devhelp2.xsl"/>
11 <xsl:include href="version-greater-or-equal.xsl"/>
13 <!-- change some parameters -->
14 <!-- http://docbook.sourceforge.net/release/xsl/current/doc/html/index.html -->
15 <xsl:param name="toc.section.depth">2</xsl:param>
16 <xsl:param name="generate.toc">
17 book toc
18 chapter toc
19 glossary toc
20 index toc
21 part toc
22 reference toc
23 </xsl:param>
25 <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
26 <xsl:param name="chunker.output.indent" select="'yes'"/>
27 <xsl:param name="chunker.output.doctype-public" select="'-//W3C//DTD HTML 4.01 Transitional//EN'"/>
28 <xsl:param name="chunk.fast" select="1"/>
30 <xsl:param name="default.encoding" select="'UTF-8'"/>
31 <xsl:param name="chapter.autolabel" select="0"/>
32 <xsl:param name="use.id.as.filename" select="1"/>
33 <xsl:param name="html.ext" select="'.html'"/>
34 <xsl:param name="refentry.generate.name" select="0"/>
35 <xsl:param name="refentry.generate.title" select="1"/>
37 <!-- use index filtering (if available) -->
38 <xsl:param name="index.on.role" select="1"/>
40 <!-- display variablelists as tables -->
41 <xsl:param name="variablelist.as.table" select="1"/>
43 <!-- new things to consider
44 <xsl:param name="glossterm.auto.link" select="0"></xsl:param>
45 -->
47 <!-- this gets set on the command line ... -->
48 <xsl:param name="gtkdoc.version" select="''"/>
49 <xsl:param name="gtkdoc.bookname" select="''"/>
51 <!-- ========================================================= -->
53 <!-- l10n is slow, we don't ue it, so we'd like to turn it off
54 this atleast avoid the re-evaluation -->
55 <xsl:template name="l10n.language">en</xsl:template>
57 <xsl:param name="gtkdoc.l10n.xml" select="document('http://docbook.sourceforge.net/release/xsl/current/common/en.xml')"/>
59 <xsl:template name="gentext">
60 <xsl:param name="key" select="local-name(.)"/>
62 <xsl:variable name="l10n.gentext"
63 select="($gtkdoc.l10n.xml/l:l10n/l:gentext[@key=$key])[1]"/>
65 <xsl:choose>
66 <xsl:when test="$l10n.gentext">
67 <xsl:value-of select="$l10n.gentext/@text"/>
68 </xsl:when>
69 <xsl:otherwise>
70 <xsl:message>
71 <xsl:text>No "en" localization of "</xsl:text>
72 <xsl:value-of select="$key"/>
73 <xsl:text>" exists.</xsl:text>
74 </xsl:message>
75 </xsl:otherwise>
76 </xsl:choose>
77 </xsl:template>
79 <xsl:template name="gentext.dingbat">
80 <xsl:param name="dingbat">bullet</xsl:param>
82 <xsl:variable name="l10n.dingbat"
83 select="($gtkdoc.l10n.xml/l:l10n/l:dingbat[@key=$dingbat])[1]"/>
85 <xsl:choose>
86 <xsl:when test="$l10n.dingbat">
87 <xsl:value-of select="$l10n.dingbat/@text"/>
88 </xsl:when>
89 <xsl:otherwise>
90 <xsl:message>
91 <xsl:text>No "en" localization of dingbat </xsl:text>
92 <xsl:value-of select="$dingbat"/>
93 <xsl:text> exists; using "en".</xsl:text>
94 </xsl:message>
95 </xsl:otherwise>
96 </xsl:choose>
97 </xsl:template>
100 <xsl:template name="gentext.template">
101 <xsl:param name="context" select="'default'"/>
102 <xsl:param name="name" select="'default'"/>
103 <xsl:param name="origname" select="$name"/>
104 <xsl:param name="verbose" select="1"/>
106 <!-- this is called with context="title|title-numbered|title-unnumbered
107 <xsl:message>
108 <xsl:text>context:</xsl:text><xsl:value-of select="$context"/>
109 </xsl:message
112 <xsl:variable name="context.node"
113 select="$gtkdoc.l10n.xml/l:l10n/l:context[@name=$context]"/>
115 <xsl:variable name="template.node"
116 select="($context.node/l:template[@name=$name])[1]"/>
118 <xsl:choose>
119 <xsl:when test="$template.node/@text">
120 <xsl:value-of select="$template.node/@text"/>
121 </xsl:when>
122 <xsl:otherwise>
123 <xsl:choose>
124 <xsl:when test="contains($name, '/')">
125 <xsl:call-template name="gentext.template">
126 <xsl:with-param name="context" select="$context"/>
127 <xsl:with-param name="name" select="substring-after($name, '/')"/>
128 <xsl:with-param name="origname" select="$origname"/>
129 <xsl:with-param name="verbose" select="$verbose"/>
130 </xsl:call-template>
131 </xsl:when>
132 <xsl:when test="$verbose = 0">
133 </xsl:when>
134 </xsl:choose>
135 </xsl:otherwise>
136 </xsl:choose>
137 </xsl:template>
139 <!-- ========================================================= -->
140 <!-- template to create the index.sgml anchor index -->
142 <xsl:param name="gtkdoc.refsect2" select="//refsect2" />
144 <xsl:template match="book|article">
145 <xsl:variable name="tooldver">
146 <xsl:call-template name="version-greater-or-equal">
147 <xsl:with-param name="ver1" select="$VERSION" />
148 <xsl:with-param name="ver2">1.36</xsl:with-param>
149 </xsl:call-template>
150 </xsl:variable>
151 <xsl:if test="$tooldver = 0">
152 <xsl:message terminate="yes">
153 FATAL-ERROR: You need the DocBook XSL Stylesheets version 1.36 or higher
154 to build the documentation.
155 Get a newer version at http://docbook.sourceforge.net/projects/xsl/
156 </xsl:message>
157 </xsl:if>
158 <xsl:apply-imports/>
160 <!-- generate the index.sgml href index -->
161 <xsl:call-template name="generate.index"/>
162 <!-- generate $book.devhelp{2} -->
163 <xsl:call-template name="generate.devhelp"/>
164 <xsl:call-template name="generate.devhelp2"/>
165 </xsl:template>
167 <xsl:template name="generate.index">
168 <xsl:call-template name="write.text.chunk">
169 <xsl:with-param name="filename" select="'index.sgml'"/>
170 <xsl:with-param name="content">
171 <xsl:apply-templates select="/book/bookinforeleaseinfo/ulink"
172 mode="generate.index.mode"/>
173 <!-- check all anchor and refentry elements -->
174 <xsl:apply-templates select="//anchor|//refentry|//refsect1|$gtkdoc.refsect2|//refsynopsisdiv|//varlistentry"
175 mode="generate.index.mode"/>
176 </xsl:with-param>
177 <xsl:with-param name="default.encoding" select="'UTF-8'"/>
178 <xsl:with-param name="chunker.output.indent" select="'no'"/>
179 </xsl:call-template>
180 </xsl:template>
182 <xsl:template match="*" mode="generate.index.mode">
183 <xsl:if test="not(@href) and count(@id) > 0">
184 <xsl:text>&lt;ANCHOR id=&quot;</xsl:text>
185 <xsl:value-of select="@id"/>
186 <xsl:text>&quot; href=&quot;</xsl:text>
187 <xsl:if test="$gtkdoc.bookname">
188 <xsl:value-of select="$gtkdoc.bookname"/>
189 <xsl:text>/</xsl:text>
190 </xsl:if>
191 <xsl:call-template name="href.target"/>
192 <xsl:text>&quot;&gt;&#10;</xsl:text>
193 </xsl:if>
194 </xsl:template>
196 <xsl:template match="/book/bookinfo/releaseinfo/ulink" mode="generate.index.mode">
197 <xsl:if test="@role='online-location'">
198 <xsl:text>&lt;ONLINE href=&quot;</xsl:text>
199 <xsl:value-of select="@url"/>
200 <xsl:text>&quot;&gt;&#10;</xsl:text>
201 </xsl:if>
202 </xsl:template>
204 <!-- ========================================================= -->
205 <!-- template to output gtkdoclink elements for the unknown targets -->
207 <xsl:template match="link">
208 <xsl:choose>
209 <xsl:when test="id(@linkend)">
210 <xsl:apply-imports/>
211 </xsl:when>
212 <xsl:otherwise>
213 <GTKDOCLINK HREF="{@linkend}">
214 <xsl:apply-templates/>
215 </GTKDOCLINK>
216 </xsl:otherwise>
217 </xsl:choose>
218 </xsl:template>
220 <!-- ========================================================= -->
221 <!-- Below are the visual portions of the stylesheet. They provide
222 the normal gtk-doc output style. -->
224 <xsl:param name="shade.verbatim" select="0"/>
225 <xsl:param name="refentry.separator" select="0"/>
227 <xsl:template match="refsect2">
228 <xsl:if test="preceding-sibling::refsect2">
229 <hr/>
230 </xsl:if>
231 <xsl:apply-imports/>
232 </xsl:template>
234 <xsl:param name="gtkdoc.linknodes" select="//part
235 |//reference
236 |//preface
237 |//chapter
238 |//article
239 |//appendix[not(parent::article)]|appendix
240 |//glossary[not(parent::article)]|glossary
241 |//index[not(parent::article)]|index"/>
243 <xsl:template name="user.head.content">
244 <xsl:if test="$gtkdoc.version">
245 <meta name="generator" content="GTK-Doc V{$gtkdoc.version} (XML mode)"/>
246 </xsl:if>
247 <link rel="stylesheet" href="style.css" type="text/css"/>
249 <!-- copied from the html.head template in the docbook stylesheets
250 we don't want links for all refentrys, thats just too much
252 <xsl:variable name="this" select="."/>
253 <xsl:for-each select="$gtkdoc.linknodes">
254 <link rel="{local-name(.)}">
255 <xsl:attribute name="href">
256 <xsl:call-template name="href.target">
257 <xsl:with-param name="context" select="$this"/>
258 <xsl:with-param name="object" select="."/>
259 </xsl:call-template>
260 </xsl:attribute>
261 <xsl:attribute name="title">
262 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
263 </xsl:attribute>
264 </link>
265 </xsl:for-each>
266 </xsl:template>
268 <xsl:template name="user.footer.content">
269 <div class="footer">
270 <hr />
271 <xsl:choose>
272 <xsl:when test="$gtkdoc.version">
273 Generated by GTK-Doc V<xsl:copy-of select="$gtkdoc.version" />
274 </xsl:when>
275 <xsl:otherwise>
276 Generated by GTK-Doc
277 </xsl:otherwise>
278 </xsl:choose>
279 </div>
280 </xsl:template>
282 <xsl:template match="title" mode="book.titlepage.recto.mode">
283 <table class="navigation" id="top" width="100%"
284 cellpadding="2" cellspacing="0">
285 <tr>
286 <th valign="middle">
287 <p class="{name(.)}">
288 <xsl:value-of select="."/>
289 </p>
290 </th>
291 </tr>
292 </table>
293 </xsl:template>
295 <xsl:template name="header.navigation">
296 <xsl:param name="prev" select="/foo"/>
297 <xsl:param name="next" select="/foo"/>
298 <xsl:variable name="home" select="/*[1]"/>
299 <xsl:variable name="up" select="parent::*"/>
300 <xsl:variable name="refsections" select="./refsect1[@role]"/>
301 <xsl:variable name="glssections" select="./glossdiv/title"/>
302 <xsl:variable name="idxsections" select="./indexdiv/indexdiv/title"/>
303 <xsl:variable name="section_id" select="./@id"/>
304 <xsl:variable name="sect_object_hierarchy" select="./refsect1[@role='object_hierarchy']"/>
305 <xsl:variable name="sect_impl_interfaces" select="./refsect1[@role='impl_interfaces']"/>
306 <xsl:variable name="sect_prerequisites" select="./refsect1[@role='prerequisites']"/>
307 <xsl:variable name="sect_derived_interfaces" select="./refsect1[@role='derived_interfaces']"/>
308 <xsl:variable name="sect_implementations" select="./refsect1[@role='implementations']"/>
309 <xsl:variable name="sect_properties" select="./refsect1[@role='properties']"/>
310 <xsl:variable name="sect_child_properties" select="./refsect1[@role='child_properties']"/>
311 <xsl:variable name="sect_style_properties" select="./refsect1[@role='style_properties']"/>
312 <xsl:variable name="sect_signal_proto" select="./refsect1[@role='signal_proto']"/>
313 <xsl:variable name="sect_desc" select="./refsect1[@role='desc']"/>
314 <xsl:variable name="sect_synopsis" select="./refsynopsisdiv[@role='synopsis']"/>
315 <!--
316 <xsl:variable name="sect_details" select="./refsect1[@id='details']"/>
317 <xsl:variable name="sect_property_details" select="./refsect1[@id='property_details']"/>
318 <xsl:variable name="sect_child_property_details" select="./refsect1[@id='child_property_details']"/>
319 <xsl:variable name="sect_style_property_details" select="./refsect1[@id='style_property_details']"/>
320 <xsl:variable name="sect_signals" select="./refsect1[@id='signals']"/>
323 <xsl:if test="$suppress.navigation = '0' and $home != .">
324 <table class="navigation" id="top" width="100%"
325 summary = "Navigation header" cellpadding="2" cellspacing="2">
326 <tr valign="middle">
327 <xsl:choose>
328 <xsl:when test="count($prev) > 0">
329 <td>
330 <a accesskey="p">
331 <xsl:attribute name="href">
332 <xsl:call-template name="href.target">
333 <xsl:with-param name="object" select="$prev"/>
334 </xsl:call-template>
335 </xsl:attribute>
336 <img src="left.png" width="24" height="24" border="0">
337 <xsl:attribute name="alt">
338 <xsl:call-template name="gentext">
339 <xsl:with-param name="key">nav-prev</xsl:with-param>
340 </xsl:call-template>
341 </xsl:attribute>
342 </img>
343 </a>
344 </td>
345 </xsl:when>
346 <xsl:otherwise>
347 <td>&#160;</td>
348 </xsl:otherwise>
349 </xsl:choose>
350 <xsl:choose>
351 <xsl:when test="count($up) > 0 and $up != $home">
352 <td>
353 <a accesskey="u">
354 <xsl:attribute name="href">
355 <xsl:call-template name="href.target">
356 <xsl:with-param name="object" select="$up"/>
357 </xsl:call-template>
358 </xsl:attribute>
359 <img src="up.png" width="24" height="24" border="0">
360 <xsl:attribute name="alt">
361 <xsl:call-template name="gentext">
362 <xsl:with-param name="key">nav-up</xsl:with-param>
363 </xsl:call-template>
364 </xsl:attribute>
365 </img>
366 </a>
367 </td>
368 </xsl:when>
369 <xsl:otherwise>
370 <td>&#160;</td>
371 </xsl:otherwise>
372 </xsl:choose>
373 <xsl:choose>
374 <xsl:when test="$home != .">
375 <td>
376 <a accesskey="h">
377 <xsl:attribute name="href">
378 <xsl:call-template name="href.target">
379 <xsl:with-param name="object" select="$home"/>
380 </xsl:call-template>
381 </xsl:attribute>
382 <img src="home.png" width="24" height="24" border="0">
383 <xsl:attribute name="alt">
384 <xsl:call-template name="gentext">
385 <xsl:with-param name="key">nav-home</xsl:with-param>
386 </xsl:call-template>
387 </xsl:attribute>
388 </img>
389 </a>
390 </td>
391 </xsl:when>
392 <xsl:otherwise>
393 <td>&#160;</td>
394 </xsl:otherwise>
395 </xsl:choose>
396 <th width="100%" align="center">
397 <xsl:apply-templates select="$home" mode="object.title.markup"/>
398 </th>
399 <xsl:choose>
400 <xsl:when test="count($next) > 0">
401 <td>
402 <a accesskey="n">
403 <xsl:attribute name="href">
404 <xsl:call-template name="href.target">
405 <xsl:with-param name="object" select="$next"/>
406 </xsl:call-template>
407 </xsl:attribute>
408 <img src="right.png" width="24" height="24" border="0">
409 <xsl:attribute name="alt">
410 <xsl:call-template name="gentext">
411 <xsl:with-param name="key">nav-next</xsl:with-param>
412 </xsl:call-template>
413 </xsl:attribute>
414 </img>
415 </a>
416 </td>
417 </xsl:when>
418 <xsl:otherwise>
419 <td>&#160;</td>
420 </xsl:otherwise>
421 </xsl:choose>
422 </tr>
423 <!--<xsl:if test="name()='refentry'"-->
424 <xsl:choose>
425 <xsl:when test="count($refsections) > 0">
426 <tr>
427 <td colspan="5" class="shortcuts">
428 <xsl:if test="count($sect_synopsis) > 0">
429 <a href="#{$section_id}.synopsis" class="shortcut">Top</a>
430 </xsl:if>
431 <xsl:if test="count($sect_desc) > 0">
432 &#160;|&#160;
433 <a href="#{$section_id}.description" class="shortcut">
434 <xsl:value-of select="./refsect1[@role='desc']/title"/>
435 </a>
436 </xsl:if>
437 <xsl:if test="count($sect_object_hierarchy) > 0">
438 &#160;|&#160;
439 <a href="#{$section_id}.object-hierarchy" class="shortcut">
440 <xsl:value-of select="./refsect1[@role='object_hierarchy']/title"/>
441 </a>
442 </xsl:if>
443 <xsl:if test="count($sect_impl_interfaces) > 0">
444 &#160;|&#160;
445 <a href="#{$section_id}.implemented-interfaces" class="shortcut">
446 <xsl:value-of select="./refsect1[@role='impl_interfaces']/title"/>
447 </a>
448 </xsl:if>
449 <xsl:if test="count($sect_prerequisites) > 0">
450 &#160;|&#160;
451 <a href="#{$section_id}.prerequisites" class="shortcut">
452 <xsl:value-of select="./refsect1[@role='prerequisites']/title"/>
453 </a>
454 </xsl:if>
455 <xsl:if test="count($sect_derived_interfaces) > 0">
456 &#160;|&#160;
457 <a href="#{$section_id}.derived-interfaces" class="shortcut">
458 <xsl:value-of select="./refsect1[@role='derived_interfaces']/title"/>
459 </a>
460 </xsl:if>
461 <xsl:if test="count($sect_implementations) > 0">
462 &#160;|&#160;
463 <a href="#{$section_id}.implementations" class="shortcut">
464 <xsl:value-of select="./refsect1[@role='implementations']/title"/>
465 </a>
466 </xsl:if>
467 <xsl:if test="count($sect_properties) > 0">
468 &#160;|&#160;
469 <a href="#{$section_id}.properties" class="shortcut">
470 <xsl:value-of select="./refsect1[@role='properties']/title"/>
471 </a>
472 </xsl:if>
473 <xsl:if test="count($sect_child_properties) > 0">
474 &#160;|&#160;
475 <a href="#{$section_id}.child-properties" class="shortcut">
476 <xsl:value-of select="./refsect1[@role='child_properties']/title"/>
477 </a>
478 </xsl:if>
479 <xsl:if test="count($sect_style_properties) > 0">
480 &#160;|&#160;
481 <a href="#{$section_id}.style-properties" class="shortcut">
482 <xsl:value-of select="./refsect1[@role='style_properties']/title"/>
483 </a>
484 </xsl:if>
485 <xsl:if test="count($sect_signal_proto) > 0">
486 &#160;|&#160;
487 <a href="#{$section_id}.signals" class="shortcut">
488 <xsl:value-of select="./refsect1[@role='signal_proto']/title"/>
489 </a>
490 </xsl:if>
491 <!--
492 <xsl:if test="count($sect_details) > 0">
493 <a href="#details" class="shortcut">
494 <xsl:value-of select="./refsect1[@id='details']/title"/>
495 </a>
496 &#160;|&#160;
497 </xsl:if>
498 <xsl:if test="count($sect_property_details) > 0">
499 <a href="#property_details" class="shortcut">
500 <xsl:value-of select="./refsect1[@id='property_details']/title"/>
501 </a>
502 &#160;|&#160;
503 </xsl:if>
504 <xsl:if test="count($sect_child_property_details) > 0">
505 <a href="#child_property_details" class="shortcut">
506 <xsl:value-of select="./refsect1[@id='property_child_details']/title"/>
507 </a>
508 &#160;|&#160;
509 </xsl:if>
510 <xsl:if test="count($sect_style_property_details) > 0">
511 <a href="#style_property_details" class="shortcut">
512 <xsl:value-of select="./refsect1[@id='style_property_details']/title"/>
513 </a>
514 &#160;|&#160;
515 </xsl:if>
516 <xsl:if test="count($sect_signals) > 0">
517 <a href="#signals" class="shortcut">
518 <xsl:value-of select="./refsect1[@id='signals']/title"/>
519 </a>
520 &#160;|&#160;
521 </xsl:if>
523 </td>
524 </tr>
525 </xsl:when>
526 <!-- this is not yet very nice, as it requires all glossdic/indexdiv
527 elements having a anchor element. maybe we can customize the xsl
528 to automaticaly create local anchors
530 <xsl:when test="count($glssections) > 0">
531 <tr>
532 <td colspan="5" class="shortcuts">
533 <xsl:for-each select="./glossdiv">
534 <xsl:if test="position() > 1">
535 &#160;|&#160;
536 </xsl:if>
537 <a class="shortcut">
538 <xsl:attribute name="href">#gls<xsl:value-of select="./title"/></xsl:attribute>
539 <xsl:value-of select="./title"/>
540 </a>
541 </xsl:for-each>
542 </td>
543 </tr>
544 </xsl:when>
545 <xsl:when test="count($idxsections) > 0">
546 <tr>
547 <td colspan="5" class="shortcuts">
548 <xsl:for-each select="./indexdiv/indexdiv">
549 <xsl:if test="position() > 1">
550 &#160;|&#160;
551 </xsl:if>
552 <a class="shortcut">
553 <xsl:attribute name="href">#idx<xsl:value-of select="./title"/></xsl:attribute>
554 <xsl:value-of select="./title"/>
555 </a>
556 </xsl:for-each>
557 </td>
558 </tr>
559 </xsl:when>
560 </xsl:choose>
561 </table>
562 </xsl:if>
563 </xsl:template>
565 <xsl:template name="footer.navigation">
566 </xsl:template>
568 <!-- avoid creating multiple identical indices
569 if the stylesheets don't support filtered indices
571 <xsl:template match="index">
572 <xsl:variable name="has-filtered-index">
573 <xsl:call-template name="version-greater-or-equal">
574 <xsl:with-param name="ver1" select="$VERSION" />
575 <xsl:with-param name="ver2">1.66</xsl:with-param>
576 </xsl:call-template>
577 </xsl:variable>
578 <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
579 <xsl:apply-imports/>
580 </xsl:if>
581 </xsl:template>
583 <xsl:template match="index" mode="toc">
584 <xsl:variable name="has-filtered-index">
585 <xsl:call-template name="version-greater-or-equal">
586 <xsl:with-param name="ver1" select="$VERSION" />
587 <xsl:with-param name="ver2">1.66</xsl:with-param>
588 </xsl:call-template>
589 </xsl:variable>
590 <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
591 <xsl:apply-imports/>
592 </xsl:if>
593 </xsl:template>
595 <xsl:template match="para">
596 <xsl:choose>
597 <xsl:when test="@role = 'gallery'">
598 <div class="container">
599 <div class="gallery-spacer"> </div>
600 <xsl:apply-templates mode="gallery.mode"/>
601 <div class="gallery-spacer"> </div>
602 </div>
603 </xsl:when>
604 <xsl:otherwise>
605 <xsl:apply-imports/>
606 </xsl:otherwise>
607 </xsl:choose>
608 </xsl:template>
609 <!-- FIXME: try if that works too -->
610 <!--xsl:template match="para[@role='gallery']">
611 <div class="container">
612 <div class="gallery-spacer"> </div>
613 <xsl:apply-templates mode="gallery.mode"/>
614 <div class="gallery-spacer"> </div>
615 </div>
616 </xsl:template-->
620 <xsl:template match="link" mode="gallery.mode">
621 <div class="gallery-float">
622 <xsl:apply-templates select="."/>
623 </div>
624 </xsl:template>
626 <!-- add gallery handling to refnamediv template -->
627 <xsl:template match="refnamediv">
628 <div class="{name(.)}">
629 <table width="100%">
630 <tr><td valign="top">
631 <xsl:call-template name="anchor"/>
632 <xsl:choose>
633 <xsl:when test="$refentry.generate.name != 0">
634 <h2>
635 <xsl:call-template name="gentext">
636 <xsl:with-param name="key" select="'RefName'"/>
637 </xsl:call-template>
638 </h2>
639 </xsl:when>
640 <xsl:when test="$refentry.generate.title != 0">
641 <h2>
642 <xsl:choose>
643 <xsl:when test="../refmeta/refentrytitle">
644 <xsl:apply-templates select="../refmeta/refentrytitle"/>
645 </xsl:when>
646 <xsl:otherwise>
647 <xsl:apply-templates select="refname[1]"/>
648 </xsl:otherwise>
649 </xsl:choose>
650 </h2>
651 </xsl:when>
652 </xsl:choose>
654 <xsl:apply-templates/>
655 </p>
656 </td>
657 <td valign="top" align="right">
658 <!-- find the gallery image to use here
659 - determine the id of the enclosing refentry
660 - look for an inlinegraphic inside a link with linkend == refentryid inside a para with role == gallery
661 - use it here
663 <xsl:variable name="refentryid" select="../@id"/>
664 <xsl:apply-templates select="//para[@role = 'gallery']/link[@linkend = $refentryid]/inlinegraphic"/>
665 </td></tr>
666 </table>
667 </div>
668 </xsl:template>
670 <!-- add anchors for index sections -->
671 <xsl:template match="indexdiv">
672 <a><xsl:attribute name="name">idx<xsl:value-of select="./title"/></xsl:attribute></a>
673 <xsl:apply-templates/>
674 </xsl:template>
676 <!-- add anchors for glossary sections -->
677 <xsl:template match="glossdiv">
678 <a><xsl:attribute name="name">gls<xsl:value-of select="./title"/></xsl:attribute></a>
679 <xsl:apply-templates/>
680 </xsl:template>
682 <!-- Exterminate any trace of indexterms in the main flow -->
683 <xsl:template match="indexterm">
684 </xsl:template>
686 <!-- Extra link on the right side of doc-blobs -->
687 <xsl:template name="user.format.extralinks">
688 <xsl:if test="../ulink[@role='extralinks']">
689 <span class="extralinks">
690 <xsl:for-each select="../ulink[@role='extralinks']">
691 <xsl:if test="position() = 1">[&#160;</xsl:if>
692 <xsl:if test="position() > 1">&#160;|&#160;</xsl:if>
694 <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
695 <xsl:copy-of select="text()" />
696 </a>
697 <xsl:if test="position() = last()">&#160;]</xsl:if>
698 </xsl:for-each>
699 </span>
700 </xsl:if>
701 <!--xsl:copy-of select="text()" /-->
702 <xsl:apply-templates/>
703 </xsl:template>
705 <!-- this is not in use yet (see gtkdoc-mkdb
706 <xsl:template match="//refsect2/ulink[@role='extralinks']"/>
707 <xsl:template match="//refsect1/ulink[@role='extralinks']"/>
709 <xsl:template match="//refsect2/title">
710 <h3><xsl:call-template name="user.format.extralinks"/></h3>
711 </xsl:template>
713 <xsl:template match="//refsect1/title">
714 <h2><xsl:call-template name="user.format.extralinks"/></h2>
715 </xsl:template>
718 <!-- ==================================================================== -->
720 <xsl:template match="acronym">
721 <xsl:call-template name="generate.acronym.link"/>
722 </xsl:template>
724 <xsl:template name="generate.acronym.link">
725 <xsl:param name="acronym">
726 <xsl:apply-templates/>
727 </xsl:param>
728 <!--
729 We use for-each to change context to the database document because key()
730 only locates elements in the same document as the context node!
733 <xsl:param name="value" >
734 <xsl:value-of select="//glossentry/glossterm[text()=$acronym]/../glossdef/para[1]" />
735 </xsl:param>
736 <xsl:choose>
737 <xsl:when test="$value=''">
738 <!-- debug -->
739 <xsl:message>
740 In gtk-doc.xsl: For acronym (<xsl:value-of select="$acronym"/>) no value found!
741 </xsl:message>
743 <xsl:attribute name="href">
744 <xsl:text>http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=</xsl:text>
745 <xsl:value-of select="$acronym"/>
746 </xsl:attribute>
747 <xsl:call-template name="inline.charseq"/>
748 </a>
749 </xsl:when>
750 <xsl:otherwise>
751 <!-- found -->
752 <acronym>
753 <xsl:attribute name="title">
754 <xsl:value-of select="$value"/>
755 </xsl:attribute>
756 <xsl:call-template name="inline.charseq"/>
757 </acronym>
758 </xsl:otherwise>
759 </xsl:choose>
760 </xsl:template>
762 </xsl:stylesheet>