Commit 8ec88ed1 authored by ankraft's avatar ankraft
Browse files

* 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 start = Domain
Domain = Domain =
element 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 xml:base { xsd:anyURI }?,
attribute id { xsd:ID }, attribute id { xsd:ID },
DocDef, DocDef,
element Imports { Domain* }?, element Imports { Domain+ }?,
element Modules { element Modules {
element ModuleClass { ModuleDef }* element ModuleClass { ModuleDef }+
}?, }?,
element Devices { element Devices {
element Device { element Device {
attribute id { xsd:Name }, attribute id { xsd:Name },
DocDef, DocDef,
Characteristics?, CharacteristicsDef?,
Modules?, Modules?,
element SubDevices { element SubDevices {
element SubDevice { element SubDevice {
attribute id { xsd:Name }, attribute id { xsd:Name },
DocDef, DocDef,
Characteristics?, CharacteristicsDef?,
Modules? Modules?
}* }+
}? }?
}* }+
}? }?
} }
Characteristics = CharacteristicsDef =
element Characteristics { element Characteristics {
element Characteristic { element Characteristic {
attribute name { text }, attribute name { text },
...@@ -46,25 +36,18 @@ Characteristics = ...@@ -46,25 +36,18 @@ Characteristics =
}+ }+
} }
DataTypeDef = DataTypeDef =
# Discuss: Doc on DataType? element DataType {
attribute unitOfMeasure { text }?,
(StructType | ArrayType | SimpleType)
StructType =
element Struct {
attribute name { text }?, attribute name { text }?,
DataTypeDef+ attribute unitOfMeasure { text }?,
} DocDef,
ArrayType = (StructType | ArrayType | SimpleType),
element Array { ConstraintsDef?
attribute name { text }?,
DataTypeDef
} }
StructType = element Struct { DataTypeDef+ }
ArrayType = element Array { DataTypeDef }
SimpleType = SimpleType =
element SimpleType { element SimpleType {
attribute name { text }?,
attribute type { BasicType } attribute type { BasicType }
# TODO Constraints Perhaps directly in DataTypeDef
} }
BasicType = BasicType =
"integer" "integer"
...@@ -79,6 +62,15 @@ BasicType = ...@@ -79,6 +62,15 @@ BasicType =
| "datetime" | "datetime"
| "blob" | "blob"
| "uri" | "uri"
ConstraintsDef =
element Constraints {
element Constraint {
attribute name { text },
attribute type { BasicType }?,
attribute value { text }?,
DocDef
}+
}
DocText = DocText =
(text (text
| element em { text } | element em { text }
...@@ -102,13 +94,13 @@ ModuleDef = ...@@ -102,13 +94,13 @@ ModuleDef =
attribute class { text } attribute class { text }
}?, }?,
DocDef, DocDef,
Characteristics?, CharacteristicsDef?,
Actions?, Actions?,
Data?, Data?,
Events? Events?
Modules = Modules =
element Modules { element Modules {
element Module { ModuleDef }* element Module { ModuleDef }+
} }
Actions = Actions =
element Actions { element Actions {
...@@ -118,7 +110,7 @@ Actions = ...@@ -118,7 +110,7 @@ Actions =
DocDef, DocDef,
DataTypeDef?, DataTypeDef?,
ArgDef? ArgDef?
}* }+
} }
ArgDef = ArgDef =
element Args { element Args {
...@@ -126,7 +118,7 @@ ArgDef = ...@@ -126,7 +118,7 @@ ArgDef =
attribute name { text }, attribute name { text },
DocDef, DocDef,
DataTypeDef DataTypeDef
}* }+
} }
Data = Data =
element Data { element Data {
...@@ -138,7 +130,7 @@ Data = ...@@ -138,7 +130,7 @@ Data =
attribute eventable { xsd:boolean }?, attribute eventable { xsd:boolean }?,
DocDef, DocDef,
DataTypeDef DataTypeDef
}* }+
} }
Events = Events =
element Events { element Events {
...@@ -147,5 +139,5 @@ Events = ...@@ -147,5 +139,5 @@ Events =
attribute optional { xsd:boolean }?, attribute optional { xsd:boolean }?,
DocDef, DocDef,
Data? Data?
}* }+
} }
<grammar xmlns="http://relaxng.org/ns/structure/1.0" <grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start> <start>
<ref name="Domain"/> <ref name="Domain"/>
</start> </start>
<define name="Domain"> <define name="Domain">
<element name="Domain"> <element name="Domain">
<optional> <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"> <attribute name="xml:base">
<data type="anyURI"/> <data type="anyURI"/>
</attribute> </attribute>
...@@ -32,61 +20,61 @@ ...@@ -32,61 +20,61 @@
<ref name="DocDef"/> <ref name="DocDef"/>
<optional> <optional>
<element name="Imports"> <element name="Imports">
<zeroOrMore> <oneOrMore>
<ref name="Domain"/> <ref name="Domain"/>
</zeroOrMore> </oneOrMore>
</element> </element>
</optional> </optional>
<optional> <optional>
<element name="Modules"> <element name="Modules">
<zeroOrMore> <oneOrMore>
<element name="ModuleClass"> <element name="ModuleClass">
<ref name="ModuleDef"/> <ref name="ModuleDef"/>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</optional> </optional>
<optional> <optional>
<element name="Devices"> <element name="Devices">
<zeroOrMore> <oneOrMore>
<element name="Device"> <element name="Device">
<attribute name="id"> <attribute name="id">
<data type="Name"/> <data type="Name"/>
</attribute> </attribute>
<ref name="DocDef"/> <ref name="DocDef"/>
<optional> <optional>
<ref name="Characteristics"/> <ref name="CharacteristicsDef"/>
</optional> </optional>
<optional> <optional>
<ref name="Modules"/> <ref name="Modules"/>
</optional> </optional>
<optional> <optional>
<element name="SubDevices"> <element name="SubDevices">
<zeroOrMore> <oneOrMore>
<element name="SubDevice"> <element name="SubDevice">
<attribute name="id"> <attribute name="id">
<data type="Name"/> <data type="Name"/>
</attribute> </attribute>
<ref name="DocDef"/> <ref name="DocDef"/>
<optional> <optional>
<ref name="Characteristics"/> <ref name="CharacteristicsDef"/>
</optional> </optional>
<optional> <optional>
<ref name="Modules"/> <ref name="Modules"/>
</optional> </optional>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</optional> </optional>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</optional> </optional>
</element> </element>
</define> </define>
<define name="Characteristics"> <define name="CharacteristicsDef">
<element name="Characteristics"> <element name="Characteristics">
<oneOrMore> <oneOrMore>
<element name="Characteristic"> <element name="Characteristic">
...@@ -103,7 +91,6 @@ ...@@ -103,7 +91,6 @@
<text/> <text/>
</attribute> </attribute>
</optional> </optional>
<ref name="DocDef"/> <ref name="DocDef"/>
<ref name="SimpleType" /> <ref name="SimpleType" />
</element> </element>
...@@ -113,27 +100,32 @@ ...@@ -113,27 +100,32 @@
<define name="DataTypeDef"> <define name="DataTypeDef">
<!-- Discuss: Doc on DataType? --> <element name="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">
<optional> <optional>
<attribute name="name"> <attribute name="name">
<text/> <text/>
</attribute> </attribute>
</optional> </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> <oneOrMore>
<ref name="DataTypeDef" /> <ref name="DataTypeDef" />
</oneOrMore> </oneOrMore>
...@@ -143,11 +135,6 @@ ...@@ -143,11 +135,6 @@
<define name="ArrayType"> <define name="ArrayType">
<element name="Array"> <element name="Array">
<optional>
<attribute name="name">
<text/>
</attribute>
</optional>
<ref name="DataTypeDef" /> <ref name="DataTypeDef" />
</element> </element>
</define> </define>
...@@ -155,15 +142,9 @@ ...@@ -155,15 +142,9 @@
<define name="SimpleType"> <define name="SimpleType">
<element name="SimpleType"> <element name="SimpleType">
<optional>
<attribute name="name">
<text/>
</attribute>
</optional>
<attribute name="type"> <attribute name="type">
<ref name="BasicType" /> <ref name="BasicType" />
</attribute> </attribute>
<!-- TODO Constraints Perhaps directly in DataTypeDef-->
</element> </element>
</define> </define>
...@@ -186,6 +167,29 @@ ...@@ -186,6 +167,29 @@
</define> </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"> <define name="DocText">
<zeroOrMore> <zeroOrMore>
<choice> <choice>
...@@ -248,7 +252,7 @@ ...@@ -248,7 +252,7 @@
</optional> </optional>
<ref name="DocDef"/> <ref name="DocDef"/>
<optional> <optional>
<ref name="Characteristics"/> <ref name="CharacteristicsDef"/>
</optional> </optional>
<optional> <optional>
<ref name="Actions"/> <ref name="Actions"/>
...@@ -264,18 +268,18 @@ ...@@ -264,18 +268,18 @@
<define name="Modules"> <define name="Modules">
<element name="Modules"> <element name="Modules">
<zeroOrMore> <oneOrMore>
<element name="Module"> <element name="Module">
<ref name="ModuleDef"/> <ref name="ModuleDef"/>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</define> </define>
<define name="Actions"> <define name="Actions">
<element name="Actions"> <element name="Actions">
<zeroOrMore> <oneOrMore>
<element name="Action"> <element name="Action">
<attribute name="name"> <attribute name="name">
<text/> <text/>
...@@ -293,25 +297,27 @@ ...@@ -293,25 +297,27 @@
<ref name="ArgDef" /> <ref name="ArgDef" />
</optional> </optional>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</define> </define>
<define name="ArgDef"> <define name="ArgDef">
<element name="Args"> <element name="Args">
<zeroOrMore> <oneOrMore>
<element name="Arg"> <element name="Arg">
<attribute name="name"/> <attribute name="name"/>
<ref name="DocDef"/> <ref name="DocDef"/>
<ref name="DataTypeDef"/> <ref name="DataTypeDef"/>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</define> </define>
<define name="Data"> <define name="Data">
<element name="Data"> <element name="Data">
<zeroOrMore> <oneOrMore>
<element name="DataPoint"> <element name="DataPoint">
<attribute name="name"> <attribute name="name">
<text/> <text/>
...@@ -339,14 +345,14 @@ ...@@ -339,14 +345,14 @@
<ref name="DocDef"/> <ref name="DocDef"/>
<ref name="DataTypeDef"/> <ref name="DataTypeDef"/>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</define> </define>
<define name="Events"> <define name="Events">
<element name="Events"> <element name="Events">
<zeroOrMore> <oneOrMore>
<element name="Event"> <element name="Event">
<attribute name="name"> <attribute name="name">
<text/> <text/>
...@@ -361,7 +367,7 @@ ...@@ -361,7 +367,7 @@
<ref name="Data" /> <ref name="Data" />
</optional> </optional>
</element> </element>
</zeroOrMore> </oneOrMore>
</element> </element>
</define> </define>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<xs:element minOccurs="0" name="Modules"> <xs:element minOccurs="0" name="Modules">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="ModuleClass"/> <xs:element maxOccurs="unbounded" ref="ModuleClass"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<xs:element name="Imports"> <xs:element name="Imports">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Domain"/> <xs:element maxOccurs="unbounded" ref="Domain"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<xs:element name="Devices"> <xs:element name="Devices">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Device"/> <xs:element maxOccurs="unbounded" ref="Device"/>
</xs:sequence> </xs:sequence>