locate.rnc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. # Copyright (C) 2003-2004, 2007-2012 Free Software Foundation, Inc.
  2. # This file is part of GNU Emacs.
  3. # GNU Emacs is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. # GNU Emacs is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  13. default namespace this = "http://thaiopensource.com/ns/locating-rules/1.0"
  14. namespace local = ""
  15. start = locatingRules
  16. locatingRules = element locatingRules { common, rule* }
  17. rule =
  18. \include
  19. # | group
  20. | applyFollowingRules
  21. | documentElement
  22. # | doctypePublicId
  23. | \namespace
  24. | uri
  25. | transformURI
  26. # | typeIdProcessingInstruction
  27. | \default
  28. | typeId
  29. # | typeIdBase
  30. | extensionRule
  31. ## Group of rules. Useful with xml:base.
  32. group = element group { common, rule* }
  33. \include =
  34. element include {
  35. common,
  36. attribute rules { xsd:anyURI }
  37. }
  38. applyFollowingRules =
  39. element applyFollowingRules {
  40. common,
  41. attribute ruleType {
  42. "documentElement"
  43. | "doctypePublicId"
  44. | "namespace"
  45. | "uri"
  46. | "transformURI"
  47. | "typeIdProcessingInstruction"
  48. | "default"
  49. }
  50. }
  51. documentElement =
  52. ## Matches if the prefix and/or local name of document element
  53. ## match the values of the prefix and localName attributes.
  54. element documentElement {
  55. common,
  56. nameAtts,
  57. targetAtt
  58. }
  59. ## If there's no prefix attribute, then only the local name must match.
  60. ## If there's no local name attribute, then only the prefix must match.
  61. nameAtts = (prefixAtt, localNameAtt?) | localNameAtt
  62. ## prefix="" matches if the document element has no prefix.
  63. prefixAtt = attribute prefix { (xsd:NCName - "xmlns") | "" }
  64. localNameAtt = attribute localName { xsd:NCName - "xmlns" }
  65. doctypePublicId =
  66. ## Matches if the document has a DOCTYPE declaration with a public
  67. ## identifier that, after normalization, matches the value of the
  68. ## publicId attribute.
  69. element doctypePublicId {
  70. common,
  71. attribute publicId { publicIdValue },
  72. targetAtt
  73. }
  74. publicIdValue =
  75. xsd:token {
  76. ## Newline and tab are excluded, because pattern applies to
  77. ## the post-normalization value.
  78. pattern = "[\-'()+,./:=?;!*#@$_%a-zA-Z0-9 ]*"
  79. }
  80. # This is separate from documentElement so it can be distinguished
  81. # by applyFollowingRules.
  82. \namespace =
  83. ## Matches if the document element has a namespace URI equal to the value
  84. ## of the ns attribute. A document element with no namespace matches if
  85. ## the value of the ns attribute is the empty string.
  86. element namespace {
  87. common,
  88. attribute ns { xsd:string },
  89. targetAtt
  90. }
  91. uri =
  92. ## Matches based on the URI of the document.
  93. element uri {
  94. common,
  95. (resourceAtt | patternAtt),
  96. targetAtt
  97. }
  98. ## Matches if it can be determined that the document resource is
  99. ## the same resource as that identified by the value of the resource
  100. ## attribute. In determining this, the implementation should apply
  101. ## the semantics of the URI scheme used by the URI.
  102. resourceAtt = attribute resource { xsd:anyURI }
  103. ## Matches if the document's URI matches the pattern specified
  104. ## by the pattern attribute. A * in the path component matches
  105. ## zero or more characters other than / (after resolving escapes).
  106. ## If the pattern is a relative URI, it means that there must
  107. ## be some URI such that when the pattern is resolved relative
  108. ## to that URI, it matches the document's URI. Thus an empty
  109. ## pattern will always match.
  110. patternAtt = attribute pattern { uriPattern }
  111. ## A pattern for a URI. Same syntax as a URI, except that a * in
  112. ## the path component has a special meaning.
  113. uriPattern = xsd:anyURI
  114. transformURI =
  115. ## Generates a URI for the related resource by transforming
  116. ## the URI of the document. Matches if the transformation
  117. ## yields a valid URI that identifies an existing resource.
  118. element transformURI {
  119. common,
  120. ## Semantics are the same as the pattern attribute of the uri element.
  121. attribute fromPattern { uriPattern },
  122. ## The result of the transformation is produced from the toPattern
  123. ## by replacing each * by the string that matched the corresponding
  124. ## * in the toPattern. The toPattern is appended to the initial
  125. ## part of the document's URI that was not explicitly matched
  126. ## by fromPattern.
  127. attribute toPattern { uriPattern }
  128. }
  129. \default =
  130. ## Always matches.
  131. element default {
  132. common,
  133. targetAtt
  134. }
  135. ## A document can be mapped onto a URI either indirectly via a typeId
  136. ## or directly.
  137. targetAtt = uriAtt | typeIdAtt
  138. ## Specifies the URI of the related resource.
  139. ## xml:base is used if it's relative.
  140. uriAtt = attribute uri { xsd:anyURI }
  141. ## Specifies an identifier of the type of document. typeId and
  142. ## typeIdBase rules will be used to map this to a URI.
  143. typeIdAtt = attribute typeId { typeIdValue }
  144. ## A type identifier can be anything convenient (e.g. a public identifier,
  145. ## a URL or just a string with no formal structure). Whitespace is
  146. ## normalized like a public identifier before comparing type identifiers
  147. ## for equality.
  148. typeIdValue = xsd:token
  149. typeIdProcessingInstruction =
  150. ## Matches if there's a processing instruction in the prolog
  151. ## before any DOCTYPE declaration whose target is the value of
  152. ## the target attribute. The value of the processing instruction
  153. ## is interpreted as a typeId, which will be mapped to a
  154. ## URI as normal.
  155. element typeIdProcessingInstruction {
  156. common,
  157. attribute target { xsd:NCName }
  158. }
  159. typeId =
  160. ## Maps a typeId onto a URI.
  161. element typeId {
  162. common,
  163. attribute id { typeIdValue },
  164. targetAtt
  165. }
  166. typeIdBase =
  167. ## Used to map a typeId onto a URI. First, any URI reserved characters
  168. ## are URI encoded. If the append attribute is specified, it is appended.
  169. ## This is then treated as a URI. If relative, it is resolved using
  170. ## the applicable base URI as usual. If the resulting URI identifies
  171. ## an existing resource, then the typeId is mapped to this resource.
  172. ## This is intended to be useful with file URIs.
  173. element typeIdBase {
  174. common,
  175. attribute append { xsd:string }?
  176. }
  177. extensionRule =
  178. element * - this:* {
  179. attribute * { text }*, (text|anyElement)*
  180. }
  181. anyElement = element * { attribute * { text }*, (text|anyElement)* }
  182. common =
  183. # attribute xml:base { xsd:anyURI }?,
  184. attribute * - (xml:base|this:*|local:*) { text }*