author | Volker Birk <vb@pep-project.org> |
Mon, 04 Nov 2019 11:38:34 +0100 | |
changeset 40 | 432ab62b2537 |
parent 38 | 90d687cbe277 |
permissions | -rw-r--r-- |
40 | 1 |
// YSLT version 2.6.2 |
0 | 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', |
|
8 | 42 |
xmlns:sets='http://exslt.org/sets', |
0 | 43 |
xmlns:date='http://exslt.org/dates-and-times', |
3 | 44 |
xmlns:yml='http://fdik.org/yml', |
9 | 45 |
extension-element-prefixes='exsl func str dyn set sets math date yml' |
0 | 46 |
); |
47 |
||
48 |
decl textstylesheet is estylesheet(*output="text") { |
|
49 |
output *output; |
|
50 |
const "space", !"'" + " " * 200 + "'"!; |
|
51 |
param "autoindent", 4; |
|
38
90d687cbe277
explicitely name match attribute
Volker Birk <vb@pep-project.org>
parents:
9
diff
changeset
|
52 |
xsl:template match="text()"; |
0 | 53 |
content; |
54 |
}, tstylesheet is textstylesheet; |
|
55 |
||
56 |
decl template(match) { |
|
57 |
_trace_param *_trace_info; |
|
58 |
param "_indent", 0; |
|
59 |
content; |
|
60 |
}; |
|
61 |
||
62 |
decl function(name) alias template { |
|
63 |
_trace_param *_trace_info; |
|
64 |
param "_indent", 0; |
|
65 |
content; |
|
66 |
}; |
|
67 |
||
68 |
decl call(name) alias call-template { |
|
69 |
_trace_with *_trace_info; |
|
70 |
content; |
|
71 |
}; |
|
72 |
||
73 |
decl namespace_alias(stylesheet-prefix, result-prefix); |
|
74 |
decl text, raw(disable-output-escaping='yes') alias text; |
|
75 |
||
76 |
decl with(name, select) alias with-param; |
|
77 |
decl withIndent(%level, name="_indent", select='$_indent + (%level) * $autoindent') alias with-param; |
|
78 |
||
79 |
decl apply(select, *indent=1) alias apply-templates { |
|
80 |
_trace_with *_trace_info; |
|
81 |
withIndent *indent; |
|
82 |
content; |
|
83 |
}; |
|
84 |
||
85 |
decl choose, when(test), otherwise; |
|
86 |
decl if(test); |
|
87 |
decl for(select) alias for-each, foreach is for; |
|
88 |
decl element(name, namespace); |
|
89 |
decl attrib(name, namespace) alias attribute, attrib_set(name) alias attribute-set; |
|
90 |
decl processing(name) alias processing-instruction; |
|
91 |
decl comment; |
|
92 |
decl number(value), sort(select), decimal_format(name, decimal-separator=".", grouping-separator=","); |
|
93 |
decl import(href), fallback; |
|
94 |
decl message, error is message(terminate='yes'), warning is message(terminate='no'); |
|
95 |
||
96 |
decl debug(%text, select='yml:debug(%text)') alias value-of; |
|
97 |
decl assert(%test, %msg="''", select='yml:assert(%test,%msg)') alias value-of; |
|
98 |
} |
|
99 |
||
100 |
define operator "«(.*?)»" as value "%1"; |
|
101 |