Commit | Line | Data |
---|---|---|
8cd39fb3 MH |
1 | # |
2 | # RELAX NG Compact Schema for RDF/XML Syntax | |
3 | # | |
4 | # This schema is for information only and NON-NORMATIVE | |
5 | # | |
6 | # It is based on one originally written by James Clark in | |
7 | # http://lists.w3.org/Archives/Public/www-rdf-comments/2001JulSep/0248.html | |
8 | # and updated with later changes. | |
9 | # | |
10 | ||
11 | namespace local = "" | |
12 | namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
13 | datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes" | |
14 | ||
15 | ||
16 | start = doc | |
17 | ||
18 | ||
19 | # I cannot seem to do this in RNGC so they are expanded in-line | |
20 | ||
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 | ||
28 | # Also needed to allow rdf:li on all property element productions | |
29 | # since we can't capture the rdf:li rewriting to rdf_<n> in relaxng | |
30 | ||
31 | # Need to add these explicitly | |
32 | xmllang = attribute xml:lang { text } | |
33 | xmlbase = attribute xml:base { text } | |
34 | # and to forbid every other xml:* attribute, element | |
35 | ||
36 | doc = | |
37 | RDF | |
38 | ||
39 | RDF = | |
40 | element rdf:RDF { | |
41 | xmllang?, xmlbase?, nodeElementList | |
42 | } | |
43 | ||
44 | nodeElementList = | |
45 | nodeElement* | |
46 | ||
47 | # Should be something like: | |
48 | # ws* , ( nodeElement , ws* )* | |
49 | # but RELAXNG does this by default, ignoring whitespace separating tags. | |
50 | ||
51 | nodeElement = | |
52 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
53 | rdf:resource | rdf:nodeID | rdf:datatype | rdf:li | | |
54 | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID ) { | |
55 | (idAttr | nodeIdAttr | aboutAttr )?, xmllang?, xmlbase?, propertyAttr*, propertyEltList | |
56 | } | |
57 | ||
58 | # It is not possible to say "and not things | |
59 | # beginning with _ in the rdf: namespace" in RELAX NG. | |
60 | ||
61 | ws = | |
62 | " " | |
63 | ||
64 | # Not used in this RELAX NG schema; but should be any legal XML | |
65 | # whitespace defined by http://www.w3.org/TR/2000/REC-xml-20001006#NT-S | |
66 | ||
67 | ||
68 | propertyEltList = | |
69 | propertyElt* | |
70 | ||
71 | # Should be something like: | |
72 | # ws* , ( propertyElt , ws* )* | |
73 | # but RELAXNG does this by default, ignoring whitespace separating tags. | |
74 | ||
75 | propertyElt = | |
76 | resourcePropertyElt | | |
77 | literalPropertyElt | | |
78 | parseTypeLiteralPropertyElt | | |
79 | parseTypeResourcePropertyElt | | |
80 | parseTypeCollectionPropertyElt | | |
81 | parseTypeOtherPropertyElt | | |
82 | emptyPropertyElt | |
83 | ||
84 | resourcePropertyElt = | |
85 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
86 | rdf:resource | rdf:nodeID | rdf:datatype | | |
87 | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID | | |
88 | xml:* ) { | |
89 | idAttr?, xmllang?, xmlbase?, nodeElement | |
90 | } | |
91 | ||
92 | literalPropertyElt = | |
93 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
94 | rdf:resource | rdf:nodeID | rdf:datatype | | |
95 | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID | | |
96 | xml:* ) { | |
97 | (idAttr | datatypeAttr )?, xmllang?, xmlbase?, text | |
98 | } | |
99 | ||
100 | parseTypeLiteralPropertyElt = | |
101 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
102 | rdf:resource | rdf:nodeID | rdf:datatype | | |
103 | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID | | |
104 | xml:* ) { | |
105 | idAttr?, parseLiteral, xmllang?, xmlbase?, literal | |
106 | } | |
107 | ||
108 | parseTypeResourcePropertyElt = | |
109 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
110 | rdf:resource | rdf:nodeID | rdf:datatype | | |
111 | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID | | |
112 | xml:* ) { | |
113 | idAttr?, parseResource, xmllang?, xmlbase?, propertyEltList | |
114 | } | |
115 | ||
116 | parseTypeCollectionPropertyElt = | |
117 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
118 | rdf:resource | rdf:nodeID | rdf:datatype | | |
119 | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID | | |
120 | xml:* ) { | |
121 | idAttr?, xmllang?, xmlbase?, parseCollection, nodeElementList | |
122 | } | |
123 | ||
124 | parseTypeOtherPropertyElt = | |
125 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
126 | rdf:resource | rdf:nodeID | rdf:datatype | | |
127 | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID | | |
128 | xml:* ) { | |
129 | idAttr?, xmllang?, xmlbase?, parseOther, any | |
130 | } | |
131 | ||
132 | emptyPropertyElt = | |
133 | element * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
134 | rdf:resource | rdf:nodeID | rdf:datatype | | |
135 | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | rdf:bagID | | |
136 | xml:* ) { | |
137 | idAttr?, (resourceAttr | nodeIdAttr)?, xmllang?, xmlbase?, propertyAttr* | |
138 | } | |
139 | ||
140 | idAttr = | |
141 | attribute rdf:ID { | |
142 | IDsymbol | |
143 | } | |
144 | ||
145 | nodeIdAttr = | |
146 | attribute rdf:nodeID { | |
147 | IDsymbol | |
148 | } | |
149 | ||
150 | aboutAttr = | |
151 | attribute rdf:about { | |
152 | URI-reference | |
153 | } | |
154 | ||
155 | propertyAttr = | |
156 | attribute * - ( local:* | rdf:RDF | rdf:ID | rdf:about | rdf:parseType | | |
157 | rdf:resource | rdf:nodeID | rdf:datatype | rdf:li | | |
158 | rdf:Description | rdf:aboutEach | | |
159 | rdf:aboutEachPrefix | rdf:bagID | | |
160 | xml:* ) { | |
161 | string | |
162 | } | |
163 | ||
164 | resourceAttr = | |
165 | attribute rdf:resource { | |
166 | URI-reference | |
167 | } | |
168 | ||
169 | datatypeAttr = | |
170 | attribute rdf:datatype { | |
171 | URI-reference | |
172 | } | |
173 | ||
174 | parseLiteral = | |
175 | attribute rdf:parseType { | |
176 | "Literal" | |
177 | } | |
178 | ||
179 | parseResource = | |
180 | attribute rdf:parseType { | |
181 | "Resource" | |
182 | } | |
183 | ||
184 | parseCollection = | |
185 | attribute rdf:parseType { | |
186 | "Collection" | |
187 | } | |
188 | ||
189 | parseOther = | |
190 | attribute rdf:parseType { | |
191 | text | |
192 | } | |
193 | ||
194 | URI-reference = | |
195 | string | |
196 | ||
197 | literal = | |
198 | any | |
199 | ||
200 | IDsymbol = | |
201 | xsd:NMTOKEN | |
202 | ||
203 | any = | |
204 | mixed { element * { attribute * { text }*, any }* } | |
205 |