rdfxml.rnc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. # RELAX NG Compact Schema for RDF/XML Syntax
  2. #
  3. # Copyright (C) 2001-2008 World Wide Web Consortium, (Massachusetts
  4. # Institute of Technology, European Research Consortium for
  5. # Informatics and Mathematics, Keio University). All Rights Reserved.
  6. # This work is distributed under the W3C(R) Software License in the
  7. # hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  8. # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  9. # PURPOSE.
  10. #
  11. # This schema is for information only and NON-NORMATIVE
  12. #
  13. # It is based on one originally written by James Clark in
  14. # http://lists.w3.org/Archives/Public/www-rdf-comments/2001JulSep/0248.html
  15. # and updated with later changes.
  16. namespace local = ""
  17. namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  18. datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
  19. start = doc
  20. # I cannot seem to do this in RNGC so they are expanded in-line
  21. # coreSyntaxTerms = rdf:RDF | rdf:ID | rdf:about | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype
  22. # syntaxTerms = coreSyntaxTerms | rdf:Description | rdf:li
  23. # oldTerms = rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID
  24. # nodeElementURIs = * - ( coreSyntaxTerms | rdf:li | oldTerms )
  25. # propertyElementURIs = * - ( coreSyntaxTerms | rdf:Description | oldTerms )
  26. # propertyAttributeURIs = * - ( coreSyntaxTerms | rdf:Description | rdf:li | oldTerms )
  27. # Also needed to allow rdf:li on all property element productions
  28. # since we can't capture the rdf:li rewriting to rdf_<n> in relaxng
  29. # Need to add these explicitly
  30. xmllang = attribute xml:lang { text }
  31. xmlbase = attribute xml:base { text }
  32. # and to forbid every other xml:* attribute, element
  33. doc =
  34. RDF
  35. RDF =
  36. element rdf:RDF {
  37. xmllang?, xmlbase?, nodeElementList
  38. }
  39. nodeElementList =
  40. nodeElement*
  41. # Should be something like:
  42. # ws* , ( nodeElement , ws* )*
  43. # but RELAXNG does this by default, ignoring whitespace separating tags.
  44. nodeElement =
  45. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  46. rdf:resource | rdf:nodeID | rdf:datatype | rdf:li |
  47. rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID ) {
  48. (idAttr | nodeIdAttr | aboutAttr )?, xmllang?, xmlbase?, propertyAttr*, propertyEltList
  49. }
  50. # It is not possible to say "and not things
  51. # beginning with _ in the rdf: namespace" in RELAX NG.
  52. ws =
  53. " "
  54. # Not used in this RELAX NG schema; but should be any legal XML
  55. # whitespace defined by http://www.w3.org/TR/2000/REC-xml-20001006#NT-S
  56. propertyEltList =
  57. propertyElt*
  58. # Should be something like:
  59. # ws* , ( propertyElt , ws* )*
  60. # but RELAXNG does this by default, ignoring whitespace separating tags.
  61. propertyElt =
  62. resourcePropertyElt |
  63. literalPropertyElt |
  64. parseTypeLiteralPropertyElt |
  65. parseTypeResourcePropertyElt |
  66. parseTypeCollectionPropertyElt |
  67. parseTypeOtherPropertyElt |
  68. emptyPropertyElt
  69. resourcePropertyElt =
  70. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  71. rdf:resource | rdf:nodeID | rdf:datatype |
  72. rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID |
  73. xml:* ) {
  74. idAttr?, xmllang?, xmlbase?, nodeElement
  75. }
  76. literalPropertyElt =
  77. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  78. rdf:resource | rdf:nodeID | rdf:datatype |
  79. rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID |
  80. xml:* ) {
  81. (idAttr | datatypeAttr )?, xmllang?, xmlbase?, text
  82. }
  83. parseTypeLiteralPropertyElt =
  84. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  85. rdf:resource | rdf:nodeID | rdf:datatype |
  86. rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID |
  87. xml:* ) {
  88. idAttr?, parseLiteral, xmllang?, xmlbase?, literal
  89. }
  90. parseTypeResourcePropertyElt =
  91. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  92. rdf:resource | rdf:nodeID | rdf:datatype |
  93. rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID |
  94. xml:* ) {
  95. idAttr?, parseResource, xmllang?, xmlbase?, propertyEltList
  96. }
  97. parseTypeCollectionPropertyElt =
  98. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  99. rdf:resource | rdf:nodeID | rdf:datatype |
  100. rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID |
  101. xml:* ) {
  102. idAttr?, xmllang?, xmlbase?, parseCollection, nodeElementList
  103. }
  104. parseTypeOtherPropertyElt =
  105. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  106. rdf:resource | rdf:nodeID | rdf:datatype |
  107. rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID |
  108. xml:* ) {
  109. idAttr?, xmllang?, xmlbase?, parseOther, any
  110. }
  111. emptyPropertyElt =
  112. element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  113. rdf:resource | rdf:nodeID | rdf:datatype |
  114. rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID |
  115. xml:* ) {
  116. idAttr?, (resourceAttr | nodeIdAttr)?, xmllang?, xmlbase?, propertyAttr*
  117. }
  118. idAttr =
  119. attribute rdf:ID {
  120. IDsymbol
  121. }
  122. nodeIdAttr =
  123. attribute rdf:nodeID {
  124. IDsymbol
  125. }
  126. aboutAttr =
  127. attribute rdf:about {
  128. URI-reference
  129. }
  130. propertyAttr =
  131. attribute * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType |
  132. rdf:resource | rdf:nodeID | rdf:datatype | rdf:li |
  133. rdf:Description | rdf:aboutEach |
  134. rdf:aboutEachPrefix | rdf:bagID |
  135. xml:* ) {
  136. string
  137. }
  138. resourceAttr =
  139. attribute rdf:resource {
  140. URI-reference
  141. }
  142. datatypeAttr =
  143. attribute rdf:datatype {
  144. URI-reference
  145. }
  146. parseLiteral =
  147. attribute rdf:parseType {
  148. "Literal"
  149. }
  150. parseResource =
  151. attribute rdf:parseType {
  152. "Resource"
  153. }
  154. parseCollection =
  155. attribute rdf:parseType {
  156. "Collection"
  157. }
  158. parseOther =
  159. attribute rdf:parseType {
  160. text
  161. }
  162. URI-reference =
  163. string
  164. literal =
  165. any
  166. IDsymbol =
  167. xsd:NMTOKEN
  168. any =
  169. mixed { element * { attribute * { text }*, any }* }