ui/input: migration of types d2::psf --> ale_psf (Libale).
[Ale.git] / doc / ale-doc.xsl
blob222a2ca9c35643b11cebc3f40bf585a5e472e4be
1 <!--
2 - Copyright 2006 David Hilvert
3 -
4 - ALE documentation stylesheet definition.
6 - This file is part of the Anti-Lamenessing Engine documentation.
8 - The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
9 - it under the terms of the GNU General Public License as published by
10 - the Free Software Foundation; either version 3 of the License, or
11 - (at your option) any later version.
13 - The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
14 - but WITHOUT ANY WARRANTY; without even the implied warranty of
15 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 - GNU General Public License for more details.
18 - You should have received a copy of the GNU General Public License
19 - along with Anti-Lamenessing Engine; if not, write to the Free Software
20 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 -->
23 <!DOCTYPE xsl:stylesheet [
25 <!--
26 - Entities
27 -->
29 <!--
30 - Character classes
31 -->
33 <!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
34 <!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
36 <!--
38 - NOTE: the below entities operate on edit records, which
39 - are expected to conform to exactly one of the following patterns:
41 - <edit by="David Hilvert" on="2006-Sep-24">
42 - <edit by="David Hilvert" in-month="2006-Sep">
43 - <edit by="David Hilvert" in-year="2006">
45 - The first form is preferred for occasional edits; the latter two
46 - are provided as shorthand for edits occurring over a number of
47 - days in succession, or for cases where the exact date of the edit
48 - is not known (e.g., when basing edit history on copyright notices
49 - from older files).
50 -->
53 <!--
54 - Obtain an editor name from an edit record.
55 -->
57 <!ENTITY editor 'normalize-space(@by)'>
59 <!--
60 - Obtain an edit year from an edit record.
61 -->
63 <!ENTITY year 'concat(@in-year, substring-before(@in-month, "-"), substring-before(@on, "-"))'>
65 <!--
66 - Generate a string unique for each (editor, year) combination.
67 -->
69 <!ENTITY editor-year 'concat(&editor;, &year;)'>
71 <!--
72 - Boolean test to determine whether the current node is within the scope of
73 - $objectroot.
74 -->
76 <!ENTITY scope 'count(ancestor::node()|$objectroot) = count(ancestor::node())'>
78 <!--
79 - Editor first name.
80 -->
82 <!ENTITY editor-firstname 'substring-before(&editor;, " ")'>
84 <!--
85 - Editor last name
86 -->
88 <!ENTITY editor-surname 'substring-after(&editor;, " ")'>
90 <!--
91 - Sort order for outputs including editor names.
92 -->
94 <!ENTITY editor-sort-order '&editor-surname;'>
96 <!--
97 - Sort order for years
98 -->
100 <!ENTITY year-sort-order '&year;'>
104 <xsl:stylesheet id="style1"
105 version="1.0"
106 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
107 xmlns:fo="http://www.w3.org/1999/XSL/Format"
108 xmlns:xi="http://www.w3.org/2001/XInclude">
110 <!--
111 - Product information
114 <xsl:param name="product-name" select="$package-name"/>
115 <xsl:param name="product-version" select="$version"/>
116 <xsl:param name="site-URL" select="$home-page"/>
117 <xsl:param name="source-package-name-tar-gz" select="$version-gz"/>
118 <xsl:param name="source-package-name" select="$version-pack"/>
119 <xsl:param name="source-URL" select="$version-url"/>
120 <xsl:param name="mailing-list-address" select="$mailing-list"/>
122 <!--
123 - License information
126 <xsl:template match="*|/" mode="license-terms">
127 <para>
128 This <xsl:apply-templates select="." mode="document-type"/> is free
129 documentation; you can redistribute it and/or modify it under the
130 terms of the GNU General Public License as published by the Free
131 Software Foundation; either version 3 of the License, or (at your
132 option) any later version.
133 </para>
134 </xsl:template>
136 <xsl:template match="*|/" mode="license-warranty">
137 <para>
138 This <xsl:apply-templates select="." mode="document-type"/> is
139 distributed in the hope that it will be useful, but WITHOUT ANY
140 WARRANTY; without even the implied warranty of MERCHANTABILITY or
141 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
142 for more details.
143 </para>
144 </xsl:template>
146 <xsl:template match="*|/" mode="license-availability">
147 <para>
148 You should have received a copy of the GNU General Public License
149 along with this <xsl:apply-templates select="."
150 mode="document-type"/>; if not, write to the Free Software
151 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
152 02110-1301, USA.
153 </para>
154 </xsl:template>
156 <xsl:template match="*|/" mode="license">
157 <legalnotice>
158 <xsl:apply-templates select="." mode="license-terms"/>
159 <xsl:apply-templates select="." mode="license-warranty"/>
160 <xsl:apply-templates select="." mode="license-availability"/>
161 </legalnotice>
162 </xsl:template>
164 <!--
165 - Editing information
168 <xsl:key name="editors" match="edit" use="&editor;"/>
169 <xsl:key name="editor-years" match="edit" use="&editor-year;"/>
171 <!--
172 - If no other template matches, we copy the tree structure unchanged.
175 <xsl:template match="@*|node()">
176 <xsl:copy>
177 <xsl:apply-templates select="@*|node()"/>
178 </xsl:copy>
179 </xsl:template>
181 <!--
182 - Do not pass edit tags to DocBook, as it doesn't understand them.
185 <xsl:template match="edit"/>
187 <!--
188 - Capitalize the initial letter of titles.
191 <xsl:template name="write_title">
192 <xsl:param name="product-name"/>
193 <xsl:param name="product-version"/>
194 <xsl:param name="title" select="."/>
196 <xsl:variable name="space-stripped-title" select="normalize-space($title)"/>
197 <xsl:variable name="initial" select="substring($space-stripped-title, 1, 1)"/>
198 <xsl:variable name="sequel" select="substring($space-stripped-title, 2)"/>
200 <title>
202 <xsl:copy-of select="$product-name"/>
203 <xsl:text> </xsl:text>
204 <xsl:copy-of select="$product-version"/>
205 <xsl:text> </xsl:text>
206 <xsl:copy-of select="concat(translate($initial, &lowercase;, &uppercase;), $sequel)"/>
208 </title>
209 </xsl:template>
211 <xsl:template match="text()" mode="title">
212 <xsl:call-template name="write_title">
213 <xsl:with-param name="title" select="."/>
214 </xsl:call-template>
215 </xsl:template>
217 <!--
218 - Titles other than article, book and set titles.
221 <xsl:template match="title|t">
222 <xsl:apply-templates select="text()" mode="title"/>
223 </xsl:template>
225 <!--
226 - Add package information to titles of articles, books and sets.
229 <xsl:template match="setinfo/title|bookinfo/title|articleinfo/title|setinfo/t|bookinfo/t|articleinfo/t">
230 <xsl:call-template name="write_title">
231 <xsl:with-param name="product-name" select="$product-name"/>
232 <xsl:with-param name="product-version" select="$product-version"/>
233 <xsl:with-param name="title" select="text()"/>
234 </xsl:call-template>
235 </xsl:template>
237 <!--
238 - Generate title, author, copyright, and license information for
239 - articles, books and sets.
242 <xsl:template match="setinfo" mode="document-type">
243 <xsl:text>set</xsl:text>
244 </xsl:template>
246 <xsl:template match="bookinfo" mode="document-type">
247 <xsl:text>book</xsl:text>
248 </xsl:template>
250 <xsl:template match="articleinfo" mode="document-type">
251 <xsl:text>article</xsl:text>
252 </xsl:template>
254 <xsl:template match="setinfo|bookinfo|articleinfo">
255 <xsl:copy>
256 <xsl:variable name="objectroot" select=".."/>
257 <xsl:variable name="editors-unique" select="$objectroot//edit[count(.|key('editors', &editor;)[&scope;][1]) = 1]"/>
258 <xsl:variable name="editor-years-unique" select="$objectroot//edit[count(.|key('editor-years', &editor-year;)[&scope;][1]) = 1]"/>
260 <!--
261 - Generate the title, if available.
264 <xsl:apply-templates select="title|t"/>
266 <!--
267 - Preserve abstracts.
270 <xsl:apply-templates select="abstract"/>
272 <!--
273 - Add author information.
276 <xsl:for-each select="$editors-unique">
277 <xsl:sort select="&editor-sort-order;"/>
278 <author>
279 <firstname>
280 <xsl:value-of select="&editor-firstname;"/>
281 </firstname>
282 <surname>
283 <xsl:value-of select="&editor-surname;"/>
284 </surname>
285 </author>
286 </xsl:for-each>
288 <!--
289 - Add copyright information
292 <xsl:for-each select="$editors-unique">
293 <xsl:sort select="&editor-sort-order;"/>
294 <xsl:variable name="this-editor" select="&editor;"/>
295 <copyright>
296 <holder>
297 <xsl:value-of select="&editor;"/>
298 </holder>
299 <xsl:for-each select="$editor-years-unique">
300 <xsl:sort select="&year-sort-order;"/>
301 <xsl:if test="&editor; = $this-editor">
302 <year>
303 <xsl:value-of select="&year;"/>
304 </year>
305 </xsl:if>
306 </xsl:for-each>
307 </copyright>
308 </xsl:for-each>
311 <!--
312 - Add a license notice
315 <xsl:apply-templates select="." mode="license"/>
317 </xsl:copy>
318 </xsl:template>
320 <!--
321 - Changelogs and news files.
324 <!--
325 - Changelog item
328 <xsl:template match="entry">
329 <listitem>
330 <xsl:apply-templates select="text/text()"/>
331 </listitem>
332 </xsl:template>
334 <!--
335 - Keys
338 <xsl:key name="word-map" match="entry" use="word/child::text()"/>
340 <!--
341 - Taxonomy
344 <xsl:variable name="taxonomy-root" select="document('taxonomy.xmli')"/>
346 <!--
347 - Write a fragment substring for a (change, category) pair.
350 <xsl:template name="write-change-category">
351 <xsl:param name="change"/>
352 <xsl:param name="category"/>
353 <xsl:value-of select="concat(generate-id($change), ':', generate-id($category), ' ')"/>
354 </xsl:template>
356 <!--
357 - Get a change category from a fragment result
360 <xsl:template name="get-change-category">
361 <xsl:param name="change"/>
362 <xsl:param name="fragment"/>
363 <xsl:value-of select="substring-before(substring-after(substring-after($fragment, generate-id($change)), ':'), ' ')"/>
364 </xsl:template>
366 <!--
367 - Get a tree fragment with categories set to zero.
370 <xsl:template name="get-zero-categories">
371 <xsl:param name="changes"/>
372 <xsl:for-each select="$changes">
373 <xsl:call-template name="write-change-category">
374 <xsl:with-param name="change" select="."/>
375 <xsl:with-param name="category" select="$taxonomy-root"/>
376 </xsl:call-template>
377 </xsl:for-each>
378 </xsl:template>
380 <!--
381 - Determine whether a category tree is valid (no undefineds) for all
382 - changes. Returns a tree fragment including the string 'fail'
383 - upon failure.
386 <xsl:template name="categories-valid">
387 <xsl:param name="changes"/>
388 <xsl:param name="fragment"/>
389 <xsl:for-each select="$changes">
390 <xsl:variable name="category">
391 <xsl:call-template name="get-change-category">
392 <xsl:with-param name="change" select="."/>
393 <xsl:with-param name="fragment" select="$fragment"/>
394 </xsl:call-template>
395 </xsl:variable>
397 <xsl:if test="$category = ''">
398 <xsl:text>fail: </xsl:text>
399 <apply-templates select="."/>
400 </xsl:if>
401 </xsl:for-each>
402 </xsl:template>
404 <!--
405 - make a map unique
407 <xsl:template name="make-map-unique">
408 <xsl:param name="map"/>
409 <xsl:param name="map-prefix"/>
411 <xsl:choose>
412 <xsl:when test="$map = ''">
413 </xsl:when>
414 <xsl:when test="contains($map-prefix, substring-before($map, ':'))">
415 <xsl:call-template name="make-map-unique">
416 <xsl:with-param name="map" select="substring-after($map, ' ')"/>
417 <xsl:with-param name="map-prefix" select="$map-prefix"/>
418 </xsl:call-template>
419 </xsl:when>
420 <xsl:otherwise>
421 <xsl:value-of select="substring-before($map, ' ')"/>
422 <xsl:text> </xsl:text>
423 <xsl:call-template name="make-map-unique">
424 <xsl:with-param name="map" select="substring-after($map, ' ')"/>
425 <xsl:with-param name="map-prefix" select="concat($map-prefix, substring-before($map, ' '))"/>
426 </xsl:call-template>
427 </xsl:otherwise>
428 </xsl:choose>
429 </xsl:template>
431 <!--
432 - Attempt to map all changes to sublevels
435 <xsl:template name="map-changes-to-sublevels">
436 <xsl:param name="taxonomy"/>
437 <xsl:param name="changes"/>
439 <xsl:variable name="non-unique-map">
440 <xsl:for-each select="$taxonomy">
441 <xsl:sort select="@match-priority" order="descending"/>
443 <xsl:variable name="category" select="."/>
445 <xsl:variable name="keywords" select=".//keyword"/>
447 <xsl:for-each select="$changes">
449 <xsl:variable name="change" select="."/>
451 <xsl:choose>
452 <xsl:when test="name($category) = name(.)">
453 <xsl:call-template name="write-change-category">
454 <xsl:with-param name="change" select="."/>
455 <xsl:with-param name="category" select="$category"/>
456 </xsl:call-template>
457 </xsl:when>
458 <xsl:when test="count(key('word-map', $keywords/child::text()))
459 = count(key('word-map', $keywords/child::text())|.)">
460 <xsl:call-template name="write-change-category">
461 <xsl:with-param name="change" select="."/>
462 <xsl:with-param name="category" select="$category"/>
463 </xsl:call-template>
464 </xsl:when>
465 </xsl:choose>
466 </xsl:for-each>
467 </xsl:for-each>
468 </xsl:variable>
470 <xsl:call-template name="make-map-unique">
471 <xsl:with-param name="map" select="$non-unique-map"/>
472 </xsl:call-template>
473 </xsl:template>
475 <!--
476 - Write changes
479 <xsl:template name="write-changes">
480 <xsl:param name="taxonomy"/>
481 <xsl:param name="changes"/>
483 <!--
484 - Attempt to map changes to sublevels
487 <xsl:variable name="map">
488 <xsl:call-template name="map-changes-to-sublevels">
489 <xsl:with-param name="taxonomy" select="$taxonomy"/>
490 <xsl:with-param name="changes" select="$changes"/>
491 </xsl:call-template>
492 </xsl:variable>
494 <xsl:variable name="map-failures">
495 <xsl:call-template name="categories-valid">
496 <xsl:with-param name="changes" select="$changes"/>
497 <xsl:with-param name="fragment" select="$map"/>
498 </xsl:call-template>
499 </xsl:variable>
501 <xsl:choose>
502 <xsl:when test="contains($map-failures, 'fail')">
504 <!--
505 - In case of failure, insert all nodes at the current level.
508 <itemizedlist>
509 <xsl:apply-templates select="$changes"/>
510 </itemizedlist>
512 </xsl:when>
513 <xsl:otherwise>
515 <!--
516 - In case of success, insert all nodes within sublevels.
519 <xsl:for-each select="$taxonomy">
520 <xsl:variable name="category" select="."/>
521 <xsl:if test="contains($map, concat(generate-id($category), ' '))">
522 <section tocexclude="1">
523 <xsl:call-template name="write_title">
524 <xsl:with-param name="title">
525 <xsl:choose>
526 <xsl:when test="@t != ''">
527 <xsl:value-of select="@t"/>
528 </xsl:when>
529 <xsl:otherwise>
530 <xsl:value-of select="translate(name($category), '-', ' ')"/>
531 </xsl:otherwise>
532 </xsl:choose>
533 </xsl:with-param>
534 </xsl:call-template>
535 <xsl:call-template name="write-changes">
536 <xsl:with-param name="taxonomy" select="$category/*"/>
537 <xsl:with-param name="changes" select="$changes[name(.) = name($category)]/*|$changes[not(name(.) = name($category))][contains($map, concat(generate-id(.), ':', generate-id($category), ' '))]"/>
538 </xsl:call-template>
539 </section>
540 </xsl:if>
541 </xsl:for-each>
543 </xsl:otherwise>
545 </xsl:choose>
547 </xsl:template>
549 <!--
550 - News entries.
553 <xsl:template match="fm">
554 <para>
555 <xsl:choose>
556 <xsl:when test="@nh">
557 <xsl:apply-templates/><xsl:text> (Freshmeat announcement via Neohapsis)</xsl:text>
558 </xsl:when>
559 <xsl:otherwise>
560 <xsl:apply-templates/><xsl:text> (Freshmeat announcement)</xsl:text>
561 </xsl:otherwise>
562 </xsl:choose>
563 </para>
564 </xsl:template>
566 <xsl:template match="sum">
567 <section tocexclude="1"><title>Program summary</title>
568 <xsl:if test="@revised">
569 <para>This release includes a revised summary:</para>
570 <!-- This release is accompanied by a revised summary: -->
571 </xsl:if>
572 <para>
573 <xsl:apply-templates/>
574 </para>
575 </section>
576 </xsl:template>
578 <xsl:template match="ed-note">
579 <xsl:apply-templates/>
580 </xsl:template>
582 <xsl:template match="notes">
583 <section tocexclude="1"><title>Notes</title>
584 <para>
585 <xsl:apply-templates/>
586 </para>
587 </section>
588 </xsl:template>
590 <xsl:template match="ch">
591 <section tocexclude="1"><title>Changelog summary</title>
592 <xsl:apply-templates/>
593 </section>
594 </xsl:template>
596 <xsl:template match="ml">
597 <section tocexclude="1"><title>Mailing list announcement</title>
598 <xsl:apply-templates/>
599 </section>
600 </xsl:template>
602 <!--
603 - Releases
606 <xsl:template match="release" name="release-news" mode="news">
607 <xsl:param name="label" select="1"/>
608 <section label="{$label}" tocexclude="1">
609 <!-- <section label="{@version}"> -->
610 <xsl:choose>
611 <xsl:when test="@date">
612 <title>
613 <xsl:text>Version </xsl:text>
614 <xsl:value-of select="@version"/>
615 <xsl:text>, </xsl:text>
616 <xsl:value-of select="@date"/>
617 </title>
618 </xsl:when>
619 <xsl:otherwise>
620 <title>
621 <xsl:text>Version </xsl:text>
622 <xsl:value-of select="@version"/>
623 </title>
624 </xsl:otherwise>
625 </xsl:choose>
627 <!--
628 - Notes
631 <xsl:apply-templates select=".//note"/>
633 <!--
634 - Write subsections.
637 <xsl:apply-templates/>
639 </section>
640 </xsl:template>
642 <xsl:template match="release" name="release-changelog" mode="changelog">
643 <xsl:param name="label" select="1"/>
644 <section label="{$label}" tocexclude="1">
645 <!-- <section label="{@version}"> -->
646 <xsl:choose>
647 <xsl:when test="@date">
648 <title>
649 <xsl:text>Version </xsl:text>
650 <xsl:value-of select="@version"/>
651 <xsl:text>, </xsl:text>
652 <xsl:value-of select="@date"/>
653 </title>
654 </xsl:when>
655 <xsl:otherwise>
656 <title>
657 <xsl:text>Version </xsl:text>
658 <xsl:value-of select="@version"/>
659 </title>
660 </xsl:otherwise>
661 </xsl:choose>
663 <!--
664 - Notes
667 <xsl:apply-templates select=".//note"/>
669 <!--
670 - Write changes according to the change taxonomy
673 <xsl:call-template name="write-changes">
674 <xsl:with-param name="taxonomy" select="$taxonomy-root/taxonomy/*"/>
675 <xsl:with-param name="changes" select="./*[name() != 'edit']"/>
676 </xsl:call-template>
677 </section>
678 </xsl:template>
680 <xsl:template match="news">
681 <xsl:for-each select="release">
682 <xsl:call-template name="release-news">
683 <xsl:with-param name="label" select="count(../release) - position()"/>
684 </xsl:call-template>
685 </xsl:for-each>
686 </xsl:template>
688 <xsl:template match="changelog">
689 <xsl:for-each select="release">
690 <xsl:call-template name="release-changelog" mode="changelog">
691 <xsl:with-param name="label" select="count(../release) - position()"/>
692 </xsl:call-template>
693 </xsl:for-each>
694 </xsl:template>
696 <!--
697 - Inline product information
700 <xsl:template match="winpack">
701 <xsl:value-of select="$windows-binary-package-name"/>
702 </xsl:template>
704 <xsl:template match="ver">
705 <xsl:value-of select="$product-version"/>
706 </xsl:template>
708 <xsl:template match="sourcepack">
709 <xsl:value-of select="$source-package-name"/>
710 </xsl:template>
712 <xsl:template match="sourcepacktargz">
713 <xsl:value-of select="$source-package-name-tar-gz"/>
714 </xsl:template>
716 <xsl:template match="winurl">
717 <xsl:choose>
718 <xsl:when test="contains($product-version, 'pre')">
719 <note>
720 Windows binaries are not available for this prerelease version.
721 </note>
722 </xsl:when>
723 <xsl:otherwise>
724 <ulink url="{$windows-binary-URL}"/>
725 </xsl:otherwise>
726 </xsl:choose>
727 </xsl:template>
729 <xsl:template match="sourceurl">
730 <ulink url="{$source-URL}"/>
731 </xsl:template>
733 <xsl:template match="mailinglist">
734 <xsl:value-of select="$mailing-list-address"/>
735 </xsl:template>
737 <!--
738 - Abbreviations for DocBook elements.
741 <xsl:template match="p">
742 <para>
743 <xsl:apply-templates/>
744 </para>
745 </xsl:template>
747 <xsl:template match="ul">
748 <itemizedlist>
749 <xsl:apply-templates/>
750 </itemizedlist>
751 </xsl:template>
753 <xsl:template match="li">
754 <listitem>
755 <xsl:apply-templates/>
756 </listitem>
757 </xsl:template>
759 <xsl:template match="s">
760 <section>
761 <xsl:apply-templates/>
762 </section>
763 </xsl:template>
765 <xsl:template match="code">
766 <literal>
767 <xsl:apply-templates/>
768 </literal>
769 </xsl:template>
771 <xsl:template match="l">
772 <literal>
773 <xsl:apply-templates/>
774 </literal>
775 </xsl:template>
777 <xsl:template match="pre">
778 <literallayout class="monospaced">
779 <xsl:apply-templates/>
780 </literallayout>
781 </xsl:template>
783 <xsl:template match="ll">
784 <literallayout class="monospaced">
785 <xsl:apply-templates/>
786 </literallayout>
787 </xsl:template>
789 <xsl:template match="ui">
790 <userinput>
791 <xsl:apply-templates/>
792 </userinput>
793 </xsl:template>
795 <xsl:template match="meta">
796 <emphasis>
797 <xsl:apply-templates/>
798 </emphasis>
799 </xsl:template>
801 <xsl:template match="i">
802 <emphasis>
803 <xsl:apply-templates/>
804 </emphasis>
805 </xsl:template>
807 <xsl:template match="sup">
808 <superscript>
809 <xsl:apply-templates/>
810 </superscript>
811 </xsl:template>
813 <xsl:template match="sub">
814 <subscript>
815 <xsl:apply-templates/>
816 </subscript>
817 </xsl:template>
820 </xsl:stylesheet>