domain.rng 9.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<!--
   - domain.rng
   -
   - Version 4.0
   -
   - This work is released by the MAS Working Group of oneM2M, December 2018.
   - The work is created and released under the 3-Clause BSD License.
   - See the license text at [https://opensource.org/licenses/BSD-3-Clause for
   - full details.
   -->

<grammar xmlns="http://relaxng.org/ns/structure/1.0"
	datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
 

	<start>
		<ref name="Domain"/>
	</start>


	<define name="Domain">
		<element name="Domain">
			<optional>
				<attribute name="xml:base">
					<data type="anyURI"/>
				</attribute>
			</optional>
			<attribute name="id">
ankraft's avatar
ankraft committed
29
				<data type="Name"/>
30
			</attribute>
31 32 33 34 35
			<optional>
				<attribute name="semanticURI">
					<data type="anyURI"/>
				</attribute>
			</optional>
36 37 38 39 40 41 42 43
			<ref name="DocDef"/>
			<optional>
				<element name="Imports">
					<oneOrMore>
						<ref name="Domain"/>
					</oneOrMore>
				</element>
			</optional>
44 45 46 47 48 49 50
			<optional>
				<element name="DataTypes">
					<oneOrMore>
						<ref name="DataTypeDef"/>
					</oneOrMore>
				</element>
			</optional>
51
			<optional>
52
				<ref name="ModuleClasses"/>
53 54
			</optional>
			<optional>
55
				<element name="DeviceClasses">
56
					<oneOrMore>
57
						<element name="DeviceClass">
58 59 60
							<attribute name="id">
								<data type="Name"/>
							</attribute>
61 62 63 64 65
							<optional>
								<attribute name="semanticURI">
									<data type="anyURI"/>
								</attribute>
							</optional>
66 67 68 69 70
							<ref name="DocDef"/>
							<optional>
								<ref name="PropertiesDef"/>
							</optional>
							<optional>
71
								<ref name="ModuleClasses"/>
72 73 74 75 76 77 78 79
							</optional>
							<optional>
								<element name="SubDevices">
									<oneOrMore>
										<element name="SubDevice">
											<attribute name="id">
												<data type="Name"/>
											</attribute>
80 81 82 83 84
											<optional>
												<attribute name="semanticURI">
													<data type="anyURI"/>
												</attribute>
											</optional>
85 86 87 88 89
											<ref name="DocDef"/>
											<optional>
												<ref name="PropertiesDef"/>
											</optional>
											<optional>
90
												<ref name="ModuleClasses"/>
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
											</optional>
										</element>
									</oneOrMore>
								</element>
							</optional>
						</element>
					</oneOrMore>
				</element>
			</optional>
		</element>
	</define>


	<define name="PropertiesDef">
		<element name="Properties">
			<oneOrMore>
				<element name="Property">
					<attribute name="name">
109
						<data type="Name"/>
110 111 112 113 114 115 116 117 118 119 120
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
					<optional>
						<attribute name="value">
							<text/>
						</attribute>
					</optional>
121 122 123 124 125
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
126 127 128 129 130 131 132 133 134 135 136 137
					<ref name="DocDef"/>
					<ref name="SimpleType" />
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="DataTypeDef">
		<element name="DataType">
			<optional>
				<attribute name="name">
138
					<data type="Name"/>
139 140 141 142 143 144 145
				</attribute>
			</optional>
			<optional>
				<attribute name="unitOfMeasure">
					<text/>
				</attribute>
			</optional>
146 147 148 149 150
			<optional>
				<attribute name="semanticURI">
					<data type="anyURI"/>
				</attribute>
			</optional>
151 152
			<ref name="DocDef"/>
			<choice>
153 154 155 156 157 158 159
				<ref name="ExtendsDef" />
				<choice>
					<ref name="StructType" />
					<ref name="ArrayType" />
					<ref name="SimpleType" />
					<ref name="EnumType" />
				</choice>
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
			</choice>
			<optional>
				<ref name="ConstraintsDef"/>
			</optional>
		</element>
	</define>


	<define name="StructType">
		<element name="Struct">
			<oneOrMore>
				<ref name="DataTypeDef" />
			</oneOrMore>
		</element>
	</define>


	<define name="ArrayType">
		<element name="Array">
			<ref name="DataTypeDef" />
		</element>
	</define>


	<define name="SimpleType">
		<element name="SimpleType">
			<attribute name="type">
				<ref name="BasicType" />
			</attribute>
		</element>
	</define>
191 192 193 194 195 196 197 198 199
	

	<define name="EnumType">
		<element name="EnumType">
			<oneOrMore>
				<ref name="EnumValueDef" />
			</oneOrMore>
		</element>
	</define>
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214


	<define name="BasicType">
		<choice>
			<value>integer</value>
			<value>boolean</value>
			<value>string</value>
			<value>byte</value>
			<value>float</value>
			<value>array</value>
			<value>date</value>
			<value>time</value>
			<value>datetime</value>
			<value>blob</value>
			<value>uri</value>
215
			<value>void</value>
216 217 218 219
		</choice>
	</define>


220 221 222
	<define name="EnumValueDef">
		<element name="EnumValue">
			<attribute name="name">
223
				<data type="Name"/>
224 225 226 227 228 229 230 231 232
			</attribute>
			<attribute name="value">
				<text/>
			</attribute>
			<optional>
				<attribute name="type">
					<ref name="BasicType"/>
				</attribute>
			</optional>
233 234 235 236 237
			<optional>
				<attribute name="semanticURI">
					<data type="anyURI"/>
				</attribute>
			</optional>
238 239 240 241
			<ref name="DocDef"/>
		</element>
	</define>

242

243 244 245 246 247
	<define name="ConstraintsDef">
		<element name="Constraints">
			<oneOrMore>
				<element name="Constraint">
					<attribute name="name">
248
						<data type="Name"/>
249 250 251 252 253 254 255 256 257 258 259
					</attribute>
					<optional>
						<attribute name="type">
							<ref name="BasicType" />
						</attribute>
					</optional>
					<optional>
						<attribute name="value">
							<text/>
						</attribute>
					</optional>
260 261 262 263 264
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>					
265 266 267 268 269 270
					<ref name="DocDef"/>
				</element>
			</oneOrMore>
		</element>
	</define>

271

272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
	<define name="DocText">
		<zeroOrMore>
			<choice>
				<text/>
				<element name="em">
					<text/>
				</element>
				<element name="b">
					<text/>
				</element>
				<element name="tt">
					<text/>
				</element>
			</choice>
		</zeroOrMore>
	</define>


	<!-- <Doc> element is always optional -->
	<define name="DocDef">
		<optional>
			<element name="Doc">
				<choice>
					<ref name="DocText"/>
					<zeroOrMore>
						<choice>
							<element name="p">
								<ref name="DocText"/>
							</element>
							<element name="img">
								<attribute name="src"/>
								<element name="caption">
									<text/>
								</element>
							</element>
						</choice>
					</zeroOrMore>
				</choice>
			</element>
		</optional>
	</define>


315 316
	<define name="ModuleClasses">
		<element name="ModuleClasses">
317
			<oneOrMore>
318 319
				<element name="ModuleClass">
					<attribute name="name">
320
						<data type="Name"/>
321 322 323 324 325 326
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
327 328 329 330 331
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
332
					<ref name="DocDef"/>
333
					<ref name="ExtendsDef" /> <!-- TODO: singular -->
334 335 336 337 338 339 340 341 342 343 344 345
					<optional>
						<ref name="PropertiesDef"/>
					</optional>
					<optional>
						<ref name="Actions"/>
					</optional>
					<optional>
						<ref name="Data"/>
					</optional>
					<optional>
						<ref name="Events"/>
					</optional>
346 347 348 349 350 351 352 353 354 355 356
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="Actions">
		<element name="Actions">
			<oneOrMore>
				<element name="Action">
					<attribute name="name">
357
						<data type="Name"/>
358 359 360 361 362 363
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
364 365 366 367 368
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
					<ref name="DocDef"/>
					<optional>
						<ref name="DataTypeDef"/>
					</optional>
					<optional>
						<ref name="ArgDef" />
					</optional>
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="ArgDef">
		<element name="Args">
			<oneOrMore>
				<element name="Arg">
386 387 388
					<attribute name="name">
						<data type="Name"/>
					</attribute>
389 390 391 392 393
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
394 395 396 397 398 399 400 401 402 403 404 405 406
					<ref name="DocDef"/>
					<ref name="DataTypeDef"/>
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="Data">
		<element name="Data">
			<oneOrMore>
				<element name="DataPoint">
					<attribute name="name">
407
						<data type="Name"/>
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
					<optional>
						<attribute name="writable">
							<data type="boolean"/>
						</attribute>
					</optional>
					<optional>
						<attribute name="readable">
							<data type="boolean"/>
						</attribute>
					</optional>
					<optional>
						<attribute name="eventable">
							<data type="boolean"/>
						</attribute>
					</optional>
429 430 431 432 433
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
434 435 436 437 438 439 440 441 442 443 444 445 446
					<ref name="DocDef"/>
					<ref name="DataTypeDef"/>
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="Events">
		<element name="Events">
			<oneOrMore>
				<element name="Event">
					<attribute name="name">
447
						<data type="Name"/>
448 449 450 451 452 453
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
454 455 456 457 458
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
459 460 461 462 463 464 465 466 467
					<ref name="DocDef"/>
					<optional>
						<ref name="Data" />
					</optional>
				</element>
			</oneOrMore>
		</element>
	</define>

468

469 470 471 472
	<define name="ExtendsDef"> <!-- TODO: singular -->
		<optional>
			<element name="extends"> <!-- TODO: Uppercase , singular-->
				<attribute name="domain">
ankraft's avatar
ankraft committed
473
					<data type="Name"/>
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
				</attribute>
				<attribute name="class"/>
				<optional>
					<element name="excludes"> <!-- TODO: Uppercase + "...s" -> Excludes-->
						<oneOrMore>
							<element name="exclude">
								<attribute name="name">
									<text/>
								</attribute>
								<attribute name="type">
									<text/> <!-- TODO: add ExcludeTypes -->
								</attribute>
							</element>
						</oneOrMore>
					</element>
				</optional>
			</element>
		</optional>
492 493
	</define>

494 495
</grammar>