Update Doxygen-to-Docbook transform with the latest transform rules for functions...
[pub/USBasp.git] / LUFA / StudioIntegration / HV1 / transform_base.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:exsl="http://exslt.org/common"
5 extension-element-prefixes="exsl"
6 exclude-result-prefixes="exsl"
7 version="1.0">
8
9 <xsl:output
10 method="xml" indent="no"
11 doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"
12 doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>
13
14 <xsl:template name="write.api.overview.contents">
15
16 <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'variable' or memberdef/@kind = 'typedef']) > 0">
17 <section>
18 <title>Variable and Type Definitions</title>
19
20 <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'variable' or memberdef/@kind = 'typedef']">
21 <section>
22 <title>
23 <xsl:value-of select="header"/>
24 </title>
25
26 <xsl:apply-templates select="description"/>
27 <xsl:apply-templates select="memberdef[@kind = 'variable' or @kind = 'typedef']"/>
28 </section>
29 </xsl:for-each>
30 </section>
31 </xsl:if>
32
33 <xsl:if test="count(ancestor::*/innerclass) > 0">
34 <section>
35 <title>Structure Definitions</title>
36
37 <xsl:for-each select="ancestor::*/innerclass">
38 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
39 </xsl:for-each>
40 </section>
41 </xsl:if>
42
43 <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'define']) > 0">
44 <section>
45 <title>Macro Definitions</title>
46
47 <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'define']">
48 <section>
49 <title>
50 <xsl:value-of select="header"/>
51 </title>
52
53 <xsl:apply-templates select="description"/>
54 <xsl:apply-templates select="memberdef[@kind = 'define']"/>
55 </section>
56 </xsl:for-each>
57 </section>
58 </xsl:if>
59
60 <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'function']) > 0">
61 <section>
62 <title>Function Definitions</title>
63
64 <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'function']">
65 <section>
66 <title>
67 <xsl:value-of select="header"/>
68 </title>
69
70 <xsl:apply-templates select="description"/>
71 <xsl:apply-templates select="memberdef[@kind = 'function']"/>
72 </section>
73 </xsl:for-each>
74 </section>
75 </xsl:if>
76
77 <xsl:if test="count(ancestor::*/sectiondef[@kind = 'enum']) > 0">
78 <section>
79 <title>Enumeration Definitions</title>
80
81 <xsl:apply-templates select="ancestor::*/sectiondef[@kind = 'enum']"/>
82 </section>
83 </xsl:if>
84
85 </xsl:template>
86
87 <xsl:template match="compounddef">
88 <!-- Discard compounddef elements unless a later template matches -->
89 </xsl:template>
90
91 <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
92 <section id="{@id}" xreflabel="{compoundname}">
93 <title>
94 <xsl:choose>
95 <xsl:when test="@kind = 'struct'">
96 <xsl:text>Struct </xsl:text>
97 </xsl:when>
98 <xsl:when test="@kind = 'union'">
99 <xsl:text>Union </xsl:text>
100 </xsl:when>
101 </xsl:choose>
102
103 <xsl:value-of select="compoundname"/>
104 </title>
105
106 <xsl:apply-templates select="detaileddescription"/>
107
108 <xsl:for-each select="sectiondef[@kind = 'public-attrib']">
109 <table tabstyle="striped">
110 <title>Members</title>
111
112 <tgroup cols="3">
113 <thead>
114 <row>
115 <entry>Type</entry>
116 <entry>Name</entry>
117 <entry>Description</entry>
118 </row>
119 </thead>
120 <tbody>
121 <xsl:for-each select="memberdef">
122 <row id="{@id}" xreflabel="{name}">
123 <entry>
124 <xsl:apply-templates select="type"/>
125 </entry>
126 <entry>
127 <xsl:value-of select="name"/>
128 <xsl:if test="starts-with(argsstring, '[')">
129 <xsl:text>[]</xsl:text>
130 </xsl:if>
131 </entry>
132 <entry>
133 <xsl:apply-templates select="detaileddescription" mode="struct"/>
134 </entry>
135 </row>
136 </xsl:for-each>
137 </tbody>
138 </tgroup>
139 </table>
140 <para>&#xa0;</para>
141 </xsl:for-each>
142 </section>
143 </xsl:template>
144
145 <xsl:template match="memberdef[@kind = 'function']">
146 <section id="{@id}" xreflabel="{name}">
147 <title> Function <xsl:value-of select="name"/>() </title>
148
149 <para>
150 <emphasis role="italic">
151 <xsl:value-of select="briefdescription"/>
152 </emphasis>
153 </para>
154
155 <programlisting language="c">
156 <emphasis role="keyword">
157 <xsl:value-of select="type"/>
158 </emphasis>
159 <xsl:text> </xsl:text>
160 <xsl:value-of select="name"/>
161 <xsl:text>(</xsl:text>
162
163 <xsl:choose>
164 <xsl:when test="argsstring = '(void)'">
165 <emphasis role="keyword">void</emphasis>
166 </xsl:when>
167
168 <xsl:otherwise>
169 <xsl:for-each select="param">
170 <xsl:if test="position() > 1">
171 <xsl:text>,</xsl:text>
172 </xsl:if>
173 <xsl:text>&#10;&#9;&#9;</xsl:text>
174 <emphasis role="keyword">
175 <xsl:value-of select="type"/>
176 </emphasis>
177 <xsl:text> </xsl:text>
178 <xsl:value-of select="declname"/>
179 </xsl:for-each>
180 </xsl:otherwise>
181 </xsl:choose>
182
183 <xsl:text>)</xsl:text>
184 </programlisting>
185
186 <xsl:apply-templates select="detaileddescription"/>
187
188 <para>&#xa0;</para>
189 </section>
190 </xsl:template>
191
192 <xsl:template match="memberdef[@kind = 'enum']">
193 <section id="{@id}" xreflabel="{name}">
194 <title> Enum <xsl:value-of select="name"/> </title>
195
196 <xsl:apply-templates select="detaileddescription"/>
197
198 <table tabstyle="striped">
199 <title>Members</title>
200 <tgroup cols="2">
201 <thead>
202 <row>
203 <entry>Enum value</entry>
204 <entry>Description</entry>
205 </row>
206 </thead>
207 <tbody>
208 <xsl:for-each select="enumvalue">
209 <row>
210 <entry>
211 <para id="{@id}" xreflabel="{name}">
212 <xsl:value-of select="name"/>
213 </para>
214 </entry>
215 <entry>
216 <xsl:apply-templates select="detaileddescription"/>
217 </entry>
218 </row>
219 </xsl:for-each>
220 </tbody>
221 </tgroup>
222 </table>
223
224 <para>&#xa0;</para>
225 </section>
226 </xsl:template>
227
228 <xsl:template match="memberdef[@kind = 'define']">
229 <section id="{@id}" xreflabel="{name}">
230 <title> Macro <xsl:value-of select="name"/> </title>
231
232 <programlisting language="c">
233 <emphasis role="preprocessor">
234 <xsl:text>#define </xsl:text>
235 <xsl:value-of select="name"/>
236 <xsl:if test="count(param) > 0">
237 <xsl:text>(</xsl:text>
238 <xsl:for-each select="param/defname">
239 <xsl:if test="position() > 1">
240 <xsl:text>, </xsl:text>
241 </xsl:if>
242 <xsl:value-of select="."/>
243 </xsl:for-each>
244 <xsl:text>)</xsl:text>
245 </xsl:if>
246 <xsl:text> </xsl:text>
247
248 <!-- Split long macro definitions across multiple lines -->
249 <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
250 <xsl:text>\&#10;&#09;&#9;</xsl:text>
251 </xsl:if>
252
253 <xsl:value-of select="initializer"/>
254 </emphasis>
255 <xsl:text> </xsl:text>
256 </programlisting>
257
258 <xsl:apply-templates select="detaileddescription"/>
259
260 <para>&#xa0;</para>
261 </section>
262 </xsl:template>
263
264 <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">
265 <section id="{@id}" xreflabel="{name}">
266 <!-- Doxygen gets confused and thinks function pointer type definitions
267 are variables, so we need to map them to this common section and
268 check the definition to see which of the two it is. -->
269 <xsl:choose>
270 <xsl:when test="contains(definition,'typedef')">
271 <title> Type <xsl:value-of select="name"/></title>
272
273 <programlisting language="c">
274 <emphasis role="keyword">
275 <xsl:text>typedef </xsl:text>
276 <xsl:value-of select="type"/>
277 </emphasis>
278 <xsl:text> </xsl:text>
279 <xsl:value-of select="name"/>
280 <xsl:text> </xsl:text>
281 <xsl:value-of select="argsstring"/>
282 </programlisting>
283 </xsl:when>
284
285 <xsl:otherwise>
286 <title> Variable <xsl:value-of select="name"/></title>
287
288 <programlisting language="c">
289 <emphasis role="keyword">
290 <xsl:value-of select="type"/>
291 </emphasis>
292 <xsl:text> </xsl:text>
293 <xsl:value-of select="name"/>
294 </programlisting>
295 </xsl:otherwise>
296 </xsl:choose>
297
298 <xsl:apply-templates select="detaileddescription"/>
299
300 <para>&#xa0;</para>
301 </section>
302 </xsl:template>
303
304 <xsl:template match="sectiondef">
305 <para>
306 <xsl:value-of select="description"/>
307 </para>
308
309 <xsl:apply-templates select="memberdef"/>
310 </xsl:template>
311
312 <xsl:template match="simplesect" mode="struct">
313 <footnote>
314 <xsl:apply-templates/>
315 </footnote>
316 </xsl:template>
317
318 <xsl:template match="simplesect">
319 <xsl:choose>
320 <xsl:when test="@kind = 'warning'">
321 <warning>
322 <title>Warning</title>
323 <xsl:apply-templates select="para"/>
324 </warning>
325 </xsl:when>
326
327 <xsl:when test="@kind = 'return'">
328 <note>
329 <title>Returns</title>
330 <xsl:apply-templates select="para"/>
331 </note>
332 </xsl:when>
333
334 <xsl:when test="@kind = 'pre'">
335 <note>
336 <title>Precondition</title>
337 <xsl:apply-templates select="para"/>
338 </note>
339 </xsl:when>
340
341 <xsl:when test="@kind = 'par'">
342 <note>
343 <title>
344 <xsl:value-of select="title"/>
345 </title>
346 <xsl:apply-templates select="para"/>
347 </note>
348 </xsl:when>
349
350 <xsl:when test="@kind = 'see'">
351 <note>
352 <title>See also</title>
353 <xsl:apply-templates select="para"/>
354 </note>
355 </xsl:when>
356
357 <xsl:when test="@kind = 'note'">
358 <!-- Notes can have special prefix keywords to transform them into
359 special styles for training documents ("AlfonsoNotes(TM)") -->
360 <xsl:variable name="note.prefix" select="substring-before(para[1]/text(), ' ')"/>
361
362 <note>
363 <xsl:choose>
364 <xsl:when test="$note.prefix = 'TODO:'">
365 <xsl:attribute name="role">todo</xsl:attribute>
366 <title>To Do</title>
367 </xsl:when>
368
369 <xsl:when test="$note.prefix = 'TIPS:'">
370 <xsl:attribute name="role">tips</xsl:attribute>
371 <title>Tip</title>
372 </xsl:when>
373
374 <xsl:when test="$note.prefix = 'INFO:'">
375 <xsl:attribute name="role">info</xsl:attribute>
376 <title>Info</title>
377 </xsl:when>
378
379 <xsl:when test="$note.prefix = 'RESULT:'">
380 <xsl:attribute name="role">result</xsl:attribute>
381 <title>Result</title>
382 </xsl:when>
383
384 <xsl:when test="$note.prefix = 'EXECUTE:'">
385 <xsl:attribute name="role">execute</xsl:attribute>
386 <title>Execute</title>
387 </xsl:when>
388
389 <xsl:when test="$note.prefix = 'WARNING:'">
390 <xsl:attribute name="role">warning</xsl:attribute>
391 <title>Warning</title>
392 </xsl:when>
393
394 <xsl:otherwise/>
395 </xsl:choose>
396
397 <xsl:apply-templates select="para"/>
398 </note>
399 </xsl:when>
400
401 </xsl:choose>
402 </xsl:template>
403
404 <!-- Strip off the special note type prefix from the special training document
405 style notes ("AlfonsoNotes(TM)") if one is present. -->
406 <xsl:template match="para[parent::simplesect/@kind='note']/text()">
407 <xsl:variable name="note.prefix" select="substring-before(., ' ')"/>
408 <xsl:variable name="note.content" select="substring-after(., ' ')"/>
409
410 <xsl:choose>
411 <xsl:when test="$note.prefix = 'TODO:'">
412 <xsl:value-of select="$note.content"/>
413 </xsl:when>
414
415 <xsl:when test="$note.prefix = 'TIPS:'">
416 <xsl:value-of select="$note.content"/>
417 </xsl:when>
418
419 <xsl:when test="$note.prefix = 'INFO:'">
420 <xsl:value-of select="$note.content"/>
421 </xsl:when>
422
423 <xsl:when test="$note.prefix = 'RESULT:'">
424 <xsl:value-of select="$note.content"/>
425 </xsl:when>
426
427 <xsl:when test="$note.prefix = 'EXECUTE:'">
428 <xsl:value-of select="$note.content"/>
429 </xsl:when>
430
431 <xsl:when test="$note.prefix = 'WARNING:'">
432 <xsl:value-of select="$note.content"/>
433 </xsl:when>
434
435 <xsl:otherwise>
436 <xsl:value-of select="."/>
437 </xsl:otherwise>
438 </xsl:choose>
439 </xsl:template>
440
441 <xsl:template match="parameterlist[@kind = 'param']">
442 <table tabstyle="striped">
443 <title>Parameters</title>
444 <tgroup cols="3">
445 <thead>
446 <row>
447 <entry>Data direction</entry>
448 <entry>Parameter name</entry>
449 <entry>Description</entry>
450 </row>
451 </thead>
452 <tbody>
453 <xsl:for-each select="parameteritem">
454 <row>
455 <xsl:apply-templates select="."/>
456 </row>
457 </xsl:for-each>
458 </tbody>
459 </tgroup>
460 </table>
461 </xsl:template>
462
463 <xsl:template match="parameterlist[@kind = 'retval']">
464 <table tabstyle="striped">
465 <title>Return Values</title>
466 <tgroup cols="2">
467 <thead>
468 <row>
469 <entry>Return value</entry>
470 <entry>Description</entry>
471 </row>
472 </thead>
473 <tbody>
474 <xsl:for-each select="parameteritem">
475 <row>
476 <xsl:apply-templates select="."/>
477 </row>
478 </xsl:for-each>
479 </tbody>
480 </tgroup>
481 </table>
482 </xsl:template>
483
484 <xsl:template match="parameteritem">
485 <xsl:if test="parent::parameterlist/@kind = 'param'">
486 <entry>
487 <para>
488 <xsl:choose>
489 <xsl:when test="not(descendant::parametername/@direction)">
490 <emphasis role="italic">?</emphasis>
491 </xsl:when>
492 <xsl:otherwise>
493 <emphasis role="bold">[<xsl:value-of select="descendant::parametername/@direction"/>]</emphasis>
494 </xsl:otherwise>
495 </xsl:choose>
496 </para>
497 </entry>
498 </xsl:if>
499
500 <entry>
501 <para>
502 <xsl:value-of select="parameternamelist/parametername"/>
503 </para>
504 </entry>
505
506 <entry>
507 <xsl:apply-templates select="parameterdescription"/>
508 </entry>
509 </xsl:template>
510
511 <xsl:template match="type">
512 <xsl:apply-templates/>
513 </xsl:template>
514
515 <xsl:template match="sect1">
516 <section id="{@id}" xreflabel="{title}">
517 <title>
518 <xsl:value-of select="title"/>
519 </title>
520
521 <xsl:apply-templates select="para"/>
522 <xsl:apply-templates select="sect2"/>
523 </section>
524 </xsl:template>
525
526 <xsl:template match="sect2">
527 <section id="{@id}" xreflabel="{title}">
528 <title>
529 <xsl:value-of select="title"/>
530 </title>
531
532 <xsl:apply-templates select="para"/>
533 <xsl:apply-templates select="sect3"/>
534 </section>
535 </xsl:template>
536
537 <xsl:template match="sect3">
538 <section id="{@id}" xreflabel="{title}">
539 <title>
540 <xsl:value-of select="title"/>
541 </title>
542
543 <xsl:apply-templates select="para"/>
544 </section>
545 </xsl:template>
546
547 <xsl:template match="detaileddescription">
548 <xsl:apply-templates select="para"/>
549 <xsl:apply-templates select="sect1"/>
550 </xsl:template>
551
552 <xsl:template match="para">
553 <para>
554 <xsl:apply-templates/>
555 </para>
556 </xsl:template>
557
558 <xsl:template match="bold">
559 <emphasis role="bold">
560 <xsl:value-of select="."/>
561 </emphasis>
562 </xsl:template>
563
564 <xsl:template match="emphasis">
565 <emphasis role="italic">
566 <xsl:value-of select="."/>
567 </emphasis>
568 </xsl:template>
569
570 <xsl:template match="computeroutput">
571 <computeroutput>
572 <xsl:value-of select="."/>
573 </computeroutput>
574 </xsl:template>
575
576 <xsl:template match="ulink">
577 <ulink url="{@url}">
578 <xsl:value-of select="."/>
579 </ulink>
580 </xsl:template>
581
582 <xsl:template match="registered">
583 <xsl:text>&#174;</xsl:text>
584 </xsl:template>
585
586 <xsl:template match="copy">
587 <xsl:text>&#169;</xsl:text>
588 </xsl:template>
589
590 <xsl:template match="trademark">
591 <xsl:text>&#8482;</xsl:text>
592 </xsl:template>
593
594 <xsl:template match="superscript">
595 <superscript>
596 <xsl:value-of select="."/>
597 </superscript>
598 </xsl:template>
599
600 <xsl:template match="subscript">
601 <subscript>
602 <xsl:value-of select="."/>
603 </subscript>
604 </xsl:template>
605
606 <xsl:template match="ref">
607 <xsl:choose>
608 <!-- Don't show links inside program listings -->
609 <xsl:when test="ancestor::programlisting">
610 <xsl:value-of select="."/>
611 </xsl:when>
612
613 <!-- Show links outside program listings -->
614 <xsl:otherwise>
615 <xsl:choose>
616 <!-- Use hard links for anchors to make the reference
617 look correct for figure and table references -->
618 <xsl:when test="//anchor[@id = current()/@refid]">
619 <xref linkend="{@refid}" xrefstyle="select: label title"/>
620 </xsl:when>
621 <xsl:otherwise>
622 <link linkend="{@refid}">
623 <xsl:value-of select="text()"/>
624 </link>
625 </xsl:otherwise>
626 </xsl:choose>
627 </xsl:otherwise>
628 </xsl:choose>
629 </xsl:template>
630
631 <xsl:template match="formula">
632 <equation>
633 <!-- LaTeX equation generation requires JLatexMath and its associated
634 FOP plugin, or you will get missing equations in the output -->
635 <latex align="center" xmlns="http://forge.scilab.org/p/jlatexmath">
636 <xsl:value-of select="."/>
637 </latex>
638 </equation>
639 </xsl:template>
640
641 <xsl:template match="table">
642 <xsl:choose>
643 <xsl:when test="caption">
644 <!-- Fetch the ID using a preceding doxygen \anchor to be
645 able to reference tables -->
646 <table tabstyle="striped" id="{preceding-sibling::anchor[last()]/@id}">
647 <title>
648 <xsl:value-of select="caption"/>
649 </title>
650 <xsl:call-template name="write.table.content"/>
651 </table>
652 </xsl:when>
653 <xsl:otherwise>
654 <informaltable tabstyle="striped">
655 <xsl:call-template name="write.table.content"/>
656 </informaltable>
657 </xsl:otherwise>
658 </xsl:choose>
659 </xsl:template>
660
661 <xsl:template name="write.table.content">
662 <tgroup cols="{@cols}">
663 <thead>
664 <xsl:for-each select="row[1]">
665 <row>
666 <xsl:for-each select="entry">
667 <entry>
668 <xsl:apply-templates select="."/>
669 </entry>
670 </xsl:for-each>
671 </row>
672 </xsl:for-each>
673 </thead>
674 <tbody>
675 <xsl:for-each select="row[position() != 1]">
676 <row>
677 <xsl:for-each select="entry">
678 <entry>
679 <xsl:apply-templates select="."/>
680 </entry>
681 </xsl:for-each>
682 </row>
683 </xsl:for-each>
684 </tbody>
685 </tgroup>
686 </xsl:template>
687
688 <xsl:template match="itemizedlist">
689 <itemizedlist>
690 <xsl:apply-templates select="listitem"/>
691 </itemizedlist>
692 </xsl:template>
693
694 <xsl:template match="orderedlist">
695 <orderedlist>
696 <xsl:apply-templates select="listitem"/>
697 </orderedlist>
698 </xsl:template>
699
700 <xsl:template match="listitem">
701 <listitem>
702 <xsl:apply-templates/>
703 </listitem>
704 </xsl:template>
705
706 <xsl:template match="programlisting">
707 <programlisting language="c">
708 <!-- Only allow really long code segments to split across pages -->
709 <xsl:if test="count(codeline) > 30">
710 <xsl:processing-instruction name="dbfo">keep-together="auto"</xsl:processing-instruction>
711 </xsl:if>
712
713 <xsl:for-each select="codeline[position() > 1 or highlight]">
714 <xsl:apply-templates select="."/>
715 <xsl:text>&#10;</xsl:text>
716 </xsl:for-each>
717 </programlisting>
718 </xsl:template>
719
720 <xsl:template match="highlight">
721 <emphasis role="{@class}">
722 <xsl:apply-templates/>
723 </emphasis>
724 </xsl:template>
725
726 <xsl:template match="sp[ancestor::codeline]">
727 <xsl:choose>
728 <!-- Need to check if this is the first part of the line - if so we may
729 need to strip off any leading <sp/> element indentation -->
730 <xsl:when test="count(../preceding-sibling::highlight) = 0">
731 <!-- Doxygen retains a level of indentation in some code fragments - obtain
732 the base indentation level by counting the leading <sp/> elements of the
733 first code line, and use that to remove the indentation on the rest -->
734 <xsl:variable name="leading.spaces" select="count(ancestor::programlisting/codeline[highlight][1]/highlight[1]/sp[not(preceding-sibling::text())])"/>
735
736 <xsl:if test="position() > $leading.spaces">
737 <xsl:text> </xsl:text>
738 </xsl:if>
739 </xsl:when>
740
741 <xsl:otherwise>
742 <xsl:text> </xsl:text>
743 </xsl:otherwise>
744 </xsl:choose>
745 </xsl:template>
746
747 <xsl:template match="image">
748 <!-- Fetch the ID using a preceding doxygen \anchor to be
749 able to reference figures -->
750 <figure id="{preceding-sibling::anchor[last()]/@id}">
751 <title>
752 <xsl:value-of select="."/>
753 </title>
754
755 <mediaobject>
756 <imageobject>
757 <imagedata scalefit="1" width="{@width}">
758 <xsl:attribute name="fileref">
759 <xsl:text>html/</xsl:text>
760 <xsl:value-of select="@name"/>
761 </xsl:attribute>
762 </imagedata>
763 </imageobject>
764 </mediaobject>
765 </figure>
766 </xsl:template>
767
768 <xsl:template match="anchor">
769 <!-- Remove anchors from the PDF output, as these are used for referencing
770 images and tables. -->
771 </xsl:template>
772
773 <xsl:template match="dot">
774 <!-- Fetch the ID using a preceding doxygen \anchor to be able to reference
775 figures -->
776 <xsl:variable name="dot.id" select="preceding-sibling::anchor[last()]/@id" />
777
778 <xsl:choose>
779 <!-- If the DOT graph has an ID, use that for the filename -->
780 <xsl:when test="$dot.id">
781 <xsl:call-template name="write.dot.content">
782 <xsl:with-param name="dot.filename" select="$dot.id"/>
783 <xsl:with-param name="dot.id" select="$dot.id"/>
784 </xsl:call-template>
785 </xsl:when>
786
787 <!-- Otherwise use the auto-generated ID for it in the document -->
788 <xsl:otherwise>
789 <xsl:call-template name="write.dot.content"/>
790 </xsl:otherwise>
791 </xsl:choose>
792 </xsl:template>
793
794 <xsl:template name="write.dot.content">
795 <xsl:param name="dot.filename" select="generate-id(.)"/>
796 <xsl:param name="dot.id" select="''"/>
797
798 <!-- We get raw DOT syntax rather than a rendered image: write the DOT code
799 to a external file, and make a image reference to a SVG version of that
800 file. The build system should then call dot to render all generated
801 DOT files into their SVG equivalents before rendering the PDF. -->
802 <exsl:document href="{$dot.filename}.dot" method="text">
803 <xsl:value-of select="." />
804 </exsl:document>
805
806 <figure id="{$dot.id}">
807 <title>
808 <xsl:value-of select="ancestor::*/title"/>
809 </title>
810 <mediaobject>
811 <imageobject>
812 <imagedata format="SVG">
813 <xsl:attribute name="fileref">
814 <xsl:value-of select="$dot.filename" />
815 <xsl:text>.svg</xsl:text>
816 </xsl:attribute>
817 </imagedata>
818 </imageobject>
819 </mediaobject>
820 </figure>
821 </xsl:template>
822
823 </xsl:stylesheet>