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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download) (as text)
Sat Oct 11 13:09:07 2003 UTC (9 years, 7 months ago) by swift
Branch: MAIN
Changes since 1.5: +11 -11 lines
File MIME type: application/xml
Cosmetic changes regarding indexes

1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4 <!-- Define global variables; if a user has
5 already defined those, this is a NOP -->
6 <xsl:param name="chap">0</xsl:param>
7 <xsl:param name="sect">0</xsl:param>
8
9 <!-- A book -->
10 <xsl:template match="/book">
11 <!-- If chap = 0, show an index -->
12 <xsl:choose>
13 <xsl:when test="$chap != 0">
14 <xsl:apply-templates select="chapter" />
15 </xsl:when>
16 <xsl:otherwise>
17 <xsl:choose>
18 <xsl:when test="$style = 'printable'">
19 <xsl:call-template name="printdoclayout" />
20 </xsl:when>
21 <xsl:otherwise>
22 <xsl:call-template name="doclayout"/>
23 </xsl:otherwise>
24 </xsl:choose>
25 </xsl:otherwise>
26 </xsl:choose>
27 </xsl:template>
28
29 <!-- Content of /book -->
30 <xsl:template name="bookcontent">
31 <xsl:call-template name="menubar" />
32 <h1><xsl:value-of select="title" /></h1>
33 <xsl:if test="$style = 'printable'">
34 <xsl:apply-templates select="author" />
35 </xsl:if>
36 <p>Content:</p>
37 <ul>
38 <xsl:for-each select="chapter">
39 <xsl:param name="curchap" select="position()" />
40 <li>
41 <b><a href="?chap={$curchap}&amp;sect=0&amp;style={$style}"><xsl:value-of select="title" /></a></b>
42 <xsl:if test="abstract">
43 <br />
44 <xsl:value-of select="abstract" />
45 </xsl:if>
46 <ol>
47 <xsl:for-each select="section">
48 <xsl:param name="cursect" select="position()" />
49 <li>
50 <b><a href="?chap={$curchap}&amp;sect={$cursect}&amp;style={$style}"><xsl:value-of select="title" /></a></b>
51 <xsl:if test="abstract">
52 <br/>
53 <xsl:value-of select="abstract" />
54 </xsl:if>
55 </li>
56 </xsl:for-each>
57 </ol>
58 </li>
59 </xsl:for-each>
60 </ul>
61 <xsl:call-template name="menubar" />
62 <xsl:apply-templates select="/book/license" />
63 </xsl:template>
64
65 <!-- Chapter inside a book -->
66 <xsl:template match="/book/chapter">
67 <xsl:if test="($sect != 0) and ($chap = position())">
68 <xsl:apply-templates select="section" />
69 </xsl:if>
70 <xsl:if test="($sect = 0) and ($chap = position())">
71 <xsl:choose>
72 <xsl:when test="$style = 'printable'">
73 <xsl:call-template name="printdoclayout" />
74 </xsl:when>
75 <xsl:otherwise>
76 <xsl:call-template name="doclayout" />
77 </xsl:otherwise>
78 </xsl:choose>
79 </xsl:if>
80 </xsl:template>
81
82 <!-- Content of /book/chapter -->
83 <xsl:template name="bookchaptercontent">
84 <xsl:call-template name="menubar" />
85 <h1><xsl:number level="multiple" format="1. " select="position()"/><xsl:value-of select="title" /></h1>
86 <xsl:if test="abstract">
87 <p><xsl:value-of select="abstract" /></p>
88 </xsl:if>
89 <p>Content:</p>
90 <ol>
91 <xsl:for-each select="section">
92 <xsl:param name="curpos" select="position()" />
93 <xsl:if test="title">
94 <li>
95 <b><a href="?chap={$chap}&amp;sect={$curpos}&amp;style={$style}"><xsl:value-of select="title" /></a></b>
96 <xsl:if test="abstract">
97 <br/><xsl:value-of select="abstract" />
98 </xsl:if>
99 </li>
100 </xsl:if>
101 </xsl:for-each>
102 </ol>
103
104 <xsl:call-template name="menubar" />
105 <xsl:apply-templates select="/book/license" />
106 </xsl:template>
107
108 <!-- Menu bar -->
109 <xsl:template name="menubar">
110 <xsl:variable name="prevchap" select="number($chap) - 1" />
111 <xsl:variable name="prevsect" select="number($sect) - 1" />
112 <xsl:variable name="nextchap" select="number($chap) + 1" />
113 <xsl:variable name="nextsect" select="number($sect) + 1" />
114 <xsl:if test="$style != 'printable'">
115 <hr />
116 <p class="alttext">
117 <!-- Previous Chapters -->
118 <xsl:choose>
119 <xsl:when test="number($prevchap) &lt; 1">
120 [ &lt;&lt; Previous Chapter ]
121 </xsl:when>
122 <xsl:otherwise>
123 [ <a href="?chap={$prevchap}&amp;sect=0">&lt;&lt; Previous Chapter</a> ]
124 </xsl:otherwise>
125 </xsl:choose>
126 <!-- Previous Sections -->
127 <xsl:choose>
128 <xsl:when test="number($prevsect) &lt; 1">
129 [ &lt; Previous Section ]
130 </xsl:when>
131 <xsl:otherwise>
132 [ <a href="?chap={$chap}&amp;sect={$prevsect}">&lt; Previous Section</a> ]
133 </xsl:otherwise>
134 </xsl:choose>
135 <!-- Content -->
136 [ <a href="?chap=0&amp;sect=0">Home</a> ]
137 <!-- Next Section -->
138 <xsl:if test="name() = 'book'">
139 [ <a href="?chap=1">Next Section &gt;</a> ]
140 </xsl:if>
141 <xsl:if test="name() = 'chapter'">
142 [ <a href="?chap={$chap}&amp;sect=1">Next Section &gt;</a> ]
143 </xsl:if>
144 <xsl:if test="name() = 'section'">
145 <xsl:choose>
146 <xsl:when test="number($sect) = count(section)">
147 [ Next Section &gt; ]
148 </xsl:when>
149 <xsl:otherwise>
150 [ <a href="?chap={$chap}&amp;sect={$nextsect}">Next Section &gt;</a> ]
151 </xsl:otherwise>
152 </xsl:choose>
153 </xsl:if>
154 <!-- Next Chapter -->
155 <xsl:if test="name() = 'book'">
156 [ <a href="?chap={$nextchap}">Next Chapter &gt;&gt;</a> ]
157 </xsl:if>
158 <xsl:if test="name() = 'chapter'">
159 <xsl:choose>
160 <xsl:when test="number($chap) = last()">
161 [ Next Chapter &gt;&gt; ]
162 </xsl:when>
163 <xsl:otherwise>
164 [ <a href="?chap={$nextchap}&amp;sect=0">Next Chapter &gt;&gt;</a> ]
165 </xsl:otherwise>
166 </xsl:choose>
167 </xsl:if>
168 <xsl:if test="name() = 'section'">
169 <xsl:choose>
170 <xsl:when test="count(/book/chapter) = number($chap)">
171 [ Next Chapter &gt;&gt; ]
172 </xsl:when>
173 <xsl:otherwise>
174 [ <a href="?chap={$nextchap}&amp;sect=0">Next Chapter &gt;&gt;</a> ]
175 </xsl:otherwise>
176 </xsl:choose>
177 </xsl:if>
178 </p>
179 <hr />
180 </xsl:if>
181 </xsl:template>
182
183
184 <!-- Section inside a chapter -->
185 <xsl:template match="/book/chapter/section">
186 <xsl:if test="$sect = position()">
187 <xsl:choose>
188 <xsl:when test="$style = 'printable'">
189 <xsl:call-template name="printdoclayout" />
190 </xsl:when>
191 <xsl:otherwise>
192 <xsl:call-template name="doclayout" />
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:if>
196 </xsl:template>
197
198 <!-- Content of /book/chapter/section -->
199 <xsl:template name="bookchaptersectioncontent">
200 <xsl:call-template name="menubar" />
201 <h1><xsl:number level="multiple" format="1. " select="position()"/><xsl:value-of select="title" /></h1>
202 <xsl:variable name="doc" select="include/@href"/>
203 <xsl:variable name="FILE" select="document($doc)" />
204 <xsl:if test="$FILE/section/subsection/title">
205 <b>Content: </b>
206 <ul>
207 <xsl:for-each select="$FILE/section/subsection/title">
208 <xsl:param name="pos" select="position()" />
209 <li><a href="#{$pos}" class="altlink"><xsl:value-of select="." /></a></li>
210 </xsl:for-each>
211 </ul>
212 </xsl:if>
213 <xsl:apply-templates select="$FILE/section/body|$FILE/section/subsection" />
214
215 <xsl:call-template name="menubar" />
216 <xsl:apply-templates select="/book/license" />
217 </xsl:template>
218
219 <!-- Subsection inside a section -->
220 <!-- The current guide.xsl doesnt allow subsections in normal guides, so
221 only book's are allowed to use subsections -->
222 <xsl:template match="subsection">
223 <xsl:param name="pos" select="position()" />
224 <a name="{$pos}"/>
225 <xsl:if test="title">
226 <p class="chaphead"><span class="chapnum"><xsl:value-of select="$sect" />.<xsl:number level="multiple" format="a. " select="position()" /></span><xsl:value-of select="title" /></p>
227 </xsl:if>
228 <xsl:apply-templates select="body|subsubsection" />
229 </xsl:template>
230
231 <!-- Subsubsection inside a subsection -->
232 <xsl:template match="subsubsection">
233 <xsl:param name="pos" select="position()"/>
234 <p class="secthead"><xsl:value-of select="title" /></p>
235 <xsl:apply-templates select="body" />
236 </xsl:template>
237
238 </xsl:stylesheet>

  ViewVC Help
Powered by ViewVC 1.1.13