1 <?xml version=
"1.0" encoding=
"UTF-8"?>
4 RELAX NG Compact Syntax Grammar for the
5 Atom Format Specification Version 11
6 https://tools.ietf.org/html/rfc4287#appendix-B
8 <grammar ns=
"http://www.w3.org/1999/xhtml" xmlns:
atom=
"http://www.w3.org/2005/Atom" xmlns:
s=
"http://www.ascc.net/xml/schematron" xmlns:
xhtml=
"http://www.w3.org/1999/xhtml" xmlns=
"http://relaxng.org/ns/structure/1.0" datatypeLibrary=
"http://www.w3.org/2001/XMLSchema-datatypes">
11 <ref name=
"atomFeed"/>
12 <ref name=
"atomEntry"/>
15 <!-- Common attributes -->
16 <define name=
"atomCommonAttributes">
18 <attribute name=
"xml:base">
23 <attribute name=
"xml:lang">
24 <ref name=
"atomLanguageTag"/>
28 <ref name=
"undefinedAttribute"/>
31 <!-- Text Constructs -->
32 <define name=
"atomPlainTextConstruct">
33 <ref name=
"atomCommonAttributes"/>
35 <attribute name=
"type">
44 <define name=
"atomXHTMLTextConstruct">
45 <ref name=
"atomCommonAttributes"/>
46 <attribute name=
"type">
49 <ref name=
"xhtmlDiv"/>
51 <define name=
"atomTextConstruct">
53 <ref name=
"atomPlainTextConstruct"/>
54 <ref name=
"atomXHTMLTextConstruct"/>
57 <!-- Person Construct -->
58 <define name=
"atomPersonConstruct">
59 <ref name=
"atomCommonAttributes"/>
61 <element name=
"atom:name">
65 <element name=
"atom:uri">
70 <element name=
"atom:email">
71 <ref name=
"atomEmailAddress"/>
75 <ref name=
"extensionElement"/>
79 <!-- Date Construct -->
80 <define name=
"atomDateConstruct">
81 <ref name=
"atomCommonAttributes"/>
82 <data type=
"dateTime"/>
85 <define name=
"atomFeed">
86 <element name=
"atom:feed">
87 <s:rule context=
"atom:feed">
88 <s:assert test=
"atom:author or not(atom:entry[not(atom:author)])">An atom:feed must have an atom:author unless all of its atom:entry children have an atom:author.
</s:assert>
90 <ref name=
"atomCommonAttributes"/>
93 <ref name=
"atomAuthor"/>
96 <ref name=
"atomCategory"/>
99 <ref name=
"atomContributor"/>
102 <ref name=
"atomGenerator"/>
105 <ref name=
"atomIcon"/>
109 <ref name=
"atomLink"/>
112 <ref name=
"atomLogo"/>
115 <ref name=
"atomRights"/>
118 <ref name=
"atomSubtitle"/>
120 <ref name=
"atomTitle"/>
121 <ref name=
"atomUpdated"/>
123 <ref name=
"extensionElement"/>
127 <ref name=
"atomEntry"/>
132 <define name=
"atomEntry">
133 <element name=
"atom:entry">
134 <s:rule context=
"atom:entry">
135 <s:assert test=
"atom:link[@rel='alternate'] or atom:link[not(@rel)] or atom:content">An atom:entry must have at least one atom:link element with a rel attribute of 'alternate' or an atom:content.
</s:assert>
139 <s:rule context=
"atom:entry">
140 <s:assert test=
"atom:author or ../atom:author or atom:source/atom:author">An atom:entry must have an atom:author if its feed does not.
</s:assert>
144 <ref name=
"atomCommonAttributes"/>
147 <ref name=
"atomAuthor"/>
150 <ref name=
"atomCategory"/>
153 <ref name=
"atomContent"/>
156 <ref name=
"atomContributor"/>
160 <ref name=
"atomLink"/>
163 <ref name=
"atomPublished"/>
166 <ref name=
"atomRights"/>
169 <ref name=
"atomSource"/>
172 <ref name=
"atomSummary"/>
174 <ref name=
"atomTitle"/>
175 <ref name=
"atomUpdated"/>
177 <ref name=
"extensionElement"/>
182 <!-- atom:content -->
183 <define name=
"atomInlineTextContent">
184 <element name=
"atom:content">
185 <ref name=
"atomCommonAttributes"/>
187 <attribute name=
"type">
199 <define name=
"atomInlineXHTMLContent">
200 <element name=
"atom:content">
201 <ref name=
"atomCommonAttributes"/>
202 <attribute name=
"type">
205 <ref name=
"xhtmlDiv"/>
208 <define name=
"atomInlineOtherContent">
209 <element name=
"atom:content">
210 <ref name=
"atomCommonAttributes"/>
212 <attribute name=
"type">
213 <ref name=
"atomMediaType"/>
219 <ref name=
"anyElement"/>
224 <define name=
"atomOutOfLineContent">
225 <element name=
"atom:content">
226 <ref name=
"atomCommonAttributes"/>
228 <attribute name=
"type">
229 <ref name=
"atomMediaType"/>
232 <attribute name=
"src">
233 <ref name=
"atomUri"/>
238 <define name=
"atomContent">
240 <ref name=
"atomInlineTextContent"/>
241 <ref name=
"atomInlineXHTMLContent"/>
242 <ref name=
"atomInlineOtherContent"/>
243 <ref name=
"atomOutOfLineContent"/>
247 <define name=
"atomAuthor">
248 <element name=
"atom:author">
249 <ref name=
"atomPersonConstruct"/>
252 <!-- atom:category -->
253 <define name=
"atomCategory">
254 <element name=
"atom:category">
255 <ref name=
"atomCommonAttributes"/>
256 <attribute name=
"term"/>
258 <attribute name=
"scheme">
259 <ref name=
"atomUri"/>
263 <attribute name=
"label"/>
265 <ref name=
"undefinedContent"/>
268 <!-- atom:contributor -->
269 <define name=
"atomContributor">
270 <element name=
"atom:contributor">
271 <ref name=
"atomPersonConstruct"/>
274 <!-- atom:generator -->
275 <define name=
"atomGenerator">
276 <element name=
"atom:generator">
277 <ref name=
"atomCommonAttributes"/>
279 <attribute name=
"uri">
280 <ref name=
"atomUri"/>
284 <attribute name=
"version"/>
290 <define name=
"atomIcon">
291 <element name=
"atom:icon">
292 <ref name=
"atomCommonAttributes"/>
293 <ref name=
"atomUri"/>
297 <define name=
"atomId">
298 <element name=
"atom:id">
299 <ref name=
"atomCommonAttributes"/>
300 <ref name=
"atomUri"/>
304 <define name=
"atomLogo">
305 <element name=
"atom:logo">
306 <ref name=
"atomCommonAttributes"/>
307 <ref name=
"atomUri"/>
311 <define name=
"atomLink">
312 <element name=
"atom:link">
313 <ref name=
"atomCommonAttributes"/>
314 <attribute name=
"href">
315 <ref name=
"atomUri"/>
318 <attribute name=
"rel">
320 <ref name=
"atomNCName"/>
321 <ref name=
"atomUri"/>
326 <attribute name=
"type">
327 <ref name=
"atomMediaType"/>
331 <attribute name=
"hreflang">
332 <ref name=
"atomLanguageTag"/>
336 <attribute name=
"title"/>
339 <attribute name=
"length"/>
341 <ref name=
"undefinedContent"/>
344 <!-- atom:published -->
345 <define name=
"atomPublished">
346 <element name=
"atom:published">
347 <ref name=
"atomDateConstruct"/>
351 <define name=
"atomRights">
352 <element name=
"atom:rights">
353 <ref name=
"atomTextConstruct"/>
357 <define name=
"atomSource">
358 <element name=
"atom:source">
359 <ref name=
"atomCommonAttributes"/>
362 <ref name=
"atomAuthor"/>
365 <ref name=
"atomCategory"/>
368 <ref name=
"atomContributor"/>
371 <ref name=
"atomGenerator"/>
374 <ref name=
"atomIcon"/>
380 <ref name=
"atomLink"/>
383 <ref name=
"atomLogo"/>
386 <ref name=
"atomRights"/>
389 <ref name=
"atomSubtitle"/>
392 <ref name=
"atomTitle"/>
395 <ref name=
"atomUpdated"/>
398 <ref name=
"extensionElement"/>
403 <!-- atom:subtitle -->
404 <define name=
"atomSubtitle">
405 <element name=
"atom:subtitle">
406 <ref name=
"atomTextConstruct"/>
409 <!-- atom:summary -->
410 <define name=
"atomSummary">
411 <element name=
"atom:summary">
412 <ref name=
"atomTextConstruct"/>
416 <define name=
"atomTitle">
417 <element name=
"atom:title">
418 <ref name=
"atomTextConstruct"/>
421 <!-- atom:updated -->
422 <define name=
"atomUpdated">
423 <element name=
"atom:updated">
424 <ref name=
"atomDateConstruct"/>
427 <!-- Low-level simple types -->
428 <define name=
"atomNCName">
430 <param name=
"minLength">1</param>
431 <param name=
"pattern">[^:]*
</param>
434 <!-- Whatever a media type is, it contains at least one slash -->
435 <define name=
"atomMediaType">
437 <param name=
"pattern">.+/.+
</param>
440 <!-- As defined in RFC 3066 -->
441 <define name=
"atomLanguageTag">
443 <param name=
"pattern">[A-Za-z]{
1,
8}(-[A-Za-z0-
9]{
1,
8})*
</param>
447 Unconstrained; it's not entirely clear how IRI fit into
448 xsd:anyURI so let's not try to constrain it here
450 <define name=
"atomUri">
453 <!-- Whatever an email address is, it contains at least one @ -->
454 <define name=
"atomEmailAddress">
456 <param name=
"pattern">.+@.+
</param>
459 <!-- Simple Extension -->
460 <define name=
"simpleExtensionElement">
464 <nsName ns=
"http://www.w3.org/2005/Atom"/>
470 <!-- Structured Extension -->
471 <define name=
"structuredExtensionElement">
475 <nsName ns=
"http://www.w3.org/2005/Atom"/>
488 <ref name=
"anyElement"/>
503 <ref name=
"anyElement"/>
508 <ref name=
"anyElement"/>
516 <!-- Other Extensibility -->
517 <define name=
"extensionElement">
519 <ref name=
"simpleExtensionElement"/>
520 <ref name=
"structuredExtensionElement"/>
523 <define name=
"undefinedAttribute">
527 <name>xml:base
</name>
528 <name>xml:lang
</name>
534 <define name=
"undefinedContent">
538 <ref name=
"anyForeignElement"/>
542 <define name=
"anyElement">
551 <ref name=
"anyElement"/>
556 <define name=
"anyForeignElement">
560 <nsName ns=
"http://www.w3.org/2005/Atom"/>
569 <ref name=
"anyElement"/>
575 <define name=
"anyXHTML">
584 <ref name=
"anyXHTML"/>
589 <define name=
"xhtmlDiv">
590 <element name=
"xhtml:div">
597 <ref name=
"anyXHTML"/>