blue.css
[cxml-rng.git] / doc / html.xsl
blob92136154cce8ef1110a2f46f17d410ddbb503a7a
1 <!--
2 This is 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"
15 xmlns:macro="http://lichteblau.com/macro"
16 version="1.0">
17 <xsl:output method="xml" indent="yes"/>
19 <xsl:template match="/">
20 <pages>
21 <xsl:call-template name="configuration-attributes"/>
22 <xsl:apply-templates select="documentation"/>
23 <xsl:apply-templates select="documentation/package"/>
24 <xsl:apply-templates select="documentation/package/symbols/*"/>
25 </pages>
26 </xsl:template>
28 <xsl:template name="configuration-attributes">
29 <macro:copy-attribute name="logo" path="documentation"/>
30 <macro:copy-attribute name="css" path="documentation"/>
31 <macro:copy-attribute name="heading" path="documentation"/>
32 </xsl:template>
35 <!--
36 page generation templates
37 -->
39 <xsl:template match="documentation">
40 <main-page title="{@index-title}">
41 <padded>
42 Index of packages:
43 </padded>
45 <columns>
46 <column width="60%">
47 <padded>
48 <xsl:for-each select="package">
49 <xsl:variable name="url"
50 select="concat('pages/', @id, '.html')"/>
51 <h2>
52 <a href="{$url}">
53 Package
54 <xsl:value-of select="@name"/>
55 </a>
56 </h2>
57 <div style="left: 100px">
58 <xsl:apply-templates select="documentation-string"/>
59 <div class="indent">
60 <xsl:if test="sections">
61 <p><i>About this package:</i></p>
62 <ul>
63 <xsl:for-each select="sections/section">
64 <li>
65 <a href="{$url}#{generate-id()}">
66 <xsl:value-of select="@section"/>
67 </a>
68 </li>
69 </xsl:for-each>
70 </ul>
71 </xsl:if>
72 </div>
73 </div>
74 </xsl:for-each>
75 </padded>
76 </column>
77 <column>
78 <h3><a name="index"></a>Symbol Index</h3>
79 <simple-table>
80 <xsl:apply-templates select="package/symbols/*"
81 mode="symbol-index">
82 <xsl:sort select="@name" data-type="text" order="ascending"/>
83 <xsl:with-param name="packagep" select="'pages/'"/>
84 </xsl:apply-templates>
85 </simple-table>
86 </column>
87 </columns>
88 </main-page>
89 </xsl:template>
91 <xsl:template match="package">
92 <page base="../"
93 pathname="pages/{@id}.html"
94 title="Package {@name}">
95 <padded>
96 <p class="noindent">
97 Up:
98 <a href="../index.html">
99 <xsl:value-of select="/documentation/@index-title"/>
100 </a>
101 </p>
102 <h1>
103 Package
104 <xsl:value-of select="@name"/>
105 </h1>
106 <xsl:apply-templates select="documentation-string"/>
107 </padded>
108 <columns>
109 <column width="60%">
110 <padded>
111 <xsl:if test="sections">
112 <div style="margin-left: -30px">
113 <h3>About This Package</h3>
114 </div>
115 <xsl:for-each select="sections/section">
116 <a href="#{generate-id()}" style="font-weight: bold">
117 <xsl:value-of select="@section"/>
118 </a>
119 <br/>
120 </xsl:for-each>
121 <br/>
122 <xsl:apply-templates select="sections"/>
123 </xsl:if>
124 </padded>
125 </column>
126 <column>
127 <h3><a name="index"></a>Symbol Index</h3>
128 <xsl:apply-templates select="symbols" mode="symbol-index"/>
129 </column>
130 </columns>
131 </page>
132 </xsl:template>
134 <xsl:template match="class-definition">
135 <page base="../"
136 pathname="pages/{@id}.html"
137 title="Class {@name}">
138 <padded>
139 <p class="noindent">
140 Package:
141 <a href="{../../@id}.html">
142 <xsl:value-of select="../../@name"/>
143 </a>
144 </p>
145 <h2>
146 Class <xsl:value-of select="@name"/>
147 </h2>
148 </padded>
149 <macro:maybe-columns
150 test="see-also
151 or //class-definition[@id=current()//superclass/@id]
152 //see-also/slot">
153 <padded>
154 <h3>Superclasses</h3>
155 <div class="indent">
156 <xsl:for-each select="cpl/superclass">
157 <xsl:call-template name="class-list"/>
158 </xsl:for-each>
159 </div>
160 <h3>Documented Subclasses</h3>
161 <div class="indent">
162 <xsl:choose>
163 <xsl:when test="subclasses/subclass">
164 <xsl:for-each select="subclasses/subclass">
165 <xsl:sort select="@id" data-type="text" order="ascending"/>
166 <xsl:call-template name="class-list"/>
167 </xsl:for-each>
168 </xsl:when>
169 <xsl:otherwise>
170 None
171 </xsl:otherwise>
172 </xsl:choose>
173 </div>
174 <xsl:call-template name="main-left"/>
175 </padded>
176 </macro:maybe-columns>
177 </page>
178 </xsl:template>
180 <xsl:template match="function-definition">
181 <page base="../"
182 pathname="pages/{@id}.html"
183 title="Function {@name}">
184 <padded>
185 <p class="noindent">
186 Package:
187 <a href="{../../@id}.html">
188 <xsl:value-of select="../../@name"/>
189 </a>
190 </p>
191 <h2>
192 Function
193 <xsl:value-of select="@name"/>
194 </h2>
195 </padded>
196 <macro:maybe-columns test="see-also">
197 <padded>
198 <h3>Lambda List</h3>
199 <div class="indent">
200 <xsl:apply-templates select="lambda-list"/>
201 </div>
202 <xsl:apply-templates select="arguments"/>
203 <xsl:apply-templates select="return"/>
204 <xsl:call-template name="main-left"/>
205 </padded>
206 </macro:maybe-columns>
207 </page>
208 </xsl:template>
210 <xsl:template match="macro-definition">
211 <page base="../"
212 pathname="pages/{@id}.html"
213 title="Macro {@name}">
214 <padded>
215 <p class="noindent">
216 Package:
217 <a href="{../../@id}.html">
218 <xsl:value-of select="../../@name"/>
219 </a>
220 </p>
221 <h2>
222 Macro
223 <xsl:value-of select="@name"/>
224 </h2>
225 <xsl:apply-templates select="lambda-list"/>
226 <xsl:call-template name="main"/>
227 </padded>
228 </page>
229 </xsl:template>
231 <xsl:template match="variable-definition">
232 <page base="../"
233 pathname="pages/{@id}.html"
234 title="Variable {@name}">
235 <padded>
236 <p class="noindent">
237 Package:
238 <a href="{../../@id}.html">
239 <xsl:value-of select="../../@name"/>
240 </a>
241 </p>
242 <h2>
243 Variable
244 <xsl:value-of select="@name"/>
245 </h2>
246 <xsl:call-template name="main"/>
247 </padded>
248 </page>
249 </xsl:template>
252 <!--
253 Symbol index
255 <xsl:template match="*" mode="symbol-index"/>
257 <xsl:template match="symbols" mode="symbol-index">
258 <xsl:param name="packagep"/>
259 <simple-table>
260 <xsl:apply-templates mode="symbol-index">
261 <xsl:sort select="@id" data-type="text" order="ascending"/>
262 <xsl:with-param name="packagep" select="$packagep"/>
263 </xsl:apply-templates>
264 </simple-table>
265 </xsl:template>
267 <xsl:template name="index-entry">
268 <xsl:param name="packagep"/>
269 <xsl:param name="kind"/>
271 <row>
272 <xsl:if test="$packagep">
273 <cell align="right">
274 <span class="nonlink">
275 <tt>
276 <span style="color: #777777">
277 <xsl:value-of select="../../@name"/>
278 <xsl:text>:</xsl:text>
279 </span>
280 </tt>
281 </span>
282 </cell>
283 </xsl:if>
284 <cell>
285 <a href="{$packagep}{@id}.html">
286 <tt>
287 <xsl:value-of select="@name"/>
288 </tt>
289 </a>
290 <xsl:text>, </xsl:text>
291 <xsl:value-of select="$kind"/>
292 <xsl:call-template name="undocumented"/>
293 </cell>
294 </row>
295 </xsl:template>
297 <xsl:template match="class-definition" mode="symbol-index">
298 <xsl:param name="packagep"/>
299 <xsl:call-template name="index-entry">
300 <xsl:with-param name="packagep" select="$packagep"/>
301 <xsl:with-param name="kind" select="'class'"/>
302 </xsl:call-template>
303 </xsl:template>
305 <xsl:template match="function-definition" mode="symbol-index">
306 <xsl:param name="packagep"/>
307 <xsl:call-template name="index-entry">
308 <xsl:with-param name="packagep" select="$packagep"/>
309 <xsl:with-param name="kind" select="'function'"/>
310 </xsl:call-template>
311 </xsl:template>
313 <xsl:template match="macro-definition" mode="symbol-index">
314 <xsl:param name="packagep"/>
315 <xsl:call-template name="index-entry">
316 <xsl:with-param name="packagep" select="$packagep"/>
317 <xsl:with-param name="kind" select="'macro'"/>
318 </xsl:call-template>
319 </xsl:template>
321 <xsl:template match="variable-definition" mode="symbol-index">
322 <xsl:param name="packagep"/>
323 <xsl:call-template name="index-entry">
324 <xsl:with-param name="packagep" select="$packagep"/>
325 <xsl:with-param name="kind" select="'variable'"/>
326 </xsl:call-template>
327 </xsl:template>
330 <!--
331 Other templates
334 <xsl:template match="arguments">
335 <h3>Arguments</h3>
336 <div class="indent">
337 <ul>
338 <xsl:for-each select="arg">
339 <li>
340 <tt>
341 <xsl:value-of select="@arg"/>
342 </tt>
343 <xsl:text> -- </xsl:text>
344 <xsl:apply-templates/>
345 </li>
346 </xsl:for-each>
347 </ul>
348 </div>
349 </xsl:template>
351 <xsl:template name="main-left">
352 <xsl:choose>
353 <xsl:when test="documentation-string">
354 <h3>Details<a name="details"/></h3>
355 <xsl:apply-templates select="documentation-string"/>
356 </xsl:when>
357 <xsl:otherwise>
358 <p style="color: red; font-weight: bold">
359 No documentation string. Possibly unimplemented or incomplete.
360 </p>
361 </xsl:otherwise>
362 </xsl:choose>
363 <xsl:apply-templates select="implementation-note"/>
364 </xsl:template>
366 <xsl:template name="main-right">
367 <xsl:if test="see-also/constructor">
368 <h3>Returned by</h3>
369 <div class="indent">
370 <simple-table>
371 <xsl:apply-templates select="see-also/constructor/see"/>
372 </simple-table>
373 </div>
374 </xsl:if>
375 <xsl:if test="see-also/slot">
376 <h3>Slot Access Functions</h3>
377 <div class="indent">
378 <simple-table>
379 <xsl:apply-templates select="see-also/slot/see"/>
380 </simple-table>
381 </div>
382 </xsl:if>
383 <xsl:if
384 test="//class-definition[@id=current()//superclass/@id]
385 //see-also
386 /slot">
387 <h3>Inherited Slot Access Functions</h3>
388 <div class="indent">
389 <simple-table>
390 <xsl:apply-templates
391 select="//class-definition[@id=current()//superclass/@id]
392 //see-also/slot/see"/>
393 </simple-table>
394 </div>
395 </xsl:if>
396 <xsl:if test="see-also/other|see-also/auto">
397 <h3>See also</h3>
398 <div class="indent">
399 <simple-table>
400 <xsl:for-each select="see-also/other/see|see-also/auto/see">
401 <xsl:variable name="name" select="text()"/>
402 <xsl:if test="not(preceding-sibling::see[text() = $name])">
403 <xsl:apply-templates select="."/>
404 </xsl:if>
405 </xsl:for-each>
406 </simple-table>
407 </div>
408 </xsl:if>
409 </xsl:template>
411 <xsl:template name="main">
412 <macro:maybe-columns test="see-also">
413 <xsl:call-template name="main-left"/>
414 </macro:maybe-columns>
415 </xsl:template>
417 <xsl:template name="class-list">
418 <xsl:if test="position() != 1">
419 <xsl:text>, </xsl:text>
420 </xsl:if>
421 <xsl:choose>
422 <xsl:when test="@id">
423 <a href="{@id}.html">
424 <tt>
425 <xsl:if test="@status = 'INTERNAL'">
426 <xsl:value-of select="@package"/>
427 <xsl:text>::</xsl:text>
428 </xsl:if>
429 <xsl:value-of select="@name"/>
430 </tt>
431 </a>
432 </xsl:when>
433 <xsl:when test="@status = 'INTERNAL'">
434 <tt style="color: #777777">
435 <xsl:value-of select="@package"/>
436 <xsl:text>::</xsl:text>
437 <xsl:value-of select="@name"/>
438 </tt>
439 </xsl:when>
440 <xsl:otherwise>
441 <tt style="color: #777777">
442 <xsl:value-of select="@package"/>
443 <xsl:text>:</xsl:text>
444 <xsl:value-of select="@name"/>
445 </tt>
446 </xsl:otherwise>
447 </xsl:choose>
448 </xsl:template>
450 <xsl:template match="lambda-list">
451 <tt><xsl:value-of select="../@name"/></tt>
452 <xsl:text> (</xsl:text>
453 <xsl:for-each select="elt">
454 <xsl:if test="position() != 1">
455 <xsl:text>&#160;</xsl:text>
456 </xsl:if>
457 <b><xsl:value-of select="text()"/></b>
458 </xsl:for-each>
459 <xsl:text>)</xsl:text>
460 </xsl:template>
462 <xsl:template mode="about-arguments" match="lambda-list">
463 <div class="def">
464 <a href="{../@id}.html">
465 Function
466 <xsl:value-of select="../@name"/>
467 <xsl:text> (</xsl:text>
468 <xsl:for-each select="elt">
469 <xsl:if test="position() != 1">
470 <xsl:text>&#160;</xsl:text>
471 </xsl:if>
472 <xsl:value-of select="text()"/>
473 </xsl:for-each>
474 <xsl:text>)</xsl:text>
475 </a>
476 </div>
477 </xsl:template>
479 <xsl:template match="documentation-string">
480 <div class="indent">
481 <xsl:apply-templates/>
482 </div>
483 </xsl:template>
485 <xsl:template match="short">
486 <xsl:apply-templates/>
487 </xsl:template>
489 <xsl:template match="em">
491 <xsl:apply-templates/>
492 </i>
493 </xsl:template>
495 <xsl:template match="b">
497 <xsl:apply-templates/>
498 </b>
499 </xsl:template>
501 <xsl:template match="var">
502 <tt>
503 <xsl:apply-templates/>
504 </tt>
505 </xsl:template>
507 <xsl:template match="code">
508 <tt>
509 <xsl:apply-templates/>
510 </tt>
511 </xsl:template>
513 <xsl:template match="pre">
514 <pre>
515 <xsl:apply-templates/>
516 </pre>
517 </xsl:template>
519 <xsl:template match="a">
520 <a href="{@a}">
521 <xsl:apply-templates/>
522 </a>
523 </xsl:template>
525 <xsl:template match="fun">
526 <a href="{@id}.html">
527 <tt>
528 <xsl:apply-templates/>
529 </tt>
530 </a>
531 </xsl:template>
533 <xsl:template match="class">
534 <a href="{@id}.html">
535 <tt>
536 <xsl:apply-templates/>
537 </tt>
538 </a>
539 </xsl:template>
541 <xsl:template match="variable">
542 <a href="{@id}.html">
543 <tt>
544 <xsl:apply-templates/>
545 </tt>
546 </a>
547 </xsl:template>
549 <xsl:template match="itemize">
550 <ul>
551 <xsl:apply-templates/>
552 </ul>
553 </xsl:template>
555 <xsl:template match="item">
556 <li>
557 <xsl:apply-templates/>
558 </li>
559 </xsl:template>
561 <xsl:template match="see">
562 <tr>
563 <td>
564 <a href="{@id}.html">
565 <tt>
566 <xsl:apply-templates/>
567 </tt>
568 </a>
569 </td>
570 <xsl:if test="@see">
571 <td>
572 &#160;&#160;&#160;&#160;
574 <xsl:value-of select="@see"/>
575 </i>
576 </td>
577 </xsl:if>
578 </tr>
579 </xsl:template>
581 <xsl:template match="return">
582 <h3>Return Value</h3>
583 <div class="indent">
584 <xsl:apply-templates/>
585 </div>
586 </xsl:template>
588 <xsl:template match="implementation-note">
589 <h3>Implementation notes</h3>
590 <xsl:apply-templates/>
591 </xsl:template>
593 <xsl:template match="break">
594 <br/><br/>
595 </xsl:template>
597 <xsl:template match="sections">
598 <xsl:for-each select="section">
599 <h2>
600 <a name="{generate-id()}"/>
601 <xsl:value-of select="@section"/>
602 </h2>
603 <xsl:apply-templates/>
604 </xsl:for-each>
605 </xsl:template>
607 <xsl:template match="aboutfun">
608 <xsl:variable name="fun" select="text()"/>
609 <xsl:apply-templates
610 mode="about-arguments"
611 select="//function-definition[@name=$fun]/lambda-list"/>
612 <div style="margin-left: 3em">
613 <xsl:choose>
614 <xsl:when
615 test="//function-definition[@name=$fun]/documentation-string//short">
616 <xsl:for-each select="//function-definition[@name=$fun]">
617 <xsl:apply-templates select="documentation-string//short"/>
618 <xsl:text> </xsl:text>
619 <a href="{@id}.html#details">...</a>
620 </xsl:for-each>
621 </xsl:when>
622 <xsl:otherwise>
623 <xsl:apply-templates
624 select="//function-definition[@name=$fun]/documentation-string"/>
625 </xsl:otherwise>
626 </xsl:choose>
627 </div>
628 <br/>
629 </xsl:template>
631 <xsl:template match="aboutclass">
632 <xsl:variable name="name" select="text()"/>
633 <xsl:for-each select="//class-definition[@name=$name]">
634 <div class="def">
635 <a href="{@id}.html">
636 Class
637 <xsl:value-of select="@name"/>
638 </a>
639 </div>
640 </xsl:for-each>
641 <div style="margin-left: 3em">
642 <xsl:choose>
643 <xsl:when
644 test="//class-definition[@name=$name]/documentation-string//short">
645 <xsl:for-each select="//class-definition[@name=$name]">
646 <xsl:apply-templates select="documentation-string//short"/>
647 <xsl:text> </xsl:text>
648 <a href="{@id}.html#details">...</a>
649 </xsl:for-each>
650 </xsl:when>
651 <xsl:otherwise>
652 <xsl:apply-templates
653 select="//class-definition[@name=$name]/documentation-string"/>
654 </xsl:otherwise>
655 </xsl:choose>
656 </div>
657 <br/>
658 </xsl:template>
660 <xsl:template name="undocumented">
661 <xsl:if test="not(documentation-string)">
662 <xsl:text>&#160;</xsl:text>
663 <span style="color: red">
664 (undocumented)
665 </span>
666 </xsl:if>
667 </xsl:template>
668 </xsl:stylesheet>