<?xml version="1.0" encoding="utf-8"?>
<!--
     OData Version 4.0 Plus Errata 01
     OASIS Standard incorporating Approved Errata 01
     04 September 2014
     Copyright (c) OASIS Open 2014. All Rights Reserved.
     Source: http://docs.oasis-open.org/odata/odata/v4.0/errata01/os/complete/schemas/
-->
<!--

Technical Committee:
  OASIS Open Data Protocol (OData) TC
  https://www.oasis-open.org/committees/odata/

Chairs:
  - Barbara Hartel (barbara.hartel@sap.com), SAP AG
  - Ram Jeyaraman (Ram.Jeyaraman@microsoft.com), Microsoft

Editors:
  - Ralf Handl (ralf.handl@sap.com), SAP AG
  - Michael Pizzo (mikep@microsoft.com), Microsoft
  - Martin Zurmuehl (martin.zurmuehl@sap.com), SAP AG

Additional artifacts: 
  This XML schema is one component of a Work Product which consists of:
  - OData Version 4.0 Part 1: Protocol
  - OData Version 4.0 Part 2: URL Conventions
  - OData Version 4.0 Part 3: Common Schema Definition Language (CSDL)
  - OData ABNF Construction Rules Version 4.0 
  - OData ABNF Test Cases
  - OData Core Vocabulary
  - OData Capabilities Vocabulary
  - OData Measures Vocabulary
  - OData Metadata Service Entity Model
  - OData EDMX XML Schema (this document)
  - OData EDM XML Schema

Related work:
  This work product is related to the following two Work Products, each of 
  which define alternate formats for OData payloads
  - OData Atom Format Version 4.0
  - OData JSON Format Version 4.0
  This specification replaces or supersedes:
  - None

Declared XML namespaces:
  - http://docs.oasis-open.org/odata/ns/edmx
  - http://docs.oasis-open.org/odata/ns/edm

Abstract:
  The Open Data Protocol (OData) enables the creation of REST-based data
  services, which allow resources, identified using Uniform Resource
  Identifiers (URLs) and defined in a data model, to be published and 
  edited by Web clients using simple HTTP messages. This document defines
  the URL syntax for requests and the serialization format for primitive 
  literals in request and response payloads.

Overview:
  This document describes the Entity Data Model Wrapper part of the Common Schema Definition Language (CSDL).
  It imports the OData EDM XML Schema, see additional artifacts.
  
  Together these two XML schemas define the shape of a well-formed CSDL document,
  but are not descriptive enough to define what a correct CSDL document MUST be
  in every imaginable use case. The prose specification document
   
    OData Version 4.0 Part 3: Common Schema Definition Language (CSDL) 
    http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part3-csdl.html
  
  defines additional rules that correct CSDL documents MUST fulfill. 
  In case of doubt on what makes a CSDL document correct the rules defined in the 
  prose specification document take precedence.

-->
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm"
  targetNamespace="http://docs.oasis-open.org/odata/ns/edmx"
>
  <xs:annotation>
    <xs:documentation xml:lang="en">
      Entity Data Model Wrapper part of the Common Schema Definition Language
    </xs:documentation>
  </xs:annotation>

  <xs:import namespace="http://docs.oasis-open.org/odata/ns/edm" />

  <xs:element name="Edmx" type="edmx:TEdmx" />
  <xs:complexType name="TEdmx">
    <xs:sequence>
      <xs:element name="Reference" type="edmx:TReference" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="DataServices" type="edmx:TDataServices" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
    <xs:attribute name="Version" type="edmx:TVersion" use="required" />
  </xs:complexType>
  <xs:complexType name="TReference">
    <xs:choice minOccurs="1" maxOccurs="unbounded">
      <xs:element name="Include" type="edmx:TInclude" />
      <xs:element name="IncludeAnnotations" type="edmx:TIncludeAnnotations" />
      <xs:element ref="edm:Annotation" minOccurs="0" maxOccurs="unbounded" />
    </xs:choice>
    <xs:attribute name="Uri" type="xs:anyURI" use="required" />
  </xs:complexType>
  <xs:complexType name="TInclude">
    <xs:attribute name="Namespace" type="edm:TNamespaceName" use="required" />
    <xs:attribute name="Alias" type="edm:TSimpleIdentifier" use="optional" />
  </xs:complexType>
  <xs:complexType name="TIncludeAnnotations">
    <xs:attribute name="TermNamespace" type="edm:TNamespaceName" use="required" />
    <xs:attribute name="Qualifier" type="edm:TSimpleIdentifier" use="optional" />
    <xs:attribute name="TargetNamespace" type="edm:TNamespaceName" use="optional" />
  </xs:complexType>
  <xs:complexType name="TDataServices">
    <xs:sequence>
      <xs:element ref="edm:Schema" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="TVersion">
    <xs:restriction base="xs:decimal">
      <xs:enumeration value="4.0" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>