domain.rng 11.6 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>
ankraft's avatar
ankraft committed
52
				<ref name="ModuleClassesDef"/>
53 54
			</optional>
			<optional>
ankraft's avatar
ankraft committed
55 56 57
				<ref name="DeviceClassesDef" />
			</optional>
			<optional>
58
				<ref name="ProductClassesDef" />
59 60 61 62 63 64 65 66 67 68
			</optional>
		</element>
	</define>


	<define name="PropertiesDef">
		<element name="Properties">
			<oneOrMore>
				<element name="Property">
					<attribute name="name">
69
						<data type="Name"/>
70 71 72 73 74 75 76 77 78 79 80
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
					<optional>
						<attribute name="value">
							<text/>
						</attribute>
					</optional>
81 82 83 84 85
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
86 87 88 89 90 91 92 93 94 95 96 97
					<ref name="DocDef"/>
					<ref name="SimpleType" />
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="DataTypeDef">
		<element name="DataType">
			<optional>
				<attribute name="name">
98
					<data type="Name"/>
99 100 101 102 103 104 105
				</attribute>
			</optional>
			<optional>
				<attribute name="unitOfMeasure">
					<text/>
				</attribute>
			</optional>
106 107 108 109 110
			<optional>
				<attribute name="semanticURI">
					<data type="anyURI"/>
				</attribute>
			</optional>
111 112
			<ref name="DocDef"/>
			<choice>
ankraft's avatar
ankraft committed
113 114 115
				<optional>
					<ref name="ExtendDef" />
				</optional>
116 117 118 119 120 121
				<choice>
					<ref name="StructType" />
					<ref name="ArrayType" />
					<ref name="SimpleType" />
					<ref name="EnumType" />
				</choice>
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
			</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>
153 154 155
	

	<define name="EnumType">
156
		<element name="Enum">
157 158 159 160 161
			<oneOrMore>
				<ref name="EnumValueDef" />
			</oneOrMore>
		</element>
	</define>
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176


	<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>
177
			<value>void</value>
178 179 180 181
		</choice>
	</define>


182 183 184
	<define name="EnumValueDef">
		<element name="EnumValue">
			<attribute name="name">
185
				<data type="Name"/>
186 187 188 189 190 191 192 193 194
			</attribute>
			<attribute name="value">
				<text/>
			</attribute>
			<optional>
				<attribute name="type">
					<ref name="BasicType"/>
				</attribute>
			</optional>
195 196 197 198 199
			<optional>
				<attribute name="semanticURI">
					<data type="anyURI"/>
				</attribute>
			</optional>
200 201 202 203
			<ref name="DocDef"/>
		</element>
	</define>

204

205 206 207 208 209
	<define name="ConstraintsDef">
		<element name="Constraints">
			<oneOrMore>
				<element name="Constraint">
					<attribute name="name">
210
						<data type="Name"/>
211 212 213 214 215 216 217 218 219 220 221
					</attribute>
					<optional>
						<attribute name="type">
							<ref name="BasicType" />
						</attribute>
					</optional>
					<optional>
						<attribute name="value">
							<text/>
						</attribute>
					</optional>
222 223 224 225 226
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>					
227 228 229 230 231 232
					<ref name="DocDef"/>
				</element>
			</oneOrMore>
		</element>
	</define>

233

234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
	<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>


ankraft's avatar
ankraft committed
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 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
	<define name="DeviceClassesDef">
		<element name="DeviceClasses">
			<oneOrMore>
				<element name="DeviceClass">
					<attribute name="id">
						<data type="Name"/>
					</attribute>
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
					<ref name="DocDef"/>
					<optional>
						<ref name="PropertiesDef"/>
					</optional>
					<optional>
						<ref name="ModuleClassesDef"/>
					</optional>
					<optional>
						<ref name="SubDevicesRef" />
					</optional>
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="SubDevicesRef">
		<element name="SubDevices">
			<oneOrMore>
				<element name="SubDevice">
					<attribute name="id">
						<data type="Name"/>
					</attribute>
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
					<ref name="DocDef"/>
					<optional>
						<ref name="PropertiesDef"/>
					</optional>
					<optional>
						<ref name="ModuleClassesDef"/>
					</optional>
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="ModuleClassesDef">
331
		<element name="ModuleClasses">
332
			<oneOrMore>
333 334
				<element name="ModuleClass">
					<attribute name="name">
335
						<data type="Name"/>
336 337 338 339 340 341
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
342 343 344 345 346
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
347
					<ref name="DocDef"/>
