2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 <xsl:output method="html"/>
7 <xsl:param name="max.toc.width" select="7"/>
9 <xsl:template match="toc/title|tocentry/title|titleabbrev">
10 <xsl:apply-templates/>
13 <xsl:template match="toc">
14 <xsl:param name="pageid" select="@id"/>
16 <xsl:variable name="relpath">
17 <xsl:call-template name="toc-rel-path">
18 <xsl:with-param name="pageid" select="$pageid"/>
22 <xsl:variable name="homebanner"
23 select="/autolayout/config[@param='homebanner'][1]"/>
25 <xsl:variable name="banner"
26 select="/autolayout/config[@param='banner'][1]"/>
28 <xsl:variable name="homebannertext"
29 select="/autolayout/config[@param='homebannertext'][1]"/>
31 <xsl:variable name="bannertext"
32 select="/autolayout/config[@param='bannertext'][1]"/>
35 <xsl:when test="$pageid = @id">
37 <xsl:when test="$homebanner">
39 <xsl:attribute name="src">
40 <xsl:value-of select="$relpath"/>
41 <xsl:value-of select="$homebanner/@value"/>
43 <xsl:attribute name="alt">
44 <xsl:value-of select="$homebanner/@altval"/>
47 <xsl:value-of select="$currentpage.marker"/>
49 <xsl:when test="$homebannertext">
50 <xsl:value-of select="$homebannertext/@value"/>
51 <xsl:value-of select="$currentpage.marker"/>
54 <xsl:call-template name="gentext.nav.home"/>
55 <xsl:value-of select="$currentpage.marker"/>
60 <a href="{$relpath}{@dir}{$filename-prefix}{@filename}">
62 <xsl:when test="$banner">
64 <xsl:attribute name="src">
65 <xsl:value-of select="$relpath"/>
66 <xsl:value-of select="$banner/@value"/>
68 <xsl:attribute name="alt">
69 <xsl:value-of select="$banner/@altval"/>
73 <xsl:when test="$bannertext">
74 <xsl:value-of select="$bannertext/@value"/>
77 <xsl:call-template name="gentext.nav.home"/>
84 <xsl:text> | </xsl:text>
86 <xsl:call-template name="process-children">
87 <xsl:with-param name="pageid" select="$pageid"/>
88 <xsl:with-param name="relpath" select="$relpath"/>
92 <xsl:template match="tocentry">
93 <xsl:param name="pageid" select="@id"/>
94 <xsl:param name="relpath" select="''"/>
96 <xsl:if test="preceding-sibling::tocentry">
97 <xsl:text> | </xsl:text>
101 <xsl:when test="$pageid = @id">
103 <xsl:when test="titleabbrev">
104 <xsl:apply-templates select="titleabbrev"/>
107 <xsl:apply-templates select="title"/>
110 <xsl:value-of select="$currentpage.marker"/>
114 <xsl:attribute name="href">
116 <xsl:when test="@href">
117 <xsl:value-of select="@href"/>
120 <xsl:value-of select="$relpath"/>
121 <xsl:value-of select="@dir"/>
122 <xsl:value-of select="$filename-prefix"/>
123 <xsl:value-of select="@filename"/>
128 <xsl:when test="titleabbrev">
129 <xsl:apply-templates select="titleabbrev"/>
132 <xsl:apply-templates select="title"/>
140 <xsl:template match="toc|tocentry|notoc" mode="toc-rel-path">
141 <xsl:call-template name="toc-rel-path"/>
144 <xsl:template name="toc-rel-path">
145 <xsl:param name="pageid" select="@id"/>
146 <xsl:variable name="entry" select="$autolayout//*[@id=$pageid]"/>
147 <xsl:variable name="filename" select="concat($entry/@dir,$entry/@filename)"/>
149 <xsl:variable name="depth">
150 <xsl:call-template name="toc-directory-depth">
151 <xsl:with-param name="filename" select="$filename"/>
155 <xsl:if test="$depth > 0">
156 <xsl:call-template name="copy-string">
157 <xsl:with-param name="string">../</xsl:with-param>
158 <xsl:with-param name="count" select="$depth"/>
163 <xsl:template name="toc-directory-depth">
164 <xsl:param name="filename"></xsl:param>
165 <xsl:param name="count" select="0"/>
168 <xsl:when test='contains($filename,"/")'>
169 <xsl:call-template name="toc-directory-depth">
170 <xsl:with-param name="filename"
171 select="substring-after($filename,'/')"/>
172 <xsl:with-param name="count" select="$count + 1"/>
176 <xsl:value-of select="$count"/>
181 <xsl:template name="process-children">
182 <xsl:param name="pageid" select="@id"/>
183 <xsl:param name="relpath" select="''"/>
186 <xsl:when test="tocentry[descendant-or-self::*[@id=$pageid]]">
187 <xsl:call-template name="process-tocentry-children">
188 <xsl:with-param name="pageid" select="$pageid"/>
189 <xsl:with-param name="relpath" select="$relpath"/>
193 <xsl:call-template name="process-toc-children">
194 <xsl:with-param name="pageid" select="$pageid"/>
195 <xsl:with-param name="relpath" select="$relpath"/>
201 <xsl:template name="process-tocentry-children">
202 <xsl:param name="pageid" select="@id"/>
203 <xsl:param name="relpath" select="''"/>
206 <xsl:when test="count(tocentry) > $max.toc.width">
207 <xsl:variable name="cur"
208 select="tocentry[descendant-or-self::*[@id=$pageid]]"/>
210 <xsl:variable name="half" select="$max.toc.width div 2"/>
212 <xsl:variable name="all-nodes"
213 select="$cur/preceding-sibling::tocentry[position() < $half]
215 | $cur/following-sibling::tocentry"/>
217 <xsl:variable name="nodes"
218 select="$all-nodes[position() < $max.toc.width]"/>
220 <xsl:if test="count($cur/preceding-sibling::tocentry) > $half">
221 <xsl:text>...</xsl:text>
223 <xsl:apply-templates select="$nodes">
224 <xsl:with-param name="pageid" select="$pageid"/>
225 <xsl:with-param name="relpath" select="$relpath"/>
226 </xsl:apply-templates>
227 <xsl:if test="count($all-nodes) > $max.toc.width">
228 <xsl:text> | ...</xsl:text>
232 <xsl:apply-templates select="tocentry">
233 <xsl:with-param name="pageid" select="$pageid"/>
234 <xsl:with-param name="relpath" select="$relpath"/>
235 </xsl:apply-templates>
241 <!-- if the current page isn't in this list, keep digging... -->
242 <xsl:if test="not(tocentry[$pageid=@id])">
243 <xsl:for-each select="tocentry">
244 <xsl:if test="descendant::*[@id=$pageid]">
245 <xsl:call-template name="process-children">
246 <xsl:with-param name="pageid" select="$pageid"/>
247 <xsl:with-param name="relpath" select="$relpath"/>
254 <xsl:template name="process-toc-children">
255 <xsl:param name="pageid" select="@id"/>
256 <xsl:param name="relpath" select="''"/>
259 <xsl:when test="count(tocentry) > $max.toc.width">
260 <xsl:variable name="half" select="$max.toc.width div 2"/>
262 <xsl:variable name="all-nodes" select="tocentry"/>
263 <xsl:variable name="nodes"
264 select="$all-nodes[position() < $max.toc.width]"/>
266 <xsl:apply-templates select="$nodes">
267 <xsl:with-param name="pageid" select="$pageid"/>
268 <xsl:with-param name="relpath" select="$relpath"/>
269 </xsl:apply-templates>
271 <xsl:if test="count($all-nodes) > $max.toc.width">
272 <xsl:text> | ...</xsl:text>
276 <xsl:apply-templates select="tocentry">
277 <xsl:with-param name="pageid" select="$pageid"/>
278 <xsl:with-param name="relpath" select="$relpath"/>
279 </xsl:apply-templates>