Commit 4addeedb authored by Dr. Martin Goik's avatar Dr. Martin Goik

E-examination SDA1 / summer 2019

parent 2e1a60f7
<?xml version="1.0" encoding="UTF-8"?>
<book version="5.0" xml:id="klausur_SoSe_2017" xml:lang="en"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:trans="http://docbook.org/ns/transclusion"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<info>
<title/>
<author>
<personname/>
</author>
<pubdate/>
</info>
<chapter xml:id="task1">
<title>Articles and categories</title>
<section xml:id="aufgabe1_prepare">
<title>Preparations</title>
<para>Download and unzip the above file <filename>exam.zip</filename>.
Then:</para>
<orderedlist>
<listitem>
<para>Import the resulting <filename>Exam</filename> Project into
your <productname>IDEA</productname> IDE by choosing »File --&gt;
Open...« subsequently selecting the
<filename>Exam/pom.xml</filename> file.</para>
</listitem>
<listitem>
<para>Also import <filename>Exam</filename> into your
<productname>Oxygenxml</productname> IDE using »Project« --&gt;
»Open Project« subsequently selecting the
<filename>Exam/sda1.xpr</filename> file.</para>
</listitem>
</orderedlist>
</section>
<section xml:id="aufgabe1_descr">
<title>Description</title>
<para>Consider a catalog of categories and articles:</para>
<programlisting language="xml">&lt;catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="catalog.xsd" &gt;
&lt;categories&gt;
&lt;category id="food"&gt;Food and drinking&lt;/category&gt;
&lt;category id="hardware"&gt;Tools, DIY&lt;/category&gt;
&lt;category id="lifestyle"&gt;Lifestyle products&lt;/category&gt;
&lt;/categories&gt;
&lt;articles&gt;
&lt;article orderNo="232434"&gt;
&lt;name&gt;Super 3D Tin Lunch Box &lt;/name&gt;
&lt;cat&gt;lifestyle&lt;/cat&gt;
&lt;cat&gt;hardware&lt;/cat&gt;
&lt;img src="232434_1" type="png"/&gt;
&lt;/article&gt;
&lt;article orderNo="544343"&gt;
&lt;name&gt;Monthly beer subscription box&lt;/name&gt;
&lt;cat&gt;food&lt;/cat&gt;
&lt;description&gt;Various brands and flavours on offer.&lt;/description&gt;
&lt;/article&gt;
&lt;/articles&gt;
&lt;/catalog&gt;</programlisting>
<para>The following data integrity rules shall apply:</para>
<orderedlist>
<listitem>
<para>Each <tag class="starttag">category</tag> has got an
<code>id</code> value being unique with respect to all
categories.</para>
</listitem>
<listitem>
<para>Each <tag class="starttag">article</tag> carries a positive
integer <code>orderNo</code> attribute being unique with respect to
all articles.</para>
</listitem>
<listitem>
<para>Each <tag class="starttag">article</tag> is being related to
at least one <tag class="starttag">category</tag> by means of <tag
class="starttag">cat</tag> references. In the given sample the
«Monthly beer subscription box» relates to the «Food and drinking»
category.</para>
</listitem>
<listitem>
<para>An <tag class="starttag">article</tag> may have one <tag
class="starttag">description</tag> and one <tag
class="starttag">img</tag> element in that order.</para>
</listitem>
<listitem>
<para>The attributes <code>src</code> and <code>type</code> of <tag
class="starttag">img</tag> are mandatory. The attribute
<code>type</code> is being restricted to the set {<code>gif</code>,
<code>png</code>, <code>svg</code>}.</para>
</listitem>
</orderedlist>
</section>
<section xml:id="aufgabe1_task">
<title>Tasks</title>
<para>Complete your schema's implementation in
<filename>Schema/catalog.xsd</filename> using the
<productname>Oxygenxml</productname> IDE. Hints:</para>
<orderedlist>
<listitem>
<para>The folder <filename>SchemaTest</filename> contains sample
files testing your schema's correctness.</para>
</listitem>
<listitem>
<para><productname>Junit</productname> execution of
<classname>de.hdm_stuttgart.mi.sda1.test.ex1.SchemaTest</classname>
from within IntelliJ executes all unit tests based on files residing
in your project's folder <filename>SchemaTest</filename>. Some of
these files, e.g.
<filename>SchemaTest/0101_missingArticles.xml</filename>, contain
comment hints regarding expected errors with respect to the intended
<filename>Schema/catalog.xsd</filename>.</para>
<programlisting language="xml"> ... &lt;!-- Expected error: &lt;articles &gt; absent --&gt;...</programlisting>
<para>Clicking on file names within test failure reports will open
e.g. <filename>SchemaTest/0101_missingArticles.xml</filename> in
<productname>IDEA</productname>. However opening the same file in
<productname>Oxygenxml</productname> will likely save time anyway
due to better <abbrev>XML</abbrev> support.</para>
</listitem>
<listitem>
<para><emphasis role="red">Never</emphasis> touch your project's
unit tests in the <filename>SchemaTest</filename> folder: The
automated tests may end up throwing meaningless exceptions.</para>
</listitem>
<listitem>
<para>Edit <filename>Schema/catalog.xsd</filename> only by small
steps executing the tests immediately. Schema changes may cause
already working tests to fail again. In case of spoiling your schema
<quote>undo</quote> is your friend.</para>
</listitem>
</orderedlist>
<tip>
<itemizedlist>
<listitem>
<para>XPath uses the dot (.) for selecting an element's content
e.g. "<emphasis role="red">food</emphasis>" from <tag
class="starttag">cat</tag><emphasis role="red">food</emphasis><tag
class="endtag">cat</tag> .</para>
</listitem>
<listitem>
<para>Choose appropriate <abbrev>XSD</abbrev> standard types
rather than defining own types by restriction.</para>
</listitem>
</itemizedlist>
</tip>
</section>
<section version="5.1" xml:id="uploadFirst">
<title>Project upload</title>
<para>Export your project by hitting »File« --&gt; »Export to Zip File«
in IDEA creating an <abbrev>e.g.</abbrev>
<filename>solution-1.zip</filename> file. Then enter your
<productname>ILIAS</productname> browser, hit the <quote>choose
file</quote> button selecting <filename>solution-1.zip</filename> and
subsequently click <quote>upload</quote>. Do not forget to advance to
the next question for actually saving your upload. Common
pitfalls:</para>
<itemizedlist>
<listitem>
<para>Do not select the wrong archive! In particular avoid choosing
the original <filename>exam.zip</filename> skeleton.</para>
</listitem>
<listitem>
<para>After uploading check for <filename>solution_1.zip</filename>
being visible in the examination system.</para>
</listitem>
<listitem>
<para>You may upload multiple versions i.e.
<filename>solution_2.zip</filename> etc. . Only your least uploaded
archive will become subject to marking.</para>
</listitem>
</itemizedlist>
</section>
<section xml:id="examCaveats">
<title>Caveats</title>
<itemizedlist>
<listitem>
<para>When approaching examination ending time check your input for
completeness.</para>
</listitem>
<listitem>
<para>Projects residing just on your local workstation cannot be
recovered after exam termination.</para>
</listitem>
</itemizedlist>
</section>
</chapter>
<chapter xml:id="task2">
<title>Relational representation of <tag class="starttag">catalog</tag>
documents</title>
<section xml:id="task2_prepare">
<title>Preparation</title>
<para>If you already started the first task just continue working on
your project using IntelliJ. Otherwise read the first task regarding the
skeleton project import.</para>
<para>Hint: A global database connection is configured on IDEA
level.</para>
</section>
<section xml:id="task2_descr">
<title>Description</title>
<para>Extend the relational schema skeleton
<filename>Schema/schema.sq</filename>l preparing your RDBMS to import
<tag class="starttag">catalog</tag> instances.</para>
</section>
<section xml:id="task2_tasks">
<title>Tasks</title>
<para>Extend your project's incomplete
<filename>Schema/schema.sql</filename> file yet containing only
<code>INSERT</code> but no <code>CREATE TABLE</code> statements. Try to
map the given <tag class="starttag">catalog</tag> integrity constraints
as closely as possible. Use <code>CHECK(...)</code> constraints where
appropriate.</para>
<tip>
<itemizedlist>
<listitem>
<para>In presence of an image both its name and type must
<emphasis role="red">not</emphasis> be <code>NULL</code>.</para>
</listitem>
<listitem>
<para>In absence of an image both its name and type must be
<code>NULL</code>.</para>
</listitem>
</itemizedlist>
</tip>
</section>
<section version="5.1" xml:id="uploadFollow">
<title>Solution upload</title>
<para>Upload your project using the previous task. Then enter «I'm
expecting points for my work on the current task» into the text
field.</para>
</section>
</chapter>
<chapter xml:id="task3">
<title>Import XML instances into RDBMS</title>
<section xml:id="task3_prepare">
<title>Preparation</title>
<para>If you already started the first task just continue working on
your project using IntelliJ. Otherwise read the first task regarding the
skeleton project import.</para>
</section>
<section xml:id="task3_descr">
<title>Description</title>
<para>Write a Java application reading <tag
class="starttag">catalog</tag> document instances and writing the
<abbrev>XML</abbrev> content to a relational database. Hints:</para>
<itemizedlist>
<listitem>
<para><package>de.hdm_stuttgart.mi.sda1</package>.<classname>Category2Rdbms</classname>
contains <abbrev>JDBC</abbrev> related connection parameters and
boilerplate code.</para>
</listitem>
<listitem>
<para>Upon invocation class
<package>de.hdm_stuttgart.mi.sda1</package>.<classname>Driver</classname>
instantiates
<package>de.hdm_stuttgart.mi.sda1</package>.<classname>Category2Rdbms</classname>
thereby:</para>
<itemizedlist>
<listitem>
<para>Reading and parsing
<filename>Schema/sampledata.xml</filename>.</para>
</listitem>
<listitem>
<para>Open a database connection to your local PostgreSQL
server.</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</section>
<section xml:id="task3_tasks">
<title>Tasks</title>
<para>Insert data from <filename>Schema/sampledata.xml</filename> into
your local database. Use your schema from the second task.</para>
</section>
<section xml:id="task3_hints">
<title>Hints</title>
<para>Even if your application <abbrev>e.g.</abbrev> just fills in
category data you'll receive points. Also partly completed but not fully
working code may contribute.</para>
</section>
<section version="5.1" xml:id="task3_upload">
<title>Solution upload</title>
<para>Upload your project using the first task. Enter either of the
following two texts:</para>
<itemizedlist>
<listitem>
<para>I'm expecting points for my work on the current task.</para>
</listitem>
<listitem>
<para>I did not work on this task.</para>
</listitem>
</itemizedlist>
<para>You may as well add other marking related comments.</para>
</section>
</chapter>
</book>
/.classpath
/.project
/.settings
/.idea
/*.iml
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<!-- TODO: define required elements -->
</xs:schema>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="catalog.xsd" >
<categories>
<category id="food">Food and drinking</category>
<category id="hardware">Tools, DIY</category>
<category id="lifestyle">Lifestyle products</category>
</categories>
<articles>
<article orderNo="232434">
<name>Super 3D Tin Lunch Box </name>
<cat>lifestyle</cat>
<cat>hardware</cat>
<img src="232434_1" type="png"/>
</article>
<article orderNo="544343">
<name>Monthly beer subscription box</name>
<cat>food</cat>
<description>Various brands and flavours on offer.</description>
</article>
</articles>
</catalog>
\ No newline at end of file
DROP TABLE IF EXISTS Foo;
CREATE TABLE ... /* TODO: Create schema closely resembling catalog.xsd integrity rules */
/* sample data below may be used for checking your schema's consistence */
/* Inserting categories */
INSERT INTO Category
VALUES ('food', 'Food and drinking');
INSERT INTO Category
VALUES ('hardware', 'Tools, DIY');
INSERT INTO Category
VALUES ('lifestyle', 'Lifestyle products');
/* Inserting articles */
INSERT INTO Article
VALUES (232434, 'Super 3D Tin Lunch Box', NULL, '232434_1', 'png');
INSERT INTO Article
VALUES (544343, 'Monthly beer subscription box', 'Various brands and flavours on offer.', NULL, NULL);
/* Relating categories and articles */
INSERT INTO Category2Article
VALUES ('lifestyle', 232434);
INSERT INTO Category2Article
VALUES ('hardware', 232434);
INSERT INTO Category2Article
VALUES ('food', 544343);
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories/>
<articles/>
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "true"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories/>
<articles/>
<articles/> <!-- Expected error: More than one <articles > element -->
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "0100validMinimum.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories/>
<categories/> <!-- Expected error: More than one <categories> element -->
<articles/>
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "0100validMinimum.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories/>
<!-- Expected error: <articles > absent -->
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "0100validMinimum.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<!-- Expected error: <categories> absent -->
<articles/>
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "0100validMinimum.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id="x">X category</category>
</categories>
<articles/>
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "true"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id=""> <!-- Expected error: Attribue id value must not be empty -->
X category</category>
</categories>
<articles/>
</catalog>
<?xmlTest
points = "2"
expectedToBeValid = "false"
preconditionValid = "0110validSingleCategory.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category> <!-- Expected error: Missing id attribute -->
X category</category>
</categories>
<articles/>
</catalog>
<?xmlTest
points = "2"
expectedToBeValid = "false"
preconditionValid = "0110validSingleCategory.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id="red green"> <!-- Expected error: Attribute must not contain whitespace characters -->
X category</category>
</categories>
<articles/>
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "0110validSingleCategory.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id="x">X category</category>
<category id="y">Y category</category>
</categories>
<articles/>
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "true"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id="x">X category</category>
<category id="x"> <!-- Expected error: Duplicate id attribute value -->
X category, identical id value</category>
</categories>
<articles/>
</catalog>
<?xmlTest
points = "2"
expectedToBeValid = "false"
preconditionValid = "0120validMultiCategory.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id="food">Food and drinking</category>
</categories>
<articles>
<article orderNo="544343">
<name>Monthly beer subscription box</name>
<cat>food</cat>
</article>
</articles>
</catalog>
<?xmlTest
points = "1"
expectedToBeValid = "true"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id="food">Food and drinking</category>
</categories>
<articles>
<article> <!-- Expected error: Missing orderNo attribute -->
<name>Monthly beer subscription box</name>
<cat>food</cat>
</article>
</articles>
</catalog>
<?xmlTest
points = "2"
expectedToBeValid = "false"
preconditionValid = "0150validMinimumArticle.xml"
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/catalog.xsd" >
<categories>
<category id="food">Food and drinking</category>
</categories>
<articles>
<article orderNo="0"> <!-- Expected error: Positive orderNo attribute value required -->
<name>Monthly beer subscription box</name>
<cat>food</cat>