summaryrefslogtreecommitdiff
path: root/etc/schema/xslt.rnc
blob: 3612ec16cbc23fdf98670b30323377c1b82d8d9a (plain)
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# Copyright (C) 2001-2008 World Wide Web Consortium, (Massachusetts
# Institute of Technology, European Research Consortium for
# Informatics and Mathematics, Keio University).  All Rights Reserved.
# This work is distributed under the W3C(R) Software License in the
# hope that it will be useful, but WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.

# This was mostly generated from the syntax summary in the XSLT
# Recommendation (using XSLT of course).

# Issues: this validates extension elements as literal result
# elements, which is overly restrictive.

namespace local = ""
default namespace xsl = "http://www.w3.org/1999/XSL/Transform"

start =
  stylesheet.element
  | transform.element
  | literal-result-element-as-stylesheet
version = "1.0"
top-level-elements.model =
  (top-level-element.category | top-level-extension)*
top-level-extension =
  element * - (xsl:* | local:*) {
    grammar {
      start = any
      any =
        (attribute * { text }
         | text
         | element * { any })*
    }
  }
template.model = (instruction.category | literal-result-element | text)*
literal-result-element-as-stylesheet =
  element * - xsl:* {
    attribute xsl:version { version },
    literal-result-element-no-version.atts,
    template.model
  }
literal-result-element =
  element * - xsl:* { literal-result-element.atts, template.model }
literal-result-element.atts =
  literal-result-element-no-version.atts,
  attribute xsl:version { version }?
literal-result-element-no-version.atts =
  (attribute * - xsl:* { avt.datatype }
   | attribute xsl:extension-element-prefixes { prefixes.datatype }
   | attribute xsl:exclude-result-prefixes { prefixes.datatype }
   | attribute xsl:use-attribute-sets { qnames.datatype })*
top-level-element.category =
  include.element
  | strip-space.element
  | preserve-space.element
  | template.element
  | namespace-alias.element
  | attribute-set.element
  | variable.element
  | param.element
  | key.element
  | decimal-format.element
  | output.element
instruction.category =
  apply-templates.element
  | apply-imports.element
  | call-template.element
  | element.element
  | attribute.element
  | text.element
  | processing-instruction.element
  | comment.element
  | copy.element
  | value-of.element
  | number.element
  | for-each.element
  | if.element
  | choose.element
  | variable.element
  | copy-of.element
  | message.element
  | fallback.element
extension.atts = attribute * - (xsl:* | local:*) { text }*
stylesheet.element = element stylesheet { stylesheet.model }
transform.element = element transform { stylesheet.model }
stylesheet.model =
  extension.atts,
  attribute id { xsd:NCName }?,
  attribute extension-element-prefixes { prefixes.datatype }?,
  attribute exclude-result-prefixes { prefixes.datatype }?,
  attribute version { version },
  (import.element*, top-level-elements.model)
include.element =
  element include {
    extension.atts,
    attribute href { xsd:anyURI }
  }
import.element =
  element import {
    extension.atts,
    attribute href { xsd:anyURI }
  }
strip-space.element =
  element strip-space {
    extension.atts,
    attribute elements { wildcards.datatype }
  }
preserve-space.element =
  element preserve-space {
    extension.atts,
    attribute elements { wildcards.datatype }
  }
template.element =
  element template {
    extension.atts,
    attribute match { pattern.datatype }?,
    attribute name { qname.datatype }?,
    attribute priority { number.datatype }?,
    attribute mode { qname.datatype }?,
    (param.element*, template.model)
  }
apply-templates.element =
  element apply-templates {
    extension.atts,
    attribute select { expression.datatype }?,
    attribute mode { qname.datatype }?,
    (sort.element | with-param.element)*
  }
apply-imports.element = element apply-imports { extension.atts }
call-template.element =
  element call-template {
    extension.atts,
    attribute name { qname.datatype },
    with-param.element*
  }
namespace-alias.element =
  element namespace-alias {
    extension.atts,
    attribute stylesheet-prefix { prefix.datatype },
    attribute result-prefix { prefix.datatype }
  }
element.element =
  element element {
    extension.atts,
    attribute name { qname.datatype | expr-avt.datatype },
    attribute namespace { xsd:anyURI | brace-avt.datatype }?,
    attribute use-attribute-sets { qnames.datatype }?,
    template.model
  }
attribute.element =
  element attribute {
    extension.atts,
    attribute name { qname.datatype | expr-avt.datatype },
    attribute namespace { xsd:anyURI | brace-avt.datatype }?,
    template.model
  }
attribute-set.element =
  element attribute-set {
    extension.atts,
    attribute name { qname.datatype },
    attribute use-attribute-sets { qnames.datatype }?,
    attribute.element*
  }
text.element =
  element text {
    extension.atts,
    attribute disable-output-escaping {
      xsd:string "yes" | xsd:string "no"
    }?,
    text
  }
processing-instruction.element =
  element processing-instruction {
    extension.atts,
    attribute name { xsd:NCName | expr-avt.datatype },
    template.model
  }
