pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / site / src / documentation / skins / common / xslt / html / book-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 book-to-menu.xsl generates the HTML menu. It outputs XML/HTML of the form:
20   <div class="menu">
21      ...
22   </div>
23 which is then merged with other HTML by site-to-xhtml.xsl
24
25 -->
26 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
27 <!-- ================================================================ -->
28 <!-- These templates SHOULD be overridden                             -->
29 <!-- ================================================================ -->
30   <xsl:template name="selected">
31     <xsl:value-of select="@label"/>
32   </xsl:template>
33   <xsl:template name="unselected"><a href="{@href}">
34     <xsl:if test="@description">
35       <xsl:attribute name="title">
36         <xsl:value-of select="@description"/>
37       </xsl:attribute>
38     </xsl:if>
39     <xsl:value-of select="@label"/></a>
40   </xsl:template>
41   <xsl:template name="print-external">
42 <!-- Use apply-imports when overriding -->
43     <xsl:value-of select="@label"/>
44   </xsl:template>
45 <!-- ================================================================ -->
46 <!-- These templates CAN be overridden                                -->
47 <!-- ================================================================ -->
48 <!-- Eg, if tab href is 'index.html#foo', this will be called when index.html
49   is selected -->
50   <xsl:template name="selected-anchor">
51 <!-- By default, render as unselected so that it is clickable (takes user
52     to the anchor) -->
53     <xsl:call-template name="unselected"/>
54   </xsl:template>
55   <xsl:template name="unselected-anchor">
56     <xsl:call-template name="unselected"/>
57   </xsl:template>
58   <xsl:template match="book">
59     <xsl:apply-templates select="menu"/>
60   </xsl:template>
61   <xsl:template match="menu">
62     <div class="menu">
63       <xsl:call-template name="base-menu"/>
64     </div>
65   </xsl:template>
66   <xsl:template match="menu-item">
67 <!-- Use apply-imports when overriding -->
68     <xsl:variable name="href-nofrag">
69       <xsl:call-template name="path-nofrag">
70         <xsl:with-param name="path" select="@href"/>
71       </xsl:call-template>
72     </xsl:variable>
73     <xsl:variable name="node-path">
74       <xsl:call-template name="normalize">
75         <xsl:with-param name="path" select="concat($dirname, $href-nofrag)"/>
76       </xsl:call-template>
77     </xsl:variable>
78     <xsl:choose>
79 <!-- Compare with extensions stripped -->
80       <xsl:when test="$node-path = $path-nofrag">
81         <xsl:choose>
82           <xsl:when test="contains(@href, '#')">
83             <xsl:call-template name="selected-anchor"/>
84           </xsl:when>
85           <xsl:otherwise>
86             <xsl:call-template name="selected"/>
87           </xsl:otherwise>
88         </xsl:choose>
89       </xsl:when>
90       <xsl:otherwise>
91         <xsl:choose>
92           <xsl:when test="contains(@href, '#')">
93             <xsl:call-template name="unselected-anchor"/>
94           </xsl:when>
95           <xsl:otherwise>
96             <xsl:call-template name="unselected"/>
97           </xsl:otherwise>
98         </xsl:choose>
99       </xsl:otherwise>
100     </xsl:choose>
101   </xsl:template>
102 <!-- ================================================================ -->
103 <!-- These templates SHOULD NOT be overridden                         -->
104 <!-- ================================================================ -->
105   <xsl:param name="path"/>
106   <xsl:include href="pathutils.xsl"/>
107   <xsl:variable name="filename">
108     <xsl:call-template name="filename">
109       <xsl:with-param name="path" select="$path"/>
110     </xsl:call-template>
111   </xsl:variable>
112   <xsl:variable name="path-nofrag">
113     <xsl:call-template name="path-nofrag">
114       <xsl:with-param name="path" select="$path"/>
115     </xsl:call-template>
116   </xsl:variable>
117   <xsl:variable name="dirname">
118     <xsl:call-template name="dirname">
119       <xsl:with-param name="path" select="$path"/>
120     </xsl:call-template>
121   </xsl:variable>
122   <xsl:template match="external">
123     <li><xsl:choose>
124         <xsl:when test="starts-with(@href, $path-nofrag)">
125           <span class="externalSelected">
126             <xsl:call-template name="print-external"/>
127           </span>
128         </xsl:when>
129         <xsl:otherwise><a href="{@href}" target="_blank">
130           <xsl:value-of select="@label"/></a>
131         </xsl:otherwise>
132       </xsl:choose></li>
133   </xsl:template>
134   <xsl:template match="menu-item[@type='hidden']"/>
135   <xsl:template match="external[@type='hidden']"/>
136   <xsl:template name="base-menu">
137     <xsl:apply-templates/>
138   </xsl:template>
139 </xsl:stylesheet>