Modeling an XML movie database XSD schema.


If not yet present from another exercise download, 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.


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.


Data model description

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

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

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

  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

Uploading, caution!