VirtualBox

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

Last change on this file since 31876 was 31761, checked in by vboxsync, 14 years ago

OSE header fixes

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