VirtualBox

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

Last change on this file since 56533 was 56532, checked in by vboxsync, 9 years ago

doc/manual: fix SDK reference to be valid docbook XML, needed adjustments in the generator (which produced creative stuff which was severely violating the DTD, e.g. custom attributes which could be easily done properly) and a LOT of manual editing. Content of the manual is essentially the same, the biggest issues were <para> sloppiness and the use of <xref> where <link> is the only solution. Also made the line lengths again as uniform as possible.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette