CIS97 YT > Relax NG Projects > Cartoon Network Listings Grammar

Relax NG Projects
Cartoon Network Listings

Project Index | Documentation | Relax NG | Sample XML File

<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
         
<start>
<element name="cartoon-network"> 
    <oneOrMore>
    <ref name ="showContent"/>
    </oneOrMore>
</element>
</start>
    
<define name="showContent">
    <element name="show">
        <attribute name = "code">
        <data type = "ID"/>
        </attribute> 
        <attribute name = "category">
            <choice>
                <value type="string">series</value>
                <value type="string">movie</value>
                <value type="string">special</value>
                <value type="string">cartoonolio</value>
            </choice>
        </attribute>
        <element name = "name">
            <text/>
        </element>
        <element name = "created">
            <data type = "integer">
                <param name = "minInclusive">1927</param>
                <param name = "maxInclusive">2002</param>
            </data>
        </element>
        <element name = "studio">
            <text/>
        </element>
        <element name = "rating">
            <data type = "string">
                <param name = "pattern">TV-(G|Y|Y7|PG|14|MA)</param>
            </data>
        </element>
        
        <optional>
        <choice>
        <element name = "star-list">
            <oneOrMore>
                <element name = "star">
                    <ref name = "starContent"/>
                </element>
            </oneOrMore>
        </element>
        <element name = "star">
            <ref name = "starContent"/>
        </element>
        </choice>
        </optional> 
        
        <element name = "description">
        <text/>       
        </element>
        
        <element name = "schedule">
            <element name = "week">
                <element name = "begin-date">
                    <data type = "date"> </data>
                </element>
                <element name = "end-date">
                    <data type = "date"> </data>
                </element>
            </element>
            
            <oneOrMore>
            <element name = "day">
                 <data type = "string">
                    <param name = "pattern">(M|TU|W|TH|F|SA|SU)(-(TH|F))?</param>
                 </data>
            </element>
                <oneOrMore>
                <element name = "time">
                    <data type = "string">
                        <param name = "pattern">\d{1,2}:\d{2}-\d{1,2}:\d{2}(a|p)</param>
                    </data>
                </element> 
                </oneOrMore>
            </oneOrMore>
        </element> 
 
         <optional>
         <element name = "note">
         <interleave>
             <text/>
             <oneOrMore>
                 <element name = "month"><text/></element>
                 <element name = "day"><text/></element>
                 <element name = "year"><text/></element>
                 <element name = "time"><text/></element>
             </oneOrMore> 
             <zeroOrMore>
                 <element name = "award"><text/></element>
             </zeroOrMore>
         </interleave>
         </element>
        </optional>
        
        <zeroOrMore>
        <element name = "fanclub">
            <ref name = "fanclubContent"/>
        </element>
        </zeroOrMore>
        
        <zeroOrMore>
        <element name = "website">
            <text/>
        </element>
        </zeroOrMore>
        
    </element>   
</define>

<define name ="starContent">
    <text/>
        <attribute name="role">
            <choice>
                <value type = "string">major</value>
                <value type = "string">minor</value>
                <value type = "string">guest</value>
            </choice>
        </attribute>
</define>
 
<define name="fanclubContent">
    <element name="club-name">
        <text/>
    </element>
    <choice>
        <element name ="email">
        <text/>
        </element>
        <group>       
            <element name = "street">
                <text/>
            </element>
            <element name = "city">
                <text/>
            </element>
            <element name = "state">
                <data type = "string">
                    <param name = "pattern">[A-Z]{2}</param>
                </data>
            </element>
            <element name = "zipcode">
                <data type = "string">
                    <param name = "pattern">\d{5}(-\d{4})?</param>
                </data>
            </element>
        </group>
    </choice>
</define>
            
</grammar>