clixdoc.xsl
  1 <?xml version="1.0" encoding="iso-8859-1" ?>
2
3 <!--
4 ;;; Copyright (c) 2008, Hans Hubner. All rights reserved.
5
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
8 ;;; are met:
9
10 ;;; * Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
12
13 ;;; * Redistributions in binary form must reproduce the above
14 ;;; copyright notice, this list of conditions and the following
15 ;;; disclaimer in the documentation and/or other materials
16 ;;; provided with the distribution.
17
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 -->
30
31 <xsl:stylesheet
32 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33 version="1.0"
34 xmlns:clix="http://bknr.net/clixdoc"
35 exclude-result-prefixes="clix">
36
37 <xsl:output method="html"
38 indent="yes"
39 omit-xml-declaration="yes"
40 doctype-public="-//W3C//DTD HTML 4.0 Strict//EN" />
41
42 <xsl:key name="index-entries" match="clix:*[@name and (name() != 'clix:chapter') and (name() != 'clix:subchapter')]" use="@name" />
43
44 <xsl:template match="/clix:documentation">
45 <html xmlns="http://www.w3.org/1999/xhtml">
46 <head>
47 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
48 <title><xsl:value-of select="clix:title"/></title>
49 <meta name="description"><xsl:attribute name="content"><xsl:value-of select="clix:short-description"/></xsl:attribute></meta>
50 <style type="text/css">
51 body { background-color: #ffffff }
52 pre { padding:5px; background-color:#e0e0e0 }
53 pre.none { padding:5px; background-color:#ffffff }
54 h3, h4, h5 { text-decoration: underline; }
55 .entry-type { padding-left: 1em; font-size: 60%; font-style: italic }
56 a { text-decoration: none; padding: 1px 2px 1px 2px; }
57 a:visited { text-decoration: none; padding: 1px 2px 1px 2px; }
58 a:hover { text-decoration: none; padding: 1px 1px 1px 1px; border: 1px solid #000000; }
59 a:focus { text-decoration: none; padding: 1px 2px 1px 2px; border: none; }
60 a.none { text-decoration: none; padding: 0; }
61 a.none:visited { text-decoration: none; padding: 0; }
62 a.none:hover { text-decoration: none; border: none; padding: 0; }
63 a.none:focus { text-decoration: none; border: none; padding: 0; }
64 a.noborder { text-decoration: none; padding: 0; }
65 a.noborder:visited { text-decoration: none; padding: 0; }
66 a.noborder:hover { text-decoration: none; border: none; padding: 0; }
67 a.noborder:focus { text-decoration: none; border: none; padding: 0; }
68 </style>
69 </head>
70 <body>
71 <xsl:apply-templates/>
72 </body>
73 </html>
74 </xsl:template>
75
76 <xsl:template match="clix:library-version">
77 <xsl:value-of select="$library-version"/>
78 </xsl:template>
79
80 <xsl:template match="clix:title"/>
81 <xsl:template match="clix:short-description"/>
82
83 <xsl:template match="clix:function">
84 <p>
85 <xsl:call-template name="make-anchor"/>
86 <xsl:choose>
87 <xsl:when test="clix:special-definition">
88 <xsl:apply-templates select="clix:special-definition"/>
89 </xsl:when>
90 <xsl:otherwise>
91 [<xsl:call-template name="nice-entry-type-name"/>]
92 <br/>
93 <xsl:call-template name="render-title"/>
94 <xsl:value-of select="' '"/>
95 <i><xsl:apply-templates select="clix:lambda-list"/></i>
96 <xsl:if test="clix:returns">
97 =&gt;
98 <i><xsl:apply-templates select="clix:returns"/></i>
99 </xsl:if>
100 </xsl:otherwise>
101 </xsl:choose>
102 <blockquote>
103 <xsl:apply-templates select="clix:description"/>
104 </blockquote>
105 </p>
106 </xsl:template>
107
108 <xsl:template match="clix:reader">
109 <p>
110 <xsl:call-template name="make-anchor"/>
111 [<xsl:call-template name="nice-entry-type-name"/>]
112 <br/>
113 <xsl:call-template name="render-title"/>
114 <xsl:value-of select="' '"/>
115 <i><xsl:apply-templates select="clix:lambda-list"/></i>
116 <xsl:if test="clix:returns">
117 =&gt;
118 <i><xsl:apply-templates select="clix:returns"/></i>
119 </xsl:if>
120 <blockquote>
121 <xsl:apply-templates select="clix:description"/>
122 </blockquote>
123 </p>
124 </xsl:template>
125
126 <xsl:template match="clix:listed-reader">
127 <xsl:call-template name="make-anchor"/>
128 <xsl:call-template name="render-title"/>
129 <xsl:value-of select="' '"/>
130 <i><xsl:apply-templates select="clix:lambda-list"/></i>
131 <xsl:if test="clix:returns">
132 =&gt;
133 <i><xsl:apply-templates select="clix:returns"/></i>
134 </xsl:if>
135 <br/>
136 </xsl:template>
137
138 <xsl:template match="clix:writer">
139 <p>
140 <xsl:call-template name="make-anchor"/>
141 [<xsl:call-template name="nice-entry-type-name"/>]
142 <br/>
143 <tt>(setf (</tt><b><xsl:value-of select="@name"/></b>
144 <xsl:value-of select="' '"/>
145 <i><xsl:apply-templates select="clix:lambda-list"/></i><tt>) <i>new-value</i>)</tt>
146 <xsl:if test="clix:returns">
147 =&gt;
148 <i><xsl:apply-templates select="clix:returns"/></i>
149 </xsl:if>
150 <blockquote>
151 <xsl:apply-templates select="clix:description"/>
152 </blockquote>
153 </p>
154 </xsl:template>
155
156 <xsl:template match="clix:accessor">
157 <p>
158 <xsl:call-template name="make-anchor"/>
159 [<xsl:call-template name="nice-entry-type-name"/>]
160 <br/>
161 <xsl:call-template name="render-title"/>
162 <xsl:value-of select="' '"/>
163 <i><xsl:apply-templates select="clix:lambda-list"/></i>
164 =&gt;
165 <i><xsl:apply-templates select="clix:returns"/></i>
166 <br/>
167 <tt>(setf (</tt><b><xsl:value-of select="@name"/></b>
168 <xsl:value-of select="' '"/>
169 <i><xsl:apply-templates select="clix:lambda-list"/></i><tt>) <i>new-value</i>)</tt>
170 <blockquote>
171 <xsl:apply-templates select="clix:description"/>
172 </blockquote>
173 </p>
174 </xsl:template>
175
176 <xsl:template match="clix:listed-accessor">
177 <xsl:call-template name="make-anchor"/>
178 <xsl:call-template name="render-title"/>
179 <xsl:value-of select="' '"/>
180 <i><xsl:apply-templates select="clix:lambda-list"/></i>
181 =&gt;
182 <i><xsl:apply-templates select="clix:returns"/></i>
183 <br/>
184 <tt>(setf (</tt><b><xsl:value-of select="@name"/></b>
185 <xsl:value-of select="' '"/>
186 <i><xsl:apply-templates select="clix:lambda-list"/></i><tt>) <i>new-value</i>)</tt>
187 <br/>
188 </xsl:template>
189
190 <xsl:template match="clix:special-variable | clix:class | clix:condition | clix:symbol | clix:constant">
191 <p>
192 <xsl:call-template name="make-anchor"/>
193 [<xsl:call-template name="nice-entry-type-name"/>]
194 <br/>
195 <xsl:call-template name="render-title"/>
196 <blockquote>
197 <xsl:apply-templates select="clix:description"/>
198 </blockquote>
199 </p>
200 </xsl:template>
201
202 <xsl:template match="clix:listed-constant">
203 <xsl:call-template name="render-title"/>
204 <br/>
205 </xsl:template>
206
207 <xsl:template match="clix:constants">
208 <!-- Display a list of constants with a common description -->
209 <p>
210 [Constants]<br/>
211 <xsl:apply-templates select="clix:listed-constant"/>
212 <blockquote>
213 <xsl:apply-templates select="clix:description"/>
214 </blockquote>
215 </p>
216 </xsl:template>
217
218 <xsl:template match="clix:readers">
219 <!-- Display a list of readers with a common description -->
220 <p>
221 [<xsl:call-template name="nice-entry-type-name"/>]<br/>
222 <xsl:apply-templates select="clix:listed-reader"/>
223 <blockquote>
224 <xsl:apply-templates select="clix:description"/>
225 </blockquote>
226 </p>
227 </xsl:template>
228
229 <xsl:template match="clix:accessors">
230 <!-- Display a list of accessors with a common description -->
231 <p>
232 [<xsl:call-template name="nice-entry-type-name"/>]<br/>
233 <xsl:apply-templates select="clix:listed-accessor"/>
234 <blockquote>
235 <xsl:apply-templates select="clix:description"/>
236 </blockquote>
237 </p>
238 </xsl:template>
239
240 <xsl:template match="clix:qualifier">
241 <!-- method qualifier -->
242 <tt><xsl:value-of select="text()"/></tt>
243 </xsl:template>
244
245 <xsl:template match="clix:lkw">
246 <!-- lambda list keyword -->
247 <tt>&#38;<xsl:value-of select="text()"/></tt>
248 </xsl:template>
249
250 <xsl:template match="clix:arg">
251 <!-- argument reference -->
252 <code><i><xsl:value-of select="text()"/></i></code>
253 </xsl:template>
254
255 <xsl:template match="clix:ref">
256 <xsl:call-template name="internal-reference">
257 <xsl:with-param name="name"><xsl:value-of select="."/></xsl:with-param>
258 </xsl:call-template>
259 </xsl:template>
260
261 <xsl:template match="clix:chapter">
262 <h3>
263 <a class="none">
264 <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
265 <xsl:value-of select="@title"/>
266 </a>
267 </h3>
268 <xsl:apply-templates/>
269 </xsl:template>
270
271 <xsl:template match="clix:subchapter">
272 <h4>
273 <a>
274 <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
275 <xsl:value-of select="@title"/>
276 </a>
277 </h4>
278 <xsl:apply-templates/>
279 </xsl:template>
280
281 <xsl:template match="clix:contents">
282 <ol>
283 <xsl:for-each select="//clix:chapter">
284 <li>
285 <a>
286 <xsl:attribute name="href">#<xsl:value-of select="@name"/></xsl:attribute>
287 <xsl:value-of select="@title"/>
288 </a>
289 <xsl:if test="clix:subchapter">
290 <ol>
291 <xsl:for-each select="clix:subchapter">
292 <li>
293 <a>
294 <xsl:attribute name="href">#<xsl:value-of select="@name"/></xsl:attribute>
295 <xsl:value-of select="@title"/>
296 </a>
297 </li>
298 </xsl:for-each>
299 </ol>
300 </xsl:if>
301 </li>
302 </xsl:for-each>
303 </ol>
304 </xsl:template>
305
306 <xsl:template match="clix:index">
307 <ul>
308 <xsl:for-each select="//clix:*[generate-id(.) = generate-id(key('index-entries', @name)[1])]">
309 <xsl:sort select="@name"/>
310 <li>
311 <xsl:choose>
312 <xsl:when test="count(key('index-entries', @name)) = 1">
313 <xsl:call-template name="internal-reference">
314 <xsl:with-param name="name"><xsl:value-of select="@name"/></xsl:with-param>
315 </xsl:call-template>
316 <span class="entry-type"><xsl:call-template name="nice-entry-type-name"/></span>
317 </xsl:when>
318 <xsl:otherwise>
319 <a>
320 <xsl:attribute name="name">
321 <xsl:value-of select="@name"/>
322 </xsl:attribute>
323 </a>
324 <xsl:value-of select="@name"/>
325 <ul>
326 <xsl:for-each select="key('index-entries', @name)">
327 <xsl:sort select="name()"/>
328 <li>
329 <xsl:call-template name="internal-reference">
330 <xsl:with-param name="name"><xsl:call-template name="make-anchor-name"/></xsl:with-param>
331 <xsl:with-param name="title"><xsl:value-of select="@name"/></xsl:with-param>
332 </xsl:call-template>
333 <span class="entry-type"><xsl:call-template name="nice-entry-type-name"/></span>
334 </li>
335 </xsl:for-each>
336 </ul>
337 </xsl:otherwise>
338 </xsl:choose>
339 </li>
340 </xsl:for-each>
341 </ul>
342 </xsl:template>
343
344 <xsl:template match="*">
345 <xsl:copy>
346 <xsl:copy-of select="@*[not(namespace-uri())]"/>
347 <xsl:apply-templates/>
348 </xsl:copy>
349 </xsl:template>
350
351 <xsl:template name="internal-reference">
352 <!-- internal reference -->
353 <xsl:param name="name"/>
354 <xsl:param name="title"/>
355 <code>
356 <a>
357 <xsl:attribute name="href">
358 #<xsl:value-of select="translate($name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
359 </xsl:attribute>
360 <xsl:choose>
361 <xsl:when test="$title != ''">
362 <xsl:value-of select="$title"/>
363 </xsl:when>
364 <xsl:otherwise>
365 <xsl:value-of select="$name"/>
366 </xsl:otherwise>
367 </xsl:choose>
368 </a>
369 </code>
370 </xsl:template>
371
372 <xsl:template name="make-anchor-name">
373 <xsl:choose>
374 <xsl:when test="count(key('index-entries', @name)) = 1">
375 <xsl:value-of select="translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
376 </xsl:when>
377 <xsl:otherwise>
378 <xsl:value-of select="translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>-<xsl:value-of select="substring(name(), 6)"/>
379 </xsl:otherwise>
380 </xsl:choose>
381 </xsl:template>
382
383 <xsl:template name="make-anchor">
384 <a class="none">
385 <xsl:attribute name="name">
386 <xsl:call-template name="make-anchor-name"/>
387 </xsl:attribute>
388 </a>
389 </xsl:template>
390
391 <xsl:template name="render-title">
392 <b><xsl:value-of select="@name"/></b>
393 </xsl:template>
394
395 <xsl:template name="nice-entry-type-name">
396 <xsl:choose>
397 <xsl:when test="name() = 'clix:function'">
398 <xsl:choose>
399 <xsl:when test="@generic = 'true'">Generic function</xsl:when>
400 <xsl:when test="@specialized = 'true'">Method</xsl:when>
401 <xsl:when test="@macro = 'true'">Macro</xsl:when>
402 <xsl:otherwise>Function</xsl:otherwise>
403 </xsl:choose>
404 </xsl:when>
405 <xsl:when test="name() = 'clix:reader'">
406 <xsl:choose>
407 <xsl:when test="@generic = 'true'">Generic reader</xsl:when>
408 <xsl:when test="@specialized = 'true'">Specialized reader</xsl:when>
409 <xsl:otherwise>Reader</xsl:otherwise>
410 </xsl:choose>
411 </xsl:when>
412 <xsl:when test="name() = 'clix:listed-reader'">
413 <xsl:choose>
414 <xsl:when test="@generic = 'true'">Generic reader</xsl:when>
415 <xsl:when test="@specialized = 'true'">Specialized reader</xsl:when>
416 <xsl:otherwise>Reader</xsl:otherwise>
417 </xsl:choose>
418 </xsl:when>
419 <xsl:when test="name() = 'clix:readers'">
420 <xsl:choose>
421 <xsl:when test="@generic = 'true'">Generic readers</xsl:when>
422 <xsl:when test="@specialized = 'true'">Specialized readers</xsl:when>
423 <xsl:otherwise>Readers</xsl:otherwise>
424 </xsl:choose>
425 </xsl:when>
426 <xsl:when test="name() = 'clix:accessors'">
427 <xsl:choose>
428 <xsl:when test="@generic = 'true'">Generic accessors</xsl:when>
429 <xsl:when test="@specialized = 'true'">Specialized accessors</xsl:when>
430 <xsl:otherwise>Accessors</xsl:otherwise>
431 </xsl:choose>
432 </xsl:when>
433 <xsl:when test="name() = 'clix:writer'">
434 <xsl:choose>
435 <xsl:when test="@generic = 'true'">Generic writer</xsl:when>
436 <xsl:when test="@specialized = 'true'">Specialized writer</xsl:when>
437 <xsl:otherwise>Writer</xsl:otherwise>
438 </xsl:choose>
439 </xsl:when>
440 <xsl:when test="name() = 'clix:listed-accessor'">
441 <xsl:choose>
442 <xsl:when test="@generic = 'true'">Generic accessor</xsl:when>
443 <xsl:when test="@specialized = 'true'">Specialized accessor</xsl:when>
444 <xsl:otherwise>Accessor</xsl:otherwise>
445 </xsl:choose>
446 </xsl:when>
447 <xsl:when test="name() = 'clix:accessor'">
448 <xsl:choose>
449 <xsl:when test="@generic = 'true'">Generic accessor</xsl:when>
450 <xsl:when test="@specialized = 'true'">Specialized accessor</xsl:when>
451 <xsl:otherwise>Accessor</xsl:otherwise>
452 </xsl:choose>
453 </xsl:when>
454 <xsl:when test="name() = 'clix:special-variable'">Special variable</xsl:when>
455 <xsl:when test="name() = 'clix:class'">Standard class</xsl:when>
456 <xsl:when test="name() = 'clix:condition'">Condition type</xsl:when>
457 <xsl:when test="name() = 'clix:symbol'">Symbol</xsl:when>
458 <xsl:when test="name() = 'clix:constant'">Constant</xsl:when>
459 <xsl:when test="name() = 'clix:listed-constant'">Constant</xsl:when>
460 <xsl:otherwise>
461 <xsl:value-of select="name()" />
462 </xsl:otherwise>
463 </xsl:choose>
464 </xsl:template>
465
466 </xsl:stylesheet>