/[gentoo]/xml/htdocs/xsl/handbook.xsl
Gentoo

Contents of /xml/htdocs/xsl/handbook.xsl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.36 - (hide annotations) (download) (as text)
Wed Aug 29 13:22:20 2007 UTC (5 years, 8 months ago) by neysx
Branch: MAIN
Changes since 1.35: +1 -3 lines
File MIME type: application/xml
Undone previous edit

1 swift 1.1 <?xml version="1.0" encoding="UTF-8"?>
2 neysx 1.20 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
3 neysx 1.30 xmlns:dyn="http://exslt.org/dynamic"
4     xmlns:func="http://exslt.org/functions"
5     extension-element-prefixes="func dyn">
6 swift 1.1
7     <!-- Define global variables; if a user has
8     already defined those, this is a NOP -->
9 swift 1.7 <xsl:param name="part">0</xsl:param>
10 swift 1.1 <xsl:param name="chap">0</xsl:param>
11 swift 1.15 <xsl:param name="full">0</xsl:param>
12 swift 1.1
13     <!-- A book -->
14     <xsl:template match="/book">
15     <!-- If chap = 0, show an index -->
16     <xsl:choose>
17 swift 1.7 <xsl:when test="$part != 0">
18     <xsl:apply-templates select="part" />
19 swift 1.1 </xsl:when>
20     <xsl:otherwise>
21 swift 1.19 <xsl:call-template name="doclayout"/>
22 swift 1.1 </xsl:otherwise>
23     </xsl:choose>
24     </xsl:template>
25    
26 neysx 1.23 <!-- <sections>, i.e. when user tries to access a book file directly -->
27     <xsl:template match="/sections">
28 neysx 1.27 <xsl:call-template name="doclayout"/>
29 neysx 1.23 </xsl:template>
30    
31 swift 1.1 <!-- Content of /book -->
32     <xsl:template name="bookcontent">
33     <xsl:call-template name="menubar" />
34     <h1><xsl:value-of select="title" /></h1>
35     <xsl:if test="$style = 'printable'">
36     <xsl:apply-templates select="author" />
37 neysx 1.25 <br/>
38     <i><xsl:call-template name="contentdate"/></i>
39 neysx 1.29 <xsl:variable name="outdated">
40     <xsl:call-template name="outdated-translation"/>
41     </xsl:variable>
42     <xsl:if test="string-length($outdated) &gt; 1">
43     <br/><i><xsl:copy-of select="$outdated"/></i>
44     </xsl:if>
45 swift 1.1 </xsl:if>
46 neysx 1.20 <p><xsl:value-of select="func:gettext('Content')"/>:</p>
47 swift 1.1 <ul>
48 swift 1.7 <xsl:for-each select="part">
49 swift 1.14 <xsl:variable name="curpart" select="position()" />
50 swift 1.1 <li>
51 neysx 1.26 <xsl:choose>
52     <xsl:when test="$full = 0">
53     <xsl:choose>
54     <xsl:when test="$style != 'printable'">
55 neysx 1.31 <b><a href="?part={$curpart}"><xsl:value-of select="title" /></a></b>
56 neysx 1.26 </xsl:when>
57     <xsl:otherwise>
58 neysx 1.31 <b><a href="?part={$curpart}&amp;style=printable"><xsl:value-of select="title" /></a></b>
59 neysx 1.26 </xsl:otherwise>
60     </xsl:choose>
61     </xsl:when>
62     <xsl:otherwise>
63     <b><a href="#book_part{$curpart}"><xsl:value-of select="title" /></a></b>
64     </xsl:otherwise>
65     </xsl:choose>
66 swift 1.1 <xsl:if test="abstract">
67 swift 1.6 <br />
68     <xsl:value-of select="abstract" />
69 swift 1.1 </xsl:if>
70 swift 1.6 <ol>
71 swift 1.7 <xsl:for-each select="chapter">
72 swift 1.14 <xsl:variable name="curchap" select="position()" />
73 swift 1.1 <li>
74 neysx 1.26 <xsl:choose>
75     <xsl:when test="$full = 0">
76     <xsl:choose>
77     <xsl:when test="$style != 'printable'">
78 neysx 1.31 <b><a href="?part={$curpart}&amp;chap={$curchap}"><xsl:value-of select="title" /></a></b>
79 neysx 1.26 </xsl:when>
80     <xsl:otherwise>
81 neysx 1.31 <b><a href="?part={$curpart}&amp;chap={$curchap}&amp;style=printable"><xsl:value-of select="title" /></a></b>
82 neysx 1.26 </xsl:otherwise>
83     </xsl:choose>
84     </xsl:when>
85     <xsl:otherwise>
86     <b><a href="#book_part{$curpart}_chap{$curchap}"><xsl:value-of select="title" /></a></b>
87     </xsl:otherwise>
88     </xsl:choose>
89 neysx 1.33 <xsl:choose>
90     <xsl:when test="abstract">
91     <br/>
92     <xsl:value-of select="abstract" />
93     </xsl:when>
94     <xsl:otherwise>
95     <br/>
96     <xsl:value-of select="document(include/@href)/*[1]/abstract" />
97     </xsl:otherwise>
98     </xsl:choose>
99 swift 1.1 </li>
100     </xsl:for-each>
101 swift 1.6 </ol>
102 swift 1.1 </li>
103     </xsl:for-each>
104     </ul>
105     <xsl:call-template name="menubar" />
106 swift 1.15
107     <xsl:if test="$full =1">
108     <xsl:apply-templates select="part" />
109     </xsl:if>
110    
111 swift 1.5 <xsl:apply-templates select="/book/license" />
112 swift 1.1 </xsl:template>
113    
114 swift 1.7 <!-- Part inside a book -->
115     <xsl:template match="/book/part">
116 swift 1.15 <xsl:if test="(($chap != 0) and ($part = position())) or ($full = 1)">
117 neysx 1.34 <xsl:variable name="pos" select="position()"/>
118 swift 1.15 <xsl:if test="$full = 1">
119     <a name="book_part{$pos}"/>
120     <h2><xsl:number level="multiple" format="A. " value="$pos"/><xsl:value-of select="title" /></h2>
121     </xsl:if>
122     <xsl:apply-templates select="chapter">
123     <xsl:with-param name="partnum" select="$pos"/>
124     </xsl:apply-templates>
125 swift 1.1 </xsl:if>
126 swift 1.7 <xsl:if test="($chap = 0) and ($part = position())">
127 swift 1.19 <xsl:call-template name="doclayout" />
128 swift 1.1 </xsl:if>
129     </xsl:template>
130    
131 swift 1.7 <!-- Content of /book/part -->
132     <xsl:template name="bookpartcontent">
133 swift 1.1 <xsl:call-template name="menubar" />
134 swift 1.9 <xsl:if test="@id">
135     <a name="{@id}"/>
136     </xsl:if>
137 swift 1.14 <h1><xsl:number level="multiple" format="1. " value="position()"/><xsl:value-of select="title" /></h1>
138 swift 1.1 <xsl:if test="abstract">
139     <p><xsl:value-of select="abstract" /></p>
140     </xsl:if>
141 neysx 1.20 <p><xsl:value-of select="func:gettext('Content')"/>:</p>
142 swift 1.6 <ol>
143 swift 1.7 <xsl:for-each select="chapter">
144 swift 1.14 <xsl:variable name="curpos" select="position()" />
145 swift 1.1 <xsl:if test="title">
146     <li>
147 neysx 1.31 <b><a href="?part={$part}&amp;chap={$curpos}"><xsl:value-of select="title" /></a></b>
148 neysx 1.33 <xsl:choose>
149     <xsl:when test="abstract">
150     <br/>
151     <xsl:value-of select="abstract" />
152     </xsl:when>
153     <xsl:otherwise>
154     <br/>
155     <xsl:value-of select="document(include/@href)/*[1]/abstract" />
156     </xsl:otherwise>
157     </xsl:choose>
158 swift 1.1 </li>
159     </xsl:if>
160     </xsl:for-each>
161 swift 1.6 </ol>
162 swift 1.1
163     <xsl:call-template name="menubar" />
164 swift 1.5 <xsl:apply-templates select="/book/license" />
165 swift 1.1 </xsl:template>
166    
167     <!-- Menu bar -->
168     <xsl:template name="menubar">
169 swift 1.7 <xsl:variable name="prevpart" select="number($part) - 1" />
170 swift 1.1 <xsl:variable name="prevchap" select="number($chap) - 1" />
171 swift 1.7 <xsl:variable name="nextpart" select="number($part) + 1" />
172 swift 1.1 <xsl:variable name="nextchap" select="number($chap) + 1" />
173 swift 1.15 <xsl:if test="($style != 'printable') and ($full = 0)">
174 swift 1.1 <hr />
175 swift 1.11 <p>
176 swift 1.7 <!-- Previous Parts -->
177 swift 1.1 <xsl:choose>
178 swift 1.7 <xsl:when test="number($prevpart) &lt; 1">
179 swift 1.12 [ &lt;&lt; ]
180 swift 1.1 </xsl:when>
181     <xsl:otherwise>
182 neysx 1.32 [ <a href="{concat($link, '?part=', $prevpart)}">&lt;&lt;</a> ]
183 swift 1.1 </xsl:otherwise>
184     </xsl:choose>
185 swift 1.7 <!-- Previous Chapter -->
186 swift 1.1 <xsl:choose>
187 swift 1.7 <xsl:when test="number($prevchap) &lt; 1">
188 swift 1.12 [ &lt; ]
189 swift 1.1 </xsl:when>
190     <xsl:otherwise>
191 neysx 1.32 [ <a href="{concat($link, '?part=', $part, '&amp;chap=', $prevchap)}">&lt;</a> ]
192 swift 1.1 </xsl:otherwise>
193     </xsl:choose>
194     <!-- Content -->
195 neysx 1.32 [ <a href="{$link}"><xsl:value-of select="func:gettext('Home')"/></a> ]
196 swift 1.7 <!-- Next Chapter -->
197 swift 1.2 <xsl:if test="name() = 'book'">
198 neysx 1.32 [ <a href="{concat($link, '?part=1')}">&gt;</a> ]
199 swift 1.7 </xsl:if>
200     <xsl:if test="name() = 'part'">
201 neysx 1.32 [ <a href="{concat($link, '?part=', $part, '&amp;chap=1')}">&gt;</a> ]
202 swift 1.1 </xsl:if>
203 swift 1.2 <xsl:if test="name() = 'chapter'">
204 swift 1.1 <xsl:choose>
205 swift 1.11 <xsl:when test="last() = position()">
206 swift 1.12 [ &gt; ]
207 swift 1.1 </xsl:when>
208     <xsl:otherwise>
209 neysx 1.32 [ <a href="{concat($link, '?part=', $part, '&amp;chap=', $nextchap)}">&gt;</a> ]
210 swift 1.1 </xsl:otherwise>
211     </xsl:choose>
212     </xsl:if>
213 swift 1.7 <!-- Next Part -->
214 swift 1.2 <xsl:if test="name() = 'book'">
215 neysx 1.32 [ <a href="{concat($link, '?part=', $nextpart)}">&gt;&gt;</a> ]
216 swift 1.1 </xsl:if>
217 swift 1.7 <xsl:if test="name() = 'part'">
218 swift 1.1 <xsl:choose>
219 swift 1.7 <xsl:when test="number($part) = last()">
220 swift 1.12 [ &gt;&gt; ]
221 swift 1.1 </xsl:when>
222     <xsl:otherwise>
223 neysx 1.32 [ <a href="{concat($link, '?part=', $nextpart)}">&gt;&gt;</a> ]
224 swift 1.1 </xsl:otherwise>
225     </xsl:choose>
226     </xsl:if>
227 swift 1.7 <xsl:if test="name() = 'chapter'">
228 swift 1.1 <xsl:choose>
229 swift 1.7 <xsl:when test="count(/book/part) = number($part)">
230 swift 1.12 [ &gt;&gt; ]
231 swift 1.1 </xsl:when>
232     <xsl:otherwise>
233 neysx 1.32 [ <a href="{concat($link, '?part=', $nextpart)}">&gt;&gt;</a> ]
234 swift 1.1 </xsl:otherwise>
235     </xsl:choose>
236     </xsl:if>
237     </p>
238     <hr />
239     </xsl:if>
240     </xsl:template>
241    
242    
243 swift 1.7 <!-- Chapter inside a part -->
244     <xsl:template match="/book/part/chapter">
245 neysx 1.34 <xsl:param name="partnum"/>
246     <xsl:variable name="pos" select="position()"/>
247 swift 1.15 <xsl:if test="($chap = position()) and ($full = 0)">
248 neysx 1.34 <xsl:call-template name="doclayout">
249     <xsl:with-param name="partnum" select="$partnum"/>
250     <xsl:with-param name="chapnum" select="$pos"/>
251     </xsl:call-template>
252 swift 1.1 </xsl:if>
253 swift 1.15 <xsl:if test="$full = 1">
254     <xsl:call-template name="bookpartchaptercontent">
255 neysx 1.34 <xsl:with-param name="partnum" select="$partnum"/>
256     <xsl:with-param name="chapnum" select="$pos"/>
257 swift 1.15 </xsl:call-template>
258     </xsl:if>
259 swift 1.1 </xsl:template>
260    
261 swift 1.7 <!-- Content of /book/part/chapter -->
262     <xsl:template name="bookpartchaptercontent">
263 neysx 1.34 <xsl:param name="partnum"/>
264     <xsl:param name="chapnum"/>
265 swift 1.1 <xsl:call-template name="menubar" />
266 swift 1.9 <xsl:if test="@id">
267     <a name="{@id}"/>
268     </xsl:if>
269 swift 1.15 <xsl:if test="$full = 1">
270     <a name="book_part{$partnum}_chap{$chapnum}"/>
271     <h3><xsl:number level="multiple" format="1. " value="position()"/><xsl:value-of select="title" /></h3>
272     </xsl:if>
273     <xsl:if test="$full = 0">
274     <h1><xsl:number level="multiple" format="1. " value="position()"/><xsl:value-of select="title" /></h1>
275     </xsl:if>
276 swift 1.2 <xsl:variable name="doc" select="include/@href"/>
277 swift 1.4 <xsl:variable name="FILE" select="document($doc)" />
278 swift 1.15 <xsl:if test="$full = 0">
279     <!-- Chapter content only when rendering a single page -->
280     <xsl:if test="$FILE/sections/section/title">
281 neysx 1.20 <b><xsl:value-of select="func:gettext('Content')"/>: </b>
282 swift 1.15 <ul>
283 neysx 1.30 <xsl:for-each select="$FILE/sections/section[not(@test) or dyn:evaluate(@test)]/title">
284 swift 1.15 <xsl:variable name="pos" select="position()" />
285     <li><a href="#doc_chap{$pos}" class="altlink"><xsl:value-of select="." /></a></li>
286     </xsl:for-each>
287     </ul>
288     </xsl:if>
289 swift 1.1 </xsl:if>
290 swift 1.15
291     <xsl:choose>
292     <xsl:when test="$full = 1">
293 neysx 1.30 <xsl:apply-templates select="$FILE/sections/section[not(@test) or dyn:evaluate(@test)]">
294 swift 1.15 <xsl:with-param name="chapnum" select="$chapnum"/>
295     <xsl:with-param name="partnum" select="$partnum"/>
296     </xsl:apply-templates>
297     </xsl:when>
298     <xsl:otherwise>
299 neysx 1.30 <xsl:apply-templates select="$FILE/sections/section[not(@test) or dyn:evaluate(@test)]">
300 swift 1.15 <xsl:with-param name="chapnum" select="$chapnum"/>
301 neysx 1.34 <xsl:with-param name="partnum" select="$partnum"/>
302 swift 1.15 </xsl:apply-templates>
303     </xsl:otherwise>
304     </xsl:choose>
305 swift 1.1
306     <xsl:call-template name="menubar" />
307 swift 1.15
308     <xsl:if test="$full = 0">
309     <xsl:apply-templates select="/book/license" />
310     </xsl:if>
311 swift 1.1 </xsl:template>
312    
313 swift 1.7 <!-- Section inside a chapter -->
314     <xsl:template match="/sections/section">
315 neysx 1.34 <xsl:param name="chapnum"/>
316     <xsl:param name="partnum"/>
317     <xsl:param name="pos" select="position()"/>
318 swift 1.15 <xsl:choose>
319     <xsl:when test="$full = 1">
320 neysx 1.18 <!-- We need two anchors, 1 for internal links, 1 for cross-chapters links -->
321 swift 1.15 <a name="book_{generate-id(../..)}_chap{$pos}"/>
322 neysx 1.18 <a name="book_part{$partnum}_chap{$chapnum}__chap{$pos}"/>
323 swift 1.15 </xsl:when>
324     <xsl:otherwise>
325     <a name="doc_chap{$pos}"/>
326     </xsl:otherwise>
327     </xsl:choose>
328 swift 1.9 <xsl:if test="@id">
329     <a name="{@id}"/>
330     </xsl:if>
331 swift 1.1 <xsl:if test="title">
332 swift 1.15 <p class="chaphead"><span class="chapnum"><xsl:value-of select="$chapnum" />.<xsl:number level="multiple" format="a. " value="position()" /></span><xsl:value-of select="title" /></p>
333 swift 1.1 </xsl:if>
334 swift 1.15
335     <xsl:choose>
336     <xsl:when test="$full = 1">
337     <xsl:apply-templates select="body|subsection">
338     <xsl:with-param name="chpos" select="$pos"/>
339 neysx 1.18 <xsl:with-param name="chapnum" select="$chapnum"/>
340     <xsl:with-param name="partnum" select="$partnum"/>
341 swift 1.15 </xsl:apply-templates>
342     </xsl:when>
343     <xsl:otherwise>
344     <xsl:apply-templates select="body|subsection">
345     <xsl:with-param name="chpos" select="$pos"/>
346     </xsl:apply-templates>
347     </xsl:otherwise>
348     </xsl:choose>
349    
350 swift 1.1 </xsl:template>
351    
352 swift 1.7 <!-- Subsubsection inside a section -->
353     <xsl:template match="/sections/section/subsection">
354 neysx 1.34 <xsl:param name="chapnum" />
355     <xsl:param name="partnum" />
356     <xsl:param name="chpos" />
357     <xsl:variable name="pos" select="position()"/>
358 neysx 1.30 <xsl:if test="not(@test) or dyn:evaluate(@test)">
359     <xsl:choose>
360     <xsl:when test="$full = 1">
361     <!-- We need two anchors, 1 for internal links, 1 for cross-chapters links -->
362     <a name="book_{generate-id(../../..)}_chap{$chpos}_sect{$pos}"/>
363     <a name="book_part{$partnum}_chap{$chapnum}__chap{$chpos}_sect{$pos}"/>
364     </xsl:when>
365     <xsl:otherwise>
366     <a name="doc_chap{$chpos}_sect{$pos}" />
367     </xsl:otherwise>
368     </xsl:choose>
369     <xsl:if test="@id">
370     <a name= "{@id}"/>
371     </xsl:if>
372     <p class="secthead"><xsl:value-of select="title" /></p>
373 neysx 1.36 <xsl:apply-templates select="body" />
374 swift 1.9 </xsl:if>
375 swift 1.1 </xsl:template>
376    
377     </xsl:stylesheet>

  ViewVC Help
Powered by ViewVC 1.1.13