Description

Modeling an XML movie database XSD schema.

Preparations

If not yet present from another exercise download exam.zip, unzip it and import the resulting Exam directory as a Maven Eclipse project into your workspace.

Subsequently mentioned relative file and directory path names refer to your project root.

Tasks

Start from Schema/movie.xsd. Extend this file to provide an XML schema grammar implementing the constraints being described in the Data model description section below.

Hints

Data model description

We consider Schema/sampledata.xml illustrating a data store containing dictionary data for translation services:

<movieDb  xsi:noNamespaceSchemaLocation="movie.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <persons>
        <person id="rAltmann" birthYear="1925">
            <name>Robert Altman</name>
        </person>
        <person id="aMacDowell" birthYear="1958">
            <name>Andie MacDowell</name>
        </person>
        <person id="sKubrick" birthYear="1928" img="kubrick.jpg">
            <name>Stanley Kubrick</name>
        </person>
        <person id="mModine" birthYear="1959">
            <name>Matthew Modine</name>
            <biography>The youngest of seven, Matthew was born ...</biography>
        </person>
        <person id="rLeeEremy" birthYear="1944">
            <name>R. Lee Ermey</name>
        </person>
    </persons>
    <movies>
        <movie id = "18113" year="1987" director="sKubrick" rating="8.3">
            <title>Full Metal Jacket</title>
            <cast>
                <actor ref="mModine" isStar="true"/>
                <actor ref="rLeeEremy"/>
            </cast>
        </movie>
        <movie rating="7.7" id="4342" year="1993" director="rAltmann">
            <title>Short Cuts</title>
            <cast>
                <actor ref="aMacDowell"/>
                <actor ref="mModine" isStar="false"/>
            </cast>
        </movie>
    </movies>
</movieDb>

The following integrity constraints shall be honored:

  1. The domain both for <person birthYear="1928" ...> and <movie year="1987" ...> shall be [1, 2100].

    Hint: Consider http://www.w3schools.com/xml/schema_facets.asp.

  2. The id attribute's values in e.g. <person id="sKubrick" ...> shall be of type name token and be unique within <persons>.

  3. The required attribute <movie director="xyz" ...> refers to a corresponding <person id="xyz" ...> element.

  4. The attributes <movie year="1987" rating="8.3" ...> are mandatory.

  5. The required attribute <actor ref="xyz"/> refers to a corresponding <person id="xyz" ...> element.

  6. The ref attribute's values in e.g. <actor ref="mModine"/> shall be unique within a given <cast>.

  7. Each actor may or may not be a star with respect to the <cast> of a given movie. This is reflected by an optional boolean attribute <actor isStar="true" .../>.
  8. The mandatory attribute rating shall be of type decimal ranging from 0.0 to 9.9. One decimal place is allowed. Thus values like 3.45 are prohibited.

    Hint: Consider the “Restrictions on Numeric Data Types” section in http://www.w3schools.com/xml/schema_dtypes_numeric.asp.

Uploading, caution!