91204
|
1 # $Id: xslt.rnc,v 1.1 2007/11/23 06:57:47 hexmode Exp $
|
86361
|
2
|
|
3 # This was mostly generated from the syntax summary in the XSLT
|
|
4 # Recommendation (using XSLT of course).
|
|
5
|
|
6 # Issues: this validates extension elements as literal result
|
|
7 # elements, which is overly restrictive.
|
|
8
|
|
9 namespace local = ""
|
|
10 default namespace xsl = "http://www.w3.org/1999/XSL/Transform"
|
|
11
|
|
12 start =
|
|
13 stylesheet.element
|
|
14 | transform.element
|
|
15 | literal-result-element-as-stylesheet
|
|
16 version = "1.0"
|
|
17 top-level-elements.model =
|
|
18 (top-level-element.category | top-level-extension)*
|
|
19 top-level-extension =
|
|
20 element * - (xsl:* | local:*) {
|
|
21 grammar {
|
|
22 start = any
|
|
23 any =
|
|
24 (attribute * { text }
|
|
25 | text
|
|
26 | element * { any })*
|
|
27 }
|
|
28 }
|
|
29 template.model = (instruction.category | literal-result-element | text)*
|
|
30 literal-result-element-as-stylesheet =
|
|
31 element * - xsl:* {
|
|
32 attribute xsl:version { version },
|
|
33 literal-result-element-no-version.atts,
|
|
34 template.model
|
|
35 }
|
|
36 literal-result-element =
|
|
37 element * - xsl:* { literal-result-element.atts, template.model }
|
|
38 literal-result-element.atts =
|
|
39 literal-result-element-no-version.atts,
|
|
40 attribute xsl:version { version }?
|
|
41 literal-result-element-no-version.atts =
|
|
42 (attribute * - xsl:* { avt.datatype }
|
|
43 | attribute xsl:extension-element-prefixes { prefixes.datatype }
|
|
44 | attribute xsl:exclude-result-prefixes { prefixes.datatype }
|
|
45 | attribute xsl:use-attribute-sets { qnames.datatype })*
|
|
46 top-level-element.category =
|
|
47 include.element
|
|
48 | strip-space.element
|
|
49 | preserve-space.element
|
|
50 | template.element
|
|
51 | namespace-alias.element
|
|
52 | attribute-set.element
|
|
53 | variable.element
|
|
54 | param.element
|
|
55 | key.element
|
|
56 | decimal-format.element
|
|
57 | output.element
|
|
58 instruction.category =
|
|
59 apply-templates.element
|
|
60 | apply-imports.element
|
|
61 | call-template.element
|
|
62 | element.element
|
|
63 | attribute.element
|
|
64 | text.element
|
|
65 | processing-instruction.element
|
|
66 | comment.element
|
|
67 | copy.element
|
|
68 | value-of.element
|
|
69 | number.element
|
|
70 | for-each.element
|
|
71 | if.element
|
|
72 | choose.element
|
|
73 | variable.element
|
|
74 | copy-of.element
|
|
75 | message.element
|
|
76 | fallback.element
|
|
77 extension.atts = attribute * - (xsl:* | local:*) { text }*
|
|
78 stylesheet.element = element stylesheet { stylesheet.model }
|
|
79 transform.element = element transform { stylesheet.model }
|
|
80 stylesheet.model =
|
|
81 extension.atts,
|
|
82 attribute id { xsd:NCName }?,
|
|
83 attribute extension-element-prefixes { prefixes.datatype }?,
|
|
84 attribute exclude-result-prefixes { prefixes.datatype }?,
|
|
85 attribute version { version },
|
|
86 (import.element*, top-level-elements.model)
|
|
87 include.element =
|
|
88 element include {
|
|
89 extension.atts,
|
|
90 attribute href { xsd:anyURI }
|
|
91 }
|
|
92 import.element =
|
|
93 element import {
|
|
94 extension.atts,
|
|
95 attribute href { xsd:anyURI }
|
|
96 }
|
|
97 strip-space.element =
|
|
98 element strip-space {
|
|
99 extension.atts,
|
|
100 attribute elements { wildcards.datatype }
|
|
101 }
|
|
102 preserve-space.element =
|
|
103 element preserve-space {
|
|
104 extension.atts,
|
|
105 attribute elements { wildcards.datatype }
|
|
106 }
|
|
107 template.element =
|
|
108 element template {
|
|
109 extension.atts,
|
|
110 attribute match { pattern.datatype }?,
|
|
111 attribute name { qname.datatype }?,
|
|
112 attribute priority { number.datatype }?,
|
|
113 attribute mode { qname.datatype }?,
|
|
114 (param.element*, template.model)
|
|
115 }
|
|
116 apply-templates.element =
|
|
117 element apply-templates {
|
|
118 extension.atts,
|
|
119 attribute select { expression.datatype }?,
|
|
120 attribute mode { qname.datatype }?,
|
|
121 (sort.element | with-param.element)*
|
|
122 }
|
|
123 apply-imports.element = element apply-imports { extension.atts }
|
|
124 call-template.element =
|
|
125 element call-template {
|
|
126 extension.atts,
|
|
127 attribute name { qname.datatype },
|
|
128 with-param.element*
|
|
129 }
|
|
130 namespace-alias.element =
|
|
131 element namespace-alias {
|
|
132 extension.atts,
|
|
133 attribute stylesheet-prefix { prefix.datatype },
|
|
134 attribute result-prefix { prefix.datatype }
|
|
135 }
|
|
136 element.element =
|
|
137 element element {
|
|
138 extension.atts,
|
|
139 attribute name { qname.datatype | expr-avt.datatype },
|
|
140 attribute namespace { xsd:anyURI | brace-avt.datatype }?,
|
|
141 attribute use-attribute-sets { qnames.datatype }?,
|
|
142 template.model
|
|
143 }
|
|
144 attribute.element =
|
|
145 element attribute {
|
|
146 extension.atts,
|
|
147 attribute name { qname.datatype | expr-avt.datatype },
|
|
148 attribute namespace { xsd:anyURI | brace-avt.datatype }?,
|
|
149 template.model
|
|
150 }
|
|
151 attribute-set.element =
|
|
152 element attribute-set {
|
|
153 extension.atts,
|
|
154 attribute name { qname.datatype },
|
|
155 attribute use-attribute-sets { qnames.datatype }?,
|
|
156 attribute.element*
|
|
157 }
|
|
158 text.element =
|
|
159 element text {
|
|
160 extension.atts,
|
|
161 attribute disable-output-escaping {
|
|
162 xsd:string "yes" | xsd:string "no"
|
|
163 }?,
|
|
164 text
|
|
165 }
|
|
166 processing-instruction.element =
|
|
167 element processing-instruction {
|
|
168 extension.atts,
|
|
169 attribute name { xsd:NCName | expr-avt.datatype },
|
|
170 template.model
|
|
171 }
|
|
172 comment.element = element comment { extension.atts, template.model }
|
|
173 copy.element =
|
|
174 element copy {
|
|
175 extension.atts,
|
|
176 attribute use-attribute-sets { qnames.datatype }?,
|
|
177 template.model
|
|
178 }
|
|
179 value-of.element =
|
|
180 element value-of {
|
|
181 extension.atts,
|
|
182 attribute select { expression.datatype },
|
|
183 attribute disable-output-escaping {
|
|
184 xsd:string "yes" | xsd:string "no"
|
|
185 }?
|
|
186 }
|
|
187 number.element =
|
|
188 element number {
|
|
189 extension.atts,
|
|
190 attribute level {
|
|
191 xsd:string "single" | xsd:string "multiple" | xsd:string "any"
|
|
192 }?,
|
|
193 attribute count { pattern.datatype }?,
|
|
194 attribute from { pattern.datatype }?,
|
|
195 attribute value { expression.datatype }?,
|
|
196 attribute format { avt.datatype }?,
|
|
197 attribute lang { xsd:NMTOKEN | expr-avt.datatype }?,
|
|
198 attribute letter-value {
|
|
199 xsd:string "alphabetic"
|
|
200 | xsd:string "traditional"
|
|
201 | expr-avt.datatype
|
|
202 }?,
|
|
203 attribute grouping-separator { char.datatype | expr-avt.datatype }?,
|
|
204 attribute grouping-size { number.datatype | expr-avt.datatype }?
|
|
205 }
|
|
206 for-each.element =
|
|
207 element for-each {
|
|
208 extension.atts,
|
|
209 attribute select { expression.datatype },
|
|
210 (sort.element*, template.model)
|
|
211 }
|
|
212 if.element =
|
|
213 element if {
|
|
214 extension.atts,
|
|
215 attribute test { expression.datatype },
|
|
216 template.model
|
|
217 }
|
|
218 choose.element =
|
|
219 element choose { extension.atts, (when.element+, otherwise.element?) }
|
|
220 when.element =
|
|
221 element when {
|
|
222 extension.atts,
|
|
223 attribute test { expression.datatype },
|
|
224 template.model
|
|
225 }
|
|
226 otherwise.element = element otherwise { extension.atts, template.model }
|
|
227 sort.element =
|
|
228 element sort {
|
|
229 extension.atts,
|
|
230 attribute select { expression.datatype }?,
|
|
231 attribute lang { xsd:NMTOKEN | expr-avt.datatype }?,
|
|
232 attribute data-type {
|
|
233 xsd:string "text"
|
|
234 | xsd:string "number"
|
|
235 | qname-but-not-ncname.datatype
|
|
236 | expr-avt.datatype
|
|
237 }?,
|
|
238 attribute order {
|
|
239 xsd:string "ascending"
|
|
240 | xsd:string "descending"
|
|
241 | expr-avt.datatype
|
|
242 }?,
|
|
243 attribute case-order {
|
|
244 xsd:string "upper-first"
|
|
245 | xsd:string "lower-first"
|
|
246 | expr-avt.datatype
|
|
247 }?
|
|
248 }
|
|
249 variable.element =
|
|
250 element variable {
|
|
251 extension.atts,
|
|
252 attribute name { qname.datatype },
|
|
253 (attribute select { expression.datatype }
|
|
254 | template.model)
|
|
255 }
|
|
256 param.element =
|
|
257 element param {
|
|
258 extension.atts,
|
|
259 attribute name { qname.datatype },
|
|
260 (attribute select { expression.datatype }
|
|
261 | template.model)
|
|
262 }
|
|
263 copy-of.element =
|
|
264 element copy-of {
|
|
265 extension.atts,
|
|
266 attribute select { expression.datatype }
|
|
267 }
|
|
268 with-param.element =
|
|
269 element with-param {
|
|
270 extension.atts,
|
|
271 attribute name { qname.datatype },
|
|
272 (attribute select { expression.datatype }
|
|
273 | template.model)
|
|
274 }
|
|
275 key.element =
|
|
276 element key {
|
|
277 extension.atts,
|
|
278 attribute name { qname.datatype },
|
|
279 attribute match { pattern.datatype },
|
|
280 attribute use { expression.datatype }
|
|
281 }
|
|
282 decimal-format.element =
|
|
283 element decimal-format {
|
|
284 extension.atts,
|
|
285 attribute name { qname.datatype }?,
|
|
286 attribute decimal-separator { char.datatype }?,
|
|
287 attribute grouping-separator { char.datatype }?,
|
|
288 attribute infinity { text }?,
|
|
289 attribute minus-sign { char.datatype }?,
|
|
290 attribute NaN { text }?,
|
|
291 attribute percent { char.datatype }?,
|
|
292 attribute per-mille { char.datatype }?,
|
|
293 attribute zero-digit { char.datatype }?,
|
|
294 attribute digit { char.datatype }?,
|
|
295 attribute pattern-separator { char.datatype }?
|
|
296 }
|
|
297 message.element =
|
|
298 element message {
|
|
299 extension.atts,
|
|
300 attribute terminate { xsd:string "yes" | xsd:string "no" }?,
|
|
301 template.model
|
|
302 }
|
|
303 fallback.element = element fallback { extension.atts, template.model }
|
|
304 output.element =
|
|
305 element output {
|
|
306 extension.atts,
|
|
307 attribute method {
|
|
308 xsd:string "xml"
|
|
309 | xsd:string "html"
|
|
310 | xsd:string "text"
|
|
311 | qname-but-not-ncname.datatype
|
|
312 }?,
|
|
313 attribute version { xsd:NMTOKEN }?,
|
|
314 attribute encoding { text }?,
|
|
315 attribute omit-xml-declaration {
|
|
316 xsd:string "yes" | xsd:string "no"
|
|
317 }?,
|
|
318 attribute standalone { xsd:string "yes" | xsd:string "no" }?,
|
|
319 attribute doctype-public { text }?,
|
|
320 attribute doctype-system { text }?,
|
|
321 attribute cdata-section-elements { qnames.datatype }?,
|
|
322 attribute indent { xsd:string "yes" | xsd:string "no" }?,
|
|
323 attribute media-type { text }?
|
|
324 }
|
|
325 prefixes.datatype = list { (xsd:NCName | "#default")* }
|
|
326 prefix.datatype = xsd:NCName | "#default"
|
|
327 wildcards.datatype =
|
|
328 list {
|
|
329 (xsd:QName
|
|
330 | xsd:token { pattern = "\*|\i\c*:\*" })*
|
|
331 }
|
|
332 qname.datatype = xsd:QName
|
|
333 qnames.datatype = list { xsd:QName* }
|
|
334 char.datatype = xsd:string { length = "1" }
|
|
335 number.datatype = xsd:decimal
|
|
336 expression.datatype = text
|
|
337 pattern.datatype = text
|
|
338 qname-but-not-ncname.datatype = xsd:QName { pattern = ".*:.*" }
|
|
339 # An AVT containing at least one expression.
|
|
340 expr-avt.datatype =
|
|
341 xsd:string {
|
|
342 pattern =
|
|
343 """([^\{\}]|\{\{|\}\})*\{([^"'\{\}]|"[^"]*"|'[^']*')+\}([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
|
|
344 }
|
|
345 # An AVT containing at least one brace; ie where instantiated AVT
|
|
346 # is not the same as the literal AVT.
|
|
347 brace-avt.datatype =
|
|
348 xsd:string {
|
|
349 pattern =
|
|
350 """[^\{\}]*(\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
|
|
351 }
|
|
352 avt.datatype =
|
|
353 xsd:string {
|
|
354 pattern =
|
|
355 """([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
|
|
356 }
|