stylesheets erklaert
[cxml-rng.git] / doc / html.xsl
blob2e2b833d7996de336f37c595e4075332a5f9a8c2
1 <!--
2 This this the main stylesheet.
3 Input must have been cleaned up using cleanup.xsl already.
5 This stylesheet does nearly all of the formatting work, but still keeps
6 all data together in one big XML document.
8 A <page> element is produced for each package and symbol.
10 The contents of each <page> will be mostly HTML, with the exception
11 of a few formatting elements like <columns> that are replaced later.
13 -->
14 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
15 <xsl:output method="xml" indent="yes"/>
17 <xsl:template match="/">
18 <pages>
19 <xsl:apply-templates select="documentation"/>
20 <xsl:apply-templates select="documentation/package"/>
21 <xsl:apply-templates select="documentation/package/symbols"/>
22 </pages>
23 </xsl:template>
25 <xsl:template match="symbols">
26 <xsl:apply-templates/>
27 </xsl:template>
30 <!--
31 page generation templates
32 -->
34 <xsl:template match="documentation">
35 <main-page title="@title">
36 Index of packages:
38 <xsl:for-each select="package">
39 <h2>
40 <a href="pages/{@id}.html">
41 Package
42 <xsl:value-of select="@name"/>
43 </a>
44 </h2>
45 <div style="left: 100px">
46 <xsl:apply-templates select="documentation-string"/>
47 </div>
48 </xsl:for-each>
49 </main-page>
50 </xsl:template>
52 <xsl:template match="package">
53 <page base="../"
54 pathname="pages/{@id}.html"
55 title="Package {@name}">
56 <p class="noindent">
57 Up:
58 <a href="../index.html">
59 <xsl:value-of select="/documentation/@title"/>
60 </a>
61 </p>
62 <h1>
63 Package
64 <xsl:value-of select="@name"/>
65 </h1>
66 <xsl:apply-templates select="documentation-string"/>
67 <columns>
68 <column width="60%">
69 <xsl:if test="sections">
70 <div style="margin-left: -30px">
71 <h3>About This Package</h3>
72 </div>
73 <xsl:apply-templates select="sections/section" mode="toc"/>
74 <br/>
75 <xsl:apply-templates select="sections"/>
76 </xsl:if>
77 </column>
78 <column>
79 <h3><a name="index"></a>Symbol Index</h3>
80 <xsl:apply-templates select="symbols" mode="symbol-index"/>
81 </column>
82 </columns>
83 </page>
84 </xsl:template>
86 <xsl:template match="class">
87 <page base="../"
88 pathname="pages/{@id}.html"
89 title="Class {@name}">
90 <p class="noindent">
91 Package:
92 <a href="{../../@id}.html">
93 <xsl:value-of select="../../@name"/>
94 </a>
95 </p>
96 <h2>
97 Class <xsl:value-of select="@name"/>
98 </h2>
99 <xsl:choose>
100 <xsl:when test="see-also">
101 <columns width="100%">
102 <column width="60%">
103 <xsl:call-template name="class-left"/>
104 </column>
105 <column width="5%">
106 &#160;
107 </column>
108 <column width="35%">
109 <xsl:call-template name="main-right"/>
110 </column>
111 </columns>
112 </xsl:when>
113 <xsl:otherwise>
114 <xsl:call-template name="class-left"/>
115 </xsl:otherwise>
116 </xsl:choose>
117 </page>
118 </xsl:template>
120 <xsl:template match="function">
121 <page base="../"
122 pathname="pages/{@id}.html"
123 title="Function {@name}">
124 <p class="noindent">
125 Package:
126 <a href="{../../@id}.html">
127 <xsl:value-of select="../../@name"/>
128 </a>
129 </p>
130 <h2>
131 Function
132 <xsl:value-of select="@name"/>
133 </h2>
134 <xsl:choose>
135 <xsl:when test="see-also">
136 <columns>
137 <column width="60%">
138 <xsl:call-template name="function-left"/>
139 </column>
140 <column width="5%">
141 &#160;
142 </column>
143 <column width="35%">
144 <xsl:call-template name="main-right"/>
145 </column>
146 </columns>
147 </xsl:when>
148 <xsl:otherwise>
149 <xsl:call-template name="function-left"/>
150 </xsl:otherwise>
151 </xsl:choose>
152 </page>
153 </xsl:template>
155 <xsl:template match="macro">
156 <page base="../"
157 pathname="pages/{@id}.html"
158 title="Macro {@name}">
159 <p class="noindent">
160 Package:
161 <a href="{../../@id}.html">
162 <xsl:value-of select="../../@name"/>
163 </a>
164 </p>
165 <h2>
166 Macro
167 <xsl:value-of select="@name"/>
168 </h2>
169 <xsl:apply-templates select="lambda-list"/>
170 <xsl:call-template name="main"/>
171 </page>
172 </xsl:template>
174 <xsl:template match="variable">
175 <page base="../"
176 pathname="pages/{@id}.html"
177 title="Variable {@name}">
178 <p class="noindent">
179 Package:
180 <a href="{../../@id}.html">
181 <xsl:value-of select="../../@name"/>
182 </a>
183 </p>
184 <h2>
185 Variable
186 <xsl:value-of select="@name"/>
187 </h2>
188 <xsl:call-template name="main"/>
189 </page>
190 </xsl:template>
193 <!--
194 Symbol index
196 <xsl:template match="class" mode="symbol-index">
197 <a href="{@id}.html">
198 <tt><xsl:value-of select="@name"/></tt>
199 </a>
200 <xsl:text>, class</xsl:text>
201 <xsl:call-template name="undocumented"/>
202 <br/>
203 </xsl:template>
205 <xsl:template match="function" mode="symbol-index">
206 <a href="{@id}.html">
207 <tt><xsl:value-of select="@name"/></tt>
208 </a>
209 <xsl:text>, function</xsl:text>
210 <xsl:call-template name="undocumented"/>
211 <br/>
212 </xsl:template>
214 <xsl:template match="macro" mode="symbol-index">
215 <a href="{@id}.html">
216 <tt><xsl:value-of select="@name"/></tt>
217 </a>
218 <xsl:text>, macro</xsl:text>
219 <xsl:call-template name="undocumented"/>
220 <br/>
221 </xsl:template>
223 <xsl:template match="variable" mode="symbol-index">
224 <a href="{@id}.html">
225 <tt><xsl:value-of select="@name"/></tt>
226 </a>
227 <xsl:text>, variable</xsl:text>
228 <xsl:call-template name="undocumented"/>
229 <br/>
230 </xsl:template>
233 <!--
234 Other templates
237 <xsl:template match="arguments">
238 <h3>Arguments</h3>
239 <div class="indent">
240 <ul>
241 <xsl:for-each select="arg">
242 <li>
243 <tt>
244 <xsl:value-of select="@arg"/>
245 </tt>
246 <xsl:text> -- </xsl:text>
247 <xsl:apply-templates/>
248 </li>
249 </xsl:for-each>
250 </ul>
251 </div>
252 </xsl:template>
254 <xsl:template name="main-left">
255 <xsl:apply-templates select="arguments"/>
256 <xsl:choose>
257 <xsl:when test="documentation-string">
258 <h3>Details<a name="details"/></h3>
259 <xsl:apply-templates select="documentation-string"/>
260 </xsl:when>
261 <xsl:otherwise>
262 <p style="color: red; font-weight: bold">
263 No documentation string. Possibly unimplemented or incomplete.
264 </p>
265 </xsl:otherwise>
266 </xsl:choose>
267 <xsl:apply-templates select="implementation-note"/>
268 </xsl:template>
270 <xsl:template name="main-right">
271 <xsl:if test="see-also/constructor">
272 <h3>Returned by</h3>
273 <div class="indent">
274 <simple-table>
275 <xsl:apply-templates select="see-also/constructor/see"/>
276 </simple-table>
277 </div>
278 </xsl:if>
279 <xsl:if test="see-also/slot">
280 <h3>Slot Access Functions</h3>
281 <div class="indent">
282 <simple-table>
283 <xsl:apply-templates select="see-also/slot/see"/>
284 </simple-table>
285 </div>
286 </xsl:if>
287 <xsl:if test="see-also/other">
288 <h3>See also</h3>
289 <div class="indent">
290 <simple-table>
291 <xsl:apply-templates select="see-also/other/see"/>
292 </simple-table>
293 </div>
294 </xsl:if>
295 </xsl:template>
297 <xsl:template name="main">
298 <xsl:choose>
299 <xsl:when test="see-also">
300 <columns>
301 <column width="60%">
302 <xsl:call-template name="main-left"/>
303 </column>
304 <column width="5%">
305 &#160;
306 </column>
307 <column width="35%">
308 <xsl:call-template name="main-right"/>
309 </column>
310 </columns>
311 </xsl:when>
312 <xsl:otherwise>
313 <xsl:call-template name="main-left"/>
314 </xsl:otherwise>
315 </xsl:choose>
316 </xsl:template>
320 <xsl:template match="*" mode="symbol-index"/>
322 <xsl:template match="symbols" mode="symbol-index">
323 <xsl:apply-templates mode="symbol-index">
324 <xsl:sort select="@id" data-type="text" order="ascending"/>
325 </xsl:apply-templates>
326 </xsl:template>
328 <xsl:template name="undocumented">
329 <xsl:if test="not(documentation-string)">
330 <xsl:text>&#160;</xsl:text>
331 <span style="color: red">
332 (undocumented)
333 </span>
334 </xsl:if>
335 </xsl:template>
337 <xsl:template name="class-left">
338 <h3>Superclasses</h3>
339 <div class="indent">
340 <xsl:for-each select="cpl/superclass">
341 <xsl:call-template name="class-list"/>
342 </xsl:for-each>
343 </div>
344 <h3>Documented Subclasses</h3>
345 <div class="indent">
346 <xsl:choose>
347 <xsl:when test="subclasses/subclass">
348 <xsl:for-each select="subclasses/subclass">
349 <xsl:sort select="@id" data-type="text" order="ascending"/>
350 <xsl:call-template name="class-list"/>
351 </xsl:for-each>
352 </xsl:when>
353 <xsl:otherwise>
354 None
355 </xsl:otherwise>
356 </xsl:choose>
357 </div>
358 <xsl:call-template name="main-left"/>
359 </xsl:template>
361 <xsl:template name="class-list">
362 <xsl:if test="position() != 1">
363 <xsl:text>, </xsl:text>
364 </xsl:if>
365 <xsl:choose>
366 <xsl:when test="@id">
367 <a href="{@id}.html">
368 <tt>
369 <xsl:if test="@status = 'INTERNAL'">
370 <xsl:value-of select="@package"/>
371 <xsl:text>::</xsl:text>
372 </xsl:if>
373 <xsl:value-of select="@name"/>
374 </tt>
375 </a>
376 </xsl:when>
377 <xsl:when test="@status = 'INTERNAL'">
378 <tt style="color: #777777">
379 <xsl:value-of select="@package"/>
380 <xsl:text>::</xsl:text>
381 <xsl:value-of select="@name"/>
382 </tt>
383 </xsl:when>
384 <xsl:otherwise>
385 <tt style="color: #777777">
386 <xsl:value-of select="@package"/>
387 <xsl:text>:</xsl:text>
388 <xsl:value-of select="@name"/>
389 </tt>
390 </xsl:otherwise>
391 </xsl:choose>
392 </xsl:template>
394 <xsl:template name="function-left">
395 <h3>Lambda List</h3>
396 <div class="indent">
397 <xsl:apply-templates select="lambda-list"/>
398 </div>
399 <xsl:apply-templates select="return"/>
400 <xsl:call-template name="main-left"/>
401 </xsl:template>
403 <xsl:template match="lambda-list">
404 <tt><xsl:value-of select="../@name"/></tt>
405 <xsl:text> (</xsl:text>
406 <xsl:for-each select="elt">
407 <xsl:if test="position() != 1">
408 <xsl:text>&#160;</xsl:text>
409 </xsl:if>
410 <b><xsl:value-of select="text()"/></b>
411 </xsl:for-each>
412 <xsl:text>)</xsl:text>
413 </xsl:template>
415 <xsl:template mode="about-arguments" match="lambda-list">
416 <div class="def">
417 <a href="{../@id}.html">
418 Function
419 <xsl:value-of select="../@name"/>
420 <xsl:text> (</xsl:text>
421 <xsl:for-each select="elt">
422 <xsl:if test="position() != 1">
423 <xsl:text>&#160;</xsl:text>
424 </xsl:if>
425 <xsl:value-of select="text()"/>
426 </xsl:for-each>
427 <xsl:text>)</xsl:text>
428 </a>
429 </div>
430 </xsl:template>
432 <xsl:template match="documentation-string">
433 <div class="indent">
434 <xsl:apply-templates/>
435 </div>
436 </xsl:template>
438 <xsl:template match="short">
439 <xsl:apply-templates/>
440 </xsl:template>
442 <xsl:template match="em">
444 <xsl:apply-templates/>
445 </i>
446 </xsl:template>
448 <xsl:template match="var">
449 <tt>
450 <xsl:apply-templates/>
451 </tt>
452 </xsl:template>
454 <xsl:template match="code">
455 <tt>
456 <xsl:apply-templates/>
457 </tt>
458 </xsl:template>
460 <xsl:template match="fun[@fun]">
461 <a href="{@id}.html">
462 <tt>
463 <xsl:apply-templates/>
464 </tt>
465 </a>
466 </xsl:template>
468 <xsl:template match="a">
469 <a href="{@a}">
470 <xsl:apply-templates/>
471 </a>
472 </xsl:template>
474 <xsl:template match="class[@class]">
475 <a href="{@id}.html">
476 <tt>
477 <xsl:apply-templates/>
478 </tt>
479 </a>
480 </xsl:template>
482 <xsl:template match="variable[@variable]">
483 <a href="{@id}.html">
484 <tt>
485 <xsl:apply-templates/>
486 </tt>
487 </a>
488 </xsl:template>
490 <xsl:template match="itemize">
491 <ul>
492 <xsl:apply-templates/>
493 </ul>
494 </xsl:template>
496 <xsl:template match="item">
497 <li>
498 <xsl:apply-templates/>
499 </li>
500 </xsl:template>
502 <xsl:template match="see">
503 <tr>
504 <td>
505 <a href="{@id}.html">
506 <tt>
507 <xsl:apply-templates/>
508 </tt>
509 </a>
510 </td>
511 <xsl:if test="@see">
512 <td>
513 &#160;&#160;&#160;&#160;
515 <xsl:value-of select="@see"/>
516 </i>
517 </td>
518 </xsl:if>
519 </tr>
520 </xsl:template>
522 <xsl:template match="return">
523 <h3>Returns</h3>
524 <div class="indent">
525 <xsl:apply-templates/>
526 </div>
527 </xsl:template>
529 <xsl:template match="implementation-note">
530 <h3>Implementation notes</h3>
531 <xsl:apply-templates/>
532 </xsl:template>
534 <xsl:template match="break">
535 <br/><br/>
536 </xsl:template>
538 <xsl:template match="sections">
539 <xsl:for-each select="section">
540 <h2>
541 <a name="{generate-id()}"/>
542 <xsl:value-of select="@section"/>
543 </h2>
544 <xsl:apply-templates/>
545 </xsl:for-each>
546 </xsl:template>
548 <xsl:template match="section" mode="toc">
549 <a href="#{generate-id()}" style="font-weight: bold">
550 <xsl:value-of select="@section"/>
551 </a>
552 <br/>
553 </xsl:template>
555 <xsl:template match="aboutfun">
556 <xsl:variable name="fun" select="text()"/>
557 <xsl:apply-templates mode="about-arguments"
558 select="//function[@name=$fun]/lambda-list"/>
559 <div style="margin-left: 3em">
560 <xsl:choose>
561 <xsl:when test="//function[@name=$fun]/documentation-string//short">
562 <xsl:for-each select="//function[@name=$fun]">
563 <xsl:apply-templates select="documentation-string//short"/>
564 <xsl:text> </xsl:text>
565 <a href="{@id}.html#details">...</a>
566 </xsl:for-each>
567 </xsl:when>
568 <xsl:otherwise>
569 <xsl:apply-templates
570 select="//function[@name=$fun]/documentation-string"/>
571 </xsl:otherwise>
572 </xsl:choose>
573 </div>
574 <br/>
575 </xsl:template>
577 <xsl:template match="aboutclass">
578 <xsl:variable name="name" select="text()"/>
579 <xsl:for-each select="//class[@name=$name]">
580 <div class="def">
581 <a href="{@id}.html">
582 Class
583 <xsl:value-of select="@name"/>
584 </a>
585 </div>
586 </xsl:for-each>
587 <div style="margin-left: 3em">
588 <xsl:choose>
589 <xsl:when test="//class[@name=$name]/documentation-string//short">
590 <xsl:for-each select="//class[@name=$name]">
591 <xsl:apply-templates select="documentation-string//short"/>
592 <xsl:text> </xsl:text>
593 <a href="{@id}.html#details">...</a>
594 </xsl:for-each>
595 </xsl:when>
596 <xsl:otherwise>
597 <xsl:apply-templates
598 select="//class[@name=$name]/documentation-string"/>
599 </xsl:otherwise>
600 </xsl:choose>
601 </div>
602 <br/>
603 </xsl:template>
604 </xsl:stylesheet>