VirtualBox

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

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

export the manual to OSE

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