Skip to content
Snippets Groups Projects
Commit 89325bfd authored by ankraft's avatar ankraft
Browse files

Added support for EnumType. Added test case.

parent f80296ed
No related branches found
No related tags found
No related merge requests found
...@@ -47,7 +47,7 @@ DataTypeDef = ...@@ -47,7 +47,7 @@ DataTypeDef =
attribute name { text }?, attribute name { text }?,
attribute unitOfMeasure { text }?, attribute unitOfMeasure { text }?,
DocDef, DocDef,
(StructType | ArrayType | SimpleType), (StructType | ArrayType | SimpleType | EnumType),
ConstraintsDef? ConstraintsDef?
} }
StructType = element Struct { DataTypeDef+ } StructType = element Struct { DataTypeDef+ }
...@@ -56,6 +56,7 @@ SimpleType = ...@@ -56,6 +56,7 @@ SimpleType =
element SimpleType { element SimpleType {
attribute type { BasicType } attribute type { BasicType }
} }
EnumType = element EnumType { EnumValueDef+ }
BasicType = BasicType =
"integer" "integer"
| "boolean" | "boolean"
...@@ -69,6 +70,13 @@ BasicType = ...@@ -69,6 +70,13 @@ BasicType =
| "blob" | "blob"
| "uri" | "uri"
| "void" | "void"
EnumValueDef =
element EnumValue {
attribute name { text },
attribute value { text },
attribute type { BasicType }?,
DocDef
}
ConstraintsDef = ConstraintsDef =
element Constraints { element Constraints {
element Constraint { element Constraint {
......
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
<ref name="StructType" /> <ref name="StructType" />
<ref name="ArrayType" /> <ref name="ArrayType" />
<ref name="SimpleType" /> <ref name="SimpleType" />
<ref name="EnumType" />
</choice> </choice>
<optional> <optional>
<ref name="ConstraintsDef"/> <ref name="ConstraintsDef"/>
...@@ -152,6 +153,15 @@ ...@@ -152,6 +153,15 @@
</attribute> </attribute>
</element> </element>
</define> </define>
<define name="EnumType">
<element name="EnumType">
<oneOrMore>
<ref name="EnumValueDef" />
</oneOrMore>
</element>
</define>
<define name="BasicType"> <define name="BasicType">
...@@ -172,6 +182,23 @@ ...@@ -172,6 +182,23 @@
</define> </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"> <define name="ConstraintsDef">
<element name="Constraints"> <element name="Constraints">
<oneOrMore> <oneOrMore>
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<xs:element ref="Struct"/> <xs:element ref="Struct"/>
<xs:element ref="Array"/> <xs:element ref="Array"/>
<xs:element ref="SimpleType"/> <xs:element ref="SimpleType"/>
<xs:element ref="EnumType"/>
</xs:choice> </xs:choice>
<xs:element minOccurs="0" ref="Constraints"/> <xs:element minOccurs="0" ref="Constraints"/>
</xs:sequence> </xs:sequence>
...@@ -121,6 +122,13 @@ ...@@ -121,6 +122,13 @@
<xs:attribute name="type" use="required" type="BasicType"/> <xs:attribute name="type" use="required" type="BasicType"/>
</xs:complexType> </xs:complexType>
</xs:element> </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:simpleType name="BasicType">
<xs:restriction base="xs:token"> <xs:restriction base="xs:token">
<xs:enumeration value="integer"/> <xs:enumeration value="integer"/>
...@@ -137,6 +145,14 @@ ...@@ -137,6 +145,14 @@
<xs:enumeration value="void"/> <xs:enumeration value="void"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </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:element name="Constraints">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
......
<?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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment