<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:fee="urn:ietf:params:xml:ns:fee-0.6"
  xmlns:eppcom="urn:ietf:params:xml:ns:eppcom-1.0"
  xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
  targetNamespace="urn:ietf:params:xml:ns:fee-0.6"
  elementFormDefault="qualified">

  <import namespace="urn:ietf:params:xml:ns:eppcom-1.0" />
  <import namespace="urn:ietf:params:xml:ns:domain-1.0" />

  <annotation>
    <documentation>
      Extensible Provisioning Protocol v1.0 domain name extension schema for fee information.
      Downloaded from https://raw.githubusercontent.com/centralnic/epp-fee-extension/master/fee.xsd.
    </documentation>
  </annotation>

  <!--
  Child elements found in EPP commands and responses
  -->
  <element name="check" type="fee:checkType" />
  <element name="chkData" type="fee:chkDataType" />
  <element name="info" type="fee:infoType" />
  <element name="infData" type="fee:infDataType" />
  <element name="create" type="fee:transformCommandType" />
  <element name="creData" type="fee:transformResultType" />
  <element name="renew" type="fee:transformCommandType" />
  <element name="renData" type="fee:transformResultType" />
  <element name="transfer" type="fee:transformCommandType" />
  <element name="trnData" type="fee:transferResultType" />
  <element name="update" type="fee:transformCommandType" />
  <element name="updData" type="fee:transformResultType" />
  <element name="delData" type="fee:deleteDataType" />

  <!--
  client <check> command
  -->
  <complexType name="checkType">
    <sequence>
      <element name="domain" type="fee:domainCheckType"
        maxOccurs="unbounded" />
    </sequence>
  </complexType>

  <complexType name="domainCheckType">
    <sequence>
      <element name="name" type="eppcom:labelType" />
      <element name="currency" type="fee:currencyType"
        minOccurs="0" />
      <element name="command" type="fee:commandType" />
      <element name="period" type="domain:periodType"
        minOccurs="0" />
    </sequence>
  </complexType>


  <!--
  server <check> result
  -->
  <complexType name="chkDataType">
    <sequence>
      <element name="cd" type="fee:domainCDType"
        maxOccurs="unbounded" />
    </sequence>
  </complexType>

  <complexType name="domainCDType">
    <sequence>
      <element name="name" type="eppcom:labelType" />
      <element name="currency" type="fee:currencyType" />
      <element name="command" type="fee:commandType" />
      <element name="period" type="domain:periodType" />
      <element name="fee" type="fee:feeType"
         minOccurs="0" maxOccurs="unbounded" />
      <element name="class" type="token" minOccurs="0" />
    </sequence>
  </complexType>

  <!--
    client <info> command
  -->
  <complexType name="infoType">
    <sequence>
      <element name="currency" type="fee:currencyType" />
      <element name="command" type="fee:commandType" />
      <element name="period" type="domain:periodType" />
    </sequence>
  </complexType>

  <!--
    server <info> result
  -->
  <complexType name="infDataType">
    <sequence>
      <element name="currency" type="fee:currencyType" />
      <element name="command" type="fee:commandType" />
      <element name="period" type="domain:periodType" />
      <element name="fee" type="fee:feeType"
        maxOccurs="unbounded" />
      <element name="class" type="token" minOccurs="0" />
    </sequence>
  </complexType>

  <!--
    general transform (create, renew, update, transfer) command
  -->
  <complexType name="transformCommandType">
    <sequence>
      <element name="currency" type="fee:currencyType" />
      <element name="fee" type="fee:feeType"
        maxOccurs="unbounded" />
    </sequence>
  </complexType>

  <!--
    general transform (create, renew, update) result
  -->
  <complexType name="transformResultType">
    <sequence>
      <element name="currency" type="fee:currencyType" />
      <element name="fee" type="fee:feeType"
        maxOccurs="unbounded" />
      <element name="balance" type="fee:balanceType"
        minOccurs="0" />
      <element name="creditLimit" type="fee:creditLimitType"
        minOccurs="0" />
    </sequence>
  </complexType>

  <!--
    transfer result
  -->
  <complexType name="transferResultType">
    <sequence>
      <element name="currency" type="fee:currencyType" />

      <!-- only used op="query" responses -->
      <element name="period" type="domain:periodType"
        minOccurs="0" />

      <element name="fee" type="fee:feeType"
        maxOccurs="unbounded" />
      <element name="balance" type="fee:balanceType"
        minOccurs="0" />
      <element name="creditLimit" type="fee:creditLimitType"
        minOccurs="0" />
    </sequence>
  </complexType>

  <!--
    delete result
  -->
  <complexType name="deleteDataType">
    <sequence>
      <element name="currency" type="fee:currencyType" />
      <element name="credit" type="fee:creditType"
        maxOccurs="unbounded" />
      <element name="balance" type="fee:balanceType"
        minOccurs="0" />
      <element name="creditLimit" type="fee:creditLimitType"
        minOccurs="0" />
    </sequence>
  </complexType>

  <!--
    common types
  -->
  <simpleType name="currencyType">
    <restriction base="string">
      <pattern value="[A-Z]{3}" />
    </restriction>
  </simpleType>

  <complexType name="commandType">
    <simpleContent>
      <extension base="fee:commandTypeValue">
        <attribute name="phase" type="token" />
        <attribute name="subphase" type="token" />
      </extension>
    </simpleContent>
  </complexType>

  <simpleType name="commandTypeValue">
    <restriction base="token">
      <minLength value="3"/>
      <maxLength value="16"/>
    </restriction>
  </simpleType>

  <simpleType name="nonNegativeDecimal">
    <restriction base="decimal">
      <minInclusive value="0" />
    </restriction>
  </simpleType>

  <simpleType name="negativeDecimal">
    <restriction base="decimal">
      <maxInclusive value="0" />
    </restriction>
  </simpleType>

  <complexType name="feeType">
    <simpleContent>
      <extension base="fee:nonNegativeDecimal">
        <attribute name="description"/>
        <attribute name="refundable" type="boolean"
          default="1" />
        <attribute name="grace-period" type="duration"
          default="P0D" />
        <attribute name="applied" default="immediate">
          <simpleType>
            <restriction base="token">
              <enumeration value="immediate" />
              <enumeration value="delayed" />
            </restriction>
          </simpleType>
        </attribute>
      </extension>
    </simpleContent>
  </complexType>

  <complexType name="creditType">
    <simpleContent>
      <extension base="fee:negativeDecimal">
        <attribute name="description"/>
      </extension>
    </simpleContent>
  </complexType>

  <simpleType name="balanceType">
    <restriction base="decimal" />
  </simpleType>

  <simpleType name="creditLimitType">
    <restriction base="decimal" />
  </simpleType>

</schema>
