<?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">
  
  <!-- QSOS container -->
  <xsd:element name="qsos">
    <xsd:complexType>
      <xsd:sequence minOccurs="0" maxOccurs="unbounded">
	<xsd:choice>
	  <xsd:element ref="xdif:qso" />
	  <xsd:element ref="xdif:cq" />
	  <xsd:element ref="xdif:qst" />
	</xsd:choice>
      </xsd:sequence>
      <!-- Allow foreign attributes -->
      <xsd:anyAttribute namespace="##other"/>
    </xsd:complexType>
  </xsd:element>


  <!-- QSO Information -->
  <xsd:complexType name="qsoType">
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:choice minOccurs="0" maxOccurs="1">
	<!-- Any addenda or updates to my station -->
	<xsd:element ref="xdif:my" />
	
	<!-- Contacted Station information -->
	<xsd:element ref="xdif:om" />
	
	<!-- Band -->
	<xsd:element name="band"  type="xdif:band" />
	
	<!-- Frequency in Megahertz -->
	<xsd:element name="frequency" type="xsd:decimal" />
	
	<!-- Mode -->
	<xsd:element name="mode" type="xdif:mode" />
	
	<!-- Comment -->
	<xsd:element name="comment"  type="xdif:mixed" />
	
	<!-- Notes -->
	<xsd:element name="notes"  type="xdif:mixed" />
	
	<!-- Propagation Mode -->
	<xsd:element name="propagation" type="xdif:propagation" />
	
	<!-- Date/Time on in UTC -->
	<xsd:element name="begin"  type="xsd:dateTime" />
	
	<!-- Date/Time off in UTC -->
	<xsd:element name="end"  type="xsd:dateTime" />
	
	<!-- Scheduled (as opposed to random) -->
	<xsd:element name="schedule" >
	  <xsd:complexType />
	</xsd:element>
	
	<!-- RX-only information (RST received, contest serial number, etc.) -->
	<xsd:element ref="xdif:rx"  />
	
	<!-- TX-only information (RST received, contest serial number, etc.) -->
	<xsd:element ref="xdif:tx" />
	
	<!-- SWL-only information -->
	<xsd:element name="swl"  type="xdif:rx" />
	
	<!-- QSL Info -->
	<xsd:element ref="xdif:qsl" />
	
	<!-- Indicates whether the QSO was complete -->
	<xsd:element name="complete" >
	  <xsd:simpleType>
	    <xsd:restriction base="xsd:string">
	      <xsd:enumeration value="yes" />
	      <xsd:enumeration value="no" />
	      <xsd:enumeration value="notHeard" />
	      <xsd:enumeration value="uncertain " />
	    </xsd:restriction>
	  </xsd:simpleType>
	</xsd:element>
	
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID" use="optional" />
    <!-- Allow foreign attributes -->
    <xsd:anyAttribute namespace="##other"/>
  </xsd:complexType>
  
  <!-- If present, attribute 'use' must refer to attribute 'id' on element 'station' inside element 'definitions' -->
  <!-- xsd:keyref name="stationRef" refer="xdif:stationKey">
       <xsd:selector xpath="xdif:my" />
       <xsd:field xpath="@xdif:use"/>
       </xsd:keyref -->

  <xsd:element name="qso" type="xdif:qsoType" />
  <xsd:element name="cq" type="xdif:qsoType" />
  <xsd:element name="qst" type="xdif:qsoType" />


  <!-- TX-only information -->
  <xsd:element name="tx" type="xdif:tx" />

  <xsd:complexType name="tx">
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:choice minOccurs="0" maxOccurs="1">
	<!-- Signal report to the contacted station -->
	<xsd:element name="rst" type="xdif:rst"  />
	<!-- Logging station's transmit frequency in Megahertz -->
	<xsd:element name="frequency" type="xsd:decimal" />
	<!-- Logging station's transmit band -->
	<xsd:element name="band" type="xdif:band" />
	<!-- Logging station's transmit mode -->
	<xsd:element name="mode" type="xdif:mode" />
	<!-- Transmitting equipment-->
	<xsd:element ref="xdif:equipment" />
	<!-- Allow foreign elements -->
	<xsd:any namespace="##other" minOccurs="0" maxOccurs="1"/>
      </xsd:choice>
    </xsd:sequence>
    <!-- Allow foreign attributes -->
    <xsd:anyAttribute namespace="##other"/>
  </xsd:complexType>
  
  <!-- RX-only information -->
  <xsd:element name="rx" type="xdif:rx" />

  <xsd:complexType name="rx">
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:choice>
	<!-- Signal report from the contacted station -->
	<xsd:element name="rst" type="xdif:rst" />
	<!-- Logging station's receiving frequency in Megahertz -->
	<xsd:element name="frequency" type="xsd:decimal" />
	<!-- Logging station's receiving band -->
	<xsd:element name="band" type="xdif:band" />
	<!-- Logging station's receiving mode -->
	<xsd:element name="mode" type="xdif:mode" />
	<!-- Contest info -->
	<xsd:element ref="xdif:contest"  />
	<!-- Allow foreign elements (contest, etc). -->
	<xsd:any namespace="##other" />
      </xsd:choice>	
    </xsd:sequence>
    <!-- Allow foreign attributes -->
    <xsd:anyAttribute namespace="##other"/>
  </xsd:complexType>
		   


</xsd:schema>

