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'"/>
116 <xsl:param name=
"product-version" select=
"'0.8.5-prerelease'"/>
119 - License information
122 <xsl:template match=
"*|/" mode=
"license-terms">
124 This
<xsl:apply-templates select=
"." mode=
"document-type"/> is free
125 documentation; you can redistribute it and/or modify it under the
126 terms of the GNU General Public License as published by the Free
127 Software Foundation; either version
2 of the License, or (at your
128 option) any later version.
132 <xsl:template match=
"*|/" mode=
"license-object">
134 Unless otherwise defined within the GNU General Public License, any
135 references to
"object code" within the license are to be interpreted
136 to refer to any non-source version of this
<xsl:apply-templates
137 select=
"." mode=
"document-type"/> (or of any work based on this
138 <xsl:apply-templates select=
"." mode=
"document-type"/>).
142 <xsl:template match=
"*|/" mode=
"license-warranty">
144 This
<xsl:apply-templates select=
"." mode=
"document-type"/> is
145 distributed in the hope that it will be useful, but WITHOUT ANY
146 WARRANTY; without even the implied warranty of MERCHANTABILITY or
147 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
152 <xsl:template match=
"*|/" mode=
"license-availability">
154 You should have received a copy of the GNU General Public License
155 along with this
<xsl:apply-templates select=
"."
156 mode=
"document-type"/>; if not, write to the Free Software
157 Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA
162 <xsl:template match=
"*|/" mode=
"license">
164 <xsl:apply-templates select=
"." mode=
"license-terms"/>
165 <xsl:apply-templates select=
"." mode=
"license-warranty"/>
166 <xsl:apply-templates select=
"." mode=
"license-availability"/>
167 <xsl:apply-templates select=
"." mode=
"license-object"/>
172 - Editing information
175 <xsl:key name=
"editors" match=
"edit" use=
"&editor;"/>
176 <xsl:key name=
"editor-years" match=
"edit" use=
"&editor-year;"/>
179 - If no other template matches, we copy the tree structure unchanged.
182 <xsl:template match=
"@*|node()">
184 <xsl:apply-templates select=
"@*|node()"/>
189 - Do not pass edit tags to DocBook, as it doesn't understand them.
192 <xsl:template match=
"edit"/>
195 - Capitalize the initial letter of titles.
198 <xsl:template name=
"write_title">
199 <xsl:param name=
"product-name"/>
200 <xsl:param name=
"product-version"/>
201 <xsl:param name=
"title" select=
"."/>
203 <xsl:variable name=
"space-stripped-title" select=
"normalize-space($title)"/>
204 <xsl:variable name=
"initial" select=
"substring($space-stripped-title, 1, 1)"/>
205 <xsl:variable name=
"sequel" select=
"substring($space-stripped-title, 2)"/>
209 <xsl:copy-of select=
"$product-name"/>
210 <xsl:text> </xsl:text>
211 <xsl:copy-of select=
"$product-version"/>
212 <xsl:text> </xsl:text>
213 <xsl:copy-of select=
"concat(translate($initial, &lowercase;, &uppercase;), $sequel)"/>
218 <xsl:template match=
"text()" mode=
"title">
219 <xsl:call-template name=
"write_title">
220 <xsl:with-param name=
"title" select=
"."/>
225 - Titles other than article, book and set titles.
228 <xsl:template match=
"title|t">
229 <xsl:apply-templates select=
"text()" mode=
"title"/>
233 - Add package information to titles of articles, books and sets.
236 <xsl:template match=
"setinfo/title|bookinfo/title|articleinfo/title|setinfo/t|bookinfo/t|articleinfo/t">
237 <xsl:call-template name=
"write_title">
238 <xsl:with-param name=
"product-name" select=
"$product-name"/>
239 <xsl:with-param name=
"product-version" select=
"$product-version"/>
240 <xsl:with-param name=
"title" select=
"text()"/>
245 - Generate title, author, copyright, and license information for
246 - articles, books and sets.
249 <xsl:template match=
"setinfo" mode=
"document-type">
250 <xsl:text>set
</xsl:text>
253 <xsl:template match=
"bookinfo" mode=
"document-type">
254 <xsl:text>book
</xsl:text>
257 <xsl:template match=
"articleinfo" mode=
"document-type">
258 <xsl:text>article
</xsl:text>
261 <xsl:template match=
"setinfo|bookinfo|articleinfo">
263 <xsl:param name=
"objectroot" select=
".."/>
264 <xsl:param name=
"editors-unique" select=
"$objectroot//edit[count(.|key('editors', &editor;)[&scope;][1]) = 1]"/>
265 <xsl:param name=
"editor-years-unique" select=
"$objectroot//edit[count(.|key('editor-years', &editor-year;)[&scope;][1]) = 1]"/>
268 - Generate the title, if available.
271 <xsl:apply-templates select=
"title|t"/>
274 - Preserve abstracts.
277 <xsl:apply-templates select=
"abstract"/>
280 - Add author information.
283 <xsl:for-each select=
"$editors-unique">
284 <xsl:sort select=
"&editor-sort-order;"/>
287 <xsl:value-of select=
"&editor-firstname;"/>
290 <xsl:value-of select=
"&editor-surname;"/>
296 - Add copyright information
299 <xsl:for-each select=
"$editors-unique">
300 <xsl:sort select=
"&editor-sort-order;"/>
301 <xsl:param name=
"this-editor" select=
"&editor;"/>
304 <xsl:value-of select=
"&editor;"/>
306 <xsl:for-each select=
"$editor-years-unique">
307 <xsl:sort select=
"&year-sort-order;"/>
308 <xsl:if test=
"&editor; = $this-editor">
310 <xsl:value-of select=
"&year;"/>
319 - Add a license notice
322 <xsl:apply-templates select=
"." mode=
"license"/>
335 <xsl:template match=
"entry">
337 <xsl:apply-templates select=
"text/text()"/>
345 <xsl:key name=
"word-map" match=
"entry" use=
"word/child::text()"/>
351 <xsl:variable name=
"taxonomy-root" select=
"document('taxonomy.xmli')"/>
354 - Write a fragment substring for a (change, category) pair.
357 <xsl:template name=
"write-change-category">
358 <xsl:param name=
"change"/>
359 <xsl:param name=
"category"/>
360 <xsl:value-of select=
"concat(generate-id($change), ':', generate-id($category), ' ')"/>
364 - Get a change category from a fragment result
367 <xsl:template name=
"get-change-category">
368 <xsl:param name=
"change"/>
369 <xsl:param name=
"fragment"/>
370 <xsl:value-of select=
"substring-before(substring-after(substring-after($fragment, generate-id($change)), ':'), ' ')"/>
374 - Get a tree fragment with categories set to zero.
377 <xsl:template name=
"get-zero-categories">
378 <xsl:param name=
"changes"/>
379 <xsl:for-each select=
"$changes">
380 <xsl:call-template name=
"write-change-category">
381 <xsl:with-param name=
"change" select=
"."/>
382 <xsl:with-param name=
"category" select=
"$taxonomy-root"/>
388 - Determine whether a category tree is valid (no undefineds) for all
389 - changes. Returns a tree fragment including the string 'fail'
393 <xsl:template name=
"categories-valid">
394 <xsl:param name=
"changes"/>
395 <xsl:param name=
"fragment"/>
396 <xsl:for-each select=
"$changes">
397 <xsl:variable name=
"category">
398 <xsl:call-template name=
"get-change-category">
399 <xsl:with-param name=
"change" select=
"."/>
400 <xsl:with-param name=
"fragment" select=
"$fragment"/>
404 <xsl:if test=
"$category = ''">
405 <xsl:text>fail:
</xsl:text>
406 <apply-templates select=
"."/>
414 <xsl:template name=
"make-map-unique">
415 <xsl:param name=
"map"/>
416 <xsl:param name=
"map-prefix"/>
419 <xsl:when test=
"$map = ''">
421 <xsl:when test=
"contains($map-prefix, substring-before($map, ':'))">
422 <xsl:call-template name=
"make-map-unique">
423 <xsl:with-param name=
"map" select=
"substring-after($map, ' ')"/>
424 <xsl:with-param name=
"map-prefix" select=
"$map-prefix"/>
428 <xsl:value-of select=
"substring-before($map, ' ')"/>
429 <xsl:text> </xsl:text>
430 <xsl:call-template name=
"make-map-unique">
431 <xsl:with-param name=
"map" select=
"substring-after($map, ' ')"/>
432 <xsl:with-param name=
"map-prefix" select=
"concat($map-prefix, substring-before($map, ' '))"/>
439 - Attempt to map all changes to sublevels
442 <xsl:template name=
"map-changes-to-sublevels">
443 <xsl:param name=
"taxonomy"/>
444 <xsl:param name=
"changes"/>
446 <xsl:variable name=
"non-unique-map">
447 <xsl:for-each select=
"$taxonomy">
448 <xsl:sort select=
"@match-priority" order=
"descending"/>
450 <xsl:variable name=
"category" select=
"."/>
452 <xsl:variable name=
"keywords" select=
".//keyword"/>
454 <xsl:for-each select=
"$changes">
456 <xsl:variable name=
"change" select=
"."/>
459 <xsl:when test=
"name($category) = name(.)">
460 <xsl:call-template name=
"write-change-category">
461 <xsl:with-param name=
"change" select=
"."/>
462 <xsl:with-param name=
"category" select=
"$category"/>
465 <xsl:when test=
"count(key('word-map', $keywords/child::text()))
466 = count(key('word-map', $keywords/child::text())|.)">
467 <xsl:call-template name=
"write-change-category">
468 <xsl:with-param name=
"change" select=
"."/>
469 <xsl:with-param name=
"category" select=
"$category"/>
477 <xsl:call-template name=
"make-map-unique">
478 <xsl:with-param name=
"map" select=
"$non-unique-map"/>
486 <xsl:template name=
"write-changes">
487 <xsl:param name=
"taxonomy"/>
488 <xsl:param name=
"changes"/>
491 - Attempt to map changes to sublevels
494 <xsl:variable name=
"map">
495 <xsl:call-template name=
"map-changes-to-sublevels">
496 <xsl:with-param name=
"taxonomy" select=
"$taxonomy"/>
497 <xsl:with-param name=
"changes" select=
"$changes"/>
501 <xsl:variable name=
"map-failures">
502 <xsl:call-template name=
"categories-valid">
503 <xsl:with-param name=
"changes" select=
"$changes"/>
504 <xsl:with-param name=
"fragment" select=
"$map"/>
509 <xsl:when test=
"contains($map-failures, 'fail')">
512 - In case of failure, insert all nodes at the current level.
516 <xsl:apply-templates select=
"$changes"/>
523 - In case of success, insert all nodes within sublevels.
526 <xsl:for-each select=
"$taxonomy">
527 <xsl:variable name=
"category" select=
"."/>
528 <xsl:if test=
"contains($map, concat(generate-id($category), ' '))">
529 <section tocexclude=
"1">
530 <xsl:call-template name=
"write_title">
531 <xsl:with-param name=
"title">
533 <xsl:when test=
"@t != ''">
534 <xsl:value-of select=
"@t"/>
537 <xsl:value-of select=
"translate(name($category), '-', ' ')"/>
542 <xsl:call-template name=
"write-changes">
543 <xsl:with-param name=
"taxonomy" select=
"$category/*"/>
544 <xsl:with-param name=
"changes" select=
"$changes[name(.) = name($category)]/*|$changes[not(name(.) = name($category))][contains($map, concat(generate-id(.), ':', generate-id($category), ' '))]"/>
560 <xsl:template match=
"release" name=
"release">
561 <xsl:param name=
"label" select=
"1"/>
562 <section label=
"{$label}">
563 <!-- <section label="{@version}"> -->
565 <xsl:when test=
"@date">
567 <xsl:text>Version
</xsl:text>
568 <xsl:value-of select=
"@version"/>
569 <xsl:text>,
</xsl:text>
570 <xsl:value-of select=
"@date"/>
575 <xsl:text>Version
</xsl:text>
576 <xsl:value-of select=
"@version"/>
585 <xsl:apply-templates select=
".//note"/>
588 - Write changes according to the change taxonomy
591 <xsl:call-template name=
"write-changes">
592 <xsl:with-param name=
"taxonomy" select=
"$taxonomy-root/taxonomy/*"/>
593 <xsl:with-param name=
"changes" select=
"./*[name() != 'edit']"/>
598 <xsl:template match=
"changelog">
599 <xsl:for-each select=
"release">
600 <xsl:call-template name=
"release">
601 <xsl:with-param name=
"label" select=
"count(../release) - position()"/>
607 - Abbreviations for DocBook elements.
610 <xsl:template match=
"ul">
612 <xsl:apply-templates/>
616 <xsl:template match=
"li">
618 <xsl:apply-templates/>
622 <xsl:template match=
"s">
624 <xsl:apply-templates/>