|
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', |
|
43 extension-element-prefixes='exsl func str dyn set math date' |
|
44 ); |
|
45 |
|
46 decl textstylesheet is estylesheet(*output="text") { |
|
47 output *output; |
|
48 const "space", !"'" + " " * 200 + "'"!; |
|
49 param "autoindent", 4; |
|
50 xsl:template "text()"; |
|
51 content; |
|
52 }, tstylesheet is textstylesheet; |
|
53 |
|
54 decl template(match) { |
|
55 _trace_param *_trace_info; |
|
56 param "_indent", 0; |
|
57 content; |
|
58 }; |
|
59 |
|
60 decl function(name) alias template { |
|
61 _trace_param *_trace_info; |
|
62 param "_indent", 0; |
|
63 content; |
|
64 }; |
|
65 |
|
66 decl call(name) alias call-template { |
|
67 _trace_with *_trace_info; |
|
68 content; |
|
69 }; |
|
70 |
|
71 decl namespace_alias(stylesheet-prefix, result-prefix); |
|
72 decl text, raw(disable-output-escaping='yes') alias text; |
|
73 |
|
74 decl with(name, select) alias with-param; |
|
75 decl withIndent(%level, name="_indent", select='$_indent + (%level) * $autoindent') alias with-param; |
|
76 |
|
77 decl apply(select, *indent=1) alias apply-templates { |
|
78 _trace_with *_trace_info; |
|
79 withIndent *indent; |
|
80 content; |
|
81 }; |
|
82 |
|
83 decl choose, when(test), otherwise; |
|
84 decl if(test); |
|
85 decl for(select) alias for-each, foreach is for; |
|
86 decl element(name, namespace); |
|
87 decl attrib(name, namespace) alias attribute, attrib_set(name) alias attribute-set; |
|
88 decl processing(name) alias processing-instruction; |
|
89 decl comment; |
|
90 decl number(value), sort(select), decimal_format(name, decimal-separator=".", grouping-separator=","); |
|
91 decl import(href), fallback; |
|
92 decl message, error is message(terminate='yes'), warning is message(terminate='no'); |
|
93 |
|
94 decl debug(%text, select='yml:debug(%text)') alias value-of; |
|
95 decl assert(%test, %msg="''", select='yml:assert(%test,%msg)') alias value-of; |
|
96 } |
|
97 |
|
98 define operator "«(.*?)»" as value "%1"; |
|
99 |