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 book-to-menu.xsl generates the HTML menu. It outputs XML/HTML of the form:
23 which is then merged with other HTML by site-to-xhtml.xsl
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"/>
33 <xsl:template name="unselected"><a href="{@href}">
34 <xsl:if test="@description">
35 <xsl:attribute name="title">
36 <xsl:value-of select="@description"/>
39 <xsl:value-of select="@label"/></a>
41 <xsl:template name="print-external">
42 <!-- Use apply-imports when overriding -->
43 <xsl:value-of select="@label"/>
45 <!-- ================================================================ -->
46 <!-- These templates CAN be overridden -->
47 <!-- ================================================================ -->
48 <!-- Eg, if tab href is 'index.html#foo', this will be called when index.html
50 <xsl:template name="selected-anchor">
51 <!-- By default, render as unselected so that it is clickable (takes user
53 <xsl:call-template name="unselected"/>
55 <xsl:template name="unselected-anchor">
56 <xsl:call-template name="unselected"/>
58 <xsl:template match="book">
59 <xsl:apply-templates select="menu"/>
61 <xsl:template match="menu">
63 <xsl:call-template name="base-menu"/>
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"/>
73 <xsl:variable name="node-path">
74 <xsl:call-template name="normalize">
75 <xsl:with-param name="path" select="concat($dirname, $href-nofrag)"/>
79 <!-- Compare with extensions stripped -->
80 <xsl:when test="$node-path = $path-nofrag">
82 <xsl:when test="contains(@href, '#')">
83 <xsl:call-template name="selected-anchor"/>
86 <xsl:call-template name="selected"/>
92 <xsl:when test="contains(@href, '#')">
93 <xsl:call-template name="unselected-anchor"/>
96 <xsl:call-template name="unselected"/>
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"/>
112 <xsl:variable name="path-nofrag">
113 <xsl:call-template name="path-nofrag">
114 <xsl:with-param name="path" select="$path"/>
117 <xsl:variable name="dirname">
118 <xsl:call-template name="dirname">
119 <xsl:with-param name="path" select="$path"/>
122 <xsl:template match="external">
124 <xsl:when test="starts-with(@href, $path-nofrag)">
125 <span class="externalSelected">
126 <xsl:call-template name="print-external"/>
129 <xsl:otherwise><a href="{@href}" target="_blank">
130 <xsl:value-of select="@label"/></a>
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/>