From 242cac83a1fe05009364350c44b107c648648356 Mon Sep 17 00:00:00 2001
From: ankraft <an.kraft@googlemail.com>
Date: Thu, 31 Jan 2019 14:49:41 +0100
Subject: [PATCH] Add extend to data type. Updated test case.

---
 SDT/schema4.0/docs/SDT_UML.uxf        | 120 +++++++-------
 SDT/schema4.0/etc/domain.rnc          |  12 +-
 SDT/schema4.0/src/domain.rng          |  59 +++----
 SDT/schema4.0/src/domain.xsd          | 224 +++++++++++++++-----------
 SDT/schema4.0/test/datatypes-test.xml |  14 ++
 SDT/schema4.0/test/mseeb.xml          |   2 +-
 6 files changed, 247 insertions(+), 184 deletions(-)

diff --git a/SDT/schema4.0/docs/SDT_UML.uxf b/SDT/schema4.0/docs/SDT_UML.uxf
index da6cc70..0d433b9 100644
--- a/SDT/schema4.0/docs/SDT_UML.uxf
+++ b/SDT/schema4.0/docs/SDT_UML.uxf
@@ -6,7 +6,7 @@
     <id>UMLNote</id>
     <coordinates>
       <x>1390</x>
-      <y>690</y>
+      <y>650</y>
       <w>310</w>
       <h>260</h>
     </coordinates>
@@ -37,7 +37,7 @@ group=1</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1520</x>
-      <y>790</y>
+      <y>750</y>
       <w>110</w>
       <h>40</h>
     </coordinates>
@@ -52,7 +52,7 @@ group=1</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1520</x>
-      <y>830</y>
+      <y>790</y>
       <w>110</w>
       <h>30</h>
     </coordinates>
@@ -65,7 +65,7 @@ group=1</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>1580</x>
-      <y>1130</y>
+      <y>1090</y>
       <w>150</w>
       <h>220</h>
     </coordinates>
@@ -89,7 +89,7 @@ void</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>960</x>
-      <y>1210</y>
+      <y>1170</y>
       <w>140</w>
       <h>80</h>
     </coordinates>
@@ -102,7 +102,7 @@ m1= 0..1
     <id>Relation</id>
     <coordinates>
       <x>960</x>
-      <y>1130</y>
+      <y>1090</y>
       <w>140</w>
       <h>80</h>
     </coordinates>
@@ -115,7 +115,7 @@ m1=0..1
     <id>UMLClass</id>
     <coordinates>
       <x>480</x>
-      <y>1130</y>
+      <y>1090</y>
       <w>190</w>
       <h>150</h>
     </coordinates>
@@ -125,8 +125,8 @@ m1=0..1
 /@ unitOfMeasure : text/
 /- Doc : Doc/
 /- semanticURI : uri/
-- TypeChoice
 /- extends : Extends/
