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 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
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=
"$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"/>
123 - License information
126 <xsl:template match=
"*|/" mode=
"license-terms">
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.
136 <xsl:template match=
"*|/" mode=
"license-warranty">
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
146 <xsl:template match=
"*|/" mode=
"license-availability">
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
156 <xsl:template match=
"*|/" mode=
"license">
158 <xsl:apply-templates select=
"." mode=
"license-terms"/>
159 <xsl:apply-templates select=
"." mode=
"license-warranty"/>
160 <xsl:apply-templates select=
"." mode=
"license-availability"/>
165 - Editing information
168 <xsl:key name=
"editors" match=
"edit" use=
"&editor;"/>
169 <xsl:key name=
"editor-years" match=
"edit" use=
"&editor-year;"/>
172 - If no other template matches, we copy the tree structure unchanged.
175 <xsl:template match=
"@*|node()">
177 <xsl:apply-templates select=
"@*|node()"/>
182 - Do not pass edit tags to DocBook, as it doesn't understand them.
185 <xsl:template match=
"edit"/>
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)"/>
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)"/>
211 <xsl:template match=
"text()" mode=
"title">
212 <xsl:call-template name=
"write_title">
213 <xsl:with-param name=
"title" select=
"."/>
218 - Titles other than article, book and set titles.
221 <xsl:template match=
"title|t">
222 <xsl:apply-templates select=
"text()" mode=
"title"/>
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()"/>
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>
246 <xsl:template match=
"bookinfo" mode=
"document-type">
247 <xsl:text>book
</xsl:text>
250 <xsl:template match=
"articleinfo" mode=
"document-type">
251 <xsl:text>article
</xsl:text>
254 <xsl:template match=
"setinfo|bookinfo|articleinfo">
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]"/>
261 - Generate the title, if available.
264 <xsl:apply-templates select=
"title|t"/>
267 - Preserve abstracts.
270 <xsl:apply-templates select=
"abstract"/>
273 - Add author information.
276 <xsl:for-each select=
"$editors-unique">
277 <xsl:sort select=
"&editor-sort-order;"/>
280 <xsl:value-of select=
"&editor-firstname;"/>
283 <xsl:value-of select=
"&editor-surname;"/>
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;"/>
297 <xsl:value-of select=
"&editor;"/>
299 <xsl:for-each select=
"$editor-years-unique">
300 <xsl:sort select=
"&year-sort-order;"/>
301 <xsl:if test=
"&editor; = $this-editor">
303 <xsl:value-of select=
"&year;"/>
312 - Add a license notice
315 <xsl:apply-templates select=
"." mode=
"license"/>
321 - Changelogs and news files.
328 <xsl:template match=
"entry">
330 <xsl:apply-templates select=
"text/text()"/>
338 <xsl:key name=
"word-map" match=
"entry" use=
"word/child::text()"/>
344 <xsl:variable name=
"taxonomy-root" select=
"document('taxonomy.xmli')"/>
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), ' ')"/>
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)), ':'), ' ')"/>
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"/>
381 - Determine whether a category tree is valid (no undefineds) for all
382 - changes. Returns a tree fragment including the string 'fail'
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"/>
397 <xsl:if test=
"$category = ''">
398 <xsl:text>fail:
</xsl:text>
399 <apply-templates select=
"."/>
407 <xsl:template name=
"make-map-unique">
408 <xsl:param name=
"map"/>
409 <xsl:param name=
"map-prefix"/>
412 <xsl:when test=
"$map = ''">
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"/>
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, ' '))"/>
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=
"."/>
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"/>
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"/>
470 <xsl:call-template name=
"make-map-unique">
471 <xsl:with-param name=
"map" select=
"$non-unique-map"/>
479 <xsl:template name=
"write-changes">
480 <xsl:param name=
"taxonomy"/>
481 <xsl:param name=
"changes"/>
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"/>
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"/>
502 <xsl:when test=
"contains($map-failures, 'fail')">
505 - In case of failure, insert all nodes at the current level.
509 <xsl:apply-templates select=
"$changes"/>
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">
526 <xsl:when test=
"@t != ''">
527 <xsl:value-of select=
"@t"/>
530 <xsl:value-of select=
"translate(name($category), '-', ' ')"/>
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), ' '))]"/>
553 <xsl:template match=
"fm">
556 <xsl:when test=
"@nh">
557 <xsl:apply-templates/><xsl:text> (Freshmeat announcement via Neohapsis)
</xsl:text>
560 <xsl:apply-templates/><xsl:text> (Freshmeat announcement)
</xsl:text>
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: -->
573 <xsl:apply-templates/>
578 <xsl:template match=
"ed-note">
579 <xsl:apply-templates/>
582 <xsl:template match=
"notes">
583 <section tocexclude=
"1"><title>Notes
</title>
585 <xsl:apply-templates/>
590 <xsl:template match=
"ch">
591 <section tocexclude=
"1"><title>Changelog summary
</title>
592 <xsl:apply-templates/>
596 <xsl:template match=
"ml">
597 <section tocexclude=
"1"><title>Mailing list announcement
</title>
598 <xsl:apply-templates/>
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}"> -->
611 <xsl:when test=
"@date">
613 <xsl:text>Version
</xsl:text>
614 <xsl:value-of select=
"@version"/>
615 <xsl:text>,
</xsl:text>
616 <xsl:value-of select=
"@date"/>
621 <xsl:text>Version
</xsl:text>
622 <xsl:value-of select=
"@version"/>
631 <xsl:apply-templates select=
".//note"/>
637 <xsl:apply-templates/>
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}"> -->
647 <xsl:when test=
"@date">
649 <xsl:text>Version
</xsl:text>
650 <xsl:value-of select=
"@version"/>
651 <xsl:text>,
</xsl:text>
652 <xsl:value-of select=
"@date"/>
657 <xsl:text>Version
</xsl:text>
658 <xsl:value-of select=
"@version"/>
667 <xsl:apply-templates select=
".//note"/>
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']"/>
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()"/>
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()"/>
697 - Inline product information
700 <xsl:template match=
"winpack">
701 <xsl:value-of select=
"$windows-binary-package-name"/>
704 <xsl:template match=
"ver">
705 <xsl:value-of select=
"$product-version"/>
708 <xsl:template match=
"sourcepack">
709 <xsl:value-of select=
"$source-package-name"/>
712 <xsl:template match=
"sourcepacktargz">
713 <xsl:value-of select=
"$source-package-name-tar-gz"/>
716 <xsl:template match=
"winurl">
718 <xsl:when test=
"contains($product-version, 'pre')">
720 Windows binaries are not available for this prerelease version.
724 <ulink url=
"{$windows-binary-URL}"/>
729 <xsl:template match=
"sourceurl">
730 <ulink url=
"{$source-URL}"/>
733 <xsl:template match=
"mailinglist">
734 <xsl:value-of select=
"$mailing-list-address"/>
738 - Abbreviations for DocBook elements.
741 <xsl:template match=
"p">
743 <xsl:apply-templates/>
747 <xsl:template match=
"ul">
749 <xsl:apply-templates/>
753 <xsl:template match=
"li">
755 <xsl:apply-templates/>
759 <xsl:template match=
"s">
761 <xsl:apply-templates/>
765 <xsl:template match=
"code">
767 <xsl:apply-templates/>
771 <xsl:template match=
"l">
773 <xsl:apply-templates/>
777 <xsl:template match=
"pre">
778 <literallayout class=
"monospaced">
779 <xsl:apply-templates/>
783 <xsl:template match=
"ll">
784 <literallayout class=
"monospaced">
785 <xsl:apply-templates/>
789 <xsl:template match=
"ui">
791 <xsl:apply-templates/>
795 <xsl:template match=
"meta">
797 <xsl:apply-templates/>
801 <xsl:template match=
"i">
803 <xsl:apply-templates/>
807 <xsl:template match=
"sup">
809 <xsl:apply-templates/>
813 <xsl:template match=
"sub">
815 <xsl:apply-templates/>