<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:is-ext-contact="urn:is.isnic:xml:ns:is-ext-contact-1.0"
        xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
        xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
        targetNamespace="urn:is.isnic:xml:ns:is-ext-contact-1.0"
        elementFormDefault="qualified">

    <annotation><documentation>.is contact extension</documentation></annotation>

    <import namespace="urn:ietf:params:xml:ns:contact-1.0"
            schemaLocation="contact-1.0.xsd"/>
    <import namespace="urn:ietf:params:xml:ns:epp-1.0"
            schemaLocation="epp-1.0.xsd"/>


    <element name="infData" type="is-ext-contact:infDataType"/>
    <element name="create" type="is-ext-contact:createType"/>
    <element name="update" type="is-ext-contact:updateType"/>

    <complexType name="infDataType">
        <annotation><documentation>Extra info returned for contacts</documentation></annotation>
        <sequence>
            <element name="type" type="is-ext-contact:contactType" minOccurs="1" maxOccurs="1" />
            <element name="status" type="is-ext-contact:statusType" maxOccurs="7" />
            <element name="mobile" type="contact:e164Type" minOccurs="0">
                <annotation><documentation>Can be used for lost password retrieval</documentation></annotation></element>
            <element name="sid" type="is-ext-contact:sidType" minOccurs="0" maxOccurs="1"><annotation><documentation>kennitala, allows island.is single sign on for persons and companies</documentation></annotation></element>
            <element name="autoUpdateFromNationalRegistry" type="boolean" minOccurs="0" maxOccurs="1">
                <annotation><documentation>If sid is not set this can be ignored. If sid is set and this variable is set to true then address will be updated according to Þjóðskrá Íslands</documentation></annotation></element>
            <element name="cancelPaper" type="boolean" minOccurs="0" maxOccurs="1">
                <annotation><documentation>Always true since 2023-06-01</documentation></annotation></element>
        </sequence>
    </complexType>

    <complexType name="createType">
        <sequence>
            <element name="type" type="is-ext-contact:contactType" minOccurs="1" maxOccurs="1" />
            <element name="mobile" type="contact:e164Type" minOccurs="0">
                <annotation><documentation>Can be used for lost password retrieval</documentation></annotation></element>
            <element name="sid" type="is-ext-contact:sidType" minOccurs="0" maxOccurs="1"><annotation><documentation>kennitala, allows island.is single sign on for persons and companies</documentation></annotation></element>
            <element name="autoUpdateFromNationalRegistry" type="boolean" minOccurs="0" maxOccurs="1">
                <annotation><documentation>If sid is not set this can be ignored. If sid is set and this variable is set to true then address will be updated according to Þjóðskrá Íslands</documentation></annotation></element>
            <element name="cancelPaper" type="boolean" minOccurs="0" maxOccurs="1">
                <annotation><documentation>Always true since 2023-06-01</documentation></annotation></element>
            <element name="lang" type="language" default="en" minOccurs="0" maxOccurs="1">
                <annotation><documentation>only en and is valid</documentation></annotation>
            </element>
        </sequence>
    </complexType>

    <complexType name="updateType">
        <sequence>
            <element name="chg" type="is-ext-contact:chgType" minOccurs="0"/>
            <element name="oldPW" type="epp:pwType"/>
        </sequence>
    </complexType>

    <complexType name="chgType">
        <sequence>
            <element name="mobile" type="contact:e164Type" minOccurs="0"/>
            <element name="autoUpdateFromNationalRegistry" type="boolean" minOccurs="0" maxOccurs="1"/>
            <element name="cancelPaper" type="boolean" minOccurs="0" maxOccurs="1"/>
            <element name="lang" type="language" default="en" minOccurs="0" maxOccurs="1"/>
        </sequence>
    </complexType>

    <!--
    Status is a combination of attributes and an optional human-readable
    message that may be expressed in languages other than English.
    -->
    <complexType name="statusType">
        <simpleContent>
            <extension base="normalizedString">
                <attribute name="s" type="is-ext-contact:statusValueType"
                           use="required"/>
                <attribute name="lang" type="language"
                           default="en"/>
            </extension>
        </simpleContent>
    </complexType>

    <simpleType name="statusValueType">
        <restriction base="token">
            <enumeration value="ok"><annotation><documentation>Contact has confirmed email</documentation></annotation></enumeration>
            <enumeration value="okUnconfirmed"><annotation><documentation>Contact was created by the server, registered provider or agent, can be used for certain things and does not have confirmed email</documentation></annotation></enumeration>
            <enumeration value="pendingCreate"><annotation><documentation>Contact has yet to confirm email, is unusable and will be purged if not email is not confirmed</documentation></annotation></enumeration>
            <enumeration value="serverExpired"><annotation><documentation>Contact is not used anywhere and has been marked for deletion</documentation></annotation></enumeration>
            <enumeration value="serverSuspended"><annotation><documentation>Registry has suspended contact due to registration info is incomplete or other abnormal actions</documentation></annotation></enumeration>
        </restriction>
    </simpleType>

    <simpleType name="contactType">
        <annotation><documentation>Is contact a person (individual) or role (organisation or something else).  Controls "do not disclose" capabilities.</documentation></annotation>
        <restriction base="token">
            <enumeration value="person"><annotation><documentation>Contact is an individual, can mark certain fields "not disclose"</documentation></annotation></enumeration>
            <enumeration value="role"><annotation><documentation>Contact is not an individual (role or organisation), cannot mark certain fields "not disclose"</documentation></annotation></enumeration>
        </restriction>
    </simpleType>

    <simpleType name="sidType">
        <annotation><documentation>Icelandic national identification number (https://en.wikipedia.org/wiki/Kennitala) only set for Icelandic individuals or organisations</documentation></annotation>
        <restriction base="token">
            <pattern value="[0-9]{10,10}"/>
            <minLength value="10"/>
            <maxLength value="10"/>
        </restriction>
    </simpleType>

</schema>