<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="bimproj">
    <xs:complexType>       
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="propertynamespace" type="propertynamespaceType"/>
        <xs:element name="propertydefinition" type="propertydefinitionType"/>
        <xs:element name="valuedefinition" type="valuedefinitionType"/>
        <xs:element name="propertyset" type="propertysetType"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="propertynamespaceType" mixed="true">
    <xs:all>
      <xs:element name="name" minOccurs="0" default="User">
        <xs:simpleType>
          <xs:restriction base="xs:normalizedString">
            <xs:maxLength value="32"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="label" minOccurs="0">
        <xs:simpleType>
          <xs:restriction base="xs:normalizedString">
            <xs:maxLength value="255"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="editable" type="xs:boolean" minOccurs="0" default="true"/>
      <xs:element name="revision" type="xs:nonNegativeInteger" minOccurs="0" default="0"/>
      <xs:element name="visible" type="xs:boolean" minOccurs="0" default="true"/>
    </xs:all>
    <xs:attribute name="id" type="xs:positiveInteger"/>
  </xs:complexType>

  <xs:complexType name="propertydefinitionType">
    <xs:all>
      <xs:element name="namespace" type="namespaceType"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="ifc_name" type="xs:string" minOccurs="0"/>
      <xs:element name="label" type="xs:string" minOccurs="0"/>
      <xs:element name="description" type="xs:string" minOccurs="0"/>
      <xs:element name="ifc_type" type="xs:string" minOccurs="0"/>
      <xs:element name="type_spec2" type="xs:string" minOccurs="0"/>
      <xs:element name="unit" minOccurs="0">
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:string">
              <xs:attribute name="default" type="xs:string" use="required"/>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
      <xs:element name="type" type="propertyType" minOccurs="0" default="String"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="valuedefinitionType">
    <xs:all>
      <xs:element name="namespace" type="namespaceType"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="ifc_name" type="xs:string" minOccurs="0"/>
      <xs:element name="label" type="xs:string" minOccurs="0"/>
      <xs:element name="description" type="xs:string" minOccurs="0"/>
      <xs:element name="ifc_type" type="xs:string" minOccurs="0"/>
      <xs:element name="value_spec" type="xs:string" minOccurs="0"/>
      <xs:element name="unit" minOccurs="0">
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:string">
              <xs:attribute name="default" type="xs:string" use="required"/>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
      <xs:element name="type" type="propertyType" minOccurs="0" default="String"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="propertysetType">
    <xs:sequence>
      <xs:element name="namespace" type="namespaceType"/>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="name">
          <xs:simpleType>
            <xs:restriction base="xs:normalizedString">
              <xs:maxLength value="255"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name="ifc_name">
          <xs:simpleType>
            <xs:restriction base="xs:normalizedString">
              <xs:maxLength value="255"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name="label">
          <xs:simpleType>
            <xs:restriction base="xs:normalizedString">
              <xs:maxLength value="255"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name="per_instance" type="xs:boolean" default="false"/>
        <xs:element name="visible" type="xs:boolean" default="true"/>
        <xs:element name="property_definition">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="name" type="xs:string" use="required"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
        <xs:element name="value_definition">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="name" type="xs:string" use="required"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
        <xs:element name="entity_type" type="entityType"/>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="namespaceType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="name" type="xs:string" use="optional"/>
        <xs:attribute name="id" type="xs:string" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:simpleType name="propertyType">
    <xs:restriction base="xs:token">
      <xs:enumeration value="Bool"/>
      <xs:enumeration value="Int32"/>
      <xs:enumeration value="Double"/>
      <xs:enumeration value="String"/>
      <xs:enumeration value="Boolean"/>
      <xs:enumeration value="Integer"/>
      <xs:enumeration value="Real"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="entityType">
    <xs:restriction base="xs:token">
      <xs:enumeration value="BimDbAnnotation"/>
      <xs:enumeration value="BimDbBeam"/>
      <xs:enumeration value="BimDbBuilding"/>
      <xs:enumeration value="BimDbBuildingElement"/>
      <xs:enumeration value="BimDbColumn"/>
      <xs:enumeration value="BimDbCovering"/>
      <xs:enumeration value="BimDbCurtainWall"/>
      <xs:enumeration value="BimDbDiscreteAccessory"/>
      <xs:enumeration value="BimDbDistributionChamberElement"/>
      <xs:enumeration value="BimDbDistributionControlElement"/>
      <xs:enumeration value="BimDbDistributionFlowElement"/>
      <xs:enumeration value="BimDbDistributionPort"/>
      <xs:enumeration value="BimDbDoor"/>
      <xs:enumeration value="BimDbEnergyConversionDevice"/>
      <xs:enumeration value="BimDbFastener"/>
      <xs:enumeration value="BimDbFlowController"/>
      <xs:enumeration value="BimDbFlowFitting"/>
      <xs:enumeration value="BimDbFlowMovingDevice"/>
      <xs:enumeration value="BimDbFlowSegment"/>
      <xs:enumeration value="BimDbFlowStorageDevice"/>
      <xs:enumeration value="BimDbFlowTerminal"/>
      <xs:enumeration value="BimDbFlowTreatmentDevice"/>
      <xs:enumeration value="BimDbFooting"/>
      <xs:enumeration value="BimDbFurnishingElement"/>
      <xs:enumeration value="BimDbGrid"/>
      <xs:enumeration value="BimDbGridAxis"/>
      <xs:enumeration value="BimDbMechanicalFastener"/>
      <xs:enumeration value="BimDbMember"/>
      <xs:enumeration value="BimDbOpening"/>
      <xs:enumeration value="BimDbPile"/>
      <xs:enumeration value="BimDbPlate"/>
      <xs:enumeration value="BimDbRailing"/>
      <xs:enumeration value="BimDbRamp"/>
      <xs:enumeration value="BimDbRampFlight"/>
      <xs:enumeration value="BimDbReinforcingBar"/>
      <xs:enumeration value="BimDbReinforcingMesh"/>
      <xs:enumeration value="BimDbRoof"/>
      <xs:enumeration value="BimDbRoom"/>
      <xs:enumeration value="BimDbSite"/>
      <xs:enumeration value="BimDbSlab"/>
      <xs:enumeration value="BimDbSpace"/>
      <xs:enumeration value="BimDbStair"/>
      <xs:enumeration value="BimDbStairFlight"/>
      <xs:enumeration value="BimDbStory"/>
      <xs:enumeration value="BimDbTendon"/>
      <xs:enumeration value="BimDbTendonAnchor"/>
      <xs:enumeration value="BimDbWall"/>
      <xs:enumeration value="BimDbWindow"/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>