xslt.rnc 10 KB

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