doc/: use a stylesheet to generate document meta-information, including author,
[Ale.git] / doc / ale-doc.xsl
blob82ae119466c1b3e9c6e5a98b06c55775ed82a1d1
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 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
21 -->
23 <!DOCTYPE xsl:stylesheet [
25 <!--
26 - Entities
29 - NOTE: all of the below entities operate on edit records, which
30 - are expected to conform to exactly one of the following patterns:
32 - <edit by="GIVEN-NAME SURNAME" on="2006-Sep-24">
33 - <edit by="GIVEN-NAME SURNAME" in-month="2006-Sep">
34 - <edit by="GIVEN-NAME SURNAME" in-year="2006">
36 - The first form is preferred for occasional edits; the latter two
37 - are provided as shorthand for edits occurring over a number of
38 - days in succesion, or for cases where the exact date of the edit
39 - is not known (e.g., when basing edit history on copyright notices
40 - from older files).
41 -->
44 <!--
45 - Obtain an editor name from an edit record.
46 -->
48 <!ENTITY editor 'normalize-space(@by)'>
50 <!--
51 - Obtain an edit year from an edit record.
52 -->
54 <!ENTITY year 'concat(@in-year, substring-before(@in-month, "-"), substring-before(@on, "-"))'>
56 <!--
57 - Generate a string unique for each (editor, year) combination.
58 -->
60 <!ENTITY editor-year 'concat(&editor;, &year;)'>
62 <!--
63 - Boolean test to determine whether the current node is within the scope of
64 - $objectroot.
65 -->
67 <!ENTITY scope 'count(ancestor::node()|$objectroot) = count(ancestor::node())'>
69 <!--
70 - Editor first name.
71 -->
73 <!ENTITY editor-firstname 'substring-before(&editor;, " ")'>
75 <!--
76 - Editor last name
77 -->
79 <!ENTITY editor-surname 'substring-after(&editor;, " ")'>
81 <!--
82 - Sort order for outputs including editor names.
83 -->
85 <!ENTITY editor-sort-order '&editor-surname;'>
89 <xsl:stylesheet id="style1"
90 version="1.0"
91 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
92 xmlns:fo="http://www.w3.org/1999/XSL/Format"
93 xmlns:xi="http://www.w3.org/2001/XInclude">
95 <!--
96 - Product information
97 -->
99 <xsl:param name="product-name" select="'ALE'"/>
101 <xsl:param name="product-number" select="'0.8.5-prerelease'"/>
103 <xsl:param name="copyright-info">
104 <copyright id="copyright-info">
105 <year> 2002, 2003, 2004, 2005, 2006 </year>
106 <holder> David Hilvert </holder>
107 </copyright>
108 </xsl:param>
110 <!--
111 - Editing information
114 <xsl:key name="editors" match="edit" use="&editor;"/>
115 <xsl:key name="editor-years" match="edit" use="&editor-year;"/>
117 <!--
118 - If no other template matches, we copy the tree structure unchanged.
121 <xsl:template match="@*|node()">
122 <xsl:copy>
123 <xsl:apply-templates select="@*|node()"/>
124 </xsl:copy>
125 </xsl:template>
127 <!--
128 - Do not pass edit tags to DocBook, as it doesn't understand them.
131 <xsl:template match="edit"/>
133 <!--
134 - Add package information to titles of articles, books and sets.
137 <xsl:template match="setinfo/title|bookinfo/title|articleinfo/title">
138 <title>
139 <xsl:copy-of select="$product-name"/>
140 <xsl:text> </xsl:text>
141 <xsl:copy-of select="$product-number"/>
142 <xsl:text> </xsl:text>
143 <xsl:apply-templates/>
144 </title>
145 </xsl:template>
147 <!--
148 - Generate title, author, and copyright information for articles,
149 - books and sets.
152 <xsl:template match="setinfo|bookinfo|articleinfo">
153 <xsl:copy>
154 <xsl:param name="objectroot" select=".."/>
155 <xsl:param name="editors-unique" select="$objectroot//edit[count(.|key('editors', &editor;)[&scope;][1]) = 1]"/>
156 <xsl:param name="editor-years-unique" select="$objectroot//edit[count(.|key('editor-years', &editor-year;)[&scope;][1]) = 1]"/>
158 <!--
159 - Generate the title, if available.
162 <xsl:apply-templates select="title"/>
164 <!--
165 - Preserve abstracts.
168 <xsl:apply-templates select="abstract"/>
170 <!--
171 - Add author information.
174 <xsl:for-each select="$editors-unique">
175 <xsl:sort select="&editor-sort-order;"/>
176 <author>
177 <firstname>
178 <xsl:value-of select="&editor-firstname;"/>
179 </firstname>
180 <surname>
181 <xsl:value-of select="&editor-surname;"/>
182 </surname>
183 </author>
184 </xsl:for-each>
186 <!--
187 - Add copyright information
190 <xsl:for-each select="$editors-unique">
191 <xsl:sort select="&editor-sort-order;"/>
192 <xsl:param name="this-editor" select="&editor;"/>
193 <copyright>
194 <holder>
195 <xsl:value-of select="&editor;"/>
196 </holder>
197 <xsl:for-each select="$editor-years-unique">
198 <xsl:if test="&editor; = $this-editor">
199 <year>
200 <xsl:value-of select="&year;"/>
201 </year>
202 </xsl:if>
203 </xsl:for-each>
204 </copyright>
205 </xsl:for-each>
207 </xsl:copy>
208 </xsl:template>
211 </xsl:stylesheet>