pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / site / src / documentation / skins / common / xslt / html / tab-to-menu.xsl
1 <?xml version="1.0"?>
2 <!--
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
9
10       http://www.apache.org/licenses/LICENSE-2.0
11
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.
17 -->
18 <!--
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:
22
23 Tab1:  ''
24 Tab2:  'community'
25 Tab3:  'community/howto'
26 Tab4:  'community/howto/xmlform/index.html'
27
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
30 path is enabled.
31
32 The output of this stylesheet is HTML of the form:
33     <div class="tab">
34       ...
35     </div>
36
37 which is then merged by site-to-xhtml.xsl
38
39 -->
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>
51   </xsl:template>
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>
59   </xsl:template>
60 <!--
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.
63   -->
64 <!-- Display a selected level 1 tab node -->
65   <xsl:template name="selected">
66     <xsl:call-template name="base-selected"/>
67   </xsl:template>
68 <!-- Display an unselected level 1 tab node -->
69   <xsl:template name="not-selected">
70     <xsl:call-template name="base-not-selected"/>
71   </xsl:template>
72 <!-- Display a selected second level tab node -->
73   <xsl:template name="level2-selected">
74     <xsl:call-template name="base-selected"/>
75   </xsl:template>
76 <!-- Display an unselected second level tab node -->
77   <xsl:template name="level2-not-selected">
78     <xsl:call-template name="base-not-selected"/>
79   </xsl:template>
80 <!-- ================================================================ -->
81 <!-- These templates CAN be overridden                             -->
82 <!-- ================================================================ -->
83   <xsl:template match="tabs">
84     <div class="tab">
85       <xsl:call-template name="base-tabs"/>
86     </div>
87   </xsl:template>
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"/>
98     </xsl:call-template>
99   </xsl:variable>
100   <xsl:variable name="skin-img-dir" select="concat(string($root), 'skin/images')"/>
101 <!--
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.
104   -->
105   <xsl:variable name="longest-dir">
106     <xsl:call-template name="longest-dir">
107       <xsl:with-param name="tabfile" select="/"/>
108     </xsl:call-template>
109   </xsl:variable>
110 <!--
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.
113   -->
114   <xsl:variable name="level2-longest-dir">
115     <xsl:call-template name="level2-longest-dir">
116       <xsl:with-param name="tabfile" select="/"/>
117     </xsl:call-template>
118   </xsl:variable>
119   <xsl:variable name="matching-id">
120     <xsl:call-template name="matching-id"/>
121   </xsl:variable>
122 <!-- Called from tabs, after it has written the outer 'div class=tabs' and
123   any other HTML -->
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"/>
129       </xsl:if>
130       <xsl:apply-templates select="." mode="level1"/>
131     </xsl:for-each>
132     <xsl:call-template name="post-separator"/>
133   </xsl:template>
134 <!-- Called from tabs, after it has written the outer 'div class=tabs' and
135   any other HTML -->
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"/>
141       </xsl:if>
142       <xsl:apply-templates select="." mode="level2"/>
143     </xsl:for-each>
144     <xsl:call-template name="level2-post-separator"/>
145   </xsl:template>
146   <xsl:template match="tab" mode="level1">
147     <xsl:choose>
148       <xsl:when test="@id and @id = $matching-id">
149         <xsl:call-template name="selected"/>
150       </xsl:when>
151       <xsl:when test="not(@id) and @dir = $longest-dir or @href = $longest-dir">
152         <xsl:call-template name="selected"/>
153       </xsl:when>
154       <xsl:when test="tab[@id = $matching-id]">
155         <xsl:call-template name="selected"/>
156       </xsl:when>
157       <xsl:otherwise>
158         <xsl:call-template name="not-selected"/>
159       </xsl:otherwise>
160     </xsl:choose>
161   </xsl:template>
162   <xsl:template match="tab" mode="level2">
163     <xsl:choose>
164       <xsl:when test="@id and @id = $matching-id">
165         <xsl:call-template name="level2-selected"/>
166       </xsl:when>
167       <xsl:when test="@dir = $level2-longest-dir">
168         <xsl:call-template name="level2-selected"/>
169       </xsl:when>
170       <xsl:otherwise>
171         <xsl:call-template name="level2-not-selected"/>
172       </xsl:otherwise>
173     </xsl:choose>
174   </xsl:template>
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"/>
181       </xsl:call-template>
182     </xsl:attribute>
183     <xsl:value-of select="@label"/></a>
184   </xsl:template>
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"/>
191       </xsl:call-template>
192     </xsl:attribute>
193     <xsl:value-of select="@label"/></a>
194   </xsl:template>
195 </xsl:stylesheet>