<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	    targetNamespace="http://www.wa5znu.org/2006/04/xdif/" 
	    xmlns:xdif="http://www.wa5znu.org/2006/04/xdif/"
	    elementFormDefault="qualified">

  <!-- Optional container for definitions of station, location, or equipment for later re-use -->
  <xsd:element name="definitions">
    <xsd:complexType>
      <xsd:sequence minOccurs="0" maxOccurs="unbounded" >
	<xsd:choice>
	  <!-- In a definition it is called station but later it is called "my" -->
	  <xsd:element name="station" type="xdif:station" />
	  <xsd:element ref="xdif:location" />
	  <xsd:element ref="xdif:equipment" />
	</xsd:choice>
      </xsd:sequence>
      <xsd:attribute name="id" type="xsd:ID" use="optional" />
      <xsd:anyAttribute namespace="##other" />
    </xsd:complexType>

    <!-- When used inside an element definitions, name of defined station equipment is specified by an id attribute -->
    <!-- xsd:key name="stationKey">
      <xsd:selector xpath="xdif:station" />
      <xsd:field xpath="@xdif:id"/>
    </xsd:key -->
    <!-- When used inside an element definitions, name of defined location is specified by an id attribute -->
    <!-- xsd:key name="locationKey">
      <xsd:selector xpath="xdif:location/*" />
      <xsd:field xpath="@xdif:id"/>
    </xsd:key -->
    <!-- When used inside an element definitions, name of defined equipment is specified by an id attribute -->
    <!-- xsd:key name="equipmentKey">
      <xsd:selector xpath="xdif:equipment" />
      <xsd:field xpath="@xdif:id"/>
    </xsd:key -->
  </xsd:element>


  <!-- Type station holds information about the logging or contacted station and can be logged as element om or element my -->
  <xsd:complexType name="station">
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:choice minOccurs="0" maxOccurs="1">
	<xsd:element name="control" type="xdif:operator" />	<!-- Control Operator -->
	<xsd:element name="guest" type="xdif:operator" />	<!-- Guest operator -->
	<xsd:element ref="xdif:location" />		        <!-- Station location-->
	<xsd:element ref="xdif:clubs" />	 		<!-- Club numbers -->
	<xsd:element name="sig" type="xdif:sig" />		<!-- SIG/Event and associated information -->
	<xsd:element ref="xdif:equipment" />		        <!-- Station equipment-->
	<xsd:any namespace="##other" />			<!-- Allow foreign elements -->
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID" use="optional" />
    <xsd:attribute name="use" use="optional" type="xsd:IDREF" />
    <xsd:anyAttribute namespace="##other" />	<!-- Allow foreign attributes -->
  </xsd:complexType>

  <!-- Element my is station information for logging station -->
  <!-- My station info -->
  <xsd:element name="my" type="xdif:station">
    <!-- If present, element location attribute use must refer to an attribute id on an element location inside an element definitions -->
    <!-- xsd:keyref name="locationRef" refer="xdif:locationKey">
      <xsd:selector xpath="xdif:location" />
      <xsd:field xpath="@xdif:use"/>
    </xsd:keyref -->
    <!-- If present, element equipment attribute use must refer to an attribute id on an element equipment inside an element definitions -->
    <!-- xsd:keyref name="equipmentRef" refer="xdif:equipmentKey">
      <xsd:selector xpath="xdif:equipment" />
      <xsd:field xpath="@xdif:use"/>
    </xsd:keyref -->
  </xsd:element>

  <!-- Element om is station information for logging station -->
  <xsd:element name="om" type="xdif:station" />

  <!-- Station location -->
  <xsd:element name="location">
    <xsd:complexType>
      <xsd:sequence minOccurs="0" maxOccurs="unbounded">
	<xsd:choice minOccurs="0" maxOccurs="1">
	  <xsd:element name="arrl_section" type="xdif:arrl_section" />  <!-- ARRL Secion-->
	  <xsd:element name="rac_section" type="xdif:rac_section"  />  <!-- RAC Secion-->
	  <xsd:element name="cq_zone" type="xdif:cq_zone"  />      <!-- CQ Zone-->
	  <xsd:element name="dxcc" type="xdif:dxcc"  />	          <!-- DXCC Number-->
	  <xsd:element name="gridsquare" type="xdif:gridsquare"  /><!-- Maidenhead Grid Square -->
	  <xsd:element name="iota" type="xdif:iota"  />            <!-- IOTA Number -->
	  <xsd:element name="itu_zone" type="xdif:itu_zone"  />        <!-- ITU Zone-->
	  <xsd:element name="lat" type="xdif:degrees90"  />	  <!-- Latitude -->
	  <xsd:element name="lon" type="xdif:degrees180"  />	  <!-- Longitude -->
	  <xsd:element name="mailingAddress" type="xdif:multiLineString"  /> <!--Station's mailing addres-->
	  <xsd:element name="wpx_prefix" type="xsd:string"  />		  <!-- WPX prefix -->
	  <xsd:element name="qth" type="xsd:string"  />		  <!-- Location reported in QSO -->
	  <xsd:element name="county" type="xdif:county"   />       <!-- County, Prefecture, etc.-->
	  <xsd:element name="state" type="xdif:state"  />	          <!-- State, Island, etc. -->
	  <xsd:element name="country" type="xdif:country"  />         <!-- Country -->
	  <xsd:element name="continent" type="xdif:continent"  />  <!-- Continent -->
	  <xsd:any namespace="##other" />			  <!-- Allow foreign elements -->
	</xsd:choice>
      </xsd:sequence>
      <xsd:attribute name="id" type="xsd:ID" use="optional" />
      <xsd:attribute name="use" type="xsd:IDREF" use="optional" />
      <xsd:anyAttribute namespace="##other" />	  <!-- Allow foreign attributes -->
    </xsd:complexType>
  </xsd:element>


  <!-- Station Equipment -->
  <xsd:element name="equipment">
    <xsd:complexType>
      <xsd:sequence minOccurs="0" maxOccurs="unbounded">
	<xsd:choice>
	  <xsd:element name="antenna" type="xdif:antenna" minOccurs="0" maxOccurs="1" />	<!-- Description of equipment -->
	  <xsd:element name="rig" type="xdif:rig" minOccurs="0" maxOccurs="1" />		<!-- Description of equipment -->
	  <xsd:element name="power" type="xsd:decimal" minOccurs="0" maxOccurs="1"/>		<!-- Power of station in watts -->
	  <xsd:element name="powersource" type="xdif:powersource" minOccurs="0" maxOccurs="1"/>	<!-- Source of electrical power for station -->
	  <xsd:any namespace="##other" minOccurs="0" maxOccurs="1" />			<!-- Allow foreign elements -->
	</xsd:choice>
      </xsd:sequence>
      <xsd:attribute name="id" type="xsd:ID" use="optional" />
      <xsd:attribute name="use" type="xsd:IDREF" use="optional" />
      <xsd:anyAttribute namespace="##other" />	<!-- Allow foreign attributes -->
    </xsd:complexType>
  </xsd:element>

</xsd:schema>

