3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
19 This stylesheet generates 'tabs' at the top left of the screen. Tabs are
20 visual indicators that a certain subsection of the URI space is being browsed.
21 For example, if we had tabs with paths:
25 Tab3: 'community/howto'
26 Tab4: 'community/howto/xmlform/index.html'
28 Then if the current path was 'community/howto/foo', Tab3 would be highlighted.
29 The rule is: the tab with the longest path that forms a prefix of the current
32 The output of this stylesheet is HTML of the form:
37 which is then merged by site-to-xhtml.xsl
40 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
41 <!-- ================================================================ -->
42 <!-- These templates SHOULD be overridden -->
43 <!-- ================================================================ -->
44 <!-- Called before first level 1 tag -->
45 <xsl:template name="pre-separator"></xsl:template>
46 <!-- Called after last level 1 tag -->
47 <xsl:template name="post-separator"></xsl:template>
48 <!-- Called between level 1 tags -->
49 <xsl:template name="separator">
50 <xsl:text> | </xsl:text>
52 <!-- Called before first level 2 tag -->
53 <xsl:template name="level2-pre-separator"></xsl:template>
54 <!-- Called after last level 2 tag -->
55 <xsl:template name="level2-post-separator"></xsl:template>
56 <!-- Called between level 2 tags -->
57 <xsl:template name="level2-separator">
58 <xsl:text> | </xsl:text>
61 Note: sub-stylesheets can't do apply-imports here, because it would choose
62 the 'tags' template and infinitely recurse. Hence call-template used instead.
64 <!-- Display a selected level 1 tab node -->
65 <xsl:template name="selected">
66 <xsl:call-template name="base-selected"/>
68 <!-- Display an unselected level 1 tab node -->
69 <xsl:template name="not-selected">
70 <xsl:call-template name="base-not-selected"/>
72 <!-- Display a selected second level tab node -->
73 <xsl:template name="level2-selected">
74 <xsl:call-template name="base-selected"/>
76 <!-- Display an unselected second level tab node -->
77 <xsl:template name="level2-not-selected">
78 <xsl:call-template name="base-not-selected"/>
80 <!-- ================================================================ -->
81 <!-- These templates CAN be overridden -->
82 <!-- ================================================================ -->
83 <xsl:template match="tabs">
85 <xsl:call-template name="base-tabs"/>
88 <!-- ================================================================ -->
89 <!-- These templates SHOULD NOT be overridden -->
90 <!-- ================================================================ -->
91 <xsl:param name="path"/>
92 <xsl:include href="dotdots.xsl"/>
93 <xsl:include href="tabutils.xsl"/>
94 <!-- NOTE: Xalan has a bug (race condition?) where sometimes $root is only half-evaluated -->
95 <xsl:variable name="root">
96 <xsl:call-template name="dotdots">
97 <xsl:with-param name="path" select="$path"/>
100 <xsl:variable name="skin-img-dir" select="concat(string($root), 'skin/images')"/>
102 The longest path of any level 1 tab, whose path is a subset of the current URL. Ie,
103 the path of the 'current' level 1 tab.
105 <xsl:variable name="longest-dir">
106 <xsl:call-template name="longest-dir">
107 <xsl:with-param name="tabfile" select="/"/>
111 The longest path of any level 2 tab, whose path is a subset of the current URL. Ie,
112 the path of the 'current' level 2 tab.
114 <xsl:variable name="level2-longest-dir">
115 <xsl:call-template name="level2-longest-dir">
116 <xsl:with-param name="tabfile" select="/"/>
119 <xsl:variable name="matching-id">
120 <xsl:call-template name="matching-id"/>
122 <!-- Called from tabs, after it has written the outer 'div class=tabs' and
124 <xsl:template name="base-tabs">
125 <xsl:call-template name="pre-separator"/>
126 <xsl:for-each select="tab">
127 <xsl:if test="position()!=1">
128 <xsl:call-template name="separator"/>
130 <xsl:apply-templates select="." mode="level1"/>
132 <xsl:call-template name="post-separator"/>
134 <!-- Called from tabs, after it has written the outer 'div class=tabs' and
136 <xsl:template name="level2tabs">
137 <xsl:call-template name="level2-pre-separator"/>
138 <xsl:for-each select="tab[@dir=$longest-dir]/tab|tab[@href=$longest-dir]/tab|tab[tab/@id=$matching-id]/tab">
139 <xsl:if test="position()!=1">
140 <xsl:call-template name="level2-separator"/>
142 <xsl:apply-templates select="." mode="level2"/>
144 <xsl:call-template name="level2-post-separator"/>
146 <xsl:template match="tab" mode="level1">
148 <xsl:when test="@id and @id = $matching-id">
149 <xsl:call-template name="selected"/>
151 <xsl:when test="not(@id) and @dir = $longest-dir or @href = $longest-dir">
152 <xsl:call-template name="selected"/>
154 <xsl:when test="tab[@id = $matching-id]">
155 <xsl:call-template name="selected"/>
158 <xsl:call-template name="not-selected"/>
162 <xsl:template match="tab" mode="level2">
164 <xsl:when test="@id and @id = $matching-id">
165 <xsl:call-template name="level2-selected"/>
167 <xsl:when test="@dir = $level2-longest-dir">
168 <xsl:call-template name="level2-selected"/>
171 <xsl:call-template name="level2-not-selected"/>
175 <!-- Called from 'selected' -->
176 <xsl:template name="base-selected"><a class="selected">
177 <xsl:attribute name="href">
178 <xsl:call-template name="calculate-tab-href">
179 <xsl:with-param name="tab" select="."/>
180 <xsl:with-param name="path" select="$path"/>
183 <xsl:value-of select="@label"/></a>
185 <!-- Called from 'not-selected' -->
186 <xsl:template name="base-not-selected"><a class="unselected">
187 <xsl:attribute name="href">
188 <xsl:call-template name="calculate-tab-href">
189 <xsl:with-param name="tab" select="."/>
190 <xsl:with-param name="path" select="$path"/>
193 <xsl:value-of select="@label"/></a>