<?xml version="1.0" encoding="UTF-8"?>

<!--
Fee extension (RFC 8748) for the public strict-RFC interface. Grammar authored for
THIS registry (we are the schema authority for our own interface): a faithful,
slightly permissive rendering of the RFC 8748 command/response elements — check
with per-command periods, and the fee agreement on create/renew/transfer/update.
-->
<schema targetNamespace="urn:ietf:params:xml:ns:epp:fee-1.0"
        xmlns:fee="urn:ietf:params:xml:ns:epp:fee-1.0"
        xmlns="http://www.w3.org/2001/XMLSchema"
        elementFormDefault="qualified">

  <annotation>
    <documentation>EPP Fee Extension (RFC 8748) — namespace.com.ua profile</documentation>
  </annotation>

  <!-- Command-side elements -->
  <element name="check"    type="fee:checkType"/>
  <element name="create"   type="fee:transformType"/>
  <element name="renew"    type="fee:transformType"/>
  <element name="transfer" type="fee:transformType"/>
  <element name="update"   type="fee:transformType"/>

  <!-- Response-side elements (emitted by the server; modeled for round-trip tooling) -->
  <element name="chkData"  type="fee:chkDataType"/>
  <element name="creData"  type="fee:transformResultType"/>
  <element name="renData"  type="fee:transformResultType"/>
  <element name="trnData"  type="fee:transformResultType"/>
  <element name="updData"  type="fee:transformResultType"/>
  <element name="delData"  type="fee:transformResultType"/>

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

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

  <complexType name="feeType">
    <simpleContent>
      <extension base="fee:nonNegativeDecimal">
        <attribute name="description" type="token"/>
        <attribute name="refundable" type="boolean"/>
        <attribute name="grace-period" type="duration"/>
        <attribute name="applied" type="token"/>
      </extension>
    </simpleContent>
  </complexType>

  <complexType name="creditType">
    <simpleContent>
      <extension base="decimal">
        <attribute name="description" type="token"/>
      </extension>
    </simpleContent>
  </complexType>

  <complexType name="periodType">
    <simpleContent>
      <extension base="positiveInteger">
        <attribute name="unit" type="token" default="y"/>
      </extension>
    </simpleContent>
  </complexType>

  <!-- fee:check — one command element per operation the client wants priced -->
  <complexType name="checkType">
    <sequence>
      <element name="currency" type="fee:currencyType" minOccurs="0"/>
      <element name="command"  type="fee:commandType"  maxOccurs="unbounded"/>
    </sequence>
  </complexType>

  <complexType name="commandType">
    <sequence>
      <element name="period" type="fee:periodType" minOccurs="0"/>
    </sequence>
    <attribute name="name" type="token" use="required"/>
    <attribute name="phase" type="token"/>
    <attribute name="subphase" type="token"/>
  </complexType>

  <!-- fee agreement on a transform command -->
  <complexType name="transformType">
    <sequence>
      <element name="currency" type="fee:currencyType" minOccurs="0"/>
      <element name="fee"      type="fee:feeType"      maxOccurs="unbounded"/>
      <element name="credit"   type="fee:creditType"   minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
  </complexType>

  <!-- check response -->
  <complexType name="chkDataType">
    <sequence>
      <element name="currency" type="fee:currencyType"/>
      <element name="cd"       type="fee:cdType" maxOccurs="unbounded"/>
    </sequence>
  </complexType>

  <complexType name="cdType">
    <sequence>
      <element name="objID"   type="token"/>
      <element name="class"   type="token" minOccurs="0"/>
      <element name="command" type="fee:resultCommandType" minOccurs="0" maxOccurs="unbounded"/>
      <element name="reason"  type="token" minOccurs="0"/>
    </sequence>
    <attribute name="avail" type="boolean" default="true"/>
  </complexType>

  <complexType name="resultCommandType">
    <sequence>
      <element name="period" type="fee:periodType" minOccurs="0"/>
      <element name="fee"    type="fee:feeType"    minOccurs="0" maxOccurs="unbounded"/>
      <element name="credit" type="fee:creditType" minOccurs="0" maxOccurs="unbounded"/>
      <element name="reason" type="token"          minOccurs="0"/>
    </sequence>
    <attribute name="name" type="token" use="required"/>
    <attribute name="standard" type="boolean" default="false"/>
    <attribute name="phase" type="token"/>
    <attribute name="subphase" type="token"/>
  </complexType>

  <!-- transform responses -->
  <complexType name="transformResultType">
    <sequence>
      <element name="currency"    type="fee:currencyType"/>
      <element name="period"      type="fee:periodType"       minOccurs="0"/>
      <element name="fee"         type="fee:feeType"          minOccurs="0" maxOccurs="unbounded"/>
      <element name="credit"      type="fee:creditType"       minOccurs="0" maxOccurs="unbounded"/>
      <element name="balance"     type="decimal"              minOccurs="0"/>
      <element name="creditLimit" type="decimal"              minOccurs="0"/>
    </sequence>
  </complexType>

</schema>
