<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
  xmlns:added="http://projets.admisource.gouv.fr/xemelios/namespaces#added">
  <xs:import namespace="http://projets.admisource.gouv.fr/xemelios/namespaces#added"
    schemaLocation="added.xsd"/>
  <xs:element name="Racine" type="TRacine"/>
  <xs:complexType name="TRacine">
    <xs:sequence>
      <xs:element name="Collectivite" type="added:TCollectivite"/>
      <xs:element name="Budget" type="added:TBudget"/>
      <xs:element name="IdentificationFlux" type="TIdentificationFlux"/>
      <xs:element name="DemandesRSA" type="TDemandesRSA"/>
      <xs:element name="Totalisations" type="TTotalisations"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TIdentificationFlux">
    <xs:sequence>
      <xs:element name="APPLIEME" type="TString5"/>
      <xs:element name="NUMVERSIONAPPLIEME" type="TInteger"/>
      <xs:element name="TYPEFLUX" type="TString1"/>
      <xs:element name="NATFLUX" type="TString1"/>
      <xs:element name="DTCREAFLUX" type="TDate"/>
      <!--xs:element name="HEUCREAFLUX" type="TTime"/-->
      <xs:element name="DTREF" type="TDate"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TDemandesRSA">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="InfosFinancieresFoyerRSA"
        type="TInfosFinancieresFoyerRSA"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TInfosFinancieresFoyerRSA">
    <xs:sequence>
      <xs:element name="IdentificationRSA" type="TIdentificationRSA"/>
      <xs:element name="Personne" type="TPersonne"/>
      <xs:element name="DonneesAdministratives" type="TDonneesAdministratives"/>
      <xs:element name="AcompteRSA" type="TAcompteRSA"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TIdentificationRSA">
    <xs:sequence>
      <xs:element name="Organisme" type="TOrganisme"/>
      <xs:element name="Partenaire" type="TPartenaire"/>
      <xs:element name="DemandeRSA" type="TDemandeRSA"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TOrganisme">
    <xs:sequence>
      <xs:element name="FONORG" type="TString3"/>
      <xs:element name="NUMORG" type="TInteger"/>
      <xs:element name="MATRICULE" type="TString"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TPartenaire">
    <xs:sequence>
      <xs:element name="TYPEPARTE" type="TString3"/>
      <xs:element name="IDEPARTE" type="TInteger"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TDemandeRSA">
    <xs:sequence>
      <xs:element name="DTDEMRSA" type="TDate"/>
      <xs:element name="NUMDEMRSA" type="TInteger"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TPersonne">
    <xs:sequence>
      <xs:element name="Identification" type="TIdentification"/>
      <xs:element name="DossierCAF" type="TDossierCAF"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TIdentification">
    <xs:sequence>
      <xs:element name="QUAL" type="TString5"/>
      <xs:element name="NOM" type="TString"/>
      <xs:element name="NOMNAI" type="TString"/>
      <xs:element name="PRENOM" type="TString"/>
      <xs:element minOccurs="0" name="PRENOM2" type="TString"/>
      <xs:element minOccurs="0" name="PRENOM3" type="TString"/>
      <xs:element name="NOMCOMNAI" type="TString"/>
      <xs:element name="DTNAI" type="TDate"/>
      <xs:element minOccurs="0" name="TYPEDTNAI" type="TString1"/>
      <!-- c'est quoi ??? -->
      <xs:element minOccurs="0" name="NIR" type="TNIR"/>
      <xs:element name="TOPVALIEC" type="TInteger"/>
      <!-- c'est quoi ??? -->
      <xs:element name="SEXE" type="TSexe"/>
      <!-- liste de valeurs ? -->
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="TNIR">
    <xs:restriction base="TString">
      <xs:length value="15"/>
      <xs:pattern value="[12][0..9]{14}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="TSexe">
    <xs:restriction base="xs:integer">
      <xs:enumeration value="1">
        <xs:annotation><xs:documentation>Homme</xs:documentation></xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="2">
        <xs:annotation><xs:documentation>Femme</xs:documentation></xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="TDossierCAF">
    <xs:sequence>
      <xs:element name="TOPRESPDOS" type="xs:integer"/>
      <xs:element name="DDRATDOS" type="TDate"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TDonneesAdministratives">
    <xs:sequence>
      <xs:element name="Adresse" type="TAdresse"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TAdresse">
    <xs:sequence>
      <xs:element name="RGADR" type="TInteger"/>
      <xs:element name="DTEMM" type="TDate"/>
      <!-- xs:NMTOKEN -->
      <xs:element name="NUMVOIE" type="TString"/>
      <xs:element name="TYPEVOIE" type="TString"/>
      <xs:element name="NOMVOIE" type="TString"/>
      <xs:element name="COMPLIDEADR" type="TString"/>
      <xs:element name="COMPLADR" type="TString"/>
      <xs:element name="LIEUDIST" type="TString"/>
      <xs:element name="NUMCOMRAT" type="TInteger"/>
      <xs:element name="NUMCOMPTT" type="TInteger"/>
      <xs:element name="CODEPOS" type="TString"/>
      <xs:element name="LOCAADR" type="TString"/>
      <xs:element name="PAYS" type="TString"/>
      <xs:element name="TYPEADR">
        <xs:simpleType>
          <xs:restriction base="TString1">
            <xs:enumeration value="D"/>
            <xs:enumeration value="P"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TAcompteRSA">
    <xs:sequence>
      <xs:element name="GeneraliteAcompteRSA" type="TGeneraliteAcompteRSA"/>
      <xs:element name="DetailAcompteRSA" type="TDetailAcompteRSA"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TGeneraliteAcompteRSA">
    <xs:sequence>
      <xs:element name="MOISMOUCOMPTA" type="TDate"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TDetailAcompteRSA">
    <xs:sequence>
      <xs:element name="AllocationsComptabilisees" type="TAllocationsComptabilisees"/>
      <xs:element minOccurs="0" name="RemisesIndus" type="TRemisesIndus"/>
      <xs:element minOccurs="0" name="IndusConstates" type="TIndusConstates"/>
      <xs:element minOccurs="0" name="IndusTransferesCG" type="TIndusTransferesCG"/>
      <xs:element minOccurs="0" name="AnnulationsFaibleMontant" type="TAnnulationsFaibleMontant"/>
      <xs:element minOccurs="0" name="AutresAnnulations" type="TAutresAnnulations"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TAllocationsComptabilisees">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="DetailAllocationComptabilisee" type="TDetail" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="somme" type="TMontant" use="required"/>
  </xs:complexType>
  <xs:complexType name="TDetail">
    <xs:sequence>
      <xs:element name="NATPFCRE" type="TString3"/>
      <xs:element name="RGCRE" type="xs:integer" minOccurs="0"/>
      <xs:element name="NUMINTMOUCOMPTA" type="TInteger" minOccurs="0"/>
      <xs:element name="TYPEOPECOMPTA" type="TString3"/>
      <xs:element name="SENSOPECOMPTA">
        <xs:simpleType>
          <xs:restriction base="TString">
            <xs:length value="2"/>
            <xs:enumeration value="AJ"/>
            <xs:enumeration value="DE"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="MTMOUCOMPTA" type="TMontant"/>
      <xs:element name="DTTRAIMOUCOMPTA" type="TDate"/>
      <!--xs:element name="HEUTRAIMOUCOMPTA" type="TTime"/-->
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TRemisesIndus">
    <xs:sequence>
      <xs:element name="DetailRemiseIndu" type="TDetail" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="somme" type="TMontant" use="required"/>
  </xs:complexType>
  <xs:complexType name="TIndusConstates">
    <xs:sequence>
      <xs:element name="DetailInduConstate" type="TDetail" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="somme" type="TMontant" use="required"/>
  </xs:complexType>
  <xs:complexType name="TIndusTransferesCG">
    <xs:sequence>
      <xs:element name="DetailnduTransfereCG" type="TDetail" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="somme" type="TMontant" use="required"/>
  </xs:complexType>
  <xs:complexType name="TAnnulationsFaibleMontant">
    <xs:sequence>
      <xs:element name="DetailAnnulationFaibleMontant" type="TDetail" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="somme" type="TMontant" use="required"/>
  </xs:complexType>
  <xs:complexType name="TAutresAnnulations">
    <xs:sequence>
      <xs:element name="DetailAutreAnnulation" type="TDetail" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="somme" type="TMontant" use="required"/>
  </xs:complexType>
  <xs:complexType name="TTotalisations">
    <xs:sequence maxOccurs="1">
      <xs:element name="TotalisationAcompte" type="TTotalisationAcompte" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TTotalisationAcompte">
    <xs:sequence>
      <xs:element name="TotalAllocationsComptabilisees" type="TTotal"/>
      <xs:element name="TotalIndusConstates" type="TTotal"/>
      <xs:element name="TotalIndusTransferesCG" type="TTotal"/>
      <xs:element name="TotalRemisesIndus" type="TTotal"/>
      <xs:element name="TotalAnnulationsIndus" type="TTotal"/>
      <xs:element name="MontantTotalAcompte" type="TTotal"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TTotal">
    <xs:sequence>
      <xs:element name="MTTOTSOCLRSA" type="TMontant"/>
      <xs:element name="MTTOTSOCLMAJORSA" type="TMontant"/>
      <xs:element name="MTTOTLOCALRSA" type="TMontant"/>
      <xs:element name="MTTOTRSA" type="TMontant"/>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="TString">
    <xs:restriction base="xs:string"/>
  </xs:simpleType>
  <xs:simpleType name="TString1">
    <xs:restriction base="xs:string">
      <xs:maxLength value="1"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="TString3">
    <xs:restriction base="xs:string">
      <xs:maxLength value="3"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="TString5">
    <xs:restriction base="xs:string">
      <xs:maxLength value="5"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="TDate">
    <xs:restriction base="xs:date"/>
  </xs:simpleType>
  <xs:simpleType name="TTime">
    <xs:restriction base="xs:time"/>
  </xs:simpleType>
  <xs:simpleType name="TDateTime">
    <xs:restriction base="xs:dateTime"/>
  </xs:simpleType>
  <xs:simpleType name="TMontant">
    <xs:restriction base="TDecimal">
      <xs:fractionDigits value="2"/>
      <xs:totalDigits value="16"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="TDecimal">
    <xs:restriction base="xs:decimal"/>
  </xs:simpleType>
  <xs:simpleType name="TInteger">
    <xs:restriction base="xs:integer"/>
  </xs:simpleType>
</xs:schema>
