comparison xslt/menu.xslt @ 1085:c454373427ef

Regenerated.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 28 Feb 2014 20:12:47 +0400
parents 2c57830e0149
children
comparison
equal deleted inserted replaced
1084:be1d72ba7e5f 1085:c454373427ef
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 Copyright (C) Igor Sysoev
4 Copyright (C) Nginx, Inc.
5 -->
6
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 7 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3 8
4 <xsl:template match="menu/item"> 9 <xsl:template match="menu/item">
5 <xsl:choose>
6 10
7 <xsl:when test="@href = $LINK"> 11 <!--
8 <xsl:choose> 12 .. variables are not allowed in a template match predicate,
13 .. therefore, we have to use ugly "if"s instead of elegant
14 .. "menu/item[@href = $LINK]", etc.
15 -->
9 16
10 <xsl:when test="$YEAR and @href='/'"> 17 <xsl:choose><xsl:when test="@href = $LINK">
18 <xsl:choose><xsl:when test="$YEAR and @href='/'">
19 <a href="./"> news </a> <br/>
20 </xsl:when><xsl:otherwise>
21 <xsl:value-of select=" normalize-space(text()) "/><br/>
22 </xsl:otherwise></xsl:choose>
11 23
12 <a href="./"> news </a> 24 </xsl:when><xsl:otherwise>
13 <br/>
14 </xsl:when>
15 25
16 <xsl:otherwise> 26 <!--
27 .. If a menu item has the switchlang attribute, then it will point
28 .. to the same document in the specified language.
29 -->
30 <xsl:choose><xsl:when test="$TRANS and @switchlang">
17 31
18 <xsl:value-of select=" normalize-space(text())"/> 32 <!--
19 <br/> 33 .. Check if list of available translations ($TRANS) contains
20 </xsl:otherwise> 34 .. the language we are going to generate link to.
21 </xsl:choose> 35 .. If yes - generate link, otherwise just name the language.
22 </xsl:when> 36 -->
37 <xsl:choose><xsl:when test="contains($TRANS, @switchlang)">
38 <a>
39 <xsl:attribute name="href">
40 <xsl:value-of select=" concat($ROOT, '/', @switchlang, '/',
41 substring-after($LINK, concat('/', $LANG, '/'))) "/>
42 </xsl:attribute>
43 <xsl:value-of select=" normalize-space(text()) "/>
44 </a>
23 45
24 <xsl:otherwise> 46 </xsl:when><xsl:otherwise>
25 <xsl:choose> 47 <a class="notrans"> <xsl:value-of select=" normalize-space(text()) "/> </a>
48 </xsl:otherwise></xsl:choose>
49 </xsl:when><xsl:otherwise>
26 50
27 <xsl:when test="$TRANS and @switchlang"> 51 <a>
28 <xsl:choose> 52 <xsl:attribute name="href">
29 53
30 <xsl:when test="contains($TRANS, @switchlang)"> 54 <xsl:choose><xsl:when test="starts-with(@href, $DIRNAME)">
55 <xsl:choose><xsl:when test="substring-after(@href, $DIRNAME) = ''">
56 <xsl:text>./</xsl:text>
57 </xsl:when><xsl:otherwise>
58 <xsl:value-of select=" substring-after(@href, $DIRNAME) "/>
59 </xsl:otherwise></xsl:choose>
31 60
32 <a> 61 </xsl:when><xsl:otherwise>
62 <xsl:value-of select=" concat($ROOT, @href) "/>
63 </xsl:otherwise></xsl:choose>
64 </xsl:attribute>
65 <xsl:value-of select=" normalize-space(text()) "/>
66 </a>
33 67
34 <xsl:attribute name="href"> 68 <xsl:if test="@lang"> <xsl:text> [</xsl:text> <xsl:value-of select="@lang"/> <xsl:text>]</xsl:text></xsl:if>
69 </xsl:otherwise></xsl:choose>
35 70
36 <xsl:value-of select=" concat($ROOT, '/', @switchlang, '/', substring-after($LINK, concat('/', $LANG, '/')))"/> 71 <br/>
37 </xsl:attribute> 72 </xsl:otherwise></xsl:choose>
73 </xsl:template>
38 74
39 <xsl:value-of select=" normalize-space(text())"/>
40 75
41 </a> 76 <xsl:template match="menu/item[@year]">
42 </xsl:when> 77 <xsl:if test="$YEAR or $LINK='/'">
78 <xsl:choose><xsl:when test="$YEAR=@year">
79 <xsl:value-of select="@year"/> <br/>
80 </xsl:when><xsl:otherwise>
81 <xsl:if test="@href"> <a href="{@href}"> <xsl:value-of select="@year"/> </a> </xsl:if>
82 <br/>
83 </xsl:otherwise></xsl:choose>
84 </xsl:if>
85 </xsl:template>
43 86
44 <xsl:otherwise>
45 87
46 <a class="notrans"> 88 <xsl:template match="menu/item[starts-with(@href, 'http://') or starts-with(@href, 'https://')]">
47 <xsl:value-of select=" normalize-space(text())"/> 89 <a href="{@href}"> <xsl:value-of select=" normalize-space(text()) "/> </a>
48 </a> 90 <xsl:if test="@lang"> <xsl:text> [</xsl:text> <xsl:value-of select="@lang"/> <xsl:text>]</xsl:text></xsl:if>
49 </xsl:otherwise> 91 <br/>
50 </xsl:choose> 92 </xsl:template>
51 </xsl:when>
52 93
53 <xsl:otherwise>
54 94
55 <a> 95 <xsl:template match="menu/item[not(@href) and not(@year)]">
56 96 <xsl:value-of select=" normalize-space(text()) "/> <br/>
57 <xsl:attribute name="href"> 97 </xsl:template>
58 <xsl:choose>
59
60 <xsl:when test="starts-with(@href, $DIRNAME)">
61 <xsl:choose>
62
63 <xsl:when test="substring-after(@href, $DIRNAME) = ''">
64
65 <xsl:text>./</xsl:text>
66 </xsl:when>
67
68 <xsl:otherwise>
69
70 <xsl:value-of select=" substring-after(@href, $DIRNAME)"/>
71 </xsl:otherwise>
72 </xsl:choose>
73 </xsl:when>
74
75 <xsl:otherwise>
76
77 <xsl:value-of select=" concat($ROOT, @href)"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:attribute>
81
82 <xsl:value-of select=" normalize-space(text())"/>
83
84 </a>
85
86 <xsl:if test="@lang">
87 <xsl:text> [</xsl:text>
88 <xsl:value-of select="@lang"/>
89 <xsl:text>]</xsl:text>
90 </xsl:if>
91 </xsl:otherwise>
92 </xsl:choose>
93
94 <br/>
95 </xsl:otherwise>
96 </xsl:choose>
97 </xsl:template>
98
99 <xsl:template match="menu/item[@year]">
100
101 <xsl:if test="$YEAR or $LINK='/'">
102 <xsl:choose>
103
104 <xsl:when test="$YEAR=@year">
105
106 <xsl:value-of select="@year"/>
107 <br/>
108 </xsl:when>
109
110 <xsl:otherwise>
111
112 <xsl:if test="@href">
113 <a href="{@href}">
114 <xsl:value-of select="@year"/>
115 </a>
116 </xsl:if>
117
118 <br/>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:if>
122 </xsl:template>
123
124 <xsl:template match="menu/item[starts-with(@href, 'http://') or starts-with(@href, 'https://')]">
125
126 <a href="{@href}">
127 <xsl:value-of select=" normalize-space(text())"/>
128 </a>
129
130 <xsl:if test="@lang">
131 <xsl:text> [</xsl:text>
132 <xsl:value-of select="@lang"/>
133 <xsl:text>]</xsl:text>
134 </xsl:if>
135
136 <br/>
137 </xsl:template>
138
139 <xsl:template match="menu/item[not(@href) and not(@year)]">
140
141 <xsl:value-of select=" normalize-space(text())"/>
142 <br/>
143 </xsl:template>
144 98
145 </xsl:stylesheet> 99 </xsl:stylesheet>