comment.element = element comment { extension.atts, template.model }
copy.element =
  element copy {
    extension.atts,
    attribute use-attribute-sets { qnames.datatype }?,
    template.model
  }
value-of.element =
  element value-of {
    extension.atts,
    attribute select { expression.datatype },
    attribute disable-output-escaping {
      xsd:string "yes" | xsd:string "no"
    }?
  }
number.element =
  element number {
    extension.atts,
    attribute level {
      xsd:string "single" | xsd:string "multiple" | xsd:string "any"
    }?,
    attribute count { pattern.datatype }?,
    attribute from { pattern.datatype }?,
    attribute value { expression.datatype }?,
    attribute format { avt.datatype }?,
    attribute lang { xsd:NMTOKEN | expr-avt.datatype }?,
    attribute letter-value {
      xsd:string "alphabetic"
      | xsd:string "traditional"
      | expr-avt.datatype
    }?,
    attribute grouping-separator { char.datatype | expr-avt.datatype }?,
    attribute grouping-size { number.datatype | expr-avt.datatype }?
  }
for-each.element =
  element for-each {
    extension.atts,
    attribute select { expression.datatype },
    (sort.element*, template.model)
  }
if.element =
  element if {
    extension.atts,
    attribute test { expression.datatype },
    template.model
  }
choose.element =
  element choose { extension.atts, (when.element+, otherwise.element?) }
when.element =
  element when {
    extension.atts,
    attribute test { expression.datatype },
    template.model
  }
otherwise.element = element otherwise { extension.atts, template.model }
sort.element =
  element sort {
    extension.atts,
    attribute select { expression.datatype }?,
    attribute lang { xsd:NMTOKEN | expr-avt.datatype }?,
    attribute data-type {
      xsd:string "text"
      | xsd:string "number"
      | qname-but-not-ncname.datatype
      | expr-avt.datatype
    }?,
    attribute order {
      xsd:string "ascending"
      | xsd:string "descending"
      | expr-avt.datatype
    }?,
    attribute case-order {
      xsd:string "upper-first"
      | xsd:string "lower-first"
      | expr-avt.datatype
    }?
  }
variable.element =
  element variable {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
param.element =
  element param {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
copy-of.element =
  element copy-of {
    extension.atts,
    attribute select { expression.datatype }
  }
with-param.element =
  element with-param {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
key.element =
  element key {
    extension.atts,
    attribute name { qname.datatype },
    attribute match { pattern.datatype },
    attribute use { expression.datatype }
  }
decimal-format.element =
  element decimal-format {
    extension.atts,
    attribute name { qname.datatype }?,
    attribute decimal-separator { char.datatype }?,
    attribute grouping-separator { char.datatype }?,
    attribute infinity { text }?,
    attribute minus-sign { char.datatype }?,
    attribute NaN { text }?,
    attribute percent { char.datatype }?,
    attribute per-mille { char.datatype }?,
    attribute zero-digit { char.datatype }?,
    attribute digit { char.datatype }?,
    attribute pattern-separator { char.datatype }?
  }
message.element =
  element message {
    extension.atts,
    attribute terminate { xsd:string "yes" | xsd:string "no" }?,
    template.model
  }
fallback.element = element fallback { extension.atts, template.model }
output.element =
  element output {
    extension.atts,
    attribute method {
      xsd:string "xml"
      | xsd:string "html"
      | xsd:string "text"
      | qname-but-not-ncname.datatype
    }?,
    attribute version { xsd:NMTOKEN }?,
    attribute encoding { text }?,
    attribute omit-xml-declaration {
      xsd:string "yes" | xsd:string "no"
    }?,
    attribute standalone { xsd:string "yes" | xsd:string "no" }?,
    attribute doctype-public { text }?,
    attribute doctype-system { text }?,
    attribute cdata-section-elements { qnames.datatype }?,
    attribute indent { xsd:string "yes" | xsd:string "no" }?,
    attribute media-type { text }?
  }
prefixes.datatype = list { (xsd:NCName | "#default")* }
prefix.datatype = xsd:NCName | "#default"
wildcards.datatype =
  list {
    (xsd:QName
     | xsd:token { pattern = "\*|\i\c*:\*" })*
  }
qname.datatype = xsd:QName
qnames.datatype = list { xsd:QName* }
char.datatype = xsd:string { length = "1" }
number.datatype = xsd:decimal
expression.datatype = text
pattern.datatype = text
qname-but-not-ncname.datatype = xsd:QName { pattern = ".*:.*" }
# An AVT containing at least one expression.
expr-avt.datatype =
  xsd:string {
    pattern =
      """([^\{\}]|\{\{|\}\})*\{([^"'\{\}]|"[^"]*"|'[^']*')+\}([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }
# An AVT containing at least one brace; ie where instantiated AVT
# is not the same as the literal AVT.
brace-avt.datatype =
  xsd:string {
    pattern =
      """[^\{\}]*(\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }
avt.datatype =
  xsd:string {
    pattern =
      """([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }