-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXSD.sublime-syntax
167 lines (144 loc) · 4.86 KB
/
XSD.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
%YAML 1.2
---
# https://www.w3.org/TR/xmlschema11-1/
name: XSD
scope: text.xml.xsd
version: 2
extends: Packages/XML/XML.sublime-syntax
file_extensions:
- xsd
- xspec
- wsdl
variables:
# attributes with regexp expression values
qualified_regexp_attribute_name: |-
(?x)
(?:
(?:
({{identifier}}) # 1: valid namespace
| ([^:=/<>\s]+) # 2: invalid namespace
)(:)
)? # namespace is optional
({{regexp_attribute_name}}) # 3: valid localname
(?=[=<>\s]|[/?]>)
regexp_attribute_name: |-
(?xi: value )
# 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: select | test | xpath )
contexts:
tag-attribute:
- meta_prepend: true
- include: tag-regexp-attribute
- include: tag-xpath-attribute
###[ REGEX TAG ATTRIBUTES ]####################################################
tag-regexp-attribute:
- match: '{{qualified_regexp_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-regexp-attribute-assignment
tag-regexp-attribute-assignment:
- meta_include_prototype: false
- match: =
scope: punctuation.separator.key-value.xml
set: tag-regexp-attribute-value
- include: tag-else-pop
tag-regexp-attribute-value:
# The multipush construct is required due to:
# https://github.com/sublimehq/sublime_text/issues/3784
- meta_include_prototype: false
- match: \"
scope: punctuation.definition.string.begin.xml
set: tag-regexp-attribute-double-qouted-body
- match: \'
scope: punctuation.definition.string.begin.xml
set: tag-regexp-attribute-single-qouted-body
- match: '[^?/<>\s]+'
scope: invalid.illegal.bad-attribute-value.xml
pop: 1
- include: tag-else-pop
tag-regexp-attribute-double-qouted-body:
- meta_include_prototype: false
- meta_scope: meta.string.regexp.xml string.quoted.double.xml
- match: \"
scope: punctuation.definition.string.end.xml
pop: 1
- match: ''
embed: regexp-content
escape: (?=\")
tag-regexp-attribute-single-qouted-body:
- meta_include_prototype: false
- meta_scope: meta.string.regexp.xml string.quoted.single.xml
- match: \'
scope: punctuation.definition.string.end.xml
pop: 1
- match: ''
embed: regexp-content
escape: (?=\')
regexp-content:
- include: scope:source.regexp.embedded.xsl
apply_prototype: true
###[ 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
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
escape: (?=\')
xpath-query-content:
- meta_scope: source.xpath.embedded.xsl
- include: scope:source.xpath.2
apply_prototype: true