2 - Copyright 2006 David Hilvert
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 2 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
23 <!DOCTYPE xsl:stylesheet [
33 <!ENTITY uppercase
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
34 <!ENTITY lowercase
"'abcdefghijklmnopqrstuvwxyz'">
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
54 - Obtain an editor name from an edit record.
57 <!ENTITY editor 'normalize-space(@by)'
>
60 - Obtain an edit year from an edit record.
63 <!ENTITY year 'concat(@in-year, substring-before(@in-month,
"-"), substring-before(@on,
"-"))'
>
66 - Generate a string unique for each (editor, year) combination.
69 <!ENTITY editor-year 'concat(
&editor;,
&year;)'
>
72 - Boolean test to determine whether the current node is within the scope of
76 <!ENTITY scope 'count(ancestor::node()|$objectroot) = count(ancestor::node())'
>
82 <!ENTITY editor-firstname 'substring-before(
&editor;,
" ")'
>
88 <!ENTITY editor-surname 'substring-after(
&editor;,
" ")'
>
91 - Sort order for outputs including editor names.
94 <!ENTITY editor-sort-order '&editor-surname;'
>
97 - Sort order for years
100 <!ENTITY year-sort-order '
&year;'
>
104 <xsl:stylesheet id=
"style1"
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">
111 - Product information
114 <xsl:param name=
"product-name" select=
"'ALE'"/>
115 <xsl:param name=
"product-version" select=
"'0.8.5-pre1'"/>
116 <xsl:param name=
"site-URL" select=
"
117 concat('http://auricle.dyndns.org/', $product-name, '/')"/>
118 <xsl:param name=
"download-URL" select=
"concat($site-URL, 'download/')"/>
119 <xsl:param name=
"windows-binary-package-name" select=
"
120 concat(translate($product-name, &uppercase;, &lowercase;), '-',
121 translate($product-version, '.', '_'), '-win32.zip')"/>
122 <xsl:param name=
"source-package-name" select=
"
123 concat(translate($product-name, &uppercase;, &lowercase;), '-', $product-version)"/>
124 <xsl:param name=
"source-package-name-tar-gz" select=
"
125 concat($source-package-name, '.tar.gz')"/>
126 <xsl:param name=
"windows-binary-URL" select=
"concat($download-URL, $windows-binary-package-name)"/>
127 <xsl:param name=
"source-URL" select=
"concat($download-URL, $source-package-name-tar-gz)"/>
128 <xsl:param name=
"mailing-list-address" select=
"'ale@ventricle.dyndns.org'"/>
131 - License information
134 <xsl:template match=
"*|/" mode=
"license-terms">
136 This
<xsl:apply-templates select=
"." mode=
"document-type"/> is free
137 documentation; you can redistribute it and/or modify it under the
138 terms of the GNU General Public License as published by the Free
139 Software Foundation; either version
2 of the License, or (at your
140 option) any later version.
144 <xsl:template match=
"*|/" mode=
"license-object">
146 Unless explicitly defined within the applicable version of the GNU
147 General Public License, any references to
"object code" within the
148 license shall refer to any non-source version of this
149 <xsl:apply-templates select=
"." mode=
"document-type"/> (or of any
150 work based on this
<xsl:apply-templates select=
"."
151 mode=
"document-type"/>).
155 <xsl:template match=
"*|/" mode=
"license-warranty">
157 This
<xsl:apply-templates select=
"." mode=
"document-type"/> is
158 distributed in the hope that it will be useful, but WITHOUT ANY
159 WARRANTY; without even the implied warranty of MERCHANTABILITY or
160 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
165 <xsl:template match=
"*|/" mode=
"license-availability">
167 You should have received a copy of the GNU General Public License
168 along with this
<xsl:apply-templates select=
"."
169 mode=
"document-type"/>; if not, write to the Free Software
170 Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA
175 <xsl:template match=
"*|/" mode=
"license">
177 <xsl:apply-templates select=
"." mode=
"license-terms"/>
178 <xsl:apply-templates select=
"." mode=
"license-warranty"/>
179 <xsl:apply-templates select=
"." mode=
"license-availability"/>
180 <xsl:apply-templates select=
"." mode=
"license-object"/>
185 - Editing information
188 <xsl:key name=
"editors" match=
"edit" use=
"&editor;"/>
189 <xsl:key name=
"editor-years" match=
"edit" use=
"&editor-year;"/>
192 - If no other template matches, we copy the tree structure unchanged.
195 <xsl:template match=
"@*|node()">
197 <xsl:apply-templates select=
"@*|node()"/>
202 - Do not pass edit tags to DocBook, as it doesn't understand them.
205 <xsl:template match=
"edit"/>
208 - Capitalize the initial letter of titles.
211 <xsl:template name=
"write_title">
212 <xsl:param name=
"product-name"/>
213 <xsl:param name=
"product-version"/>
214 <xsl:param name=
"title" select=
"."/>
216 <xsl:variable name=
"space-stripped-title" select=
"normalize-space($title)"/>
217 <xsl:variable name=
"initial" select=
"substring($space-stripped-title, 1, 1)"/>
218 <xsl:variable name=
"sequel" select=
"substring($space-stripped-title, 2)"/>
222 <xsl:copy-of select=
"$product-name"/>
223 <xsl:text> </xsl:text>
224 <xsl:copy-of select=
"$product-version"/>
225 <xsl:text> </xsl:text>
226 <xsl:copy-of select=
"concat(translate($initial, &lowercase;, &uppercase;), $sequel)"/>
231 <xsl:template match=
"text()" mode=
"title">
232 <xsl:call-template name=
"write_title">
233 <xsl:with-param name=
"title" select=
"."/>
238 - Titles other than article, book and set titles.
241 <xsl:template match=
"title|t">
242 <xsl:apply-templates select=
"text()" mode=
"title"/>
246 - Add package information to titles of articles, books and sets.
249 <xsl:template match=
"setinfo/title|bookinfo/title|articleinfo/title|setinfo/t|bookinfo/t|articleinfo/t">
250 <xsl:call-template name=
"write_title">
251 <xsl:with-param name=
"product-name" select=
"$product-name"/>
252 <xsl:with-param name=
"product-version" select=
"$product-version"/>
253 <xsl:with-param name=
"title" select=
"text()"/>
258 - Generate title, author, copyright, and license information for
259 - articles, books and sets.
262 <xsl:template match=
"setinfo" mode=
"document-type">
263 <xsl:text>set
</xsl:text>
266 <xsl:template match=
"bookinfo" mode=
"document-type">
267 <xsl:text>book
</xsl:text>
270 <xsl:template match=
"articleinfo" mode=
"document-type">
271 <xsl:text>article
</xsl:text>
274 <xsl:template match=
"setinfo|bookinfo|articleinfo">
276 <xsl:param name=
"objectroot" select=
".."/>
277 <xsl:param name=
"editors-unique" select=
"$objectroot//edit[count(.|key('editors', &editor;)[&scope;][1]) = 1]"/>
278 <xsl:param name=
"editor-years-unique" select=
"$objectroot//edit[count(.|key('editor-years', &editor-year;)[&scope;][1]) = 1]"/>
281 - Generate the title, if available.
284 <xsl:apply-templates select=
"title|t"/>
287 - Preserve abstracts.
290 <xsl:apply-templates select=
"abstract"/>
293 - Add author information.
296 <xsl:for-each select=
"$editors-unique">
297 <xsl:sort select=
"&editor-sort-order;"/>
300 <xsl:value-of select=
"&editor-firstname;"/>
303 <xsl:value-of select=
"&editor-surname;"/>
309 - Add copyright information
312 <xsl:for-each select=
"$editors-unique">
313 <xsl:sort select=
"&editor-sort-order;"/>
314 <xsl:param name=
"this-editor" select=
"&editor;"/>
317 <xsl:value-of select=
"&editor;"/>
319 <xsl:for-each select=
"$editor-years-unique">
320 <xsl:sort select=
"&year-sort-order;"/>
321 <xsl:if test=
"&editor; = $this-editor">
323 <xsl:value-of select=
"&year;"/>
332 - Add a license notice
335 <xsl:apply-templates select=
"." mode=
"license"/>
341 - Changelogs and news files.
348 <xsl:template match=
"entry">
350 <xsl:apply-templates select=
"text/text()"/>
358 <xsl:key name=
"word-map" match=
"entry" use=
"word/child::text()"/>
364 <xsl:variable name=
"taxonomy-root" select=
"document('taxonomy.xmli')"/>
367 - Write a fragment substring for a (change, category) pair.
370 <xsl:template name=
"write-change-category">
371 <xsl:param name=
"change"/>
372 <xsl:param name=
"category"/>
373 <xsl:value-of select=
"concat(generate-id($change), ':', generate-id($category), ' ')"/>
377 - Get a change category from a fragment result
380 <xsl:template name=
"get-change-category">
381 <xsl:param name=
"change"/>
382 <xsl:param name=
"fragment"/>
383 <xsl:value-of select=
"substring-before(substring-after(substring-after($fragment, generate-id($change)), ':'), ' ')"/>
387 - Get a tree fragment with categories set to zero.
390 <xsl:template name=
"get-zero-categories">
391 <xsl:param name=
"changes"/>
392 <xsl:for-each select=
"$changes">
393 <xsl:call-template name=
"write-change-category">
394 <xsl:with-param name=
"change" select=
"."/>
395 <xsl:with-param name=
"category" select=
"$taxonomy-root"/>
401 - Determine whether a category tree is valid (no undefineds) for all
402 - changes. Returns a tree fragment including the string 'fail'
406 <xsl:template name=
"categories-valid">
407 <xsl:param name=
"changes"/>
408 <xsl:param name=
"fragment"/>
409 <xsl:for-each select=
"$changes">
410 <xsl:variable name=
"category">
411 <xsl:call-template name=
"get-change-category">
412 <xsl:with-param name=
"change" select=
"."/>
413 <xsl:with-param name=
"fragment" select=
"$fragment"/>
417 <xsl:if test=
"$category = ''">
418 <xsl:text>fail:
</xsl:text>
419 <apply-templates select=
"."/>
427 <xsl:template name=
"make-map-unique">
428 <xsl:param name=
"map"/>
429 <xsl:param name=
"map-prefix"/>
432 <xsl:when test=
"$map = ''">
434 <xsl:when test=
"contains($map-prefix, substring-before($map, ':'))">
435 <xsl:call-template name=
"make-map-unique">
436 <xsl:with-param name=
"map" select=
"substring-after($map, ' ')"/>
437 <xsl:with-param name=
"map-prefix" select=
"$map-prefix"/>
441 <xsl:value-of select=
"substring-before($map, ' ')"/>
442 <xsl:text> </xsl:text>
443 <xsl:call-template name=
"make-map-unique">
444 <xsl:with-param name=
"map" select=
"substring-after($map, ' ')"/>
445 <xsl:with-param name=
"map-prefix" select=
"concat($map-prefix, substring-before($map, ' '))"/>
452 - Attempt to map all changes to sublevels
455 <xsl:template name=
"map-changes-to-sublevels">
456 <xsl:param name=
"taxonomy"/>
457 <xsl:param name=
"changes"/>
459 <xsl:variable name=
"non-unique-map">
460 <xsl:for-each select=
"$taxonomy">
461 <xsl:sort select=
"@match-priority" order=
"descending"/>
463 <xsl:variable name=
"category" select=
"."/>
465 <xsl:variable name=
"keywords" select=
".//keyword"/>
467 <xsl:for-each select=
"$changes">
469 <xsl:variable name=
"change" select=
"."/>
472 <xsl:when test=
"name($category) = name(.)">
473 <xsl:call-template name=
"write-change-category">
474 <xsl:with-param name=
"change" select=
"."/>
475 <xsl:with-param name=
"category" select=
"$category"/>
478 <xsl:when test=
"count(key('word-map', $keywords/child::text()))
479 = count(key('word-map', $keywords/child::text())|.)">
480 <xsl:call-template name=
"write-change-category">
481 <xsl:with-param name=
"change" select=
"."/>
482 <xsl:with-param name=
"category" select=
"$category"/>
490 <xsl:call-template name=
"make-map-unique">
491 <xsl:with-param name=
"map" select=
"$non-unique-map"/>
499 <xsl:template name=
"write-changes">
500 <xsl:param name=
"taxonomy"/>
501 <xsl:param name=
"changes"/>
504 - Attempt to map changes to sublevels
507 <xsl:variable name=
"map">
508 <xsl:call-template name=
"map-changes-to-sublevels">
509 <xsl:with-param name=
"taxonomy" select=
"$taxonomy"/>
510 <xsl:with-param name=
"changes" select=
"$changes"/>
514 <xsl:variable name=
"map-failures">
515 <xsl:call-template name=
"categories-valid">
516 <xsl:with-param name=
"changes" select=
"$changes"/>
517 <xsl:with-param name=
"fragment" select=
"$map"/>
522 <xsl:when test=
"contains($map-failures, 'fail')">
525 - In case of failure, insert all nodes at the current level.
529 <xsl:apply-templates select=
"$changes"/>
536 - In case of success, insert all nodes within sublevels.
539 <xsl:for-each select=
"$taxonomy">
540 <xsl:variable name=
"category" select=
"."/>
541 <xsl:if test=
"contains($map, concat(generate-id($category), ' '))">
542 <section tocexclude=
"1">
543 <xsl:call-template name=
"write_title">
544 <xsl:with-param name=
"title">
546 <xsl:when test=
"@t != ''">
547 <xsl:value-of select=
"@t"/>
550 <xsl:value-of select=
"translate(name($category), '-', ' ')"/>
555 <xsl:call-template name=
"write-changes">
556 <xsl:with-param name=
"taxonomy" select=
"$category/*"/>
557 <xsl:with-param name=
"changes" select=
"$changes[name(.) = name($category)]/*|$changes[not(name(.) = name($category))][contains($map, concat(generate-id(.), ':', generate-id($category), ' '))]"/>
573 <xsl:template match=
"fm">
576 <xsl:when test=
"@nh">
577 <xsl:apply-templates/><xsl:text> (Freshmeat announcement via Neohapsis)
</xsl:text>
580 <xsl:apply-templates/><xsl:text> (Freshmeat announcement)
</xsl:text>
586 <xsl:template match=
"sum">
587 <section tocexclude=
"1"><title>Program summary
</title>
588 <xsl:if test=
"@revised">
589 <para>This release includes a revised summary:
</para>
590 <!-- This release is accompanied by a revised summary: -->
593 <xsl:apply-templates/>
598 <xsl:template match=
"ed-note">
599 <xsl:apply-templates/>
602 <xsl:template match=
"notes">
603 <section tocexclude=
"1"><title>Notes
</title>
605 <xsl:apply-templates/>
610 <xsl:template match=
"ch">
611 <section tocexclude=
"1"><title>Changelog summary
</title>
612 <xsl:apply-templates/>
616 <xsl:template match=
"ml">
617 <section tocexclude=
"1"><title>Mailing list announcement
</title>
618 <xsl:apply-templates/>
626 <xsl:template match=
"release" name=
"release-news" mode=
"news">
627 <xsl:param name=
"label" select=
"1"/>
628 <section label=
"{$label}" tocexclude=
"1">
629 <!-- <section label="{@version}"> -->
631 <xsl:when test=
"@date">
633 <xsl:text>Version
</xsl:text>
634 <xsl:value-of select=
"@version"/>
635 <xsl:text>,
</xsl:text>
636 <xsl:value-of select=
"@date"/>
641 <xsl:text>Version
</xsl:text>
642 <xsl:value-of select=
"@version"/>
651 <xsl:apply-templates select=
".//note"/>
657 <xsl:apply-templates/>
662 <xsl:template match=
"release" name=
"release-changelog" mode=
"changelog">
663 <xsl:param name=
"label" select=
"1"/>
664 <section label=
"{$label}" tocexclude=
"1">
665 <!-- <section label="{@version}"> -->
667 <xsl:when test=
"@date">
669 <xsl:text>Version
</xsl:text>
670 <xsl:value-of select=
"@version"/>
671 <xsl:text>,
</xsl:text>
672 <xsl:value-of select=
"@date"/>
677 <xsl:text>Version
</xsl:text>
678 <xsl:value-of select=
"@version"/>
687 <xsl:apply-templates select=
".//note"/>
690 - Write changes according to the change taxonomy
693 <xsl:call-template name=
"write-changes">
694 <xsl:with-param name=
"taxonomy" select=
"$taxonomy-root/taxonomy/*"/>
695 <xsl:with-param name=
"changes" select=
"./*[name() != 'edit']"/>
700 <xsl:template match=
"news">
701 <xsl:for-each select=
"release">
702 <xsl:call-template name=
"release-news">
703 <xsl:with-param name=
"label" select=
"count(../release) - position()"/>
708 <xsl:template match=
"changelog">
709 <xsl:for-each select=
"release">
710 <xsl:call-template name=
"release-changelog" mode=
"changelog">
711 <xsl:with-param name=
"label" select=
"count(../release) - position()"/>
717 - Inline product information
720 <xsl:template match=
"winpack">
721 <xsl:value-of select=
"$windows-binary-package-name"/>
724 <xsl:template match=
"ver">
725 <xsl:value-of select=
"$product-version"/>
728 <xsl:template match=
"sourcepack">
729 <xsl:value-of select=
"$source-package-name"/>
732 <xsl:template match=
"sourcepacktargz">
733 <xsl:value-of select=
"$source-package-name-tar-gz"/>
736 <xsl:template match=
"winurl">
737 <ulink url=
"{$windows-binary-URL}"/>
740 <xsl:template match=
"sourceurl">
741 <ulink url=
"{$source-URL}"/>
744 <xsl:template match=
"mailinglist">
745 <xsl:value-of select=
"$mailing-list-address"/>
749 - Abbreviations for DocBook elements.
752 <xsl:template match=
"p">
754 <xsl:apply-templates/>
758 <xsl:template match=
"ul">
760 <xsl:apply-templates/>
764 <xsl:template match=
"li">
766 <xsl:apply-templates/>
770 <xsl:template match=
"s">
772 <xsl:apply-templates/>
776 <xsl:template match=
"l">
778 <xsl:apply-templates/>
782 <xsl:template match=
"ll">
783 <literallayout class=
"monospaced">
784 <xsl:apply-templates/>
788 <xsl:template match=
"ui">
790 <xsl:apply-templates/>
794 <xsl:template match=
"meta">
796 <xsl:apply-templates/>