﻿<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="1.7.0">
  <!--This XSD (XML Schema definition implements the requirements as of https://collaboration.nowhow.ch/burweb/foswiki/bin/view/Burweb/DatenExtrakteAnforderungen-->

  <!-- Overall Structural definition of an Extract -->
  <xs:element name="dataExtractBurWeb">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="dataExtractInfo" type="dataExtractInfo"/>
        <xs:element name="enterpriseUnits" minOccurs="0" type="enterpriseUnits"/>
        <xs:element name="enterpriseGroups" minOccurs="0" type="enterpriseGroups"/>
        <xs:element name="localUnits" minOccurs="0" type="localUnits"/>
        <xs:element name="persons" minOccurs="0" type="persons"/>
        <xs:element name="dataExtractStatistics" type="dataExtractStatistics"/>
      </xs:sequence>
      <xs:attribute name="version" use="required" type="xs:NMTOKEN" />
    </xs:complexType>
  </xs:element>

  <!-- Definition of the parts of the overall structure -->
  <xs:complexType name="dataExtractInfo">
    <xs:sequence>
      <xs:element name="message" minOccurs="0" type="message"/>
      <xs:element name="userId" type="limitedString50"/>
      <xs:element name="scope" type="scope" />
      <!--Census data is only provided if the user is in the corresponding role-->
      <xs:element name="containsCensus" type="xs:boolean" />
      <!--Person data is only provided if the user is in the corresponding role-->
      <xs:element name="containsPerson" type="xs:boolean" />
      <xs:choice>
        <xs:element name="fullExtract" type="fullExtract"/>
        <xs:element name="incrementalExtract" type="incrementalExtract"/>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="enterpriseUnits">
    <xs:sequence>
      <xs:element name="enterpriseUnit" minOccurs="0" maxOccurs="unbounded" type="enterpriseUnit"/>
      <xs:element name="deletedEnterpriseUnit" minOccurs="0" maxOccurs="unbounded" type="deletedEnterpriseUnit"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="enterpriseGroups">
    <xs:sequence>
      <xs:annotation>
        <xs:documentation xml:lang="de"> Für Groups werden keine physikalischen Löschungen geführt) </xs:documentation>
      </xs:annotation>
      <xs:element name="enterpriseGroup" minOccurs="0" maxOccurs="unbounded" type="enterpriseGroup" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="localUnits">
    <xs:sequence>
      <xs:element name="localUnit" minOccurs="0" maxOccurs="unbounded" type="localUnit" />
      <xs:element name="deletedLocalUnit" minOccurs="0" maxOccurs="unbounded" type="deletedLocalUnit" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="persons">
    <xs:sequence>
      <xs:element name="person" minOccurs="0" maxOccurs="unbounded" type="person" />
      <xs:element name="deletedPerson" minOccurs="0" maxOccurs="unbounded" type="deletedPerson" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="secoFields">
    <xs:sequence>
      <xs:element name="industrialEnterpriseLegalBasisCd" type="changeableInteger" nillable="true"/>
      <xs:element name="industrialEnterpriseOperationEndDate" type="changeableDate" nillable="true" />
      <xs:element name="industrialEnterpriseOperationStartDate" type="changeableDate" nillable="true" />
      <xs:element name="isConstructionSite" type="changeableBoolean" nillable="true" />
      <xs:element name="isFederalEnterprise" type="changeableBoolean" nillable="true" />
      <xs:element name="isIndustrialEnterprise" type="changeableBoolean" nillable="true" />
      <xs:element name="isPlanAssist" type="changeableBoolean" nillable="true" />
      <xs:element name="isSubmittedPlanApproval" type="changeableBoolean" nillable="true" />
      <xs:element name="isUsedInTacho" type="changeableBoolean" nillable="true" />
      <xs:element name="suvaNumber" type="changeableLimitedString40" nillable="true" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="scope">
    <xs:choice>
      <xs:element name="scopeCountry" type="scopeCountry"/>
      <xs:element name="scopeCanton" type="scopeCanton"/>
      <xs:element name="scopeFullAccess"      type="scopeFullAccess" />
      <xs:element name="scopeMunicipality"     type="scopeMunicipality" />
      <xs:element name="scopeNoga2008"    type="scopeNoga2008" />
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="scopeCountry">
    <xs:sequence>
      <xs:element name="countryAbbreviation" maxOccurs="unbounded" type="twoLetterCode" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="scopeCanton">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="cantonAbbreviation" type="twoLetterCode" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="scopeMunicipality">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="municipalityId" type="xs:integer"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="scopeNoga2008">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="noga2008" type="sixNumberCode" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="scopeFullAccess">
    <xs:annotation>
      <xs:documentation xml:lang="en">Full access does not have any specifics</xs:documentation>
    </xs:annotation>
  </xs:complexType>
  <xs:complexType name="fullExtract">
    <xs:sequence>
      <xs:element name="dateTime" type="xs:dateTime" nillable="true" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="incrementalExtract">
    <xs:sequence>
      <xs:element name="dateTimeFrom" type="xs:dateTime" nillable="true" />
      <xs:element name="dateTimeThrough" type="xs:dateTime" nillable="true" />
      <xs:element name="dateTimeRequestedFrom" type="xs:dateTime" />
      <xs:element name="dateTimeRequestedThrough" type="xs:dateTime" />
    </xs:sequence>
  </xs:complexType>

  <!-- Definition of the individual entities -->

  <xs:complexType name="enterpriseUnit">
    <xs:sequence>
      <xs:element name="enterpriseUnitOid" type="primaryOid" />
      <xs:element name="enterpriseUnitId" type="changeableInteger"/>
      <xs:element name="adminStatus" type="changeableLimitedString10" nillable="false"/>
      <xs:element name="cantonAbbreviation" type="changeableTwoLetterCode" nillable="true"/>
      <xs:element name="capitalAmount" type="changeableInteger" nillable="true"/>
      <xs:element name="census" type="census" minOccurs="0" nillable="true" />
      <xs:element name="countryIdISO2" type="changeableTwoLetterCode"/>
      <xs:element name="enterpriseGroups" minOccurs="0" type="enterpriseGroups">
        <xs:annotation>
          <xs:documentation xml:lang="en">The enterpriseGroups element only exists here for compatibility with the webservice output, where the related enterpriseGroups are returned directly as part of an enterprise unit. With an extract, enterprise groups are related to enterprise units via the group's father and/or child OID element.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="enterpriseUnitClassification" type="enterpriseUnitClassification"/>
      <xs:element name="group1" type="changeableLimitedString30" nillable="true" />
      <xs:element name="group2" type="changeableLimitedString30" nillable="true" />
      <xs:element name="group3" type="changeableLimitedString30" nillable="true" />
      <xs:element name="group4" type="changeableLimitedString30" nillable="true" />
      <xs:element name="lastChangeDate" type="changeableDate" nillable="true" />
      <xs:element name="latestYearAsImporter" type="changeableInteger" nillable="true" />
      <xs:element name="latestYearAsExporter" type="changeableInteger" nillable="true" />
      <xs:element name="legalId" type="changeableLimitedString13" nillable="true"/>
      <xs:element name="legalName" type="changeableLimitedString255" nillable="true"/>
      <xs:element name="municipalityId" type="changeableInteger" nillable="true"/>
      <xs:element name="name" type="changeableLimitedString302" nillable="true"/>
      <xs:element name="numberOfLocals" type="changeableInteger"/>
      <xs:element name="registeredDate" type="changeableDate" nillable="true"/>
      <xs:element name="sizeClass" type="changeableInteger" nillable="true"/>
      <xs:element name="sourceCreationCd" type="changeableInteger" />
      <xs:element name="sourceModificationCd" type="changeableInteger" nillable="true" />
      <xs:element name="statisticalStatus" type="changeableLimitedString10" nillable="false"/>
      <xs:element name="enterpriseUnitStatus" type="changeableInteger"/>
      <xs:element name="uid" type="uid" nillable="true" />
      <xs:element name="uidStatus" type="changeableInteger" nillable="true"/>
      <xs:element name="wwwAddress" type="changeableLimitedString250" nillable="true"/>
    </xs:sequence>
    <xs:attribute ref="new" />
  </xs:complexType>

  <xs:complexType name="enterpriseGroup">
    <xs:sequence>
      <xs:element name="childEnterpriseUnitOid" type="changeableInteger"/>
      <xs:element name="fatherEnterpriseUnitOid" type="changeableInteger"/>
      <xs:element name="lastChangeDate" type="changeableDate" nillable="true" />
      <xs:element name="registeredDate" type="changeableDate"/>
      <xs:element name="sourceCreationCd" type="changeableInteger" />
      <xs:element name="sourceModificationCd" type="changeableInteger" nillable="true" />
      <xs:element name="enterpriseGroupStatus" type="changeableInteger" />
    </xs:sequence>
    <xs:attribute ref="new" />
  </xs:complexType>

  <xs:complexType name="person">
    <xs:sequence>
      <xs:element name="additionalName"          type="changeableLimitedString60"     nillable="true"       minOccurs="0" />
      <xs:element name="cantonalPersonId"        type="changeableLimitedString40"     nillable="true"       minOccurs="0" />
      <xs:element name="firstName"               type="changeableLimitedString60"     nillable="true"       minOccurs="0" />
      <xs:element name="lastChangeDate"          type="changeableDate"                nillable="true"       minOccurs="0" />
      <xs:element name="lastName"                type="changeableLimitedString60"     nillable="true"       minOccurs="0" />
      <xs:element name="personId"                type="changeableInteger"             nillable="false"      minOccurs="1" />
      <xs:element name="registeredDate"          type="changeableDate"                nillable="false"      minOccurs="1" />
      <xs:element name="sourceCreationCd"        type="changeableInteger"             nillable="false"      minOccurs="1" />
      <xs:element name="sourceModificationCd"    type="changeableInteger"             nillable="true"       minOccurs="0" />
      <xs:element name="yearOfBirth"             type="changeableInteger"             nillable="true"       minOccurs="0" />
    </xs:sequence>
    <xs:attribute ref="new" />
  </xs:complexType>

  <xs:complexType name="localUnit">
    <xs:sequence>
      <xs:element name="localUnitOid" type="primaryOid"/>
      <xs:element name="localUnitIdentifier" type="localUnitIdentifier" />
      <xs:element name="addressLine1" type="changeableLimitedString100" nillable="true"/>
      <xs:element name="adminStatus" type="changeableLimitedString10" nillable="false"/>
      <xs:element name="cantonAbbreviation" type="changeableTwoLetterCode" nillable="true"/>
      <xs:element name="census" type="census" minOccurs="0" nillable="true" />
      <xs:element name="countryIdISO2" type="changeableTwoLetterCode"/>
      <xs:element name="creationDateCantonalRegister" type="changeableDate" nillable="true"/>
      <xs:element name="egidNr" type="changeableInteger" nillable="true"/>
      <xs:element name="ehraId" type="changeableLimitedString13" nillable="true" />
      <xs:element name="emailAddress" type="changeableLimitedString100" nillable="true"/>
      <xs:element name="enterpriseUnitId" type="changeableInteger"/>
      <xs:element name="enterpriseUnitOid" type="changeableInteger"/>
      <xs:element name="fatherLocalUnitOid" type="changeableInteger" minOccurs="0" nillable="true" />
      <xs:element name="fatherLocalUnitIdentifier"  type="localUnitIdentifier" minOccurs="0" nillable="true" />
      <xs:element name="foreignZipCode"  type="changeableLimitedString15" nillable="true"/>
      <xs:element name="mainPostalAddress"  type="changeableBoolean" nillable="false"/>
      <xs:element name="language" type="changeableInteger" nillable="true"/>
      <xs:element name="lastChangeDate" type="changeableDate" nillable="true" />
      <xs:element name="latestYearAsApprenticeTrainer" type="changeableInteger" nillable="true" />
      <xs:element name="legalDeletionDate" type="changeableDate" nillable="true"/>
      <xs:element name="legalId" type="changeableLimitedString13" nillable="true"/>
      <xs:element name="legalName" type="changeableLimitedString255" nillable="true"/>
      <xs:element name="legalRegistrationDate" type="changeableDate" nillable="true" />
      <xs:element name="localUnitClassification" type="localUnitClassification"/>
      <xs:element name="lv95ECoordinate" type="changeableLv95ECoordinateType" nillable="true"/>
      <xs:element name="lv95NCoordinate"  type="changeableLv95NCoordinateType" nillable="true"/>
      <xs:element name="municipalityId" type="changeableInteger" nillable="true"/>
      <xs:element name="name" type="changeableLimitedString302" nillable="true"/>
      <xs:element name="nameBusiness" type="changeableLimitedString255" nillable="true"/>
      <xs:element name="person" type="person" minOccurs="0" nillable="true">
        <xs:annotation>
          <xs:documentation xml:lang="en">The person element only exists here for compatibility with the QueryService webservice output, where the related person, if any, is returned directly as part of a local unit. With an extract, a person, if any, is related to a LocalUnit via the PersonId property.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="personId" type="changeableInteger" minOccurs="0" nillable="true">
        <xs:annotation>
          <xs:documentation xml:lang="en">With extracts (as opposed to the QueryService) the person is related via this PersonId, if any.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="phoneNumber" type="changeableLimitedString15" nillable="true"/>
      <xs:element name="postOfficeBox" type="changeableInteger" nillable="true" />
      <xs:element name="postOfficeBoxSwissZipCode" type="changeableInteger" nillable="true" />
      <xs:element name="postOfficeBoxSwissZipCodeAddOn" type="changeableInteger" nillable="true" />
      <xs:element name="postOfficeBoxTown" type="changeableLimitedString40" nillable="true"/>
      <xs:element name="primarySectorData" type="primarySectorData" />
      <xs:element name="registeredDate" type="changeableDate"/>
      <xs:element name="seasonActivity"  type="changeableInteger" nillable="true" />
      <xs:element name="seco" type="secoFields" minOccurs="0" nillable="true">
        <xs:annotation>
          <xs:documentation xml:lang="en">Contains the SECO-related fields.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="sizeClass" type="changeableInteger" nillable="true"/>
      <xs:element name="sourceCreationCd" type="changeableInteger" />
      <xs:element name="sourceModificationCd" type="changeableInteger" nillable="true" />
      <xs:element name="statisticalStatus" type="changeableLimitedString10" nillable="true"/>
      <xs:element name="localUnitStatus" type="changeableInteger"/>
      <xs:element name="localUnitStatusDate" type="changeableDate"/>
      <xs:element name="street" type="changeableLimitedString60" nillable="true"/>
      <xs:element name="streetNumber"  type="changeableInteger" nillable="true" />
      <xs:element name="streetNumberAddOn" type="changeableLimitedString10" nillable="true"/>
      <xs:element name="swissZipCode"  type="changeableInteger" nillable="true" />
      <xs:element name="swissZipCodeAddOn" type="changeableInteger" nillable="true" />
      <xs:element name="town"  type="changeableLimitedString40" nillable="true"/>
      <xs:element name="transferNewDate" type="changeableDate" minOccurs="0" nillable="true"/>
      <xs:element name="transferNewEnterpriseUnitId" type="changeableInteger" minOccurs="0" nillable="true" />
      <xs:element name="transferNewLocalUnitIdentifier"  type="localUnitIdentifier" minOccurs="0" nillable="true" />
      <xs:element name="transferNewLocalUnitOid"  type="changeableInteger" minOccurs="0" nillable="true" />
      <xs:element name="transferOldDate" type="changeableDate" minOccurs="0" nillable="true" />
      <xs:element name="transferOldEnterpriseUnitId" type="changeableInteger" minOccurs="0" nillable="true" />
      <xs:element name="transferOldLocalUnitIdentifier" type="localUnitIdentifier" minOccurs="0" nillable="true" />
      <xs:element name="transferOldLocalUnitOid" type="changeableInteger" minOccurs="0" nillable="true" />
      <xs:element name="uid" type="uid" nillable="true" >
        <xs:annotation>
          <xs:documentation xml:lang="en">uid is the UID of this local unit</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="uidMainUnit" type="uid" nillable="true">
        <xs:annotation>
          <xs:documentation xml:lang="en">uidMainUnit is the UID of the main local unit of the related enterprise unit</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="uidStatus" type="changeableInteger" nillable="true">
        <xs:annotation>
          <xs:documentation xml:lang="en">uidStatus is the status of the UID of this local unit</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="unitType" type="changeableLimitedString40" nillable="false"/>
      <xs:element name="wwwAddress" type="changeableLimitedString250" nillable="true"/>
    </xs:sequence>
    <xs:attribute ref="new" />
  </xs:complexType>

  <xs:complexType name="deletedEnterpriseUnit">
    <xs:sequence>
      <xs:element name="enterpriseUnitOid" type="primaryOid"/>
      <xs:element name="enterpriseUnitId" type="xs:integer"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="deletedLocalUnit">
    <xs:sequence>
      <xs:element name="localUnitOid" type="primaryOid"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="deletedPerson">
    <xs:sequence>
      <xs:element name="personId" type="xs:integer"/>
    </xs:sequence>
  </xs:complexType>

  <!-- Type definition for the UID-->
  <xs:complexType name="uid">
    <xs:annotation>
      <xs:documentation xml:lang="en">The UID (Unternehmens-Identifikationsnummer) is specified in http://www.bfs.admin.ch/bfs/portal/de/index/themen/00/05/blank/03/02.html </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="uidOrganisationId" nillable="true"/>
      <xs:element name="uidOrganisationIdCategorie" nillable="true"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="uidOrganisationIdCategorie">
    <xs:simpleContent>
      <xs:extension base="uidOrganisationIdCategorieType">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:simpleType name="uidOrganisationIdCategorieType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="CHE" />
      <xs:enumeration value="ADM" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="uidOrganisationId">
    <xs:simpleContent>
      <xs:extension base="uidOrganisationIdType">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:simpleType name="uidOrganisationIdType">
    <xs:restriction base="xs:nonNegativeInteger">
      <xs:totalDigits value="9" />
      <xs:fractionDigits value="0" />
      <xs:minInclusive value="000000001" />
      <xs:maxInclusive value="999999999" />
    </xs:restriction>
  </xs:simpleType>

  <!-- Type definition for the Swiss Grid -->
  <xs:complexType name="changeableLv95ECoordinateType">
    <xs:simpleContent>
      <xs:extension base="lv95ECoordinateType">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:simpleType name="lv95ECoordinateType">
    <xs:annotation>
      <xs:documentation xml:lang="de">Easting (LV95)</xs:documentation>
      <xs:documentation xml:lang="fr">Easting (LV95)</xs:documentation>
      <xs:documentation xml:lang="it">Easting (LV95)</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:decimal">
      <xs:totalDigits value="10" />
      <xs:fractionDigits value="3" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="changeableLv95NCoordinateType">
    <xs:simpleContent>
      <xs:extension base="lv95NCoordinateType">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:simpleType name="lv95NCoordinateType">
    <xs:annotation>
      <xs:documentation xml:lang="de">Northing (LV95)</xs:documentation>
      <xs:documentation xml:lang="fr">Northing (LV95)</xs:documentation>
      <xs:documentation xml:lang="it">Northing (LV95)</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:decimal">
      <xs:totalDigits value="10" />
      <xs:fractionDigits value="3" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="dataExtractStatistics">
    <xs:sequence>
      <!--Person data is only provided if the user is in the corresponding role, thus defined as optional-->
      <!--Deletions are only used in incremental extract, thus defined as optional-->
      <xs:element name="enterpriseUnitCount" type="xs:integer" />
      <xs:element name="enterpriseUnitDeletionCount" minOccurs="0" type="xs:integer" />
      <xs:element name="enterpriseGroupCount" type="xs:integer" />
      <xs:element name="localUnitCount" type="xs:integer" />
      <xs:element name="localUnitDeletionCount" minOccurs="0" type="xs:integer" />
      <xs:element name="personCount" minOccurs="0" type="xs:integer" />
      <xs:element name="personDeletionCount" minOccurs="0" type="xs:integer" />
      <xs:element name="processingDateTimeStart" type="xs:dateTime" />
      <xs:element name="processingDateTimeEnd" type="xs:dateTime" />
      <!-- type="xs:duration" is not easily human readable, thus a more convenient format is allowed here -->
      <xs:element name="duration" type="xs:string" />
    </xs:sequence>
  </xs:complexType>


  <!-- Definitions of strings with a specified maximum length. Implements requirement DATEX-010 -->
  <xs:simpleType name="limitedString1">
    <xs:restriction base="xs:string">
      <xs:maxLength value="1" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString3">
    <xs:restriction base="xs:string">
      <xs:maxLength value="3" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString5">
    <xs:restriction base="xs:string">
      <xs:maxLength value="5" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString10">
    <xs:restriction base="xs:string">
      <xs:maxLength value="10" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString13">
    <xs:restriction base="xs:string">
      <xs:maxLength value="13" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString15">
    <xs:restriction base="xs:string">
      <xs:maxLength value="15" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString20">
    <xs:restriction base="xs:string">
      <xs:maxLength value="20" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString30">
    <xs:restriction base="xs:string">
      <xs:maxLength value="30" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString32">
    <xs:restriction base="xs:string">
      <xs:maxLength value="32" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString39">
    <xs:restriction base="xs:string">
      <xs:maxLength value="39" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString40">
    <xs:restriction base="xs:string">
      <xs:maxLength value="40" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString50">
    <xs:restriction base="xs:string">
      <xs:maxLength value="50" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString60">
    <xs:restriction base="xs:string">
      <xs:maxLength value="60" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString70">
    <xs:restriction base="xs:string">
      <xs:maxLength value="70" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString100">
    <xs:restriction base="xs:string">
      <xs:maxLength value="100" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString200">
    <xs:restriction base="xs:string">
      <xs:maxLength value="200" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString250">
    <xs:restriction base="xs:string">
      <xs:maxLength value="250" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString255">
    <xs:restriction base="xs:string">
      <xs:maxLength value="255" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString302">
    <xs:restriction base="xs:string">
      <xs:maxLength value="302" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="limitedString2000">
    <xs:restriction base="xs:string">
      <xs:maxLength value="2000" />
    </xs:restriction>
  </xs:simpleType>

  <!-- Changeable Strings of a maximum length. Implements requirement DATEX-010 -->
  <xs:complexType name="changeableLimitedString3">
    <xs:simpleContent>
      <xs:extension base="limitedString3">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString5">
    <xs:simpleContent>
      <xs:extension base="limitedString5">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString10">
    <xs:simpleContent>
      <xs:extension base="limitedString10">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString13">
    <xs:simpleContent>
      <xs:extension base="limitedString13">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString15">
    <xs:simpleContent>
      <xs:extension base="limitedString15">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString30">
    <xs:simpleContent>
      <xs:extension base="limitedString30">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString39">
    <xs:simpleContent>
      <xs:extension base="limitedString39">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString40">
    <xs:simpleContent>
      <xs:extension base="limitedString40">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString60">
    <xs:simpleContent>
      <xs:extension base="limitedString60">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString100">
    <xs:simpleContent>
      <xs:extension base="limitedString100">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString250">
    <xs:simpleContent>
      <xs:extension base="limitedString250">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString255">
    <xs:simpleContent>
      <xs:extension base="limitedString255">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableLimitedString302">
    <xs:simpleContent>
      <xs:extension base="limitedString302">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>


  <!-- Specialty types 
