Commit 8ec88ed1 authored by ankraft's avatar ankraft

* Added <Doc> to DataTypes

* Added name attribute to DataTypes. This is mostly optional and not needed, but mandatory for elements of a struct.
* Changed cardinality of the occurrence of elements that are part of a list of elements (e.g. <Arg><Args>...</Args></Arg> from ?zero or more? to ?one or more? when the surrounding list element itself is optional* Added Constraints to DataTypes
parent 50d65407
start = Domain
Domain =
element Domain {
# still having some problems with included documents ...
# the included document is given the attribute xml:base ...
# but my schema does not permit this ...
#
# This almost generates the correct schema ... but it
# doesn't have the correct schemaLocation
#
# <attribute ns="http://www.w3.org/XML/1998/namespace" name="base">
# <data type="anyURI"/>
# </attribute>
attribute xml:base { xsd:anyURI }?,
attribute id { xsd:ID },
DocDef,
element Imports { Domain* }?,
element Imports { Domain+ }?,
element Modules {
element ModuleClass { ModuleDef }*
element ModuleClass { ModuleDef }+
}?,
element Devices {
element Device {
attribute id { xsd:Name },
DocDef,
Characteristics?,
CharacteristicsDef?,
Modules?,
element SubDevices {
element SubDevice {
attribute id { xsd:Name },
DocDef,
Characteristics?,
CharacteristicsDef?,
Modules?
}*
}+
}?
}*
}+
}?
}
Characteristics =
CharacteristicsDef =
element Characteristics {
element Characteristic {
attribute name { text },
......@@ -46,25 +36,18 @@ Characteristics =
}+
}
DataTypeDef =
# Discuss: Doc on DataType?
attribute unitOfMeasure { text }?,
(StructType | ArrayType | SimpleType)
StructType =
element Struct {
element DataType {
attribute name { text }?,
DataTypeDef+
}
ArrayType =
element Array {
attribute name { text }?,
DataTypeDef
attribute unitOfMeasure { text }?,
DocDef,
(StructType | ArrayType | SimpleType),
ConstraintsDef?
}
StructType = element Struct { DataTypeDef+ }
ArrayType = element Array { DataTypeDef }
SimpleType =
element SimpleType {
attribute name { text }?,
attribute type { BasicType }
# TODO Constraints Perhaps directly in DataTypeDef
}
BasicType =
"integer"
......@@ -79,6 +62,15 @@ BasicType =
| "datetime"
| "blob"
| "uri"
ConstraintsDef =
element Constraints {
element Constraint {
attribute name { text },
attribute type { BasicType }?,
attribute value { text }?,
DocDef
}+
}
DocText =
(text
| element em { text }
......@@ -102,13 +94,13 @@ ModuleDef =
attribute class { text }
}?,
DocDef,
Characteristics?,
CharacteristicsDef?,
Actions?,
Data?,
Events?
Modules =
element Modules {
element Module { ModuleDef }*
element Module { ModuleDef }+
}
Actions =
element Actions {
......@@ -118,7 +110,7 @@ Actions =
DocDef,
DataTypeDef?,
ArgDef?
}*
}+
}
ArgDef =
element Args {
......@@ -126,7 +118,7 @@ ArgDef =
attribute name { text },
DocDef,
DataTypeDef
}*
}+
}
Data =
element Data {
......@@ -138,7 +130,7 @@ Data =
attribute eventable { xsd:boolean }?,
DocDef,
DataTypeDef
}*
}+
}
Events =
element Events {
......@@ -147,5 +139,5 @@ Events =
attribute optional { xsd:boolean }?,
DocDef,
Data?
}*
}+
}
<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>
<!-- still having some problems with included documents ...
the included document is given the attribute xml:base ...
but my schema does not permit this ...
This almost generates the correct schema ... but it
doesn't have the correct schemaLocation
<attribute ns="http://www.w3.org/XML/1998/namespace" name="base">
<data type="anyURI"/>
</attribute>
-->
<attribute name="xml:base">
<data type="anyURI"/>
</attribute>
......@@ -32,61 +20,61 @@
<ref name="DocDef"/>
<optional>
<element name="Imports">
<zeroOrMore>
<oneOrMore>
<ref name="Domain"/>
</zeroOrMore>
</oneOrMore>
</element>
</optional>
<optional>
<element name="Modules">
<zeroOrMore>
<oneOrMore>
<element name="ModuleClass">
<ref name="ModuleDef"/>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</optional>
<optional>
<element name="Devices">
<zeroOrMore>
<oneOrMore>
<element name="Device">
<attribute name="id">
<data type="Name"/>
</attribute>
<ref name="DocDef"/>
<optional>
<ref name="Characteristics"/>
<ref name="CharacteristicsDef"/>
</optional>
<optional>
<ref name="Modules"/>
</optional>
<optional>
<element name="SubDevices">
<zeroOrMore>
<oneOrMore>
<element name="SubDevice">
<attribute name="id">
<data type="Name"/>
</attribute>
<ref name="DocDef"/>
<optional>
<ref name="Characteristics"/>
<ref name="CharacteristicsDef"/>
</optional>
<optional>
<ref name="Modules"/>
</optional>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</optional>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</optional>
</element>
</define>
<define name="Characteristics">
<define name="CharacteristicsDef">
<element name="Characteristics">
<oneOrMore>
<element name="Characteristic">
......@@ -103,7 +91,6 @@
<text/>
</attribute>
</optional>
<ref name="DocDef"/>
<ref name="SimpleType" />
</element>
......@@ -113,27 +100,32 @@
<define name="DataTypeDef">
<!-- Discuss: Doc on DataType? -->
<optional>
<attribute name="unitOfMeasure">
<text/>
</attribute>
</optional>
<choice>
<ref name="StructType" />
<ref name="ArrayType" />
<ref name="SimpleType" />
</choice>
</define>
<define name="StructType">
<element name="Struct">
<element name="DataType">
<optional>
<attribute name="name">
<text/>
</attribute>
</optional>
<optional>
<attribute name="unitOfMeasure">
<text/>
</attribute>
</optional>
<ref name="DocDef"/>
<choice>
<ref name="StructType" />
<ref name="ArrayType" />
<ref name="SimpleType" />
</choice>
<optional>
<ref name="ConstraintsDef"/>
</optional>
</element>
</define>
<define name="StructType">
<element name="Struct">
<oneOrMore>
<ref name="DataTypeDef" />
</oneOrMore>
......@@ -143,11 +135,6 @@
<define name="ArrayType">
<element name="Array">
<optional>
<attribute name="name">
<text/>
</attribute>
</optional>
<ref name="DataTypeDef" />
</element>
</define>
......@@ -155,15 +142,9 @@
<define name="SimpleType">
<element name="SimpleType">
<optional>
<attribute name="name">
<text/>
</attribute>
</optional>
<attribute name="type">
<ref name="BasicType" />
</attribute>
<!-- TODO Constraints Perhaps directly in DataTypeDef-->
</element>
</define>
......@@ -186,6 +167,29 @@
</define>
<define name="ConstraintsDef">
<element name="Constraints">
<oneOrMore>
<element name="Constraint">
<attribute name="name">
<text/>
</attribute>
<optional>
<attribute name="type">
<ref name="BasicType" />
</attribute>
</optional>
<optional>
<attribute name="value">
<text/>
</attribute>
</optional>
<ref name="DocDef"/>
</element>
</oneOrMore>
</element>
</define>
<define name="DocText">
<zeroOrMore>
<choice>
......@@ -248,7 +252,7 @@
</optional>
<ref name="DocDef"/>
<optional>
<ref name="Characteristics"/>
<ref name="CharacteristicsDef"/>
</optional>
<optional>
<ref name="Actions"/>
......@@ -264,18 +268,18 @@
<define name="Modules">
<element name="Modules">
<zeroOrMore>
<oneOrMore>
<element name="Module">
<ref name="ModuleDef"/>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</define>
<define name="Actions">
<element name="Actions">
<zeroOrMore>
<oneOrMore>
<element name="Action">
<attribute name="name">
<text/>
......@@ -293,25 +297,27 @@
<ref name="ArgDef" />
</optional>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</define>
<define name="ArgDef">
<element name="Args">
<zeroOrMore>
<oneOrMore>
<element name="Arg">
<attribute name="name"/>
<ref name="DocDef"/>
<ref name="DataTypeDef"/>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</define>
<define name="Data">
<element name="Data">
<zeroOrMore>
<oneOrMore>
<element name="DataPoint">
<attribute name="name">
<text/>
......@@ -339,14 +345,14 @@
<ref name="DocDef"/>
<ref name="DataTypeDef"/>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</define>
<define name="Events">
<element name="Events">
<zeroOrMore>
<oneOrMore>
<element name="Event">
<attribute name="name">
<text/>
......@@ -361,7 +367,7 @@
<ref name="Data" />
</optional>
</element>
</zeroOrMore>
</oneOrMore>
</element>
</define>
......
......@@ -13,7 +13,7 @@
<xs:element minOccurs="0" name="Modules">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="ModuleClass"/>
<xs:element maxOccurs="unbounded" ref="ModuleClass"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -26,7 +26,7 @@
<xs:element name="Imports">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Domain"/>
<xs:element maxOccurs="unbounded" ref="Domain"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -34,7 +34,7 @@
<xs:element name="Devices">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Device"/>
<xs:element maxOccurs="unbounded" ref="Device"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -52,7 +52,7 @@
<xs:element name="SubDevices">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="SubDevice"/>
<xs:element maxOccurs="unbounded" ref="SubDevice"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -84,31 +84,37 @@
<xs:attribute name="value"/>
</xs:complexType>
</xs:element>
<xs:element name="DataTypeDef" abstract="true"/>
<xs:attributeGroup name="DataTypeDef">
<xs:attribute name="unitOfMeasure"/>
</xs:attributeGroup>
<xs:element name="Struct" substitutionGroup="DataTypeDef">
<xs:element name="DataType">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="DataTypeDef"/>
<xs:group ref="DocDef"/>
<xs:choice>
<xs:element ref="Struct"/>
<xs:element ref="Array"/>
<xs:element ref="SimpleType"/>
</xs:choice>
<xs:element minOccurs="0" ref="Constraints"/>
</xs:sequence>
<xs:attribute name="name"/>
<xs:attributeGroup ref="DataTypeDef"/>
<xs:attribute name="unitOfMeasure"/>
</xs:complexType>
</xs:element>
<xs:element name="Array" substitutionGroup="DataTypeDef">
<xs:element name="Struct">
<xs:complexType>
<xs:sequence>
<xs:element ref="DataTypeDef"/>
<xs:element maxOccurs="unbounded" ref="DataType"/>
</xs:sequence>
<xs:attribute name="name"/>
<xs:attributeGroup ref="DataTypeDef"/>
</xs:complexType>
</xs:element>
<xs:element name="SimpleType" substitutionGroup="DataTypeDef">
<xs:element name="Array">
<xs:complexType>
<xs:sequence>
<xs:element ref="DataType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SimpleType">
<xs:complexType>
<xs:attribute name="name"/>
<xs:attribute name="type" use="required" type="BasicType"/>
</xs:complexType>
</xs:element>
......@@ -128,6 +134,21 @@
<xs:enumeration value="uri"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="Constraints">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="Constraint"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Constraint">
<xs:complexType>
<xs:group ref="DocDef"/>
<xs:attribute name="name" use="required"/>
<xs:attribute name="type" type="BasicType"/>
<xs:attribute name="value"/>
</xs:complexType>
</xs:element>
<xs:group name="DocText">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
......@@ -192,7 +213,7 @@
<xs:element name="Modules">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Module"/>
<xs:element maxOccurs="unbounded" ref="Module"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -200,7 +221,7 @@
<xs:element name="Actions">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Action"/>
<xs:element maxOccurs="unbounded" ref="Action"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -208,18 +229,17 @@
<xs:complexType>
<xs:sequence>
<xs:group ref="DocDef"/>
<xs:element minOccurs="0" ref="DataTypeDef"/>
<xs:element minOccurs="0" ref="DataType"/>
<xs:element minOccurs="0" ref="Args"/>
</xs:sequence>
<xs:attribute name="name" use="required"/>
<xs:attribute name="optional" type="xs:boolean"/>
<xs:attributeGroup ref="DataTypeDef"/>
</xs:complexType>
</xs:element>
<xs:element name="Args">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Arg"/>
<xs:element maxOccurs="unbounded" ref="Arg"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -227,16 +247,15 @@
<xs:complexType>
<xs:sequence>
<xs:group ref="DocDef"/>
<xs:element ref="DataTypeDef"/>
<xs:element ref="DataType"/>
</xs:sequence>
<xs:attribute name="name" use="required"/>
<xs:attributeGroup ref="DataTypeDef"/>
</xs:complexType>
</xs:element>
<xs:element name="Data">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="DataPoint"/>
<xs:element maxOccurs="unbounded" ref="DataPoint"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......@@ -244,20 +263,19 @@
<xs:complexType>
<xs:sequence>
<xs:group ref="DocDef"/>
<xs:element ref="DataTypeDef"/>
<xs:element ref="DataType"/>
</xs:sequence>
<xs:attribute name="name" use="required"/>
<xs:attribute name="optional" type="xs:boolean"/>
<xs:attribute name="writable" type="xs:boolean"/>
<xs:attribute name="readable" type="xs:boolean"/>
<xs:attribute name="eventable" type="xs:boolean"/>
<xs:attributeGroup ref="DataTypeDef"/>
</xs:complexType>
</xs:element>
<xs:element name="Events">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Event"/>
<xs:element maxOccurs="unbounded" ref="Event"/>
</xs:sequence>
</xs:complexType>
</xs:element>
......
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