<?xml version="1.0"?>
<schema targetNamespace="http://ws.infotorg.no/xml/EVRY/Masterdata/2016-06-15/Masterdata.xsd"
    xmlns:tns="http://ws.infotorg.no/xml/EVRY/Masterdata/2016-06-15/Masterdata.xsd"
    xmlns="http://www.w3.org/2001/XMLSchema">
    
    <annotation>
        <documentation xml:lang="no">
           ©  2016 EVRY AS
        </documentation>
    </annotation>

    <complexType name="OPPDRAGSDEF">
       <simpleContent>
           <extension base="tns:OPPDRAGSID">
               <attribute name="antall">
                   <simpleType>
                        <restriction base="string">
                        </restriction>
                    </simpleType>
                </attribute>
            </extension>
        </simpleContent>
    </complexType> 

    <simpleType name="OPPDRAGSID">
        <annotation>
            <documentation>Verdi 'OPPDRAGSID' : Identifisering av kundens portefoelje</documentation>
            <documentation>Value 'OPPDRAGSID' : Identification of customer portfolio</documentation>
        </annotation>
        <restriction base="string">
            <minLength value="1" />
            <maxLength value="10" />
        </restriction>
    </simpleType>      

    <simpleType name="KUNDEID">
        <annotation>
            <documentation>Verdi 'KUNDEID' : Kundens unike referanse til objektet</documentation>
            <documentation>Value 'CUSTOMERID' : Customer unique reference to the object</documentation>
        </annotation>
        <restriction base="string">
            <maxLength value="36" />
        </restriction>
    </simpleType>

  <complexType name="KILDEDEF">
    <simpleContent>
       <extension base="tns:KILDEID">
        <attribute name="type">
            <simpleType>
            <restriction base="string">
            </restriction>
                </simpleType>
        </attribute>
        </extension>
    </simpleContent>
    </complexType> 
            
    <simpleType name="KILDEID">
        <annotation>
            <documentation>Verdi 'KILDEID' : Identifisering av objekted i kilden. Dersom type='FNR' og privat tilgang hos Skatt, er det påkrevd med fornavn og etternavn etter fnr, eks.: "12345678901 Donald Duck".</documentation>
            <documentation>Value 'SOURCEID' : Identification of the object in the datasource</documentation>
        </annotation>
        <restriction base="string">
            <maxLength value="150" />
        </restriction>
    </simpleType>
    
   <simpleType name="UUID">
        <annotation>
            <documentation>universally unique identifier - For fremtidig bruk</documentation>
            <documentation>universally unique identifier - Not in use</documentation>
        </annotation>
        <restriction base="string"/>
    </simpleType>

    <simpleType name="DATOENDR">
        <annotation>
            <documentation>Verdi 'DATOENDR' : YYYY-MM-DD Dato for siste endring</documentation>
            <documentation>Value 'DATOENDR' : YYYY-MM-DD Date of last change</documentation>
        </annotation>
        <restriction base="string">
           <maxLength value="10" />
        </restriction>
    </simpleType>

    <simpleType name="KILDEDATA">
        <annotation>
            <documentation>JSON-objekt - Kildedata paafoert av Evry</documentation>
            <documentation>JSON-objekt - Data inflicted by Evry</documentation>
        </annotation>
        <restriction base="string">
            <minLength value="1" />
        </restriction>
    </simpleType>

    <simpleType name="SYSTEMDATA">
        <annotation>
            <documentation>JSON-objekt - Kunde data</documentation>
            <documentation>JSON-objekt - Customer data</documentation>
        </annotation>
        <restriction base="string"/> 
    </simpleType>

    <simpleType name="SYSTEMDATA_OCC">
        <annotation>
            <documentation>JSON-objekt Optimistic Concurrency Control - mulighet for optimistisk laasing</documentation>
            <documentation>JSON-objekt Optimistic Concurrency Control - possibility of optimistic locking</documentation>
        </annotation>
        <restriction base="string"/> 
    </simpleType>
    
    <complexType name="STATUSDEF">
        <simpleContent>
            <extension base="tns:STATUS">
                <attribute name="kode">
                    <simpleType>
                        <restriction base="string">
                          <enumeration value="E1"/> <!-- Systemdata er endret paa objektet -->
                          <enumeration value="E2"/> <!-- Objektet er endret med ny kildeid -->
                          <enumeration value="R1"/> <!-- Objektet finnes ikke -->
                          <enumeration value="R2"/> <!-- Objektet finnes ikke -->
                          <enumeration value="D1"/> <!-- Systemdata er slettet paa objektet -->
                          <enumeration value="D2"/> <!-- Objektet er slettet i portefoeljen -->
                        </restriction>
                    </simpleType>
                </attribute>
            </extension>
        </simpleContent>
    </complexType> 

    <simpleType name="STATUS">
        <annotation>
            <documentation>Informasjon om status på transaksjonen</documentation>
            <documentation>Information on the status of the transaction</documentation>
        </annotation>
        <restriction base="string">
            <maxLength value="100" />
        </restriction>
    </simpleType>
    
    
    <element name="hentMasterdataSkriv">
        <complexType>
            <sequence>
                <element name="oppdragsid" type="tns:OPPDRAGSID"/>
                <element name="kundeid" type="tns:KUNDEID"/>
                <sequence>
                    <choice>
                        <element name="kildeid" type="tns:KILDEDEF" nillable="true" minOccurs="0"  maxOccurs="1"/>
                        <element name="uuid" type="tns:UUID" nillable="true" minOccurs="0"  maxOccurs="1"/>
                    </choice>
                </sequence>
                <element name="systemdata" type="tns:SYSTEMDATA" nillable="true" minOccurs="0"  maxOccurs="1"/>
                <element name="systemdata_occ" type="tns:SYSTEMDATA_OCC" minOccurs="0" maxOccurs="1"/>
            </sequence>
        </complexType>
    </element>

    <element name="hentMasterdataLes">
        <complexType>
            <sequence>
                <element name="oppdragsid" type="tns:OPPDRAGSID"/>
                <sequence>
                    <choice>
                        <element name="kundeid" type="tns:KUNDEID"/>
                        <element name="kildeid" type="tns:KILDEDEF"/>
                        <element name="uuid" type="tns:UUID" nillable="true"/>
                    </choice>
                </sequence>
            </sequence>
        </complexType>
    </element>

    <element name="MasterdataSkriv">
        <complexType>
            <sequence>
                <element name="OPPDRAGSID" type="tns:OPPDRAGSDEF"/>             
                <element name="KUNDEID" type="tns:KUNDEID"/>
                <element name="KILDEID" type="tns:KILDEDEF" minOccurs="0" maxOccurs="1"/>
                <element name="UUID" type="tns:UUID" nillable="true" minOccurs="0" maxOccurs="1" />
                <element name="SIST_ENDRET" type="tns:DATOENDR" minOccurs="0"  maxOccurs="1"/>
                <element name="KILDEDATA" type="tns:KILDEDATA" minOccurs="0"  maxOccurs="1"/>
                <element name="SYSTEMDATA" type="tns:SYSTEMDATA" nillable="true" minOccurs="0"  maxOccurs="1"/>
                <element name="SYSTEMDATA_OCC" type="tns:SYSTEMDATA_OCC" minOccurs="0"  maxOccurs="1"/>
                <element name="STATUS" type="tns:STATUSDEF" minOccurs="0"  maxOccurs="1"/>
            </sequence>
        </complexType>
    </element>

    <element name="MasterdataLes">
        <complexType>
            <sequence>
                <element name="OPPDRAGSID" type="tns:OPPDRAGSDEF"/> 
                <choice>
                    <sequence>                  
                        <element name="KUNDEID" type="tns:KUNDEID" minOccurs="0" maxOccurs="1"/>
                        <element name="KILDEID" type="tns:KILDEDEF" minOccurs="0" maxOccurs="1"/>
                        <element name="UUID" type="tns:UUID" nillable="true" minOccurs="0" maxOccurs="1" />
                        <element name="SIST_ENDRET" type="tns:DATOENDR" minOccurs="0" maxOccurs="1"/>
                        <element name="KILDEDATA" type="tns:KILDEDATA" minOccurs="0" maxOccurs="1"/>
                        <element name="SYSTEMDATA" type="tns:SYSTEMDATA"  minOccurs="0" maxOccurs="1"/>
                        <element name="STATUS" type="tns:STATUSDEF" minOccurs="0"  maxOccurs="1"/>
                    </sequence>
                    <element name="TREFFLISTE" minOccurs="0" maxOccurs="unbounded">
                        <complexType> 
                            <sequence>  
                                <element name="KUNDEID" type="tns:KUNDEID"/>
                                <element name="KILDEID" type="tns:KILDEDEF"/>
                                <element name="UUID" type="tns:UUID" minOccurs="0" maxOccurs="1"/>
                                <element name="SIST_ENDRET" type="tns:DATOENDR" minOccurs="0"  maxOccurs="1"/>
                            </sequence>
                        </complexType> 
                    </element>
                </choice>
            </sequence>
        </complexType>
    </element>
</schema>

  