<?xml version="1.0" encoding="UTF-8"?>
<!--
  Elements the activity_files package writes into the extension areas of
  GPX 1.0, GPX 1.1 and TCX files.

  Namespace: https://schemas.eikedreier.com/activity_files/v1
  Location:  https://schemas.eikedreier.com/activity_files/v1.xsd
  Package:   https://pub.dev/packages/activity_files

  The namespace stays the same as long as changes are additions: new
  elements are optional and existing ones keep their meaning.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="https://schemas.eikedreier.com/activity_files/v1"
           targetNamespace="https://schemas.eikedreier.com/activity_files/v1"
           elementFormDefault="qualified"
           version="1">

  <!-- The recording device. GPX: file-level extensions. TCX: Activity/Creator extensions. -->
  <xs:element name="device" type="deviceType"/>

  <xs:complexType name="deviceType">
    <!-- Every field is optional and written only when known; order does not matter. -->
    <xs:all>
      <xs:element name="manufacturer" type="xs:string" minOccurs="0"/>
      <xs:element name="model" type="xs:string" minOccurs="0"/>
      <xs:element name="product" type="xs:string" minOccurs="0"/>
      <xs:element name="serialNumber" type="xs:string" minOccurs="0"/>
      <xs:element name="softwareVersion" type="xs:string" minOccurs="0"/>
      <!-- FIT manufacturer ID (FIT profile type "manufacturer"). -->
      <xs:element name="fitManufacturerId" type="xs:nonNegativeInteger" minOccurs="0"/>
      <!-- FIT product ID (FIT field "product" / "garmin_product"). -->
      <xs:element name="fitProductId" type="xs:nonNegativeInteger" minOccurs="0"/>
    </xs:all>
  </xs:complexType>

  <!-- The software that created the file, as a free label. TCX only: GPX has the creator attribute. -->
  <xs:element name="creator" type="xs:string"/>

  <!-- A track's type. GPX 1.0 only, which has no trk/type of its own. -->
  <xs:element name="type" type="xs:string"/>

  <!--
    A track's extension elements. TCX only: a Track holds only trackpoints,
    so they are kept in the activity's extensions. The content is whatever
    the source file carried, in its own namespaces.
  -->
  <xs:element name="trackExtensions">
    <xs:complexType>
      <xs:sequence>
        <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:anyAttribute namespace="##other" processContents="lax"/>
    </xs:complexType>
  </xs:element>

  <!--
    TCX lap extensions: the required lap elements that were filled with the
    schema's neutral value because the activity had none, space-separated by
    local name (e.g. "TotalTimeSeconds Calories"). A reader treats them as absent.
  -->
  <xs:element name="DefaultedFields">
    <xs:simpleType>
      <xs:list itemType="xs:NCName"/>
    </xs:simpleType>
  </xs:element>

</xs:schema>
