forked from Shinniam/sh-kimutispeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changes.xsls
134 lines (95 loc) · 3.21 KB
/
changes.xsls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
X:stylesheet {
X:output method="text";
X:param lang="'en'";
X:param configuration="'../xml/change_log_conf.xml'";
X:var conf = "document($configuration)/configuration";
X:var start = "$conf/start";
X:var indent = "$conf/indent";
X:var max = "$conf/length";
X:var br = {<br>}
X:template = "/" { !! "change_log"; }
X:template = "change_log" { !! "changes"; }
X:template = "changes" {
X:text { }
!{substring(concat($conf/changes[@lang=$lang]/title,
//change_log/@title,
' ', @ver,
' '),
1, $conf/changes[@lang=$lang]/length)}
X:if "$lang='ru'" {
!{substring(@date, 9, 2)}
X:text {.}
!{substring(@date, 6, 2)}
X:text {.}
!{substring(@date, 1, 4)}
}
X:if "$lang='en'" {
!{substring(@date, 9, 2)}
!{$conf/changes[@lang=$lang]/month[number(substring(current()/@date,
6, 2))]}
!{substring(@date, 1, 4)}
}
X:text { }
!! "change";
X:text { }
}
X:template = "change" {
X:var prefix = "$conf/changes[@lang=$lang]/*[local-name(.)=current()/@type]"
X:var postfix = { X:if "$prefix" { X:text {: } } }
!! "para[@lang=$lang]" (prefix = "concat($start, $prefix, $postfix)");
}
X:template para(prefix) = "para" {
X:var text = { !!; }
X:text { }
!wrap(text = "normalize-space($text)",
prefix = { X:if "position() = 1" { !{$prefix} } else { !{$indent} } })
}
X:template wrap(text, prefix) {
X:if "$text" {
X:var offset = {
X:choose {
X:when "starts-with($text, concat($br, ' '))" {
!{string-length($br) + 2}
}
X:when "starts-with($text, $br)" {
!{string-length($br) + 1}
}
X:otherwise {
1
}
}
}
X:var length = {
!length(text = "substring($text, $offset)",
prefix = "string-length($prefix)",
length = "$max")
}
!{$prefix}
!{normalize-space(translate(substring($text, $offset, $length),
' ', ' '))}
X:text { }
!wrap(text = "substring($text, $length + $offset)", prefix = "$indent")
}
}
X:template length(text, prefix, length) {
X:var break = "substring-before(substring($text, 1,
$length - $prefix + string-length($br)),
$br)"
X:choose {
X:when "$break" { !{string-length($break)} }
X:when "$length = 0" { !{$max - $prefix} }
X:when "string-length($text) + $prefix <= $length" {
!{$length - $prefix}
}
X:when "substring($text, $length - $prefix + 1, 1) = ' '" {
!{$length - $prefix + 1}
}
X:otherwise {
!length(text = "$text", prefix = "$prefix", length = "$length - 1")
}
}
}
X:template = "at" {@}
X:template = "br" { !{$br} }
X:template = "nobr" { !{translate(., ' ', ' ')} }
}