+/- TypeChoice/
 /* Constraints : Constraint/
 fg=blue</panel_attributes>
     <additional_attributes/>
@@ -135,7 +135,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>630</x>
-      <y>1070</y>
+      <y>1030</y>
       <w>710</w>
       <h>130</h>
     </coordinates>
@@ -148,7 +148,7 @@ m2=1..n
     <id>Relation</id>
     <coordinates>
       <x>630</x>
-      <y>1070</y>
+      <y>1030</y>
       <w>710</w>
       <h>190</h>
     </coordinates>
@@ -161,7 +161,7 @@ m2=1
     <id>UMLClass</id>
     <coordinates>
       <x>1080</x>
-      <y>1250</y>
+      <y>1210</y>
       <w>190</w>
       <h>50</h>
     </coordinates>
@@ -175,7 +175,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1260</x>
-      <y>1270</y>
+      <y>1230</y>
       <w>340</w>
       <h>50</h>
     </coordinates>
@@ -188,7 +188,7 @@ m1= 1
     <id>UMLClass</id>
     <coordinates>
       <x>1080</x>
-      <y>1370</y>
+      <y>1330</y>
       <w>190</w>
       <h>110</h>
     </coordinates>
@@ -206,7 +206,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>660</x>
-      <y>1230</y>
+      <y>1190</y>
       <w>440</w>
       <h>180</h>
     </coordinates>
@@ -219,7 +219,7 @@ m1=0..n
     <id>Relation</id>
     <coordinates>
       <x>1260</x>
-      <y>1340</y>
+      <y>1300</y>
       <w>420</w>
       <h>140</h>
     </coordinates>
@@ -232,7 +232,7 @@ m1=1
     <id>UMLClass</id>
     <coordinates>
       <x>1080</x>
-      <y>1130</y>
+      <y>1090</y>
       <w>190</w>
       <h>50</h>
     </coordinates>
@@ -246,7 +246,7 @@ fg=blue</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>1080</x>
-      <y>1190</y>
+      <y>1150</y>
       <w>190</w>
       <h>50</h>
     </coordinates>
@@ -260,7 +260,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>960</x>
-      <y>1180</y>
+      <y>1140</y>
       <w>140</w>
       <h>50</h>
     </coordinates>
@@ -274,7 +274,7 @@ m1= 0..1
     <id>UMLClass</id>
     <coordinates>
       <x>480</x>
-      <y>990</y>
+      <y>950</y>
       <w>1250</w>
       <h>40</h>
     </coordinates>
@@ -289,7 +289,7 @@ lw=0.1</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>100</x>
-      <y>40</y>
+      <y>0</y>
       <w>1590</w>
       <h>40</h>
     </coordinates>
@@ -304,7 +304,7 @@ lw=0.1</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>830</x>
-      <y>170</y>
+      <y>130</y>
       <w>220</w>
       <h>180</h>
     </coordinates>
@@ -327,7 +327,7 @@ fg=blue
     <id>UMLClass</id>
     <coordinates>
       <x>1170</x>
-      <y>170</y>
+      <y>130</y>
       <w>220</w>
       <h>130</h>
     </coordinates>
@@ -346,7 +346,7 @@ fg=blue</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>1520</x>
-      <y>260</y>
+      <y>220</y>
       <w>170</w>
       <h>100</h>
     </coordinates>
@@ -363,7 +363,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1380</x>
-      <y>260</y>
+      <y>220</y>
       <w>160</w>
       <h>40</h>
     </coordinates>
@@ -375,7 +375,7 @@ m1= 0..n</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>490</x>
-      <y>170</y>
+      <y>130</y>
       <w>220</w>
       <h>150</h>
     </coordinates>
@@ -395,7 +395,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>170</y>
+      <y>130</y>
       <w>150</w>
       <h>100</h>
     </coordinates>
@@ -407,7 +407,7 @@ m1= 0..n</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>490</x>
-      <y>480</y>
+      <y>440</y>
       <w>220</w>
       <h>110</h>
     </coordinates>
@@ -425,7 +425,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>260</y>
+      <y>220</y>
       <w>70</w>
       <h>120</h>
     </coordinates>
@@ -438,7 +438,7 @@ m1=0..n
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>480</y>
+      <y>440</y>
       <w>150</w>
       <h>70</h>
     </coordinates>
@@ -450,7 +450,7 @@ m1= 0..n</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>1520</x>
-      <y>540</y>
+      <y>500</y>
       <w>170</w>
       <h>50</h>
     </coordinates>
@@ -463,7 +463,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1040</x>
-      <y>170</y>
+      <y>130</y>
       <w>150</w>
       <h>70</h>
     </coordinates>
@@ -476,7 +476,7 @@ m1= 0..n
     <id>Relation</id>
     <coordinates>
       <x>1440</x>
-      <y>540</y>
+      <y>500</y>
       <w>100</w>
       <h>40</h>
     </coordinates>
@@ -488,7 +488,7 @@ m1=0..1</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1040</x>
-      <y>230</y>
+      <y>190</y>
       <w>150</w>
       <h>120</h>
     </coordinates>
@@ -501,7 +501,7 @@ m1= 0..n
     <id>UMLClass</id>
     <coordinates>
       <x>1170</x>
-      <y>310</y>
+      <y>270</y>
       <w>220</w>
       <h>160</h>
     </coordinates>
@@ -524,7 +524,7 @@ fg=blue
     <id>UMLClass</id>
     <coordinates>
       <x>1170</x>
-      <y>480</y>
+      <y>440</y>
       <w>220</w>
       <h>110</h>
     </coordinates>
@@ -543,7 +543,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1040</x>
-      <y>330</y>
+      <y>290</y>
       <w>150</w>
       <h>190</h>
     </coordinates>
@@ -556,7 +556,7 @@ m1= 0..n
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>330</y>
+      <y>290</y>
       <w>150</w>
       <h>240</h>
     </coordinates>
@@ -569,7 +569,7 @@ m1= 0..n
     <id>UMLClass</id>
     <coordinates>
       <x>490</x>
-      <y>340</y>
+      <y>300</y>
       <w>220</w>
       <h>130</h>
     </coordinates>
@@ -588,7 +588,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>430</y>
+      <y>390</y>
       <w>70</w>
       <h>100</h>
     </coordinates>
@@ -600,7 +600,7 @@ m1=0..n</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>330</y>
+      <y>290</y>
       <w>150</w>
       <h>90</h>
     </coordinates>
@@ -612,7 +612,7 @@ m1= 0..n</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>410</y>
+      <y>370</y>
       <w>150</w>
       <h>100</h>
     </coordinates>
@@ -623,7 +623,7 @@ m1= 0..n</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>830</x>
-      <y>460</y>
+      <y>420</y>
       <w>220</w>
       <h>130</h>
     </coordinates>
@@ -643,7 +643,7 @@ transparency=80</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1380</x>
-      <y>290</y>
+      <y>250</y>
       <w>80</w>
       <h>260</h>
     </coordinates>
@@ -656,7 +656,7 @@ m1=0..n
     <id>Relation</id>
     <coordinates>
       <x>1040</x>
-      <y>330</y>
+      <y>290</y>
       <w>70</w>
       <h>190</h>
     </coordinates>
@@ -668,7 +668,7 @@ m1=0..n</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>780</x>
-      <y>1140</y>
+      <y>1100</y>
       <w>190</w>
       <h>110</h>
     </coordinates>
@@ -687,7 +687,7 @@ Enum : EnumType
     <id>Relation</id>
     <coordinates>
       <x>660</x>
-      <y>1150</y>
+      <y>1110</y>
       <w>140</w>
       <h>80</h>
     </coordinates>
@@ -700,7 +700,7 @@ m1= 1
     <id>UMLClass</id>
     <coordinates>
       <x>100</x>
-      <y>360</y>
+      <y>320</y>
       <w>330</w>
       <h>230</h>
     </coordinates>
@@ -725,7 +725,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>420</x>
-      <y>350</y>
+      <y>310</y>
       <w>90</w>
       <h>50</h>
     </coordinates>
@@ -738,7 +738,7 @@ m1=0..1
     <id>Relation</id>
     <coordinates>
       <x>280</x>
-      <y>140</y>
+      <y>100</y>
       <w>570</w>
       <h>240</h>
     </coordinates>
@@ -750,7 +750,7 @@ m1=0..1
     <id>Relation</id>
     <coordinates>
       <x>280</x>
-      <y>560</y>
+      <y>520</y>
       <w>570</w>
       <h>90</h>
     </coordinates>
@@ -762,7 +762,7 @@ m1= 0..n</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>420</x>
-      <y>480</y>
+      <y>440</y>
       <w>90</w>
       <h>40</h>
     </coordinates>
@@ -774,7 +774,7 @@ m1=0..n</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>1080</x>
-      <y>1310</y>
+      <y>1270</y>
       <w>190</w>
       <h>50</h>
     </coordinates>
@@ -788,7 +788,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>960</x>
-      <y>1220</y>
+      <y>1180</y>
       <w>140</w>
       <h>130</h>
     </coordinates>
@@ -801,7 +801,7 @@ m1=0..1
     <id>UMLClass</id>
     <coordinates>
       <x>1330</x>
-      <y>1330</y>
+      <y>1290</y>
       <w>210</w>
       <h>110</h>
     </coordinates>
@@ -819,7 +819,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>1260</x>
-      <y>1320</y>
+      <y>1280</y>
       <w>90</w>
       <h>50</h>
     </coordinates>
@@ -832,7 +832,7 @@ m1=1..n
     <id>Relation</id>
     <coordinates>
       <x>1530</x>
-      <y>1340</y>
+      <y>1300</y>
       <w>120</w>
       <h>80</h>
     </coordinates>
@@ -844,7 +844,7 @@ m1=0..1</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>490</x>
-      <y>670</y>
+      <y>630</y>
       <w>220</w>
       <h>80</h>
     </coordinates>
@@ -861,7 +861,7 @@ fg=blue</panel_attributes>
     <id>UMLClass</id>
     <coordinates>
       <x>830</x>
-      <y>670</y>
+      <y>630</y>
       <w>220</w>
       <h>70</h>
     </coordinates>
@@ -876,7 +876,7 @@ fg=blue</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>700</x>
-      <y>670</y>
+      <y>630</y>
       <w>150</w>
       <h>80</h>
     </coordinates>
@@ -888,7 +888,7 @@ m1= 0..n</panel_attributes>
     <id>Relation</id>
     <coordinates>
       <x>410</x>
-      <y>660</y>
+      <y>620</y>
       <w>100</w>
       <h>50</h>
     </coordinates>
diff --git a/SDT/schema4.0/etc/domain.rnc b/SDT/schema4.0/etc/domain.rnc
index eedce92..9eeaa53 100644
--- a/SDT/schema4.0/etc/domain.rnc
+++ b/SDT/schema4.0/etc/domain.rnc
@@ -18,7 +18,7 @@ Domain =
     ModuleClasses?,
     element DeviceClasses {
       element DeviceClass {
-        attribute id { xsd:NCName },
+        attribute id { xsd:Name },
         DocDef,
         PropertiesDef?,
         ModuleClasses?,
@@ -48,7 +48,7 @@ DataTypeDef =
     attribute name { text }?,
     attribute unitOfMeasure { text }?,
     DocDef,
-    (StructType | ArrayType | SimpleType | EnumType),
+    (ExtendsDef | (StructType | ArrayType | SimpleType | EnumType)),
     ConstraintsDef?
   }
 StructType = element Struct { DataTypeDef+ }
@@ -107,8 +107,9 @@ ModuleClasses =
     element ModuleClass {
       attribute name { text },
       attribute optional { xsd:boolean }?,
-      ExtendsDef?,
       DocDef,
+      ExtendsDef,
+      # TODO: singular
       PropertiesDef?,
       Actions?,
       Data?,
@@ -155,8 +156,9 @@ Events =
     }+
   }
 ExtendsDef =
+  # TODO: singular
   element extends {
-    # TODO: Uppercase
+    #  TODO: Uppercase , singular
     attribute domain { xsd:IDREF },
     attribute class { text },
     element excludes {
@@ -170,4 +172,4 @@ ExtendsDef =
         }
       }+
     }?
-  }
+  }?
diff --git a/SDT/schema4.0/src/domain.rng b/SDT/schema4.0/src/domain.rng
index 1989aef..7527cab 100644
--- a/SDT/schema4.0/src/domain.rng
+++ b/SDT/schema4.0/src/domain.rng
@@ -125,10 +125,13 @@
 			</optional>
 			<ref name="DocDef"/>
 			<choice>
-				<ref name="StructType" />
-				<ref name="ArrayType" />
-				<ref name="SimpleType" />
-				<ref name="EnumType" />
+				<ref name="ExtendsDef" />
+				<choice>
+					<ref name="StructType" />
+					<ref name="ArrayType" />
+					<ref name="SimpleType" />
+					<ref name="EnumType" />
+				</choice>
 			</choice>
 			<optional>
 				<ref name="ConstraintsDef"/>
@@ -285,10 +288,8 @@
 							<data type="boolean"/>
 						</attribute>
 					</optional>
-					<optional>
-						<ref name="ExtendsDef" />
-					</optional>
 					<ref name="DocDef"/>
+					<ref name="ExtendsDef" /> <!-- TODO: singular -->
 					<optional>
 						<ref name="PropertiesDef"/>
 					</optional>
@@ -402,27 +403,29 @@
 	</define>
 
 
-	<define name="ExtendsDef">
-		<element name="extends"> <!-- TODO: Uppercase -->
-			<attribute name="domain">
-				<data type="IDREF"/>
-			</attribute>
-			<attribute name="class"/>
-			<optional>
-				<element name="excludes"> <!-- TODO: Uppercase + "...s" -> Excludes-->
-					<oneOrMore>
-						<element name="exclude">
-							<attribute name="name">
-								<text/>
-							</attribute>
-							<attribute name="type">
-								<text/> <!-- TODO: add ExcludeTypes -->
-							</attribute>
-						</element>
-					</oneOrMore>
-				</element>
-			</optional>
-		</element>
+	<define name="ExtendsDef"> <!-- TODO: singular -->
+		<optional>
+			<element name="extends"> <!-- TODO: Uppercase , singular-->
+				<attribute name="domain">
+					<data type="IDREF"/>
+				</attribute>
+				<attribute name="class"/>
+				<optional>
+					<element name="excludes"> <!-- TODO: Uppercase + "...s" -> Excludes-->
+						<oneOrMore>
+							<element name="exclude">
+								<attribute name="name">
+									<text/>
+								</attribute>
+								<attribute name="type">
+									<text/> <!-- TODO: add ExcludeTypes -->
+								</attribute>
+							</element>
+						</oneOrMore>
+					</element>
+				</optional>
+			</element>
+		</optional>
 	</define>
 
 </grammar>
diff --git a/SDT/schema4.0/src/domain.xsd b/SDT/schema4.0/src/domain.xsd
index 4bca234..5375d8a 100644
--- a/SDT/schema4.0/src/domain.xsd
+++ b/SDT/schema4.0/src/domain.xsd
@@ -17,15 +17,18 @@
   <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
   <xs:element name="Domain">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <xs:element minOccurs="0" ref="Imports"/>
-        <xs:element minOccurs="0" ref="DataTypes"/>
-        <xs:element minOccurs="0" ref="ModuleClasses"/>
-        <xs:element minOccurs="0" ref="DeviceClasses"/>
-      </xs:sequence>
-      <xs:attribute ref="xml:base"/>
-      <xs:attribute name="id" use="required" type="xs:ID"/>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:element minOccurs="0" ref="Imports"/>
+            <xs:element minOccurs="0" ref="DataTypes"/>
+            <xs:element minOccurs="0" ref="ModuleClasses"/>
+            <xs:element minOccurs="0" ref="DeviceClasses"/>
+          </xs:sequence>
+          <xs:attribute ref="xml:base"/>
+          <xs:attribute name="id" use="required" type="xs:ID"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Imports">
@@ -51,13 +54,16 @@
   </xs:element>
   <xs:element name="DeviceClass">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <xs:element minOccurs="0" ref="Properties"/>
-        <xs:element minOccurs="0" ref="ModuleClasses"/>
-        <xs:element minOccurs="0" ref="SubDevices"/>
-      </xs:sequence>
-      <xs:attribute name="id" use="required" type="xs:NCName"/>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:element minOccurs="0" ref="Properties"/>
+            <xs:element minOccurs="0" ref="ModuleClasses"/>
+            <xs:element minOccurs="0" ref="SubDevices"/>
+          </xs:sequence>
+          <xs:attribute name="id" use="required" type="xs:Name"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="SubDevices">
@@ -69,12 +75,15 @@
   </xs:element>
   <xs:element name="SubDevice">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <xs:element minOccurs="0" ref="Properties"/>
-        <xs:element minOccurs="0" ref="ModuleClasses"/>
-      </xs:sequence>
-      <xs:attribute name="id" use="required" type="xs:Name"/>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:element minOccurs="0" ref="Properties"/>
+            <xs:element minOccurs="0" ref="ModuleClasses"/>
+          </xs:sequence>
+          <xs:attribute name="id" use="required" type="xs:Name"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Properties">
@@ -86,29 +95,38 @@
   </xs:element>
   <xs:element name="Property">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <xs:element ref="SimpleType"/>
-      </xs:sequence>
-      <xs:attribute name="name" use="required"/>
-      <xs:attribute name="optional" type="xs:boolean"/>
-      <xs:attribute name="value"/>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:element ref="SimpleType"/>
+          </xs:sequence>
+          <xs:attribute name="name" use="required"/>
+          <xs:attribute name="optional" type="xs:boolean"/>
+          <xs:attribute name="value"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="DataType">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <xs:choice>
-          <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>
-      <xs:attribute name="name"/>
-      <xs:attribute name="unitOfMeasure"/>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:choice>
+              <xs:group ref="ExtendsDef"/>
+              <xs:choice>
+                <xs:element ref="Struct"/>
+                <xs:element ref="Array"/>
+                <xs:element ref="SimpleType"/>
+                <xs:element ref="EnumType"/>
+              </xs:choice>
+            </xs:choice>
+            <xs:element minOccurs="0" ref="Constraints"/>
+          </xs:sequence>
+          <xs:attribute name="name"/>
+          <xs:attribute name="unitOfMeasure"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Struct">
@@ -155,10 +173,13 @@
   </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:complexContent>
+        <xs:extension base="DocDef">
+          <xs:attribute name="name" use="required"/>
+          <xs:attribute name="value" use="required"/>
+          <xs:attribute name="type" type="BasicType"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Constraints">
@@ -170,10 +191,13 @@
   </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:complexContent>
+        <xs:extension base="DocDef">
+          <xs:attribute name="name" use="required"/>
+          <xs:attribute name="type" type="BasicType"/>
+          <xs:attribute name="value"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:group name="DocText">
@@ -189,11 +213,11 @@
   <xs:element name="b" type="xs:string"/>
   <xs:element name="tt" type="xs:string"/>
   <!-- <Doc> element is always optional -->
-  <xs:group name="DocDef">
+  <xs:complexType name="DocDef">
     <xs:sequence>
       <xs:element minOccurs="0" ref="Doc"/>
     </xs:sequence>
-  </xs:group>
+  </xs:complexType>
   <xs:element name="Doc">
     <xs:complexType mixed="true">
       <xs:choice>
@@ -228,16 +252,19 @@
   </xs:element>
   <xs:element name="ModuleClass">
     <xs:complexType>
-      <xs:sequence>
-        <xs:element minOccurs="0" ref="extends"/>
-        <xs:group ref="DocDef"/>
-        <xs:element minOccurs="0" ref="Properties"/>
-        <xs:element minOccurs="0" ref="Actions"/>
-        <xs:element minOccurs="0" ref="Data"/>
-        <xs:element minOccurs="0" ref="Events"/>
-      </xs:sequence>
-      <xs:attribute name="name" use="required"/>
-      <xs:attribute name="optional" type="xs:boolean"/>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:group ref="ExtendsDef"/>
+            <xs:element minOccurs="0" ref="Properties"/>
+            <xs:element minOccurs="0" ref="Actions"/>
+            <xs:element minOccurs="0" ref="Data"/>
+            <xs:element minOccurs="0" ref="Events"/>
+          </xs:sequence>
+          <xs:attribute name="name" use="required"/>
+          <xs:attribute name="optional" type="xs:boolean"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Actions">
@@ -249,13 +276,16 @@
   </xs:element>
   <xs:element name="Action">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <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:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <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:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Args">
@@ -267,11 +297,14 @@
   </xs:element>
   <xs:element name="Arg">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <xs:element ref="DataType"/>
-      </xs:sequence>
-      <xs:attribute name="name" use="required"/>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:element ref="DataType"/>
+          </xs:sequence>
+          <xs:attribute name="name" use="required"/>
+        </xs:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Data">
@@ -283,15 +316,18 @@
   </xs:element>
   <xs:element name="DataPoint">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <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:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <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:extension>
+      </xs:complexContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="Events">
@@ -303,14 +339,22 @@
   </xs:element>
   <xs:element name="Event">
     <xs:complexType>
-      <xs:sequence>
-        <xs:group ref="DocDef"/>
-        <xs:element minOccurs="0" ref="Data"/>
-      </xs:sequence>
-      <xs:attribute name="name" use="required"/>
-      <xs:attribute name="optional" type="xs:boolean"/>
-    </xs:complexType>
-  </xs:element>
+      <xs:complexContent>
+        <xs:extension base="DocDef">
+          <xs:sequence>
+            <xs:element minOccurs="0" ref="Data"/>
+          </xs:sequence>
+          <xs:attribute name="name" use="required"/>
+          <xs:attribute name="optional" type="xs:boolean"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:group name="ExtendsDef">
+    <xs:sequence>
+      <xs:element minOccurs="0" ref="extends"/>
+    </xs:sequence>
+  </xs:group>
   <xs:element name="extends">
     <xs:complexType>
       <xs:sequence>
diff --git a/SDT/schema4.0/test/datatypes-test.xml b/SDT/schema4.0/test/datatypes-test.xml
index 782b26f..340c31a 100644
--- a/SDT/schema4.0/test/datatypes-test.xml
+++ b/SDT/schema4.0/test/datatypes-test.xml
@@ -14,4 +14,18 @@
 			</EnumType>
 		</DataType>
 	</DataTypes>
+
+	<ModuleClasses>
+		<ModuleClass name="TestDataTypes">
+			<Data>
+				<DataPoint name="TestDataPoint" writable="true">
+					<DataType>
+						<extends domain="datatypes-test" class="temperatureType" />
+					</DataType>
+				</DataPoint>
+			</Data>
+		</ModuleClass>
+	</ModuleClasses>
+
+
 </Domain>
\ No newline at end of file
diff --git a/SDT/schema4.0/test/mseeb.xml b/SDT/schema4.0/test/mseeb.xml
index cd233dd..34500f3 100644
--- a/SDT/schema4.0/test/mseeb.xml
+++ b/SDT/schema4.0/test/mseeb.xml
@@ -155,11 +155,11 @@
 
             <ModuleClasses>
                 <ModuleClass name="rootPowerOnOff" optional="true">
-                    <extends domain="hgi.dal.core" class="BooleanState"/>
                     <Doc>
                         The proprietry interface for turning all switches of the extension block on and off. 
                         The action "BooleanState:get" returns "true" when any of the sub-devices is in the state "on", otherwise it returns "false".
                     </Doc>
+                    <extends domain="hgi.dal.core" class="BooleanState"/>
                     <Properties>
                         <Property name="version" value="1.0.0">
                             <Doc>Version for this ModuleClass</Doc>
-- 
GitLab