From 89325bfdf70c95d2aec76a60224daaf9e9424d2a Mon Sep 17 00:00:00 2001 From: ankraft <an.kraft@googlemail.com> Date: Wed, 30 Jan 2019 15:43:24 +0100 Subject: [PATCH] Added support for EnumType. Added test case. --- SDT/schema4.0/etc/domain.rnc | 10 +++++++++- SDT/schema4.0/src/domain.rng | 27 +++++++++++++++++++++++++++ SDT/schema4.0/src/domain.xsd | 16 ++++++++++++++++ SDT/schema4.0/test/enumtype-test.xml | 20 ++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 SDT/schema4.0/test/enumtype-test.xml diff --git a/SDT/schema4.0/etc/domain.rnc b/SDT/schema4.0/etc/domain.rnc index 88a4219..d30de59 100644 --- a/SDT/schema4.0/etc/domain.rnc +++ b/SDT/schema4.0/etc/domain.rnc @@ -47,7 +47,7 @@ DataTypeDef = attribute name { text }?, attribute unitOfMeasure { text }?, DocDef, - (StructType | ArrayType | SimpleType), + (StructType | ArrayType | SimpleType | EnumType), ConstraintsDef? } StructType = element Struct { DataTypeDef+ } @@ -56,6 +56,7 @@ SimpleType = element SimpleType { attribute type { BasicType } } +EnumType = element EnumType { EnumValueDef+ } BasicType = "integer" | "boolean" @@ -69,6 +70,13 @@ BasicType = | "blob" | "uri" | "void" +EnumValueDef = + element EnumValue { + attribute name { text }, + attribute value { text }, + attribute type { BasicType }?, + DocDef + } ConstraintsDef = element Constraints { element Constraint { diff --git a/SDT/schema4.0/src/domain.rng b/SDT/schema4.0/src/domain.rng index 3f5e129..188fa93 100644 --- a/SDT/schema4.0/src/domain.rng +++ b/SDT/schema4.0/src/domain.rng @@ -121,6 +121,7 @@ <ref name="StructType" /> <ref name="ArrayType" /> <ref name="SimpleType" /> + <ref name="EnumType" /> </choice> <optional> <ref name="ConstraintsDef"/> @@ -152,6 +153,15 @@ </attribute> </element> </define> + + + <define name="EnumType"> + <element name="EnumType"> + <oneOrMore> + <ref name="EnumValueDef" /> + </oneOrMore> + </element> + </define> <define name="BasicType"> @@ -172,6 +182,23 @@ </define> + <define name="EnumValueDef"> + <element name="EnumValue"> + <attribute name="name"> + <text/> + </attribute> + <attribute name="value"> + <text/> + </attribute> + <optional> + <attribute name="type"> + <ref name="BasicType"/> + </attribute> + </optional> + <ref name="DocDef"/> + </element> + </define> + <define name="ConstraintsDef"> <element name="Constraints"> <oneOrMore> diff --git a/SDT/schema4.0/src/domain.xsd b/SDT/schema4.0/src/domain.xsd index 02696bf..72a7717 100644 --- a/SDT/schema4.0/src/domain.xsd +++ b/SDT/schema4.0/src/domain.xsd @@ -95,6 +95,7 @@ <xs:element ref="Struct"/> <xs:element ref="Array"/> <xs:element ref="SimpleType"/> + <xs:element ref="EnumType"/> </xs:choice> <xs:element minOccurs="0" ref="Constraints"/> </xs:sequence> @@ -121,6 +122,13 @@ <xs:attribute name="type" use="required" type="BasicType"/> </xs:complexType> </xs:element> + <xs:element name="EnumType"> + <xs:complexType> + <xs:sequence> + <xs:element maxOccurs="unbounded" ref="EnumValue"/> + </xs:sequence> + </xs:complexType> + </xs:element> <xs:simpleType name="BasicType"> <xs:restriction base="xs:token"> <xs:enumeration value="integer"/> @@ -137,6 +145,14 @@ <xs:enumeration value="void"/> </xs:restriction> </xs:simpleType> + <xs:element name="EnumValue"> + <xs:complexType> + <xs:group ref="DocDef"/> + <xs:attribute name="name" use="required"/> + <xs:attribute name="value" use="required"/> + <xs:attribute name="type" type="BasicType"/> + </xs:complexType> + </xs:element> <xs:element name="Constraints"> <xs:complexType> <xs:sequence> diff --git a/SDT/schema4.0/test/enumtype-test.xml b/SDT/schema4.0/test/enumtype-test.xml new file mode 100644 index 0000000..2b7a418 --- /dev/null +++ b/SDT/schema4.0/test/enumtype-test.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Test the void BasicType --> + +<Domain id="enumtype-test" xmlns="http://homegatewayinitiative.org/xml/dal/4.0" xmlns:xi="http://www.w3.org/2001/XInclude"> + <ModuleClasses> + <ModuleClass name="TestEnumType"> + <Data> + <DataPoint name="TestEnumTypeDataPoint" writable="true"> + <DataType> + <EnumType> + <EnumValue name="red" value="1" type="integer" /> + <EnumValue name="green" value="2" /> + <EnumValue name="blue" value="3" /> + </EnumType> + </DataType> + </DataPoint> + </Data> + </ModuleClass> + </ModuleClasses> +</Domain> \ No newline at end of file -- GitLab