0
|
1 |
// YSLT version 2.5.4
|
|
2 |
|
|
3 |
!!
|
|
4 |
def indent(level):
|
|
5 |
return "value 'substring($space, 1, $_indent+" + str(level) + "*$autoindent)';"
|
|
6 |
!!
|
|
7 |
|
|
8 |
in exsl decl document(href, method) alias document;
|
|
9 |
in func decl def(name) alias function, result(select);
|
|
10 |
|
|
11 |
decl debug_off(exclude-result-prefixes="yml");
|
|
12 |
|
|
13 |
in xsl {
|
|
14 |
decl _trace_param(%text, name="yml:trace", select='yml:debug("* %text")') alias param;
|
|
15 |
decl _trace_with is _trace_param alias with-param;
|
|
16 |
|
|
17 |
decl param(name, select);
|
|
18 |
decl const(name, select) alias variable, variable is const;
|
|
19 |
decl output(method), key(name, match, use);
|
|
20 |
decl value(select) alias value-of, copy(select) alias copy-of;
|
|
21 |
|
|
22 |
decl indent is value(%level, select='substring($space, 1, $_indent + (%level) * $autoindent)');
|
|
23 |
|
|
24 |
decl stylesheet(
|
|
25 |
*output="xml",
|
|
26 |
version="1.0",
|
|
27 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
28 |
) {
|
|
29 |
output *output;
|
|
30 |
const "space", !"'" + " " * 200 + "'"!;
|
|
31 |
param "autoindent", 4;
|
|
32 |
content;
|
|
33 |
};
|
|
34 |
|
|
35 |
decl estylesheet is stylesheet (
|
|
36 |
xmlns:exsl='http://exslt.org/common',
|
|
37 |
xmlns:math='http://exslt.org/math',
|
|
38 |
xmlns:func='http://exslt.org/functions',
|
|
39 |
xmlns:str='http://exslt.org/strings',
|
|
40 |
xmlns:dyn='http://exslt.org/dynamic',
|
|
41 |
xmlns:set='http://exslt.org/sets',
|
|
42 |
xmlns:date='http://exslt.org/dates-and-times',
|
3
|
43 |
xmlns:yml='http://fdik.org/yml',
|
|
44 |
extension-element-prefixes='exsl func str dyn set math date yml'
|
0
|
45 |
);
|
|
46 |
|
|
47 |
decl textstylesheet is estylesheet(*output="text") {
|
|
48 |
output *output;
|
|
49 |
const "space", !"'" + " " * 200 + "'"!;
|
|
50 |
param "autoindent", 4;
|
|
51 |
xsl:template "text()";
|
|
52 |
content;
|
|
53 |
}, tstylesheet is textstylesheet;
|
|
54 |
|
|
55 |
decl template(match) {
|
|
56 |
_trace_param *_trace_info;
|
|
57 |
param "_indent", 0;
|
|
58 |
content;
|
|
59 |
};
|
|
60 |
|
|
61 |
decl function(name) alias template {
|
|
62 |
_trace_param *_trace_info;
|
|
63 |
param "_indent", 0;
|
|
64 |
content;
|
|
65 |
};
|
|
66 |
|
|
67 |
decl call(name) alias call-template {
|
|
68 |
_trace_with *_trace_info;
|
|
69 |
content;
|
|
70 |
};
|
|
71 |
|
|
72 |
decl namespace_alias(stylesheet-prefix, result-prefix);
|
|
73 |
decl text, raw(disable-output-escaping='yes') alias text;
|
|
74 |
|
|
75 |
decl with(name, select) alias with-param;
|
|
76 |
decl withIndent(%level, name="_indent", select='$_indent + (%level) * $autoindent') alias with-param;
|
|
77 |
|
|
78 |
decl apply(select, *indent=1) alias apply-templates {
|
|
79 |
_trace_with *_trace_info;
|
|
80 |
withIndent *indent;
|
|
81 |
content;
|
|
82 |
};
|
|
83 |
|
|
84 |
decl choose, when(test), otherwise;
|
|
85 |
decl if(test);
|
|
86 |
decl for(select) alias for-each, foreach is for;
|
|
87 |
decl element(name, namespace);
|
|
88 |
decl attrib(name, namespace) alias attribute, attrib_set(name) alias attribute-set;
|
|
89 |
decl processing(name) alias processing-instruction;
|
|
90 |
decl comment;
|
|
91 |
decl number(value), sort(select), decimal_format(name, decimal-separator=".", grouping-separator=",");
|
|
92 |
decl import(href), fallback;
|
|
93 |
decl message, error is message(terminate='yes'), warning is message(terminate='no');
|
|
94 |
|
|
95 |
decl debug(%text, select='yml:debug(%text)') alias value-of;
|
|
96 |
decl assert(%test, %msg="''", select='yml:assert(%test,%msg)') alias value-of;
|
|
97 |
}
|
|
98 |
|
|
99 |
define operator "«(.*?)»" as value "%1";
|
|
100 |
|