<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<!--
    Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>

    This library is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License as published by
    the Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    This library is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
    License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to the
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
-->

  <!-- The root element of every ContactGroup document -->
  <xsd:element name="contactGroup">
    <xsd:complexType>
      <!-- A list of contacts or contact references -->
      <xsd:choice minOccurs="0" maxOccurs="unbound">
        <xsd:element name="contactData" type="contactDataType"/>
        <xsd:element name="contactReference" type="contactReferenceType"/>
      </xsd:choice>

      <!-- The unique identifier of this contact group -->
      <xsd:attribute name="uid" type="xsd:string" use="required" />

      <!-- The i18n'ed name of this contact group -->
      <xsd:attribute name="name" type="xsd:string" use="required" />
    </xsd:complexType>
  </xsd:element>

  <!-- The type for inline contacts. -->
  <xsd:complexType name="contactDataType">
    <xsd:sequence>
      <!-- The i18n'ed name of this contact -->
      <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>

      <!-- The plain email address (without the name) of this contact -->
      <xsd:element name="email" type="xsd:string" minOccurs="1" maxOccurs="1"/>

      <!-- A list of custom fields for this contact -->
      <xsd:element name="custom" minOccurs="0" maxOccurs="unbound">
        <xsd:complexType>
          <xsd:attribute name="key" type="xsd:string" use="required" />
          <xsd:attribute name="value" type="xsd:string" use="required" />
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="contactReferenceType">
    <xsd:sequence>
      <!-- The uid of the contact this entry references -->
      <xsd:element name="uid" type="xsd:string" minOccurs="1" maxOccurs="1"/>

      <!-- The preferred email address which shall be used for the contact -->
      <xsd:element name="preferredEmail" type="xsd:string" minOccurs="0" maxOccurs="1"/>

      <!-- A list of custom fields for this contact -->
      <xsd:element name="custom" minOccurs="0" maxOccurs="unbound">
        <xsd:complexType>
          <xsd:attribute name="key" type="xsd:string" use="required" />
          <xsd:attribute name="value" type="xsd:string" use="required" />
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

</xsd:schema>