Remark about "changeable" types: Most of the data items in incremental extract can change. If they have during the observation period, they are marked with this attribute
to make it easier for client software to find these changed items.
-->
  <xs:simpleType name="message">
    <xs:annotation>
      <xs:documentation xml:lang="en">A message to the consumer of this extract. This may contain informational text, warnings, limitations or error messages.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="primaryOid">
    <xs:annotation>
      <xs:documentation xml:lang="en">A primary OID is just an integer. It has no "changed" attribute, since it is used as a primary key to entities.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:integer">
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="twoLetterCode">
    <xs:annotation>
      <xs:documentation xml:lang="en">A two letter code.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[a-zA-Z]{2}" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="changeableTwoLetterCode">
    <xs:annotation>
      <xs:documentation xml:lang="en">A two letter code with an optional "changed" attribute.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="twoLetterCode">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:simpleType name="sixNumberCode">
    <xs:annotation>
      <xs:documentation xml:lang="en">A code consisting of six numbers. This may get used for representing a NOGA2008 code.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]{6}" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="changeableSixNumberCode">
    <xs:annotation>
      <xs:documentation xml:lang="en">A code consisting of six numbers with an optional "changed" attribute. This may get used for representing a NOGA2008 code.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="sixNumberCode">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:simpleType name="twoNumberCode">
    <xs:annotation>
      <xs:documentation xml:lang="en">A two number code.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]{2}" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="changeableTwoNumberCode">
    <xs:annotation>
      <xs:documentation xml:lang="en">A two number code with an optional "changed" attribute.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="twoNumberCode">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableInteger">
    <xs:annotation>
      <xs:documentation xml:lang="en">An integer with an optional "changed" attribute.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:integer">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableDecimal">
    <xs:annotation>
      <xs:documentation xml:lang="en">A decimal with an optional "changed" attribute.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:decimal">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableDate">
    <xs:annotation>
      <xs:documentation xml:lang="en">A date with an optional "changed" attribute.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:dateTime">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="changeableBoolean">
    <xs:annotation>
      <xs:documentation xml:lang="en">A boolean with an optional "changed" attribute.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:boolean">
        <xs:attribute ref="changed" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!-- Special, reusable parts -->
  <xs:complexType name="census">
    <xs:annotation>
      <xs:documentation xml:lang="en">An element containing census data.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="date" type="changeableDate" nillable="true"/>
      <xs:element name="employedTotal" type="changeableDecimal" nillable="true" />
      <xs:element name="fteFemale" type="changeableDecimal" nillable="true" />
      <xs:element name="fteMale" type="changeableDecimal" nillable="true" />
      <xs:element name="fteTotal"  type="changeableDecimal" nillable="true" />
      <xs:element name="fullFemale" type="changeableInteger" nillable="true" />
      <xs:element name="fullMale" type="changeableInteger" nillable="true" />
      <xs:element name="method"  type="changeableInteger" nillable="true" />
      <xs:element name="part1Female" type="changeableInteger" nillable="true" />
      <xs:element name="part1Male"  type="changeableInteger" nillable="true" />
      <xs:element name="part2Female" type="changeableInteger" nillable="true" />
      <xs:element name="part2Male" type="changeableInteger" nillable="true" />
      <xs:element name="part3Female" type="changeableInteger" nillable="true" />
      <xs:element name="part3Male" type="changeableInteger" nillable="true" />
      <xs:element name="source" type="changeableInteger" nillable="true" />
      <xs:element name="totalFemale" type="changeableDecimal" nillable="true" />
      <xs:element name="totalMale"  type="changeableDecimal" nillable="true" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="primarySectorData">
    <xs:annotation>
      <xs:documentation xml:lang="en">An element containing primary sector data.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="agrarKindCd" type="changeableTwoNumberCode" nillable="true" />
      <xs:element name="cantonUnitNumber"  type="changeableLimitedString40" nillable="true" />
      <xs:element name="tvdNumber" type="changeableLimitedString40" nillable="true" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="enterpriseUnitClassification">
    <xs:annotation>
      <xs:documentation xml:lang="en">An element containing enterprise unit classification data.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="enterpriseUnitKind" type="changeableInteger"/>
      <xs:element name="enterpriseUnitType" type="changeableLimitedString3" nillable="true"/>
      <xs:element name="instituteSector" type="changeableLimitedString5" nillable="true"/>
      <xs:element name="legalForm" type="changeableTwoNumberCode" nillable="true"/>
      <xs:element name="noga2008" type="changeableSixNumberCode"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="localUnitClassification">
    <xs:annotation>
      <xs:documentation xml:lang="en">An element containing local unit classification data.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="legalForm" type="changeableTwoNumberCode" nillable="true"/>
      <xs:element name="localUnitKind" type="changeableInteger"/>
      <xs:element name="localUnitType" type="changeableLimitedString3" nillable="true"/>
      <xs:element name="noga2008" type="changeableSixNumberCode"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="localUnitIdentifier" >
    <xs:annotation>
      <xs:documentation xml:lang="en">An identifier for a local unit (BUR Nummer), with a prefix.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="prefix" nillable="false" type="limitedString1"/>
      <xs:element name="id" type="xs:int" nillable="false"/>
    </xs:sequence>
    <xs:attribute ref="changed" />
  </xs:complexType>

  <!-- Attributes for incremental extracts -->
  <xs:attribute name="changed" type="xs:boolean" default="false">
    <xs:annotation>
      <xs:documentation xml:lang="en">The "changed" attribute denotes a field/column/property which has changed within an incremental extract's observation period. It is not used for full extracts.</xs:documentation>
    </xs:annotation>
  </xs:attribute>
  <xs:attribute name="new" type="xs:boolean" default="false">
    <xs:annotation>
      <xs:documentation xml:lang="en">The "new" attribute denotes an entity/row/object which is new within an incremental extract's observation period. It is not used for full extracts.</xs:documentation>
    </xs:annotation>
  </xs:attribute>
</xs:schema>