rfc4287.rng 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. -*- rnc -*-
  4. RELAX NG Compact Syntax Grammar for the
  5. Atom Format Specification Version 11
  6. https://tools.ietf.org/html/rfc4287#appendix-B
  7. -->
  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">
  9. <start>
  10. <choice>
  11. <ref name="atomFeed"/>
  12. <ref name="atomEntry"/>
  13. </choice>
  14. </start>
  15. <!-- Common attributes -->
  16. <define name="atomCommonAttributes">
  17. <optional>
  18. <attribute name="xml:base">
  19. <ref name="atomUri"/>
  20. </attribute>
  21. </optional>
  22. <optional>
  23. <attribute name="xml:lang">
  24. <ref name="atomLanguageTag"/>
  25. </attribute>
  26. </optional>
  27. <zeroOrMore>
  28. <ref name="undefinedAttribute"/>
  29. </zeroOrMore>
  30. </define>
  31. <!-- Text Constructs -->
  32. <define name="atomPlainTextConstruct">
  33. <ref name="atomCommonAttributes"/>
  34. <optional>
  35. <attribute name="type">
  36. <choice>
  37. <value>text</value>
  38. <value>html</value>
  39. </choice>
  40. </attribute>
  41. </optional>
  42. <text/>
  43. </define>
  44. <define name="atomXHTMLTextConstruct">
  45. <ref name="atomCommonAttributes"/>
  46. <attribute name="type">
  47. <value>xhtml</value>
  48. </attribute>
  49. <ref name="xhtmlDiv"/>
  50. </define>
  51. <define name="atomTextConstruct">
  52. <choice>
  53. <ref name="atomPlainTextConstruct"/>
  54. <ref name="atomXHTMLTextConstruct"/>
  55. </choice>
  56. </define>
  57. <!-- Person Construct -->
  58. <define name="atomPersonConstruct">
  59. <ref name="atomCommonAttributes"/>
  60. <interleave>
  61. <element name="atom:name">
  62. <text/>
  63. </element>
  64. <optional>
  65. <element name="atom:uri">
  66. <ref name="atomUri"/>
  67. </element>
  68. </optional>
  69. <optional>
  70. <element name="atom:email">
  71. <ref name="atomEmailAddress"/>
  72. </element>
  73. </optional>
  74. <zeroOrMore>
  75. <ref name="extensionElement"/>
  76. </zeroOrMore>
  77. </interleave>
  78. </define>
  79. <!-- Date Construct -->
  80. <define name="atomDateConstruct">
  81. <ref name="atomCommonAttributes"/>
  82. <data type="dateTime"/>
  83. </define>
  84. <!-- atom:feed -->
  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>
  89. </s:rule>
  90. <ref name="atomCommonAttributes"/>
  91. <interleave>
  92. <zeroOrMore>
  93. <ref name="atomAuthor"/>
  94. </zeroOrMore>
  95. <zeroOrMore>
  96. <ref name="atomCategory"/>
  97. </zeroOrMore>
  98. <zeroOrMore>
  99. <ref name="atomContributor"/>
  100. </zeroOrMore>
  101. <optional>
  102. <ref name="atomGenerator"/>
  103. </optional>
  104. <optional>
  105. <ref name="atomIcon"/>
  106. </optional>
  107. <ref name="atomId"/>
  108. <zeroOrMore>
  109. <ref name="atomLink"/>
  110. </zeroOrMore>
  111. <optional>
  112. <ref name="atomLogo"/>
  113. </optional>
  114. <optional>
  115. <ref name="atomRights"/>
  116. </optional>
  117. <optional>
  118. <ref name="atomSubtitle"/>
  119. </optional>
  120. <ref name="atomTitle"/>
  121. <ref name="atomUpdated"/>
  122. <zeroOrMore>
  123. <ref name="extensionElement"/>
  124. </zeroOrMore>
  125. </interleave>
  126. <zeroOrMore>
  127. <ref name="atomEntry"/>
  128. </zeroOrMore>
  129. </element>
  130. </define>
  131. <!-- atom:entry -->
  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>
  136. </s:rule>
  137. <s:rule context="atom:entry">
  138. <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>
  139. </s:rule>
  140. <ref name="atomCommonAttributes"/>
  141. <interleave>
  142. <zeroOrMore>
  143. <ref name="atomAuthor"/>
  144. </zeroOrMore>
  145. <zeroOrMore>
  146. <ref name="atomCategory"/>
  147. </zeroOrMore>
  148. <optional>
  149. <ref name="atomContent"/>
  150. </optional>
  151. <zeroOrMore>
  152. <ref name="atomContributor"/>
  153. </zeroOrMore>
  154. <ref name="atomId"/>
  155. <zeroOrMore>
  156. <ref name="atomLink"/>
  157. </zeroOrMore>
  158. <optional>
  159. <ref name="atomPublished"/>
  160. </optional>
  161. <optional>
  162. <ref name="atomRights"/>
  163. </optional>
  164. <optional>
  165. <ref name="atomSource"/>
  166. </optional>
  167. <optional>
  168. <ref name="atomSummary"/>
  169. </optional>
  170. <ref name="atomTitle"/>
  171. <ref name="atomUpdated"/>
  172. <zeroOrMore>
  173. <ref name="extensionElement"/>
  174. </zeroOrMore>
  175. </interleave>
  176. </element>
  177. </define>
  178. <!-- atom:content -->
  179. <define name="atomInlineTextContent">
  180. <element name="atom:content">
  181. <ref name="atomCommonAttributes"/>
  182. <optional>
  183. <attribute name="type">
  184. <choice>
  185. <value>text</value>
  186. <value>html</value>
  187. </choice>
  188. </attribute>
  189. </optional>
  190. <zeroOrMore>
  191. <text/>
  192. </zeroOrMore>
  193. </element>
  194. </define>
  195. <define name="atomInlineXHTMLContent">
  196. <element name="atom:content">
  197. <ref name="atomCommonAttributes"/>
  198. <attribute name="type">
  199. <value>xhtml</value>
  200. </attribute>
  201. <ref name="xhtmlDiv"/>
  202. </element>
  203. </define>
  204. <define name="atomInlineOtherContent">
  205. <element name="atom:content">
  206. <ref name="atomCommonAttributes"/>
  207. <optional>
  208. <attribute name="type">
  209. <ref name="atomMediaType"/>
  210. </attribute>
  211. </optional>
  212. <zeroOrMore>
  213. <choice>
  214. <text/>
  215. <ref name="anyElement"/>
  216. </choice>
  217. </zeroOrMore>
  218. </element>
  219. </define>
  220. <define name="atomOutOfLineContent">
  221. <element name="atom:content">
  222. <ref name="atomCommonAttributes"/>
  223. <optional>
  224. <attribute name="type">
  225. <ref name="atomMediaType"/>
  226. </attribute>
  227. </optional>
  228. <attribute name="src">
  229. <ref name="atomUri"/>
  230. </attribute>
  231. <empty/>
  232. </element>
  233. </define>
  234. <define name="atomContent">
  235. <choice>
  236. <ref name="atomInlineTextContent"/>
  237. <ref name="atomInlineXHTMLContent"/>
  238. <ref name="atomInlineOtherContent"/>
  239. <ref name="atomOutOfLineContent"/>
  240. </choice>
  241. </define>
  242. <!-- atom:author -->
  243. <define name="atomAuthor">
  244. <element name="atom:author">
  245. <ref name="atomPersonConstruct"/>
  246. </element>
  247. </define>
  248. <!-- atom:category -->
  249. <define name="atomCategory">
  250. <element name="atom:category">
  251. <ref name="atomCommonAttributes"/>
  252. <attribute name="term"/>
  253. <optional>
  254. <attribute name="scheme">
  255. <ref name="atomUri"/>
  256. </attribute>
  257. </optional>
  258. <optional>
  259. <attribute name="label"/>
  260. </optional>
  261. <ref name="undefinedContent"/>
  262. </element>
  263. </define>
  264. <!-- atom:contributor -->
  265. <define name="atomContributor">
  266. <element name="atom:contributor">
  267. <ref name="atomPersonConstruct"/>
  268. </element>
  269. </define>
  270. <!-- atom:generator -->
  271. <define name="atomGenerator">
  272. <element name="atom:generator">
  273. <ref name="atomCommonAttributes"/>
  274. <optional>
  275. <attribute name="uri">
  276. <ref name="atomUri"/>
  277. </attribute>
  278. </optional>
  279. <optional>
  280. <attribute name="version"/>
  281. </optional>
  282. <text/>
  283. </element>
  284. </define>
  285. <!-- atom:icon -->
  286. <define name="atomIcon">
  287. <element name="atom:icon">
  288. <ref name="atomCommonAttributes"/>
  289. <ref name="atomUri"/>
  290. </element>
  291. </define>
  292. <!-- atom:id -->
  293. <define name="atomId">
  294. <element name="atom:id">
  295. <ref name="atomCommonAttributes"/>
  296. <ref name="atomUri"/>
  297. </element>
  298. </define>
  299. <!-- atom:logo -->
  300. <define name="atomLogo">
  301. <element name="atom:logo">
  302. <ref name="atomCommonAttributes"/>
  303. <ref name="atomUri"/>
  304. </element>
  305. </define>
  306. <!-- atom:link -->
  307. <define name="atomLink">
  308. <element name="atom:link">
  309. <ref name="atomCommonAttributes"/>
  310. <attribute name="href">
  311. <ref name="atomUri"/>
  312. </attribute>
  313. <optional>
  314. <attribute name="rel">
  315. <choice>
  316. <ref name="atomNCName"/>
  317. <ref name="atomUri"/>
  318. </choice>
  319. </attribute>
  320. </optional>
  321. <optional>
  322. <attribute name="type">
  323. <ref name="atomMediaType"/>
  324. </attribute>
  325. </optional>
  326. <optional>
  327. <attribute name="hreflang">
  328. <ref name="atomLanguageTag"/>
  329. </attribute>
  330. </optional>
  331. <optional>
  332. <attribute name="title"/>
  333. </optional>
  334. <optional>
  335. <attribute name="length"/>
  336. </optional>
  337. <ref name="undefinedContent"/>
  338. </element>
  339. </define>
  340. <!-- atom:published -->
  341. <define name="atomPublished">
  342. <element name="atom:published">
  343. <ref name="atomDateConstruct"/>
  344. </element>
  345. </define>
  346. <!-- atom:rights -->
  347. <define name="atomRights">
  348. <element name="atom:rights">
  349. <ref name="atomTextConstruct"/>
  350. </element>
  351. </define>
  352. <!-- atom:source -->
  353. <define name="atomSource">
  354. <element name="atom:source">
  355. <ref name="atomCommonAttributes"/>
  356. <interleave>
  357. <zeroOrMore>
  358. <ref name="atomAuthor"/>
  359. </zeroOrMore>
  360. <zeroOrMore>
  361. <ref name="atomCategory"/>
  362. </zeroOrMore>
  363. <zeroOrMore>
  364. <ref name="atomContributor"/>
  365. </zeroOrMore>
  366. <optional>
  367. <ref name="atomGenerator"/>
  368. </optional>
  369. <optional>
  370. <ref name="atomIcon"/>
  371. </optional>
  372. <optional>
  373. <ref name="atomId"/>
  374. </optional>
  375. <zeroOrMore>
  376. <ref name="atomLink"/>
  377. </zeroOrMore>
  378. <optional>
  379. <ref name="atomLogo"/>
  380. </optional>
  381. <optional>
  382. <ref name="atomRights"/>
  383. </optional>
  384. <optional>
  385. <ref name="atomSubtitle"/>
  386. </optional>
  387. <optional>
  388. <ref name="atomTitle"/>
  389. </optional>
  390. <optional>
  391. <ref name="atomUpdated"/>
  392. </optional>
  393. <zeroOrMore>
  394. <ref name="extensionElement"/>
  395. </zeroOrMore>
  396. </interleave>
  397. </element>
  398. </define>
  399. <!-- atom:subtitle -->
  400. <define name="atomSubtitle">
  401. <element name="atom:subtitle">
  402. <ref name="atomTextConstruct"/>
  403. </element>
  404. </define>
  405. <!-- atom:summary -->
  406. <define name="atomSummary">
  407. <element name="atom:summary">
  408. <ref name="atomTextConstruct"/>
  409. </element>
  410. </define>
  411. <!-- atom:title -->
  412. <define name="atomTitle">
  413. <element name="atom:title">
  414. <ref name="atomTextConstruct"/>
  415. </element>
  416. </define>
  417. <!-- atom:updated -->
  418. <define name="atomUpdated">
  419. <element name="atom:updated">
  420. <ref name="atomDateConstruct"/>
  421. </element>
  422. </define>
  423. <!-- Low-level simple types -->
  424. <define name="atomNCName">
  425. <data type="string">
  426. <param name="minLength">1</param>
  427. <param name="pattern">[^:]*</param>
  428. </data>
  429. </define>
  430. <!-- Whatever a media type is, it contains at least one slash -->
  431. <define name="atomMediaType">
  432. <data type="string">
  433. <param name="pattern">.+/.+</param>
  434. </data>
  435. </define>
  436. <!-- As defined in RFC 3066 -->
  437. <define name="atomLanguageTag">
  438. <data type="string">
  439. <param name="pattern">[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*</param>
  440. </data>
  441. </define>
  442. <!--
  443. Unconstrained; it's not entirely clear how IRI fit into
  444. xsd:anyURI so let's not try to constrain it here
  445. -->
  446. <define name="atomUri">
  447. <text/>
  448. </define>
  449. <!-- Whatever an email address is, it contains at least one @ -->
  450. <define name="atomEmailAddress">
  451. <data type="string">
  452. <param name="pattern">.+@.+</param>
  453. </data>
  454. </define>
  455. <!-- Simple Extension -->
  456. <define name="simpleExtensionElement">
  457. <element>
  458. <anyName>
  459. <except>
  460. <nsName ns="http://www.w3.org/2005/Atom"/>
  461. </except>
  462. </anyName>
  463. <text/>
  464. </element>
  465. </define>
  466. <!-- Structured Extension -->
  467. <define name="structuredExtensionElement">
  468. <element>
  469. <anyName>
  470. <except>
  471. <nsName ns="http://www.w3.org/2005/Atom"/>
  472. </except>
  473. </anyName>
  474. <choice>
  475. <group>
  476. <oneOrMore>
  477. <attribute>
  478. <anyName/>
  479. </attribute>
  480. </oneOrMore>
  481. <zeroOrMore>
  482. <choice>
  483. <text/>
  484. <ref name="anyElement"/>
  485. </choice>
  486. </zeroOrMore>
  487. </group>
  488. <group>
  489. <zeroOrMore>
  490. <attribute>
  491. <anyName/>
  492. </attribute>
  493. </zeroOrMore>
  494. <group>
  495. <optional>
  496. <text/>
  497. </optional>
  498. <oneOrMore>
  499. <ref name="anyElement"/>
  500. </oneOrMore>
  501. <zeroOrMore>
  502. <choice>
  503. <text/>
  504. <ref name="anyElement"/>
  505. </choice>
  506. </zeroOrMore>
  507. </group>
  508. </group>
  509. </choice>
  510. </element>
  511. </define>
  512. <!-- Other Extensibility -->
  513. <define name="extensionElement">
  514. <choice>
  515. <ref name="simpleExtensionElement"/>
  516. <ref name="structuredExtensionElement"/>
  517. </choice>
  518. </define>
  519. <define name="undefinedAttribute">
  520. <attribute>
  521. <anyName>
  522. <except>
  523. <name>xml:base</name>
  524. <name>xml:lang</name>
  525. <nsName ns=""/>
  526. </except>
  527. </anyName>
  528. </attribute>
  529. </define>
  530. <define name="undefinedContent">
  531. <zeroOrMore>
  532. <choice>
  533. <text/>
  534. <ref name="anyForeignElement"/>
  535. </choice>
  536. </zeroOrMore>
  537. </define>
  538. <define name="anyElement">
  539. <element>
  540. <anyName/>
  541. <zeroOrMore>
  542. <choice>
  543. <attribute>
  544. <anyName/>
  545. </attribute>
  546. <text/>
  547. <ref name="anyElement"/>
  548. </choice>
  549. </zeroOrMore>
  550. </element>
  551. </define>
  552. <define name="anyForeignElement">
  553. <element>
  554. <anyName>
  555. <except>
  556. <nsName ns="http://www.w3.org/2005/Atom"/>
  557. </except>
  558. </anyName>
  559. <zeroOrMore>
  560. <choice>
  561. <attribute>
  562. <anyName/>
  563. </attribute>
  564. <text/>
  565. <ref name="anyElement"/>
  566. </choice>
  567. </zeroOrMore>
  568. </element>
  569. </define>
  570. <!-- XHTML -->
  571. <define name="anyXHTML">
  572. <element>
  573. <nsName/>
  574. <zeroOrMore>
  575. <choice>
  576. <attribute>
  577. <anyName/>
  578. </attribute>
  579. <text/>
  580. <ref name="anyXHTML"/>
  581. </choice>
  582. </zeroOrMore>
  583. </element>
  584. </define>
  585. <define name="xhtmlDiv">
  586. <element name="xhtml:div">
  587. <zeroOrMore>
  588. <choice>
  589. <attribute>
  590. <anyName/>
  591. </attribute>
  592. <text/>
  593. <ref name="anyXHTML"/>
  594. </choice>
  595. </zeroOrMore>
  596. </element>
  597. </define>
  598. </grammar>
  599. <!-- EOF -->