<?xml version="1.0" encoding="UTF-8"?>
<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
    xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
    <define name="personnel">
        <element name="personnel">
            <a:documentation>
                Defines the personnel as a collection of person elements.
            </a:documentation>            
            <ref name="attlist.personnel"/>
            <oneOrMore>
                <ref name="person"/>
            </oneOrMore>
        </element>
    </define>
    <define combine="interleave" name="attlist.personnel">
        <empty/>
    </define>
    <define name="person">
        <element name="person">
            <a:documentation>
                Specify information about a person.
            </a:documentation>
            <ref name="attlist.person"/>
            <ref name="name"/>
            <zeroOrMore>
                <ref name="email"/>
            </zeroOrMore>
            <zeroOrMore>
                <ref name="url"/>
            </zeroOrMore>
            <optional>
                <ref name="link"/>
            </optional>
        </element>
    </define>
    <define combine="interleave" name="attlist.person">
        <attribute name="id">
            <a:documentation>
                Specify a required unique ID for this person.
            </a:documentation>
            <data type="ID"/>
        </attribute>
    </define>
    <define combine="interleave" name="attlist.person">
        <optional>
            <attribute name="note">
                <a:documentation>
                    If there is anything to note about this person.
                </a:documentation>
            </attribute>
        </optional>
    </define>
    <define combine="interleave" name="attlist.person">
        <optional>
            <attribute a:defaultValue="false" name="contr">
                <choice>
                    <value>true</value>
                    <value>false</value>
                </choice>
            </attribute>
        </optional>
    </define>
    <define combine="interleave" name="attlist.person">
        <optional>
            <attribute name="salary">
                <a:documentation>
                    Specifies the salary for this person.
                </a:documentation>
            </attribute>
        </optional>
    </define>
    <define name="name">
        <element name="name">
            <a:documentation>
                Specify the person family and given name.
            </a:documentation>
            <ref name="attlist.name"/>
            <choice>
                <group>
                    <ref name="family"/>
                    <ref name="given"/>
                </group>
                <group>
                    <ref name="given"/>
                    <ref name="family"/>
                </group>
            </choice>
        </element>
    </define>
    <define combine="interleave" name="attlist.name">
        <empty/>
    </define>
    <define name="family">
        <element name="family">
            <a:documentation>
                The person last name.
            </a:documentation>
            <ref name="attlist.family"/>
            <text/>
        </element>
    </define>
    <define combine="interleave" name="attlist.family">
        <empty/>
    </define>
    <define name="given">
        <element name="given">
            <a:documentation>
                The person first name.
            </a:documentation>
            <ref name="attlist.given"/>
            <text/>
        </element>
    </define>
    <define combine="interleave" name="attlist.given">
        <empty/>
    </define>
    <define name="email">
        <element name="email">
            <a:documentation>
                Email address for this person.
            </a:documentation>
            <ref name="attlist.email"/>
            <text/>
        </element>
    </define>
    <define combine="interleave" name="attlist.email">
        <empty/>
    </define>
    <define name="url">
        <element name="url">
            <a:documentation>
                Enter an URL for this person.
            </a:documentation>
            <ref name="attlist.url"/>
            <empty/>
        </element>
    </define>
    <define combine="interleave" name="attlist.url">
        <optional>
            <attribute a:defaultValue="http://" name="href">
                <a:documentation>
                    Enter an URL for this person.
                </a:documentation>                
            </attribute>
        </optional>
    </define>
    <define name="link">
        <element name="link">
            <a:documentation>
                Specify who is the manager and who are the subordinates for this person.
            </a:documentation>
            <ref name="attlist.link"/>
            <empty/>
        </element>
    </define>
    <define combine="interleave" name="attlist.link">
        <optional>
            <attribute name="manager">
                <a:documentation>
                    The manager ID.
                </a:documentation>
                <data type="IDREF"/>
            </attribute>
        </optional>
    </define>
    <define combine="interleave" name="attlist.link">
        <optional>
            <attribute name="subordinates">
                <a:documentation>
                    Space separated list with the subordinates IDs.
                </a:documentation>
                <data type="IDREFS"/>
            </attribute>
        </optional>
    </define>
    <start>
        <choice>
            <ref name="personnel"/>
        </choice>
    </start>
</grammar>
