Mercurial > hg > nginx
comparison docs/xslt/changes.xslt @ 5586:db6d07dbef3c
Docs: xslt regenerated.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 28 Feb 2014 20:17:01 +0400 |
parents | 76bc29f06168 |
children | b7e02f47a339 |
comparison
equal
deleted
inserted
replaced
5585:f303f3e43f7b | 5586:db6d07dbef3c |
---|---|
1 <?xml version="1.0" encoding="utf-8"?> | 1 <?xml version="1.0" encoding="utf-8"?> |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | 2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
3 | 3 |
4 <xsl:output method="text"/> | 4 <xsl:output method="text"/> |
5 | 5 |
6 <xsl:param select="'en'" name="lang"/> | 6 <xsl:param select="'en'" name="lang"/> |
7 <xsl:param select="'../xml/change_log_conf.xml'" name="configuration"/> | |
7 | 8 |
8 <xsl:param select="'../xml/change_log_conf.xml'" name="configuration"/> | 9 <xsl:variable select="document($configuration)/configuration" name="conf"/> |
10 <xsl:variable select="$conf/start" name="start"/> | |
11 <xsl:variable select="$conf/indent" name="indent"/> | |
12 <xsl:variable select="$conf/length" name="max"/> | |
13 <xsl:variable name="br"><br></xsl:variable> | |
9 | 14 |
10 <xsl:variable select="document($configuration)/configuration" name="conf"/> | |
11 | 15 |
12 <xsl:variable select="$conf/start" name="start"/> | 16 <xsl:template match="/"> <xsl:apply-templates select="change_log"/> </xsl:template> |
17 <xsl:template match="change_log"> <xsl:apply-templates select="changes"/> </xsl:template> | |
13 | 18 |
14 <xsl:variable select="$conf/indent" name="indent"/> | |
15 | 19 |
16 <xsl:variable select="$conf/length" name="max"/> | 20 <xsl:template match="changes"> |
21 <xsl:text> </xsl:text> | |
17 | 22 |
18 <xsl:variable name="br"><br></xsl:variable> | 23 <xsl:value-of select="substring(concat($conf/changes[@lang=$lang]/title, |
24 //change_log/@title, | |
25 ' ', @ver, | |
26 ' '), | |
27 1, $conf/changes[@lang=$lang]/length)"/> | |
19 | 28 |
20 <xsl:template match="/"> | 29 <xsl:if test="$lang='ru'"> <xsl:value-of select="@date"/> </xsl:if> |
21 <xsl:apply-templates select="change_log"/> | |
22 </xsl:template> | |
23 | 30 |
24 <xsl:template match="change_log"> | 31 <xsl:if test="$lang='en'"> |
25 <xsl:apply-templates select="changes"/> | 32 <xsl:value-of select="substring(@date, 1, 2)"/> |
26 </xsl:template> | 33 <xsl:value-of select="$conf/changes[@lang=$lang]/month[number(substring(current()/@date, |
34 4, 2))]"/> | |
35 <xsl:value-of select="substring(@date, 7, 4)"/> | |
36 </xsl:if> | |
27 | 37 |
28 <xsl:template match="changes"> | 38 <xsl:text> </xsl:text> |
29 | 39 |
30 <xsl:text> | 40 <xsl:apply-templates select="change"/> |
31 </xsl:text> | |
32 | 41 |
33 <xsl:value-of select="substring(concat($conf/changes[@lang=$lang]/title, //change_log/@title, ' ', @ver, ' '), 1, $conf/changes[@lang=$lang]/length)"/> | 42 <xsl:text> </xsl:text> |
43 </xsl:template> | |
34 | 44 |
35 <xsl:if test="$lang='ru'"> | |
36 <xsl:value-of select="@date"/> | |
37 </xsl:if> | |
38 | 45 |
39 <xsl:if test="$lang='en'"> | 46 <xsl:template match="change"> |
47 <xsl:variable select="$conf/changes[@lang=$lang]/*[local-name(.)=current()/@type]" name="prefix"/> | |
40 | 48 |
41 <xsl:value-of select="substring(@date, 1, 2)"/> | 49 <xsl:variable name="postfix"> <xsl:if test="$prefix"> <xsl:text>: </xsl:text> </xsl:if> </xsl:variable> |
42 | 50 |
43 <xsl:value-of select="$conf/changes[@lang=$lang]/month[number(substring(current()/@date, 4, 2))]"/> | 51 <xsl:apply-templates select="para[@lang=$lang]"><xsl:with-param select="concat($start, $prefix, $postfix)" name="prefix"/></xsl:apply-templates> |
52 </xsl:template> | |
44 | 53 |
45 <xsl:value-of select="substring(@date, 7, 4)"/> | |
46 </xsl:if> | |
47 | 54 |
48 <xsl:text> | 55 <xsl:template name="para" match="para"><xsl:param name="prefix"/> |
49 </xsl:text> | 56 <xsl:variable name="text"> <xsl:apply-templates/> </xsl:variable> |
50 | 57 |
51 <xsl:apply-templates select="change"/> | 58 <xsl:text> </xsl:text> |
52 | 59 |
53 <xsl:text> | 60 <xsl:call-template name="wrap"><xsl:with-param select="normalize-space($text)" name="text"/><xsl:with-param name="prefix"> <xsl:choose><xsl:when test="position() = 1"> <xsl:value-of select="$prefix"/> </xsl:when><xsl:otherwise> <xsl:value-of select="$indent"/> </xsl:otherwise></xsl:choose> </xsl:with-param></xsl:call-template></xsl:template> |
54 </xsl:text> | |
55 </xsl:template> | |
56 | 61 |
57 <xsl:template match="change"> | |
58 | 62 |
59 <xsl:variable select="$conf/changes[@lang=$lang]/*[local-name(.)=current()/@type]" name="prefix"/> | 63 <xsl:template name="wrap"><xsl:param name="text"/><xsl:param name="prefix"/> |
64 <xsl:if test="$text"> | |
65 <xsl:variable name="offset"> | |
66 <xsl:choose> | |
67 <xsl:when test="starts-with($text, concat($br, ' '))"> | |
68 <xsl:value-of select="string-length($br) + 2"/> | |
69 </xsl:when> | |
70 <xsl:when test="starts-with($text, $br)"> | |
71 <xsl:value-of select="string-length($br) + 1"/> | |
72 </xsl:when> | |
73 <xsl:otherwise> | |
74 1 | |
75 </xsl:otherwise> | |
76 </xsl:choose> | |
77 </xsl:variable> | |
60 | 78 |
61 <xsl:variable name="postfix"> | 79 <xsl:variable name="length"> |
62 <xsl:if test="$prefix"> | 80 <xsl:call-template name="length"><xsl:with-param select="substring($text, $offset)" name="text"/><xsl:with-param select="string-length($prefix)" name="prefix"/><xsl:with-param select="$max" name="length"/></xsl:call-template></xsl:variable> |
63 <xsl:text>: </xsl:text> | |
64 </xsl:if> | |
65 </xsl:variable> | |
66 | 81 |
67 <xsl:apply-templates select="para[@lang=$lang]"> | 82 <xsl:value-of select="$prefix"/> |
68 <xsl:with-param select="concat($start, $prefix, $postfix)" name="prefix"/> | |
69 </xsl:apply-templates> | |
70 </xsl:template> | |
71 | 83 |
72 <xsl:template match="para" name="para"> | 84 <xsl:value-of select="normalize-space(translate(substring($text, $offset, $length), |
73 <xsl:param name="prefix"/> | 85 ' ', ' '))"/> |
74 | 86 |
75 <xsl:variable name="text"> | 87 <xsl:text> </xsl:text> |
76 <xsl:apply-templates/> | |
77 </xsl:variable> | |
78 | 88 |
79 <xsl:text> | 89 <xsl:call-template name="wrap"><xsl:with-param select="substring($text, $length + $offset)" name="text"/><xsl:with-param select="$indent" name="prefix"/></xsl:call-template></xsl:if> |
80 </xsl:text> | 90 </xsl:template> |
81 | 91 |
82 <xsl:call-template name="wrap"> | |
83 <xsl:with-param select="normalize-space($text)" name="text"/> | |
84 <xsl:with-param name="prefix"> | |
85 <xsl:choose> | |
86 | 92 |
87 <xsl:when test="position() = 1"> | 93 <xsl:template name="length"><xsl:param name="text"/><xsl:param name="prefix"/><xsl:param name="length"/> |
88 <xsl:value-of select="$prefix"/> | 94 <xsl:variable select="substring-before(substring($text, 1, |
89 </xsl:when> | 95 $length - $prefix + string-length($br)), |
90 <xsl:otherwise> | 96 $br)" name="break"/> |
91 <xsl:value-of select="$indent"/> | |
92 </xsl:otherwise> | |
93 </xsl:choose> | |
94 </xsl:with-param> | |
95 </xsl:call-template> | |
96 </xsl:template> | |
97 | 97 |
98 <xsl:template name="wrap"> | 98 <xsl:choose> |
99 <xsl:param name="text"/> | 99 <xsl:when test="$break"> <xsl:value-of select="string-length($break)"/> </xsl:when> |
100 <xsl:param name="prefix"/> | |
101 | 100 |
102 <xsl:if test="$text"> | 101 <xsl:when test="$length = 0"> <xsl:value-of select="$max - $prefix"/> </xsl:when> |
103 | 102 |
104 <xsl:variable name="offset"> | 103 <xsl:when test="string-length($text) + $prefix <= $length"> |
104 <xsl:value-of select="$length - $prefix"/> | |
105 </xsl:when> | |
105 | 106 |
106 <xsl:choose> | 107 <xsl:when test="substring($text, $length - $prefix + 1, 1) = ' '"> |
107 <xsl:when test="starts-with($text, concat($br, ' '))"> | 108 <xsl:value-of select="$length - $prefix + 1"/> |
108 <xsl:value-of select="string-length($br) + 2"/> | 109 </xsl:when> |
109 </xsl:when> | |
110 <xsl:when test="starts-with($text, $br)"> | |
111 <xsl:value-of select="string-length($br) + 1"/> | |
112 </xsl:when> | |
113 <xsl:otherwise> | |
114 1</xsl:otherwise> | |
115 </xsl:choose> | |
116 </xsl:variable> | |
117 | 110 |
118 <xsl:variable name="length"> | 111 <xsl:otherwise> |
112 <xsl:call-template name="length"><xsl:with-param select="$text" name="text"/><xsl:with-param select="$prefix" name="prefix"/><xsl:with-param select="$length - 1" name="length"/></xsl:call-template></xsl:otherwise> | |
113 </xsl:choose> | |
114 </xsl:template> | |
119 | 115 |
120 <xsl:call-template name="length"> | |
121 <xsl:with-param select="substring($text, $offset)" name="text"/> | |
122 <xsl:with-param select="string-length($prefix)" name="prefix"/> | |
123 <xsl:with-param select="$max" name="length"/> | |
124 </xsl:call-template> | |
125 </xsl:variable> | |
126 | 116 |
127 <xsl:value-of select="$prefix"/> | 117 <xsl:template match="at">@</xsl:template> |
118 <xsl:template match="br"> <xsl:value-of select="$br"/> </xsl:template> | |
119 <xsl:template match="nobr"> <xsl:value-of select="translate(., ' ', ' ')"/> </xsl:template> | |
128 | 120 |
129 <xsl:value-of select="normalize-space(translate(substring($text, $offset, $length), ' ', ' '))"/> | |
130 | |
131 <xsl:text> | |
132 </xsl:text> | |
133 | |
134 <xsl:call-template name="wrap"> | |
135 <xsl:with-param select="substring($text, $length + $offset)" name="text"/> | |
136 <xsl:with-param select="$indent" name="prefix"/> | |
137 </xsl:call-template> | |
138 </xsl:if> | |
139 </xsl:template> | |
140 | |
141 <xsl:template name="length"> | |
142 <xsl:param name="text"/> | |
143 <xsl:param name="prefix"/> | |
144 <xsl:param name="length"/> | |
145 | |
146 <xsl:variable select="substring-before(substring($text, 1, $length - $prefix + string-length($br)), $br)" name="break"/> | |
147 | |
148 <xsl:choose> | |
149 <xsl:when test="$break"> | |
150 <xsl:value-of select="string-length($break)"/> | |
151 </xsl:when> | |
152 <xsl:when test="$length = 0"> | |
153 <xsl:value-of select="$max - $prefix"/> | |
154 </xsl:when> | |
155 <xsl:when test="string-length($text) + $prefix <= $length"> | |
156 <xsl:value-of select="$length - $prefix"/> | |
157 </xsl:when> | |
158 <xsl:when test="substring($text, $length - $prefix + 1, 1) = ' '"> | |
159 <xsl:value-of select="$length - $prefix + 1"/> | |
160 </xsl:when> | |
161 <xsl:otherwise> | |
162 | |
163 <xsl:call-template name="length"> | |
164 <xsl:with-param select="$text" name="text"/> | |
165 <xsl:with-param select="$prefix" name="prefix"/> | |
166 <xsl:with-param select="$length - 1" name="length"/> | |
167 </xsl:call-template> | |
168 </xsl:otherwise> | |
169 </xsl:choose> | |
170 </xsl:template> | |
171 | |
172 <xsl:template match="at">@</xsl:template> | |
173 | |
174 <xsl:template match="br"> | |
175 <xsl:value-of select="$br"/> | |
176 </xsl:template> | |
177 | |
178 <xsl:template match="nobr"> | |
179 <xsl:value-of select="translate(., ' ', ' ')"/> | |
180 </xsl:template> | |
181 | 121 |
182 </xsl:stylesheet> | 122 </xsl:stylesheet> |