-
Notifications
You must be signed in to change notification settings - Fork 0
/
XSL 1.0.sublime-syntax
193 lines (163 loc) · 5.83 KB
/
XSL 1.0.sublime-syntax
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
%YAML 1.2
---
# https://www.w3.org/TR/1999/REC-xslt-19991116
name: XSL 1.0
scope: text.xml.xsl.1
version: 2
extends: Packages/XML/XML.sublime-syntax
variables:
qualified_xsl_tag_name: |-
(?xi)
(xsl) (:) # 1: valid xsl namespace
(?:
({{identifier}})(?=[/<>\s]) # 3: valid localname
|
([^?!/<>\s][^/<>\s]*) # 4: invalid localname
)
# attributes with xpath expression values
qualified_xpath_attribute_name: |-
(?x)
(?:
(?:
({{identifier}}) # 1: valid namespace
| ([^:=/<>\s]+) # 2: invalid namespace
)(:)
)? # namespace is optional
({{xpath_attribute_name}}) # 3: valid localname
(?=[=<>\s]|[/?]>)
xpath_attribute_name: |-
(?xi: elements | match | select | test | use )
contexts:
###[ XML EXTENSIONS ]##########################################################
main:
- meta_prepend: true
- include: xpath-text-interpolations
tag:
- meta_prepend: true
- include: xsl-tag
- include: scope:text.html.basic#script-tag
- include: scope:text.html.basic#style-tag
tag-attribute:
- meta_prepend: true
- include: tag-xpath-attribute
- include: scope:text.html.basic#tag-event-attribute
- include: scope:text.html.basic#tag-style-attribute
comment-content:
- meta_prepend: true
- include: xpath-text-interpolations
cdata-content:
- meta_prepend: true
- include: xpath-string-interpolations
string-common-content:
- meta_prepend: true
- include: xpath-string-interpolations
###[ XSL TAGS ]################################################################
xsl-tag:
# scope `<xsl:template ...>` special for adding it to symbol list.
- match: (<)(xsl)(:)(template)(?=[/<>\s])
captures:
1: punctuation.definition.tag.begin.opening.xsl
2: entity.name.tag.namespace.xsl
3: entity.name.tag.xsl punctuation.separator.namespace.xsl
4: entity.name.tag.localname.xsl
push: xsl-begin-template-tag-content
# opening maybe self-closing tag with optional attributes
- match: (<){{qualified_xsl_tag_name}}
captures:
1: punctuation.definition.tag.begin.opening.xsl
2: entity.name.tag.namespace.xsl
3: entity.name.tag.xsl punctuation.separator.namespace.xsl
4: entity.name.tag.localname.xsl
5: invalid.illegal.bad-tag-name.xsl
push: xsl-begin-tag-content
# end-tag without attribute support
- match: (</){{qualified_xsl_tag_name}}
captures:
1: punctuation.definition.tag.begin.closing.xsl
2: entity.name.tag.namespace.xsl
3: entity.name.tag.xsl punctuation.separator.namespace.xsl
4: entity.name.tag.localname.xsl
5: invalid.illegal.bad-tag-name.xsl
push: xsl-end-tag-content
xsl-begin-template-tag-content:
- meta_scope: meta.tag.template.xsl
- include: begin-tag-content
xsl-begin-tag-content:
- meta_scope: meta.tag.xsl
- include: begin-tag-content
xsl-end-tag-content:
- meta_scope: meta.tag.xsl
- include: end-tag-content
###[ XPATH TAG ATTRIBUTES ]####################################################
tag-xpath-attribute:
- match: '{{qualified_xpath_attribute_name}}'
captures:
1: entity.other.attribute-name.namespace.xml
2: invalid.illegal.bad-attribute-name.xml
3: entity.other.attribute-name.xml punctuation.separator.namespace.xml
4: entity.other.attribute-name.localname.xml
push: tag-xpath-attribute-assignment
tag-xpath-attribute-assignment:
- meta_include_prototype: false
- match: =
scope: punctuation.separator.key-value.xml
set: tag-xpath-attribute-value
- include: tag-else-pop
tag-xpath-attribute-value:
# The multipush construct is required due to:
# https://github.com/sublimehq/sublime_text/issues/3784
- meta_include_prototype: false
- match: \"
scope: string.quoted.double.xml punctuation.definition.string.begin.xml
set: tag-xpath-attribute-double-qouted-body
- match: \'
scope: string.quoted.single.xml punctuation.definition.string.begin.xml
set: tag-xpath-attribute-single-qouted-body
- match: '[^?/<>\s]+'
scope: invalid.illegal.bad-attribute-value.xml
pop: 1
- include: tag-else-pop
tag-xpath-attribute-double-qouted-body:
- meta_include_prototype: false
- meta_scope: meta.string.xml
- match: \"
scope: string.quoted.double.xml punctuation.definition.string.end.xml
pop: 1
- match: ''
embed: xpath-query-content
embed_scope: source.xpath.embedded.xsl
escape: (?=\")
tag-xpath-attribute-single-qouted-body:
- meta_include_prototype: false
- meta_scope: meta.string.xml
- match: \'
scope: string.quoted.single.xml punctuation.definition.string.end.xml
pop: 1
- match: ''
embed: xpath-query-content
embed_scope: source.xpath.embedded.xsl
escape: (?=\')
###[ XPATH INTERPOLATIONS ]####################################################
xpath-string-interpolations:
- match: \{
scope: punctuation.section.interpolation.begin.xsl
push: xpath-string-interpolation-body
xpath-string-interpolation-body:
- clear_scopes: 1
- meta_scope: meta.interpolation.xsl
- meta_content_scope: source.xpath.embedded.xsl
- include: xpath-text-interpolation-body
xpath-text-interpolations:
- match: \{
scope: punctuation.section.interpolation.begin.xsl
push: xpath-text-interpolation-body
xpath-text-interpolation-body:
- meta_scope: meta.interpolation.xsl
- meta_content_scope: source.xpath.embedded.xsl
- match: \}
scope: punctuation.section.interpolation.end.xsl
pop: 1
- include: xpath-query-content
xpath-query-content:
- include: scope:source.xpath.1
apply_prototype: true