ankraft's avatar
ankraft committed
348 349 350
					<optional>
						<ref name="ExtendDef" />
					</optional>
351 352 353 354 355 356 357 358 359 360 361 362
					<optional>
						<ref name="PropertiesDef"/>
					</optional>
					<optional>
						<ref name="Actions"/>
					</optional>
					<optional>
						<ref name="Data"/>
					</optional>
					<optional>
						<ref name="Events"/>
					</optional>
363 364 365 366 367 368
				</element>
			</oneOrMore>
		</element>
	</define>


369 370
	<define name="ProductClassesDef">
		<element name="ProductClasses">
ankraft's avatar
ankraft committed
371
			<oneOrMore>
372
				<element name="ProductClass">
ankraft's avatar
ankraft committed
373 374 375 376 377 378 379 380 381
					<attribute name="id">
						<data type="Name"/>
					</attribute>
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
					<ref name="DocDef"/>
382 383 384
					<optional>
						<ref name="ExtendDef" />
					</optional>
ankraft's avatar
ankraft committed
385 386 387 388 389 390 391 392 393
					<optional>
						<ref name="PropertiesDef"/>
					</optional>
					<optional>
						<ref name="ModuleClassesDef"/>
					</optional>
					<optional>
						<ref name="SubDevicesRef" />
					</optional>
394
					<optional>
395
						<element name="ExtendDevice">
396 397 398
							<ref name="ExtendDef" />
						</element>
					</optional>
ankraft's avatar
ankraft committed
399 400 401 402 403 404
				</element>
			</oneOrMore>
		</element>
	</define>


405 406 407 408 409
	<define name="Actions">
		<element name="Actions">
			<oneOrMore>
				<element name="Action">
					<attribute name="name">
410
						<data type="Name"/>
411 412 413 414 415 416
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
417 418 419 420 421
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
					<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">
439 440 441
					<attribute name="name">
						<data type="Name"/>
					</attribute>
442 443 444 445 446
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
447 448 449 450 451
					<optional>
						<attribute name="default">
							<text />
						</attribute>
					</optional>
452 453 454 455 456
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
457 458 459 460 461 462 463 464 465 466 467 468 469
					<ref name="DocDef"/>
					<ref name="DataTypeDef"/>
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="Data">
		<element name="Data">
			<oneOrMore>
				<element name="DataPoint">
					<attribute name="name">
470
						<data type="Name"/>
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
					</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>
492 493 494 495 496
					<optional>
						<attribute name="default">
							<text />
						</attribute>
					</optional>
497 498 499 500 501
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
502 503 504 505 506 507 508 509 510 511 512 513 514
					<ref name="DocDef"/>
					<ref name="DataTypeDef"/>
				</element>
			</oneOrMore>
		</element>
	</define>


	<define name="Events">
		<element name="Events">
			<oneOrMore>
				<element name="Event">
					<attribute name="name">
515
						<data type="Name"/>
516 517 518 519 520 521
					</attribute>
					<optional>
						<attribute name="optional">
							<data type="boolean"/>
						</attribute>
					</optional>
522 523 524 525 526
					<optional>
						<attribute name="semanticURI">
							<data type="anyURI"/>
						</attribute>
					</optional>
527 528 529 530 531 532 533 534 535
					<ref name="DocDef"/>
					<optional>
						<ref name="Data" />
					</optional>
				</element>
			</oneOrMore>
		</element>
	</define>

536

537
	<define name="ExtendDef">
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
		<element name="Extend">
			<ref name="ExtendBodyDef" />
		</element>
	</define>


	<define name="ExtendBodyDef">
		<attribute name="domain">
			<data type="Name"/>
		</attribute>
		<attribute name="entity">
			<data type="Name"/>
		</attribute>
		<optional>
			<choice>
				<oneOrMore>
					<element name="Exclude">
						<attribute name="name">
							<data type="Name"/>
						</attribute>
						<attribute name="type">
							<ref name="ExtendType" />
						</attribute>
					</element>
				</oneOrMore>
				<oneOrMore>
					<element name="Include">
						<attribute name="name">
							<data type="Name"/>
						</attribute>
						<attribute name="type">
							<ref name="ExtendType" />
						</attribute>
					</element>
				</oneOrMore>
			</choice>
		</optional>
575 576
	</define>

577 578 579 580 581 582 583 584 585 586 587 588 589

	<define name="ExtendType">
		<choice>
			<value>action</value>
			<value>datapoint</value>
			<value>event</value>
			<value>moduleclass</value>
			<value>property</value>
			<value>device</value>
			<value>subdevice</value>
		</choice>
	</define>

590 591
</grammar>