<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0">


<!--RootNode: Packets-->
    <xsd:element name="Templates">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Protocol" type="CommunicationDirection" minOccurs="0" maxOccurs="unbounded" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
        
        
<!--Type defs-->
    <!--CommunicationDirection-->
    <xsd:complexType name="CommunicationDirection">
        <xsd:sequence>
            <xsd:element name="Packet" type="PacketType" minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
        <xsd:attribute name="type" type="CommunicationDirectionTypes" use="required" />
    </xsd:complexType>


    <!--CommunicationDirection enumeration-->
    <xsd:simpleType name="CommunicationDirectionTypes">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="ctols" />
            <xsd:enumeration value="lstoc" />
            <xsd:enumeration value="ctogs" />
            <xsd:enumeration value="gstoc" />

            <!--WILL BE IGNORED: (backwards compatibility)-->
            <xsd:enumeration value="CtoLS" />
            <xsd:enumeration value="LStoC" />
            <xsd:enumeration value="CtoGS" />
            <xsd:enumeration value="GStoC" />
        </xsd:restriction>
    </xsd:simpleType>


    <!--MetaInfo-->
    <!--Used whenever a packet or type has a special name or description, as documentation-->
    <xsd:complexType name="MetaInfo">
        <xsd:sequence>
            <xsd:element name="Name"        type="xsd:string" minOccurs="0" maxOccurs="1" />
            <xsd:element name="Description" type="xsd:string" minOccurs="0" maxOccurs="1" />

            <!--WILL BE IGNORED: (backwards compatibility)-->
            <xsd:element name="Author"      type="xsd:string" minOccurs="0" maxOccurs="1" />
        </xsd:sequence>
    </xsd:complexType>


    <!--MetaInfoAttachment-->
    <!--Inherit from this type to get an optional meta-info attachment element-->
    <xsd:complexType name="MetaInfoAttachment">
        <xsd:sequence>
            <xsd:element name="Info" type="MetaInfo" minOccurs="0" maxOccurs="1" />
        </xsd:sequence>
    </xsd:complexType>


    <!--PacketType-->
    <!--Encapsulates a whole packet-->
    <xsd:complexType name="PacketType">
        <xsd:complexContent>
            <xsd:extension base="MetaInfoAttachment">
                <xsd:sequence>
                    <xsd:element name="Field"       type="FieldType"   minOccurs="0" maxOccurs="unbounded" />
                </xsd:sequence>
                <xsd:attribute name="header"        type="xsd:integer"      use="required" />

                <!--WILL BE IGNORED: (backwards compatibility)-->
                <xsd:attribute name="typeSize"      type="xsd:integer"      use="optional" /><!--Minimum storage size? (plus pointers)-->
                <xsd:attribute name="staticSize"    type="xsd:integer"      use="optional" /><!--Minimum space required to store this?-->
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>


    <!--FieldType-->
    <!--Encapsulates one field (and possible subfields)-->
    <xsd:complexType name="FieldType">
        <xsd:complexContent>
            <xsd:extension base="MetaInfoAttachment">
                <xsd:sequence>
                    <!--optional nested fields-->
                    <xsd:element name="Field"   type="FieldType"        minOccurs="0" maxOccurs="unbounded" />
                </xsd:sequence>
                <xsd:attribute name="type"      type="PacketSimpleTypes" use="required" />

                <!--optional static array length-->
                <xsd:attribute name="elements"  type="xsd:unsignedInt"  use="optional" />

                <!--WILL BE IGNORED: (backwards compatibility)-->
                <xsd:attribute name="typeSize"  type="xsd:integer"      use="optional" />
                <xsd:attribute name="staticSize" type="xsd:integer"     use="optional" />
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>


    <!--PacketSimpleTypes-->
    <xsd:simpleType name="PacketSimpleTypes">
        <xsd:restriction base="xsd:string">

            <!--No structs, also in GW1-->
            <xsd:enumeration value="byte" />                <!--8 Bit-->
            <xsd:enumeration value="short" />               <!--16 Bit-->
            <xsd:enumeration value="int" />                 <!--32 Bit-->
            <xsd:enumeration value="agentid" />             <!--32 Bit-->
            <xsd:enumeration value="float" />               <!--32 Bit-->
            <xsd:enumeration value="vec2" />                <!--64 Bit-->
            <xsd:enumeration value="vec3" />                <!--96 Bit-->
            <xsd:enumeration value="utf16" />               <!--Prefix: 16 Bit, Payload: array of 16 Bit chars-->
            <xsd:enumeration value="buffer_static" />       <!--No Prefix,      Payload: fixed sized byte-buffer-->

            <!--No structs, just in GW2-->
            <xsd:enumeration value="long" />                <!--64 Bit-->
            <xsd:enumeration value="varint" />              <!--variable length (packed) number-->
            <xsd:enumeration value="vec4" />                <!--128 Bit-->
            <xsd:enumeration value="dw3" />                 <!--96 Bit-->
            <xsd:enumeration value="uid16" />               <!--16 Byte-->
            <xsd:enumeration value="guid18" />              <!--18 Byte-->
            <xsd:enumeration value="ascii" />               <!--Prefix: 16 Bit, Payload: array of 8 Bit chars-->
            <xsd:enumeration value="buffer_var_small" />    <!--Prefix: 8 Bit,  Payload: byte-buffer-->
            <xsd:enumeration value="buffer_var_big" />      <!--Prefix: 16 Bit, Payload: byte-buffer-->

            <!--Structs, also in GW1-->
            <xsd:enumeration value="array_static" />        <!--No Prefix,      Payload: fixed sized array-->
            <xsd:enumeration value="array_var_small" />     <!--Prefix: 8 Bit,  Payload: array-->
            <xsd:enumeration value="array_var_big" />       <!--Prefix: 16 Bit, Payload: array-->

            <!--Structs, just in GW2-->
            <xsd:enumeration value="optional" />            <!--Prefix: 8 Bit,  Payload: nested-->

            <!--Deprecated-->
            <!--<xsd:enumeration value="varbyte" />             8-64 Bit-->
        </xsd:restriction>
    </xsd:simpleType>

</xsd:schema>
