VirtualBox

source: vbox/trunk/doc/manual/xidl2docbook.xsl@ 96300

Last change on this file since 96300 was 96300, checked in by vboxsync, 22 months ago

doc: comment fixing

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 20.0 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 xidl2docbook.xsl:
5 XSLT stylesheet that generates docbook from
6 VirtualBox.xidl.
7-->
8<!--
9 Copyright (C) 2006-2020 Oracle Corporation
10
11 This file is part of VirtualBox Open Source Edition (OSE), as
12 available from http://www.virtualbox.org. This file is free software;
13 you can redistribute it and/or modify it under the terms of the GNU
14 General Public License (GPL) as published by the Free Software
15 Foundation, in version 2 as it comes in the "COPYING" file of the
16 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18-->
19
20<xsl:stylesheet
21 version="1.0"
22 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
23 xmlns:exsl="http://exslt.org/common"
24 extension-element-prefixes="exsl">
25
26 <xsl:output
27 method="xml"
28 version="1.0"
29 encoding="utf-8"
30 indent="yes"/>
31
32 <xsl:strip-space elements="*"/>
33
34 <!-- - - - - - - - - - - - - - - - - - - - - - -
35 Keys for more efficiently looking up of types.
36 - - - - - - - - - - - - - - - - - - - - - - -->
37
38<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
39<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
40<xsl:key name="G_keyResultsByName" match="//result[@name]" use="@name"/>
41
42<!-- - - - - - - - - - - - - - - - - - - - - - -
43 global XSLT variables
44 - - - - - - - - - - - - - - - - - - - - - - -->
45
46<xsl:variable name="G_xsltFilename" select="'glue-jaxws.xsl'" />
47
48<!-- collect all interfaces with "wsmap='suppress'" in a global variable for
49 quick lookup -->
50<xsl:variable name="G_setSuppressedInterfaces"
51 select="//interface[@wsmap='suppress']" />
52
53<xsl:template name="makeLinkId">
54 <xsl:param name="ifname" />
55 <xsl:param name="member" />
56 <xsl:value-of select="concat($ifname, '__', $member)"/>
57</xsl:template>
58
59<xsl:template name="emitType">
60 <xsl:param name="type" />
61 <xsl:choose>
62 <xsl:when test="$type">
63 <xsl:choose>
64 <xsl:when test="count(key('G_keyInterfacesByName',$type)) > 0">
65 <link>
66 <xsl:attribute name="linkend">
67 <xsl:value-of select="translate($type, ':', '_')" />
68 </xsl:attribute>
69 <xsl:value-of select="$type" />
70 </link>
71 </xsl:when>
72 <xsl:when test="count(key('G_keyEnumsByName',$type)) > 0">
73 <link>
74 <xsl:attribute name="linkend">
75 <xsl:value-of select="translate($type, ':', '_')" />
76 </xsl:attribute>
77 <xsl:value-of select="$type" />
78 </link>
79 </xsl:when>
80 <xsl:otherwise>
81 <xsl:value-of select="$type" />
82 </xsl:otherwise>
83 </xsl:choose>
84 </xsl:when>
85 <xsl:otherwise>
86 <xsl:value-of select="'void'" />
87 </xsl:otherwise>
88 </xsl:choose>
89</xsl:template>
90
91<xsl:template name="isWebserviceOnly">
92 <xsl:for-each select="ancestor-or-self::*">
93 <xsl:if test="(name()='if') and (@target='wsdl')">
94 <xsl:text>yes</xsl:text>
95 </xsl:if>
96 </xsl:for-each>
97</xsl:template>
98
99
100<!-- - - - - - - - - - - - - - - - - - - - - - -
101 root match
102 - - - - - - - - - - - - - - - - - - - - - - -->
103
104<xsl:template match="/idl">
105 <book> <!-- Need a single top-level element for xi:include, we'll skip it using xpointer. -->
106 <chapter id="sdkref_classes">
107 <title>Classes (interfaces)</title>
108 <xsl:for-each select="//interface">
109 <xsl:sort select="@name"/>
110
111 <!-- ignore those interfaces within module sections; they don't have uuid -->
112 <xsl:if test="@uuid">
113 <xsl:variable name="ifname" select="@name" />
114 <xsl:variable name="wsmap" select="@wsmap" />
115 <xsl:variable name="wscpp" select="@wscpp" />
116 <xsl:variable name="wsonly"><xsl:call-template name="isWebserviceOnly" /></xsl:variable>
117 <xsl:variable name="extends" select="@extends" />
118 <xsl:variable name="reportExtends" select="not($extends='$unknown') and not($extends='$errorinfo')" />
119
120 <sect1>
121 <xsl:attribute name="id">
122 <xsl:value-of select="$ifname" />
123 </xsl:attribute>
124 <title><xsl:value-of select="$ifname" />
125 <xsl:if test="$reportExtends">
126 <xsl:value-of select="concat(' (', @extends, ')')" />
127 </xsl:if>
128 </title>
129
130 <xsl:choose>
131 <xsl:when test="$wsmap='suppress'">
132 <para><note><para>
133 This interface is not supported in the web service.
134 </para></note></para>
135 </xsl:when>
136 <xsl:when test="$wsmap='struct'">
137 <para><note><para>With the web service, this interface is mapped to a structure. Attributes that return this interface will not return an object, but a complete structure
138 containing the attributes listed below as structure members.</para></note></para>
139 </xsl:when>
140 <xsl:when test="$wsonly='yes'">
141 <para><note><para>This interface is supported in the web service only, not in COM/XPCOM.</para></note></para>
142 </xsl:when>
143 </xsl:choose>
144
145 <xsl:if test="$reportExtends">
146 <para><note><para>
147 This interface extends
148 <link>
149 <xsl:attribute name="linkend"><xsl:value-of select="$extends" /></xsl:attribute>
150 <xsl:value-of select="$extends" />
151 </link>
152 and therefore supports all its methods and attributes as well.
153 </para></note></para>
154 </xsl:if>
155
156 <xsl:apply-templates select="desc" />
157
158 <xsl:if test="attribute">
159 <sect2>
160 <title>Attributes</title>
161 <xsl:for-each select="attribute">
162 <xsl:variable name="attrtype" select="@type" />
163 <sect3>
164 <xsl:attribute name="id">
165 <xsl:call-template name="makeLinkId">
166 <xsl:with-param name="ifname" select="$ifname" />
167 <xsl:with-param name="member" select="@name" />
168 </xsl:call-template>
169 </xsl:attribute>
170 <title>
171 <xsl:choose>
172 <xsl:when test="@readonly='yes'">
173 <xsl:value-of select="concat(@name, ' (read-only)')" />
174 </xsl:when>
175 <xsl:otherwise>
176 <xsl:value-of select="concat(@name, ' (read/write)')" />
177 </xsl:otherwise>
178 </xsl:choose>
179 </title>
180 <programlisting>
181 <xsl:call-template name="emitType">
182 <xsl:with-param name="type" select="$attrtype" />
183 </xsl:call-template>
184 <xsl:value-of select="concat(' ', $ifname, '::', @name)" />
185 <xsl:if test="(@array='yes') or (@safearray='yes')">
186 <xsl:text>[]</xsl:text>
187 </xsl:if>
188 </programlisting>
189 <xsl:if test="( ($attrtype=($G_setSuppressedInterfaces/@name)) )">
190 <para><note><para>
191 This attribute is not supported in the web service.
192 </para></note></para>
193 </xsl:if>
194 <xsl:apply-templates select="desc" />
195 </sect3>
196 </xsl:for-each>
197 </sect2>
198 </xsl:if>
199
200 <xsl:if test="method">
201<!-- <sect2> -->
202<!-- <title>Methods</title> -->
203 <xsl:for-each select="method">
204 <xsl:sort select="@name" />
205 <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
206 <sect2>
207 <xsl:attribute name="id">
208 <xsl:call-template name="makeLinkId">
209 <xsl:with-param name="ifname" select="$ifname" />
210 <xsl:with-param name="member" select="@name" />
211 </xsl:call-template>
212 </xsl:attribute>
213 <title>
214 <xsl:value-of select="@name" />
215 </title>
216 <xsl:if test=" (param[@type=($G_setSuppressedInterfaces/@name)])
217 or (param[@mod='ptr'])" >
218 <para><note><para>
219 This method is not supported in the web service.
220 </para></note></para>
221 </xsl:if>
222 <!-- make a set of all parameters with in and out direction -->
223 <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
224 <programlisting>
225 <!--emit return type-->
226 <xsl:call-template name="emitType">
227 <xsl:with-param name="type" select="$returnidltype" />
228 </xsl:call-template>
229 <xsl:if test="(param[@dir='return']/@array='yes') or (param[@dir='return']/@safearray='yes')">
230 <xsl:text>[]</xsl:text>
231 </xsl:if>
232 <xsl:value-of select="concat(' ', $ifname, '::', @name, '(')" />
233 <xsl:if test="$paramsinout">
234 <xsl:for-each select="$paramsinout">
235 <xsl:text>&#10;</xsl:text>
236 <xsl:value-of select="concat(' [', @dir, '] ')" />
237 <xsl:if test="@mod = 'ptr'">
238 <xsl:text>[ptr] </xsl:text>
239 </xsl:if>
240 <xsl:call-template name="emitType">
241 <xsl:with-param name="type" select="@type" />
242 </xsl:call-template>
243 <emphasis role="bold">
244 <xsl:value-of select="concat(' ', @name)" />
245 </emphasis>
246 <xsl:if test="(@array='yes') or (@safearray='yes')">
247 <xsl:text>[]</xsl:text>
248 </xsl:if>
249 <xsl:if test="not(position()=last())">
250 <xsl:text>, </xsl:text>
251 </xsl:if>
252 </xsl:for-each>
253 </xsl:if>
254 <xsl:text>)</xsl:text>
255 </programlisting>
256
257 <xsl:if test="$paramsinout">
258 <glosslist>
259 <xsl:for-each select="$paramsinout">
260 <glossentry>
261 <glossterm>
262 <xsl:value-of select="@name" />
263 </glossterm>
264 <glossdef>
265 <xsl:if test="not(desc)">
266 <para/>
267 </xsl:if>
268 <xsl:apply-templates select="desc" />
269 </glossdef>
270 </glossentry>
271 </xsl:for-each>
272 </glosslist>
273 </xsl:if>
274
275 <!-- dump the description here -->
276 <xsl:apply-templates select="desc" />
277
278 <xsl:if test="desc/result">
279 <para>If this method fails, the following error codes may be reported:</para>
280 <itemizedlist>
281 <xsl:for-each select="desc/result">
282 <listitem>
283 <para><code><xsl:value-of select="@name" />: </code>
284 <xsl:apply-templates />
285 </para>
286 </listitem>
287 </xsl:for-each>
288 </itemizedlist>
289 </xsl:if>
290 </sect2>
291 </xsl:for-each>
292<!-- </sect2> -->
293 </xsl:if>
294
295 </sect1>
296 </xsl:if>
297 </xsl:for-each>
298 </chapter>
299
300 <chapter id="sdkref_enums">
301 <title>Enumerations (enums)</title>
302 <xsl:for-each select="//enum">
303 <xsl:sort select="@name"/>
304
305 <xsl:variable name="ifname" select="@name" />
306 <xsl:variable name="wsmap" select="@wsmap" />
307 <xsl:variable name="wscpp" select="@wscpp" />
308
309 <sect1>
310 <xsl:attribute name="id">
311 <xsl:value-of select="$ifname" />
312 </xsl:attribute>
313 <title><xsl:value-of select="$ifname" /></title>
314
315 <xsl:apply-templates select="desc" />
316
317 <glosslist>
318 <xsl:for-each select="const">
319 <glossentry>
320 <glossterm>
321 <xsl:attribute name="id">
322 <xsl:call-template name="makeLinkId">
323 <xsl:with-param name="ifname" select="$ifname" />
324 <xsl:with-param name="member" select="@name" />
325 </xsl:call-template>
326 </xsl:attribute>
327 <xsl:value-of select="@name" />
328 </glossterm>
329 <glossdef>
330 <xsl:if test="not(desc)">
331 <para/>
332 </xsl:if>
333 <xsl:apply-templates select="desc" />
334 </glossdef>
335 </glossentry>
336 </xsl:for-each>
337 </glosslist>
338 </sect1>
339 </xsl:for-each>
340 </chapter>
341 </book>
342</xsl:template>
343
344<!-- - - - - - - - - - - - - - - - - - - - - - -
345 if
346 - - - - - - - - - - - - - - - - - - - - - - -->
347
348<!--
349 * ignore all |if|s except those for WSDL target
350-->
351<xsl:template match="if">
352 <xsl:if test="@target='wsdl'">
353 <xsl:apply-templates/>
354 </xsl:if>
355</xsl:template>
356
357<!-- - - - - - - - - - - - - - - - - - - - - - -
358 cpp
359 - - - - - - - - - - - - - - - - - - - - - - -->
360
361<xsl:template match="cpp">
362<!-- ignore this -->
363</xsl:template>
364
365<!-- - - - - - - - - - - - - - - - - - - - - - -
366 result
367 - - - - - - - - - - - - - - - - - - - - - - -->
368
369<xsl:template match="result">
370 <!-- ignore this, we handle them explicitly in method loops -->
371</xsl:template>
372
373<!-- - - - - - - - - - - - - - - - - - - - - - -
374 library
375 - - - - - - - - - - - - - - - - - - - - - - -->
376
377<xsl:template match="library">
378 <xsl:apply-templates />
379</xsl:template>
380
381<!-- - - - - - - - - - - - - - - - - - - - - - -
382 class
383 - - - - - - - - - - - - - - - - - - - - - - -->
384
385<xsl:template match="module/class">
386<!-- TODO swallow for now -->
387</xsl:template>
388
389<!-- - - - - - - - - - - - - - - - - - - - - - -
390 enum
391 - - - - - - - - - - - - - - - - - - - - - - -->
392
393<xsl:template match="enum">
394</xsl:template>
395
396<!-- - - - - - - - - - - - - - - - - - - - - - -
397 const
398 - - - - - - - - - - - - - - - - - - - - - - -->
399
400<!--
401<xsl:template match="const">
402 <xsl:apply-templates />
403</xsl:template>
404-->
405
406<!-- - - - - - - - - - - - - - - - - - - - - - -
407 desc
408 - - - - - - - - - - - - - - - - - - - - - - -->
409
410<xsl:template match="desc">
411 <!-- todo: wrapping the entire content in a single para is actually not
412 entirely correct, as it contains empty lines denoting new paragraphs -->
413 <para>
414 <xsl:apply-templates />
415 </para>
416</xsl:template>
417
418<xsl:template name="getCurrentInterface">
419 <xsl:for-each select="ancestor-or-self::*">
420 <xsl:if test="name()='interface'">
421 <xsl:value-of select="@name"/>
422 </xsl:if>
423 </xsl:for-each>
424</xsl:template>
425
426<!-- <link to="DeviceType::HardDisk"/> -->
427<xsl:template match="link">
428 <link>
429 <xsl:variable name="tmp" select="@to" />
430 <xsl:variable name="enumNameFromCombinedName">
431 <xsl:value-of select="substring-before($tmp, '_')" />
432 </xsl:variable>
433 <xsl:variable name="enumValueFromCombinedName">
434 <xsl:value-of select="substring-after($tmp, '_')" />
435 </xsl:variable>
436 <xsl:choose>
437 <xsl:when test="count(key('G_keyInterfacesByName',$tmp)) > 0 or count(key('G_keyEnumsByName',$tmp)) > 0"><!-- link to interface only -->
438 <xsl:attribute name="linkend"><xsl:value-of select="@to" /></xsl:attribute>
439 <xsl:value-of select="$tmp" />
440 </xsl:when>
441 <xsl:when test="count(key('G_keyEnumsByName',$enumNameFromCombinedName)) > 0">
442 <xsl:attribute name="linkend">
443 <xsl:value-of select="concat($enumNameFromCombinedName, '__', $enumValueFromCombinedName)" />
444 </xsl:attribute>
445 <xsl:value-of select="$enumValueFromCombinedName" />
446 </xsl:when>
447 <xsl:otherwise>
448 <xsl:variable name="currentif">
449 <xsl:call-template name="getCurrentInterface" />
450 </xsl:variable>
451 <xsl:variable name="if"><!-- interface -->
452 <xsl:choose>
453 <xsl:when test="contains(@to, '#')">
454 <xsl:value-of select="$currentif" />
455 </xsl:when>
456 <xsl:otherwise>
457 <xsl:value-of select="substring-before(@to, '::')" />
458 </xsl:otherwise>
459 </xsl:choose>
460 </xsl:variable>
461 <xsl:variable name="member"><!-- member in that interface -->
462 <xsl:choose>
463 <xsl:when test="contains(@to, '#')">
464 <xsl:value-of select="substring-after(@to, '#')" />
465 </xsl:when>
466 <xsl:otherwise>
467 <xsl:value-of select="substring-after(@to, '::')" />
468 </xsl:otherwise>
469 </xsl:choose>
470 </xsl:variable>
471
472 <xsl:attribute name="linkend"><xsl:value-of select="concat($if, '__', $member)" /></xsl:attribute>
473 <xsl:variable name="autotextsuffix">
474 <xsl:choose>
475 <!-- if link points to a method, append "()" -->
476 <xsl:when test="key('G_keyInterfacesByName',$if)/method[@name=$member]">
477 <xsl:value-of select="'()'" />
478 </xsl:when>
479 <!-- if link points to a safearray attribute, append "[]" -->
480 <xsl:when test="key('G_keyInterfacesByName',$if)/attribute[@name=$member]/@safearray = 'yes'">
481 <xsl:value-of select="'[]'" />
482 </xsl:when>
483 <xsl:when test="key('G_keyInterfacesByName',$if)/attribute[@name=$member]"/>
484 <xsl:when test="key('G_keyEnumsByName',$if)/const[@name=$member]"/>
485 <xsl:when test="count(key('G_keyResultsByName',$tmp)) > 0"/>
486 <xsl:otherwise>
487 <xsl:message terminate="yes">
488 <xsl:value-of select="concat('Invalid link pointing to &quot;', $tmp, '&quot;')" />
489 </xsl:message>
490 </xsl:otherwise>
491 </xsl:choose>
492 </xsl:variable>
493 <xsl:choose>
494 <xsl:when test="./text()"><!-- link text given in source -->
495 <xsl:apply-templates />
496 </xsl:when>
497 <xsl:when test="$if=$currentif"><!-- "near" link to method or attribute in current interface -->
498 <xsl:value-of select="concat($member, $autotextsuffix)" />
499 </xsl:when>
500 <xsl:otherwise><!-- "far" link to other method or attribute -->
501 <xsl:value-of select="concat($if, '::', $member, $autotextsuffix)" />
502 </xsl:otherwise>
503 </xsl:choose>
504 </xsl:otherwise>
505 </xsl:choose>
506 </link>
507</xsl:template>
508
509<!-- - - - - - - - - - - - - - - - - - - - - - -
510 note
511 - - - - - - - - - - - - - - - - - - - - - - -->
512
513<xsl:template match="note">
514 <xsl:if test="not(@internal='yes')">
515 <note><para>
516 <xsl:apply-templates />
517 </para></note>
518 </xsl:if>
519</xsl:template>
520
521<xsl:template match="tt">
522 <computeroutput>
523 <xsl:apply-templates />
524 </computeroutput>
525</xsl:template>
526
527<xsl:template match="b">
528 <emphasis role="bold">
529 <xsl:apply-templates />
530 </emphasis>
531</xsl:template>
532
533<xsl:template match="i">
534 <emphasis>
535 <xsl:apply-templates />
536 </emphasis>
537</xsl:template>
538
539<xsl:template match="see">
540 <xsl:text>See also: </xsl:text>
541 <xsl:apply-templates />
542</xsl:template>
543
544<xsl:template match="ul">
545 <itemizedlist>
546 <xsl:apply-templates />
547 </itemizedlist>
548</xsl:template>
549
550<xsl:template match="ol">
551 <orderedlist>
552 <xsl:apply-templates />
553 </orderedlist>
554</xsl:template>
555
556<xsl:template match="li">
557 <listitem>
558 <para>
559 <xsl:apply-templates />
560 </para>
561 </listitem>
562</xsl:template>
563
564<xsl:template match="h3">
565 <emphasis role="bold">
566 <xsl:apply-templates />
567 </emphasis>
568</xsl:template>
569
570<xsl:template match="pre">
571 <screen><xsl:apply-templates /></screen>
572</xsl:template>
573
574<xsl:template match="table">
575 <xsl:apply-templates /> <!-- todo -->
576</xsl:template>
577
578</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use