Articles and categories

Preparations

Download and unzip the above file exam.zip. Then:

  1. Import the resulting Exam Project into your IDEA IDE by choosing »File --> Open...« subsequently selecting the Exam/pom.xml file.

  2. Also import the Exam folder into your Oxygenxml IDE using »Project« --> »Open Project« subsequently selecting the Exam/sda1.xpr file.

Description

Consider a catalog of categories and articles:

<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>

The following data integrity rules shall apply:

  1. Each <category> has got an id value being unique with respect to all categories.

  2. Each <article> carries a positive integer orderNo attribute being unique with respect to all articles.

  3. Each <article> is being related to at least one <category> by means of <cat> references. In the given sample the «Monthly beer subscription box» relates to the «Food and drinking» category.

  4. An <article> may have one <description> and one <img> element in that order.

  5. The attributes src and type of <img> are mandatory. The attribute type is being restricted to the set {gif, png, svg}.

Tasks

Complete your schema's implementation in Schema/catalog.xsd using the Oxygenxml IDE. Hints:

  1. The folder SchemaTest contains sample files testing your schema's correctness.

  2. Junit execution of de.hdm_stuttgart.mi.sda1.test.ex1.SchemaTest from within IntelliJ executes all unit tests based on files residing in your project's folder SchemaTest. Some of these files, e.g. SchemaTest/0101_missingArticles.xml, contain comment hints regarding expected errors with respect to the intended Schema/catalog.xsd.

     ... <!-- Expected error: <articles > absent -->...

    Clicking on file names within test failure reports will open e.g. SchemaTest/0101_missingArticles.xml in IDEA. However opening the same file in Oxygenxml will likely save time anyway due to better XML support.

  3. Never touch your project's unit tests in the SchemaTest folder: The automated tests may end up throwing meaningless exceptions.

  4. Edit Schema/catalog.xsd only by small steps executing the tests immediately. Schema changes may cause already working tests to fail again. In case of spoiling your schema undo is your friend.

Tip

  • XPath uses the dot (.) for selecting an element's content e.g. "food" from <cat>food</cat> .

  • Choose appropriate XSD standard types rather than defining own types by restriction.

Project upload

Export your project by hitting »File« --> »Export to Zip File« in IDEA creating an e.g. solution-1.zip file. Then enter your ILIAS browser, hit the choose file button selecting solution-1.zip and subsequently click upload. Do not forget to advance to the next question for actually saving your upload. Common pitfalls:

  • Do not select the wrong archive! In particular avoid choosing the original exam.zip skeleton.

  • After uploading check for solution_1.zip being visible in the examination system.

  • You may upload multiple versions i.e. solution_2.zip etc. . Only your least uploaded archive will become subject to marking.

Caveats
  • When approaching examination ending time check your input for completeness.

  • Projects residing just on your local workstation cannot be recovered after exam termination.