From 97c72ebf0aae19ca255bfd85fb930ebdd0984f77 Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Wed, 7 Jan 2015 22:25:26 +0100
Subject: [PATCH] E-Test: Create XML schema from relational schema

---
 Sda1/Etest/XmlSchema2RdbmsSchema/address.xsd  | 52 +++++++++++++++++++
 .../XmlSchema2RdbmsSchema/sampleData.xml      | 23 ++++++++
 Sda1/Etest/XmlSchema2RdbmsSchema/schema.sql   | 24 +++++++++
 Sda2/Ref/Fig/jpacache.svg                     | 15 ++++--
 4 files changed, 109 insertions(+), 5 deletions(-)
 create mode 100644 Sda1/Etest/XmlSchema2RdbmsSchema/address.xsd
 create mode 100644 Sda1/Etest/XmlSchema2RdbmsSchema/sampleData.xml
 create mode 100644 Sda1/Etest/XmlSchema2RdbmsSchema/schema.sql

diff --git a/Sda1/Etest/XmlSchema2RdbmsSchema/address.xsd b/Sda1/Etest/XmlSchema2RdbmsSchema/address.xsd
new file mode 100644
index 000000000..27b2eb10f
--- /dev/null
+++ b/Sda1/Etest/XmlSchema2RdbmsSchema/address.xsd
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
+    vc:minVersion="1.1" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"> 
+
+    <xs:simpleType name="personCategory">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="friend" />
+            <xs:enumeration value="customer" />
+            <xs:enumeration value="colleague" />
+        </xs:restriction>
+    </xs:simpleType>
+    
+
+    <xs:element name="addressbook">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element ref="person" minOccurs="0" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+        <xs:key name="uniquePersonId">
+            <xs:selector xpath="person"/>
+            <xs:field xpath="@id"/>
+        </xs:key>
+    </xs:element>
+
+    <xs:element name="person">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="fullName" type="xs:string"/>
+                <xs:element name="birth" type="xs:date"/>
+                <xs:element name="category" type="personCategory"/>
+                
+                <xs:sequence>
+                    <xs:element ref="address" minOccurs="0" maxOccurs="unbounded"/>
+                </xs:sequence>
+            </xs:sequence>
+            <xs:attribute name="id" type="xs:int"/>
+        </xs:complexType>
+    </xs:element>
+
+    <xs:element name="address">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="street" type="xs:string"/>
+                <xs:element name="number" type="xs:string"/>
+                <xs:element name="town" type="xs:string"/>
+                <xs:element name="zip" type="xs:string"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+</xs:schema>
diff --git a/Sda1/Etest/XmlSchema2RdbmsSchema/sampleData.xml b/Sda1/Etest/XmlSchema2RdbmsSchema/sampleData.xml
new file mode 100644
index 000000000..61b2243cd
--- /dev/null
+++ b/Sda1/Etest/XmlSchema2RdbmsSchema/sampleData.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<addressbook xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="address.xsd">
+    
+    <person id="23">
+        <fullName>Eve Gardener</fullName>
+        <birth>1982-10-26</birth>
+        <category>friend</category>
+        <address>
+            <street>Honkytong Ave</street>
+            <number>23</number>
+            <town>Tuxamoon</town>
+            <zip>12345</zip>
+        </address>
+    </person>
+    
+    <person id="24">
+        <fullName>Eve Gardener</fullName>
+        <birth>1982-10-26</birth>
+        <category>customer</category>
+    </person>
+    
+</addressbook>
\ No newline at end of file
diff --git a/Sda1/Etest/XmlSchema2RdbmsSchema/schema.sql b/Sda1/Etest/XmlSchema2RdbmsSchema/schema.sql
new file mode 100644
index 000000000..5f0c1dc1e
--- /dev/null
+++ b/Sda1/Etest/XmlSchema2RdbmsSchema/schema.sql
@@ -0,0 +1,24 @@
+DROP TABLE Address;
+DROP TABLE Person;
+
+CREATE TABLE Person (
+   id INTEGER NOT NULL PRIMARY KEY
+  ,fullName VARCHAR(20) NOT NULL
+  ,birth DATE
+  ,category CHAR(12)
+  ,CHECK (category IN ('friend', 'customer', 'colleague')) 
+);
+
+CREATE TABLE Address (
+   person INTEGER NOT NULL PRIMARY KEY REFERENCES Person
+     ON DELETE CASCADE
+     ON UPDATE CASCADE
+     
+  ,street VARCHAR(255) NOT NULL
+  ,number VARCHAR(255) NOT NULL
+  ,town VARCHAR(255) NOT NULL
+  ,zip CHAR(7) NOT NULL
+);
+
+
+
diff --git a/Sda2/Ref/Fig/jpacache.svg b/Sda2/Ref/Fig/jpacache.svg
index 4104f9520..8ecaf808a 100644
--- a/Sda2/Ref/Fig/jpacache.svg
+++ b/Sda2/Ref/Fig/jpacache.svg
@@ -583,7 +583,7 @@
        transform="translate(120,130)">
       <path
          transform="translate(12.790299,-56.427792)"
-         d="m 710,454.09448 a 85,30 0 1 1 -170,0 85,30 0 1 1 170,0 z"
+         d="m 710,454.09448 c 0,16.56854 -38.0558,30 -85,30 -46.9442,0 -85,-13.43146 -85,-30 0,-16.56854 38.0558,-30 85,-30 46.9442,0 85,13.43146 85,30 z"
          sodipodi:ry="30"
          sodipodi:rx="85"
          sodipodi:cy="454.09448"
@@ -593,7 +593,7 @@
          sodipodi:type="arc" />
       <path
          transform="translate(11.943107,58.992702)"
-         d="m 710,454.09448 a 85,30 0 1 1 -170,0 85,30 0 1 1 170,0 z"
+         d="m 710,454.09448 c 0,16.56854 -38.0558,30 -85,30 -46.9442,0 -85,-13.43146 -85,-30 0,-16.56854 38.0558,-30 85,-30 46.9442,0 85,13.43146 85,30 z"
          sodipodi:ry="30"
          sodipodi:rx="85"
          sodipodi:cy="454.09448"
@@ -1428,7 +1428,7 @@
          sodipodi:open="true"
          sodipodi:end="6.2802964"
          sodipodi:start="0"
-         d="m 590,229.09448 a 85,55 0 1 1 -3.5e-4,-0.15889"
+         d="m 590,229.09448 c 0,30.37566 -38.0558,55 -85,55 -46.9442,0 -85,-24.62434 -85,-55 0,-30.37566 38.0558,-55 85,-55 46.84834,0 84.8643,24.52761 84.99965,54.84111"
          sodipodi:ry="55"
          sodipodi:rx="85"
          sodipodi:cy="229.09448"
@@ -1828,7 +1828,7 @@
          sodipodi:role="line"
          x="20"
          y="334.09448"
-         id="tspan3343"> </tspan><tspan
+         id="tspan3343" /><tspan
          sodipodi:role="line"
          x="20"
          y="364.09448"
@@ -2002,7 +2002,12 @@
        id="text4862"
        sodipodi:linespacing="125%"><tspan
          sodipodi:role="line"
-         id="tspan4864"></tspan></text>
+         id="tspan4864" /></text>
+    <path
+       style="color:#000000;fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       d="m 480,124.09448 560,0"
+       id="path3343"
+       inkscape:connector-curvature="0" />
   </g>
   <g
      inkscape:groupmode="layer"
-- 
GitLab