pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / site / src / documentation / skins / common / xslt / html / tabutils.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 Some callable templates useful when dealing with tab paths.  Mostly used in
20 tab-to-menu.xsl
21 -->
22 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
23   <xsl:param name="site-file" select="'cocoon://abs-menulinks'"/>
24   <xsl:variable name="site" select="document($site-file)"/>
25 <!-- Given the current path and a tabs.xml entry, returns a relative path to
26   the specified tab's URL.  When rendering a set of tabs, this template will be
27   called once per tab.
28   -->
29   <xsl:template name="calculate-tab-href">
30     <xsl:param name="dir_index" select="'index.html'"/>
31     <xsl:param name="tab"/>
32 <!-- current 'tab' node -->
33     <xsl:param name="path" select="$path"/>
34     <xsl:if test="starts-with($tab/@href, 'http')">
35 <!-- Absolute URL -->
36       <xsl:value-of select="$tab/@href"/>
37     </xsl:if>
38     <xsl:if test="not(starts-with($tab/@href, 'http'))">
39 <!-- Root-relative path -->
40       <xsl:variable name="backpath">
41         <xsl:call-template name="dotdots">
42           <xsl:with-param name="path" select="$path"/>
43         </xsl:call-template>
44 <xsl:text>/</xsl:text>
45         <xsl:value-of select="$tab/@dir | $tab/@href"/>
46 <!-- If we obviously have a directory, add /index.html -->
47         <xsl:if test="$tab/@dir or substring($tab/@href, string-length($tab/@href),
48           string-length($tab/@href)) = '/'">
49 <xsl:text>/</xsl:text>
50           <xsl:if test="$tab/@indexfile">
51             <xsl:value-of select="$tab/@indexfile"/>
52           </xsl:if>
53           <xsl:if test="not(@indexfile)">
54             <xsl:value-of select="$dir_index"/>
55           </xsl:if>
56         </xsl:if>
57       </xsl:variable>
58       <xsl:value-of
59         select="translate(normalize-space(translate($backpath, ' /', '/ ')), ' /', '/ ')"/>
60 <!-- Link to backpath, normalizing slashes -->
61     </xsl:if>
62   </xsl:template>
63 <!--
64     The id of any tab, whose path is a subset of the current URL.  Ie,
65     the path of the 'current' tab.
66   -->
67   <xsl:template name="matching-id" xmlns:l="http://apache.org/forrest/linkmap/1.0">
68     <xsl:value-of select="$site//*[starts-with(@href, $path)]/@tab"/>
69   </xsl:template>
70 <!--
71     The longest path of any level 1 tab, whose path is a subset of the current URL.  Ie,
72     the path of the 'current' tab.
73   -->
74   <xsl:template name="longest-dir">
75     <xsl:param name="tabfile"/>
76     <xsl:for-each select="$tabfile/tabs/tab[starts-with($path, @dir|@href)]">
77       <xsl:sort select="string-length(@dir|@href)"
78         data-type="number" order="descending"/>
79       <xsl:if test="position()=1">
80         <xsl:value-of select="@dir|@href"/>
81       </xsl:if>
82     </xsl:for-each>
83   </xsl:template>
84 <!--
85     The longest path of any level 2 tab, whose path is a subset of the current URL.  Ie,
86     the path of the 'current' tab.
87   -->
88   <xsl:template name="level2-longest-dir">
89     <xsl:param name="tabfile"/>
90     <xsl:for-each select="$tabfile/tabs/tab/tab[starts-with($path, @dir|@href)]">
91       <xsl:sort select="string-length(@dir|@href)"
92         data-type="number" order="descending"/>
93       <xsl:if test="position()=1">
94         <xsl:value-of select="@dir|@href"/>
95       </xsl:if>
96     </xsl:for-each>
97   </xsl:template>
98 </xsl:stylesheet>