<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:element name="positions">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="SetPosition" maxOccurs="unbounded" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    

    <xsd:element name="SetPosition" type="uuvPositionCommandType">
    </xsd:element>
    
    <xsd:complexType name="uuvPositionCommandType">
        <xsd:sequence>
            <xsd:group ref="AbsoluteHorizontalPositionElements"/>
            <xsd:element name="Depth" type="positiveScalarElementType" minOccurs="0"/>
        </xsd:sequence>
        <xsd:attributeGroup ref="CommonAttributes"/>
    </xsd:complexType>
    
    <xsd:group name="AbsoluteHorizontalPositionElements">
        <xsd:choice>
            <xsd:element name="LatitudeLongitude" type="latitudeLongitudeElementType">
            </xsd:element>
            <xsd:element name="XYPosition" type="xyElementType">
            </xsd:element>
        </xsd:choice>
    </xsd:group>
    
    <xsd:complexType name="xyElementType">
        <xsd:attribute name="x" type="xsd:double" use="required"/>
        <xsd:attribute name="y" type="xsd:double" use="required"/>
        <xsd:attributeGroup ref="CommonAttributes"/>
    </xsd:complexType>
    
    <xsd:complexType name="latitudeLongitudeElementType">
        <xsd:attribute name="latitude" type="latitudeType" use="required"/>
        <xsd:attribute name="longitude" type="longitudeType" use="required"/>
        <xsd:attributeGroup ref="CommonAttributes"/>
    </xsd:complexType>
    
    <xsd:simpleType name="latitudeType">
        <xsd:restriction base="xsd:double">
            <xsd:minInclusive value="-90"/>
            <xsd:maxInclusive value="90"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="longitudeType">
        <xsd:restriction base="xsd:double">
            <xsd:minInclusive value="-180"/>
            <xsd:maxInclusive value="180"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:complexType name="positiveScalarElementType">
        <xsd:attribute name="value" type="positiveScalarType" use="required"/>
        <xsd:attributeGroup ref="CommonAttributes"/>
    </xsd:complexType>
    
    <xsd:simpleType name="positiveScalarType">
        <xsd:restriction base="xsd:double">
            <xsd:minInclusive value="0"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="nonNegativeScalarType">
        <xsd:restriction base="xsd:double">
            <xsd:minInclusive value="0"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:attributeGroup name="CommonAttributes">
        <xsd:attribute name="timeStamp" type="nonNegativeScalarType" use="optional"/>
        <xsd:attribute name="description" type="xsd:string" use="optional"/>
        <xsd:attribute name="id" type="xsd:ID" use="optional"/>
        <!--		<xsd:attribute name="idRef" type="xsd:IDREF" use="optional"/> -->
    </xsd:attributeGroup>
    
    <!-- ?????? -->
    <xsd:group name="PointListElements">
        <xsd:annotation>
            <xsd:documentation>Selectable element to represent a horizontal position using latitude longitude, (x, y) coordinate pair, or (x, y) coordinate relative to the vehicle's current position.</xsd:documentation>
        </xsd:annotation>
        <xsd:choice>
            <xsd:element name="LatitudeLongitude" type="latitudeLongitudeElementType" maxOccurs="unbounded"/>
            <xsd:element name="XYPosition" type="xyElementType" maxOccurs="unbounded"/>
        </xsd:choice>
    </xsd:group>
    <xsd:group name="HorizontalPositionElements">
        <xsd:annotation>
            <xsd:documentation>Selectable element to represent a horizontal position using latitude longitude, (x, y) coordinate pair, or (x, y) coordinate relative to the vehicle's current position.</xsd:documentation>
        </xsd:annotation>
        <xsd:choice>
            <xsd:element name="LatitudeLongitude" type="latitudeLongitudeElementType">
                <xsd:annotation>
                    <xsd:documentation>Absolute geographic position using latitude and longitude (+ value for North or East, - value for South or West)</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="XYPosition" type="xyElementType">
                <xsd:annotation>
                    <xsd:documentation>Absolute geographic position using a cartesian coordinate system (X north, Y east) and a specified or default geographic origin.</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="RelativeXYPosition" type="xyElementType">
                <xsd:annotation>
                    <xsd:documentation>Position specified relative to the vehicle's current position (X meters north, Y meters east).</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:choice>
    </xsd:group>
    
</xsd:schema> 