CIS 97YT Index > Assignment 4 > movies.rng

Assignment 4
movies.rng

<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
  xmlns="http://relaxng.org/ns/structure/1.0">

<start>
<element name="movie-list">
    <oneOrMore>
        <element name="movie">
            <ref name="header_defn"/>
            <ref name="synopsis_defn"/>
            <ref name="credits_defn"/>
            <ref name="reviews_defn"/>
        </element>
    </oneOrMore>
</element>
</start>

<define name="header_defn">
    <element name="heading">
        <element name="title"><text/></element>
        <optional>
            <element name="rating">
                <data type="string">
                    <param name="pattern">\*{1,4}</param>
                </data>
            </element>
        </optional>
        <element name="technical-details">
            <element name="country"><text/></element>
            <element name="year">
                <data type="positiveInteger"/>
            </element>
            <element name="running-time"><text/></element>
            <element name="color"><text/></element>
        </element>
        <element name="production">
            <element name="studio"><text/></element>
            <optional>
                <element name="producer"><text/></element>
            </optional>
        </element>
    </element>
</define>

<define name="synopsis_defn">
    <element name="synopsis">
        <oneOrMore>
            <element name="para">
                <interleave>
                    <text/>
                    <zeroOrMore>
                        <element name="ref"><text/></element>
                    </zeroOrMore>
                </interleave>
            </element>
        </oneOrMore>
    </element>
</define>

<define name="credits_defn">
    <element name="credits">
        <interleave>
        <element name="writer">
            <ref name="special_attr"/>
        </element>
        <element name="director">
            <ref name="special_attr"/>
        </element>
        <optional>
            <element name="photography">
                <ref name="special_attr"/>
            </element>
        </optional>
        <optional>
            <element name="music">
                <ref name="special_attr"/>
            </element>
        </optional>
        <element name="actors">
            <interleave>
                <text/>
                <oneOrMore>
                    <ref name="actor_defn"/>
                </oneOrMore>
            </interleave>
        </element>
        </interleave>
    </element>
</define>

<define name="actor_defn">
    <element name="actor">
        <text/>
        <ref name="special_attr"/>
        <optional>
            <attribute name="type">
                <choice>
                    <value>supporting</value>
                    <value>lead</value>
                </choice>
            </attribute>
        </optional>
        <optional>
            <attribute name="gender">
                <choice>
                    <value>M</value>
                    <value>F</value>
                </choice>
            </attribute>
        </optional>
    </element>
</define>

<define name="reviews_defn">
    <element name="reviews">
        <oneOrMore>
            <element name="review">
                <interleave>
                    <text/>
                    <optional>
                        <element name="reviewer">
                            <text/>
                            <optional>
                                <attribute name="type">
                                    <text/>
                                </attribute>
                            </optional>
                        </element>
                    </optional>
                </interleave>
            </element>
        </oneOrMore>
    </element>
</define>

<define name="special_attr">
    <text/>
    <optional>
        <attribute name="special">
            <choice>
                <value>yes</value>
            </choice>
        </attribute>
    </optional>
</define>
</grammar>