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