Commit 89325bfd authored by ankraft's avatar ankraft
Browse files

Added support for EnumType. Added test case.

parent f80296ed
......@@ -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 {
......
......@@ -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>
......
......@@ -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>
......
<?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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment