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