diff --git a/docs/odata-csdl-json/odata-csdl-json.html b/docs/odata-csdl-json/odata-csdl-json.html index ffc701f79..dd6c22e4c 100644 --- a/docs/odata-csdl-json/odata-csdl-json.html +++ b/docs/odata-csdl-json/odata-csdl-json.html @@ -17,6 +17,70 @@ margin: 0 0.8em 0.2em -1.6em; vertical-align: middle; } + /* CSS for syntax highlighting */ + pre > code.sourceCode { white-space: pre; position: relative; } + pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } + pre > code.sourceCode > span:empty { height: 1.2em; } + .sourceCode { overflow: visible; } + code.sourceCode > span { color: inherit; text-decoration: inherit; } + div.sourceCode { margin: 1em 0; } + pre.sourceCode { margin: 0; } + @media screen { + div.sourceCode { overflow: auto; } + } + @media print { + pre > code.sourceCode { white-space: pre-wrap; } + pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } + } + pre.numberSource code + { counter-reset: source-line 0; } + pre.numberSource code > span + { position: relative; left: -4em; counter-increment: source-line; } + pre.numberSource code > span > a:first-child::before + { content: counter(source-line); + position: relative; left: -1em; text-align: right; vertical-align: baseline; + border: none; display: inline-block; + -webkit-touch-callout: none; -webkit-user-select: none; + -khtml-user-select: none; -moz-user-select: none; + -ms-user-select: none; user-select: none; + padding: 0 4px; width: 4em; + color: #aaaaaa; + } + pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } + div.sourceCode + { } + @media screen { + pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } + } + code span.al { color: #ff0000; font-weight: bold; } /* Alert */ + code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ + code span.at { color: #7d9029; } /* Attribute */ + code span.bn { color: #40a070; } /* BaseN */ + code span.bu { color: #008000; } /* BuiltIn */ + code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ + code span.ch { color: #4070a0; } /* Char */ + code span.cn { color: #880000; } /* Constant */ + code span.co { color: #60a0b0; font-style: italic; } /* Comment */ + code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ + code span.do { color: #ba2121; font-style: italic; } /* Documentation */ + code span.dt { color: #902000; } /* DataType */ + code span.dv { color: #40a070; } /* DecVal */ + code span.er { color: #ff0000; font-weight: bold; } /* Error */ + code span.ex { } /* Extension */ + code span.fl { color: #40a070; } /* Float */ + code span.fu { color: #06287e; } /* Function */ + code span.im { color: #008000; font-weight: bold; } /* Import */ + code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ + code span.kw { color: #007020; font-weight: bold; } /* Keyword */ + code span.op { color: #666666; } /* Operator */ + code span.ot { color: #007020; } /* Other */ + code span.pp { color: #bc7a00; } /* Preprocessor */ + code span.sc { color: #4070a0; } /* SpecialChar */ + code span.ss { color: #bb6688; } /* SpecialString */ + code span.st { color: #4070a0; } /* String */ + code span.va { color: #19177c; } /* Variable */ + code span.vs { color: #4070a0; } /* VerbatimString */ + code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ @@ -32,7 +96,7 @@

OData Common Schema Definition Language (CSDL) JSON Representation Version 4.02

Committee Specification Draft 01

14 July 2023

-

 

+

\(\hbox{}\)

This stage:

https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-json-v4.02-csd01.md (Authoritative)
https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-json-v4.02-csd01.html
@@ -52,14 +116,12 @@

Editors:

Ralf Handl (ralf.handl@sap.com), SAP SE
Michael Pizzo (mikep@microsoft.com), Microsoft
Heiko Theißen (heiko.theissen@sap.com), SAP SE

-

Additional artifacts:

+

Additional artifacts:

This prose specification is one component of a Work Product that also includes:

- +

This specification replaces or supersedes:

-
[RFC2119]
-

Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997 http://www.rfc-editor.org/info/rfc2119.

-
[RFC8174]
-

Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017 http://www.rfc-editor.org/info/rfc8174.

-

A.2 Informative References

-
[RFC3552]
-

Rescorla, E. and B. Korver, "Guidelines for Writing RFC Text on Security Considerations", BCP 72, RFC 3552, DOI 10.17487/RFC3552, July 2003 https://www.rfc-editor.org/info/rfc3552.

-
-

Appendix B. Safety, Security and Privacy Considerations

- - -

(Note: OASIS strongly recommends that Technical Committees consider issues that might affect safety, security, privacy, and/or data protection in implementations of their specification and document them for implementers and adopters. For some purposes, you may find it required, e.g. if you apply for IANA registration.

-

While it may not be immediately obvious how your specification might make systems vulnerable to attack, most specifications, because they involve communications between systems, message formats, or system settings, open potential channels for exploit. For example, IETF [[RFC3552](#rfc3552)] lists “eavesdropping, replay, message insertion, deletion, modification, and man-in-the-middle” as well as potential denial of service attacks as threats that must be considered and, if appropriate, addressed in IETF RFCs.

-

In addition to considering and describing foreseeable risks, this section should include guidance on how implementers and adopters can protect against these risks.

-

We encourage editors and TC members concerned with this subject to read _Guidelines for Writing RFC Text on Security Considerations_, IETF [[RFC3552](#rfc3552)], for more information.

-

Remove this note before submitting for publication.)

-
-

Appendix C. Acknowledgments

- - -

Note: A Work Product approved by the TC must include a list of people who participated in the development of the Work Product. This is generally done by collecting the list of names in this appendix. This list shall be initially compiled by the Chair, and any Member of the TC may add or remove their names from the list by request. Remove this note before submitting for publication.

-

C.1 Special Thanks

- - -

Substantial contributions to this document from the following individuals are gratefully acknowledged:

-

Participant Name, Affiliation or "Individual Member"

-

C.2 Participants

- +

See OData-JSON for the exact rules.

+

2.1.2.2 metadata=full

+

The metadata=full format parameter indicates that the service MUST include all control information explicitly in the payload.

+

This means that the @type control information is included in annotation values except for primitive values whose type can be heuristically determined from the representation of the value, see OData-JSON for the exact rules.

+

2.1.2.3 metadata=none

+

The metadata=none format parameter indicates that the service SHOULD omit all control information.

+

2.2 Design Considerations

+

CSDL JSON documents are designed for easy and efficient lookup of model constructs by their name without having to know or guess what kind of model element it is. Thus, all primary model elements (entity types, complex types, type definitions, enumeration types, terms, actions, functions, and the entity container) are direct members of their schema, using the schema-unique name as the member name. Similarly, child elements of primary model elements (properties, navigation properties, enumeration type members, entity sets, singletons, action imports, and function imports) are direct members of the objects describing their parent model element, using their locally unique name as the member name.

+

To avoid name collisions, all fixed member names are prefixed with a dollar ($) sign and otherwise have the same name and capitalization as their counterparts in the CSDL XML representation OData-CSDLXML (with one exception: the counterpart of the EntitySet element's EntityType member is $Type, to harmonize it with all other type references).

+

Additional fixed members introduced by this specification and without counterpart in OData-CSDLXML are also prefixed with a dollar ($) sign and use upper-camel-case names. One of these is $Kind which represents the kind of model element. Its value is the upper-camel-case local name of the XML element representing this kind of model element in OData-CSDLXML, e.g. EntityType or NavigationProperty.

+

While the XML representation of CSDL allows referencing model elements with alias-qualified names as well as with namespace-qualified names, this JSON representation requires the use of alias-qualified names if an alias is specified for an included or document-defined schema. Aliases are usually shorter than namespaces, so this reduces text size of the JSON document. Text size matters even if the actual HTTP messages are sent in compressed form because the decompressed form needs to be reconstructed, and clients not using a streaming JSON parser have to materialize the full JSON document before parsing.

+

To further reduce size the member $Kind is optional for structural properties as these are more common than navigation properties, and the member $Type is optional for string properties, parameters, and return types, as this type is more common than other primitive types.

+

In general, all members that have a default value SHOULD be omitted if they have the default value.

+

2.3 JSON Schema Definition

+

The structure of CSDL JSON documents can be verified with the JSON Schema OData-CSDL-Schema provided as an additional artifact of this prose specification. This schema only defines the shape of a well-formed CSDL JSON document but is not descriptive enough to define what a correct CSDL JSON document MUST be in every imaginable use case. This specification document defines additional rules that correct CSDL JSON documents MUST fulfill. In case of doubt on what makes a CSDL JSON document correct the rules defined in this specification document take precedence.

+ -

The following individuals have participated in the creation of this specification and are gratefully acknowledged:

-

OpenC2 TC Members:

+

3 Entity Model

+

An OData service exposes a single entity model. This model may be distributed over several schemas, and these schemas may be distributed over several documents.

+

A service is defined by a single CSDL document which can be accessed by sending a GET request to <serviceRoot>/$metadata. This document is called the metadata document. It MAY reference other CSDL documents.

+

The metadata document contains a single entity container that defines the resources exposed by this service. This entity container MAY extend an entity container defined in a referenced document.

+

The model of the service consists of all CSDL constructs used in its entity containers.

+

The scope of a CSDL document is the document itself and all schemas included from directly referenced documents. All entity types, complex types and other named model elements in scope (that is, defined in the document itself or a schema of a directly referenced document) can be accessed from a referencing document by their qualified names. This includes the built-in primitive and abstract types.

+

Referencing another document may alter the model defined by the referencing document. For instance, if a referenced document defines an entity type derived from an entity type in the referencing document, then an entity set of the service defined by the referencing document may return entities of the derived type. This is identical to the behavior if the derived type had been defined directly in the referencing document.

+

Note: referencing documents is not recursive. Only named model elements defined in directly referenced documents can be used within the schema. However, those elements may in turn include or reference model elements defined in schemas referenced by their defining schema.

+

3.1 Nominal Types

+

A nominal type has a name that MUST be a simple identifier. Nominal types are referenced using their qualified name. The qualified type name MUST be unique within a model as it facilitates references to the element from other parts of the model.

+

Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

+

3.2 Structured Types

+

Structured types are composed of other model elements. Structured types are common in entity models as the means of representing entities and structured properties in an OData service. Entity types and complex types are both structured types.

+

Structured Types are composed of zero or more structural properties and navigation properties.

+

Open entity types and open complex types allow properties to be added dynamically to instances of the open type.

+

3.3 Primitive Types

+

Structured types are composed of other structured types and primitive types. OData defines the following primitive types:

- - - + + - - - + + - - - + + - - - + + - - - + + - -
First NameLast NameCompanyTypeMeaning
PhilippeAlmanSomething NetworksEdm.BinaryBinary data
AlexAmirnovmanCompany BEdm.BooleanBinary-valued logic
KrisAndermanMini MicroEdm.ByteUnsigned 8-bit integer
DarrenAnstmanBig NetworksEdm.DateDate without a time-zone offset
-
-

Appendix D. Revision History

- - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + +
RevisionDateEditorChanges Made
Edm.DateTimeOffsetDate and time with a time-zone offset, no leap seconds
Edm.DecimalNumeric values with decimal representation
Edm.DoubleIEEE 754 binary64 floating-point number (15-17 decimal digits)
Edm.DurationSigned duration in days, hours, minutes, and (sub)seconds
Edm.Guid16-byte (128-bit) unique identifier
Edm.Int16Signed 16-bit integer
Edm.Int32Signed 32-bit integer
Edm.Int64Signed 64-bit integer
Edm.SByteSigned 8-bit integer
Edm.SingleIEEE 754 binary32 floating-point number (6-9 decimal digits)
Edm.StreamBinary data stream
Edm.StringSequence of characters
Edm.TimeOfDayClock time 00:00-23:59:59.999999999999
Edm.GeographyAbstract base type for all Geography types
Edm.GeographyPointA point in a round-earth coordinate system
Edm.GeographyLineStringLine string in a round-earth coordinate system
Edm.GeographyPolygonPolygon in a round-earth coordinate system
Edm.GeographyMultiPointCollection of points in a round-earth coordinate system
Edm.GeographyMultiLineStringCollection of line strings in a round-earth coordinate system
Edm.GeographyMultiPolygonCollection of polygons in a round-earth coordinate system
Edm.GeographyCollectionCollection of arbitrary Geography values
Edm.GeometryAbstract base type for all Geometry types
Edm.GeometryPointPoint in a flat-earth coordinate system
Edm.GeometryLineStringLine string in a flat-earth coordinate system
Edm.GeometryPolygonPolygon in a flat-earth coordinate system
Edm.GeometryMultiPointCollection of points in a flat-earth coordinate system
Edm.GeometryMultiLineStringCollection of line strings in a flat-earth coordinate system
Edm.GeometryMultiPolygonCollection of polygons in a flat-earth coordinate system
specname-v1.0-wd01yyyy-mm-ddEditor NameInitial working draftEdm.GeometryCollectionCollection of arbitrary Geometry values
+

Edm.Date and Edm.DateTimeOffset follow XML-Schema-2 and use the proleptic Gregorian calendar, allowing the year 0000 (equivalent to 1 BCE) and negative years (year -0001 being equivalent to 2 BCE etc.). The supported date range is service-specific and typically depends on the underlying persistency layer, e.g. SQL only supports years 0001 to 9999.

+

Edm.Decimal with a Scale value of floating, Edm.Double, and Edm.Single allow the special numeric values -INF, INF, and NaN.

+

Edm.Stream is a primitive type that can be used as a property of an entity type or complex type, the underlying type for a type definition, or the binding parameter or return type of an action or function. Edm.Stream, or a type definition whose underlying type is Edm.Stream, cannot be used in collections or for non-binding parameters to functions or actions.

+

Some of these types allow facets, defined in section "Type Facets".

+

See rule primitiveLiteral in OData-ABNF for the representation of primitive type values in URLs and OData-JSON for the representation in requests and responses.

+

3.4 Built-In Abstract Types

+

The following built-in abstract types can be used within a model:

+ +

Conceptually, these are the abstract base types for primitive types (including type definitions and enumeration types), complex types, entity types, or any type or collection of types, respectively, and can be used anywhere a corresponding concrete type can be used, except:

+ +

3.5 Built-In Types for defining Vocabulary Terms

+

Vocabulary terms can, in addition, use

+ +

as the type of a primitive term, or the type of a property of a complex type (recursively) that is exclusively used as the type of a term. See section "Path Expressions" for details.

+

3.6 Annotations

+

Many parts of the model can be decorated with additional information using annotations. Annotations are identified by their term name and an optional qualifier that allows applying the same term multiple times to the same model element.

+

A model element MUST NOT specify more than one annotation for a given combination of term and qualifier.


-

Appendix E. Example Appendix with subsections

-

E.1 Subsection title

-

E.1.1 Sub-subsection

-
-

Appendix F. Notices

- +

4 CSDL JSON Document

+ -

Copyright © OASIS Open 2023. All Rights Reserved.

-

All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.

-

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English.

-

The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.

-

This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

-

As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata).

-

[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.]

-

[OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.]

-

[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.]

-

The name "OASIS" is a trademark of OASIS, the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance.

+
+

Document Object

+

A CSDL JSON document consists of a single JSON object. This document object MUST contain the member $Version.

+

The document object MAY contain the member $Reference to reference other CSDL documents.

+

It also MAY contain members for schemas.

+

If the CSDL JSON document is the metadata document of an OData service, the document object MUST contain the member $EntityContainer.

+

$Version

+

The value of $Version is a string containing either 4.0 or 4.01.

+

$EntityContainer

+

The value of $EntityContainer is value is the namespace-qualified name of the entity container of that service. This is the only place where a model element MUST be referenced with its namespace-qualified name and use of the alias-qualified name is not allowed.

+
+
+

Example 2:

+
{
+  "$Version": "4.01",
+  "$EntityContainer": "org.example.DemoService",
+  ...
+}
+
+ + +

4.1 Reference

+

A reference to an external CSDL document allows to bring part of the referenced document's content into the scope of the referencing document.

+

A reference MUST specify a URI that uniquely identifies the referenced document, so two references MUST NOT specify the same URI. The URI SHOULD be a URL that locates the referenced document. If the URI is not dereferencable it SHOULD identify a well-known schema. The URI MAY be absolute or relative URI; relative URLs are relative to the URL of the document containing the reference, or relative to a base URL specified in a format-specific way.

+

A reference MAY be annotated.

+

The Core.SchemaVersion annotation, defined in OData-VocCore, MAY be used to indicate a particular version of the referenced document. If the Core.SchemaVersion annotation is present, the $schemaversion system query option, defined OData-Protocol, SHOULD be used when retrieving the referenced schema document.

+
+

$Reference

+

The value of $Reference is an object that contains one member per referenced CSDL document. The name of the pair is a URI for the referenced document. The URI MAY be relative to the document containing the $Reference. The value of each member is a reference object.

+

Reference Object

+

The reference object MAY contain the members $Include and $IncludeAnnotations as well as annotations.

+
+
+

Example 3: references to other CSDL documents

+
{
+  ...
+  "$Reference": {
+    "http://vocabs.odata.org/capabilities/v1": {
+      ...
+    },
+    "http://vocabs.odata.org/core/v1": {
+      ...
+    },
+    "http://example.org/display/v1": {
+      ...
+    }
+  },
+  ...
+}
+
+

4.2 Included Schema

+

A reference MAY include zero or more schemas from the referenced document.

+

The included schemas are identified via their namespace. The same namespace MUST NOT be included more than once, even if it is declared in more than one referenced document.

+

When including a schema, a simple identifier value MAY be specified as an alias for the schema that is used in qualified names instead of the namespace. For example, an alias of display might be assigned to the namespace org.example.vocabularies.display. An alias-qualified name is resolved to a fully qualified name by examining aliases for included schemas and schemas defined within the document.

+
+

If an included schema specifies an alias, the alias MUST be used in qualified names throughout the document to identify model elements of the included schema. A mixed use of namespace-qualified names and alias-qualified names is not allowed.

+
+

Aliases are document-global, so all schemas defined within or included into a document MUST have different aliases, and aliases MUST differ from the namespaces of all schemas defined within or included into a document.

+

The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

+

An alias is only valid within the document in which it is declared; a referencing document may define its own aliases for included schemas.

+
+

$Include

+

The value of $Include is an array. Array items are objects that MUST contain the member $Namespace and MAY contain the member $Alias.

+

The item objects MAY contain annotations.

+

$Namespace

+

The value of $Namespace is a string containing the namespace of the included schema.

+

$Alias

+

The value of $Alias is a string containing the alias for the included schema.

+
+
+

Example 4: references to entity models containing definitions of vocabulary terms

+
{
+  ...
+  "$Reference": {
+    "http://vocabs.odata.org/capabilities/v1": {
+      "$Include": [
+        {
+          "$Namespace": "Org.OData.Capabilities.V1",
+          "$Alias": "Capabilities"
+        }
+      ]
+    },
+    "http://vocabs.odata.org/core/v1": {
+      "$Include": [
+        {
+          "$Namespace": "Org.OData.Core.V1",
+          "$Alias": "Core",
+          "@Core.DefaultNamespace": true
+        }
+      ]
+    },
+    "http://example.org/display/v1": {
+      "$Include": [
+        {
+          "$Namespace": "org.example.display",
+          "$Alias": "UI"
+        }
+      ]
+    }
+  },
+  ...
+}
+
+

4.3 Included Annotations

+

In addition to including whole schemas with all model constructs defined within that schema, annotations can be included with more flexibility.

+

Annotations are selectively included by specifying the namespace of the annotations' term. Consumers can opt not to inspect the referenced document if none of the term namespaces is of interest for the consumer.

+

In addition, the qualifier of annotations to be included MAY be specified. For instance, a service author might want to supply a different set of annotations for various device form factors. If a qualifier is specified, only those annotations from the specified term namespace with the specified qualifier (applied to a model element of the target namespace, if present) SHOULD be included. If no qualifier is specified, all annotations within the referenced document from the specified term namespace (taking into account the target namespace, if present) SHOULD be included.

+

The qualifier also provides consumers insight about what qualifiers are present in the referenced document. If the consumer is not interested in that particular qualifier, the consumer can opt not to inspect the referenced document.

+

In addition, the namespace of the annotations' target MAY be specified. If a target namespace is specified, only those annotations which apply a term form the specified term namespace to a model element of the target namespace (with the specified qualifier, if present) SHOULD be included. If no target namespace is specified, all annotations within the referenced document from the specified term namespace (taking into account the qualifier, if present) SHOULD be included.

+

The target namespace also provides consumers insight about what namespaces are present in the referenced document. If the consumer is not interested in that particular target namespace, the consumer can opt not to inspect the referenced document.

+
+

$IncludeAnnotations

+

The value of $IncludeAnnotations is an array. Array items are objects that MUST contain the member $TermNamespace and MAY contain the members $Qualifier and $TargetNamespace.

+

$TermNamespace

+

The value of $TermNamespace is a namespace.

+

$Qualifier

+

The value of $Qualifier is a simple identifier.

+

$TargetNamespace

+

The value of $TargetNamespace is a namespace.

+
+
+

Example 5: reference documents that contain annotations

+
{
+  ...
+  "$Reference": {
+    "http://odata.org/ann/b": {
+      "$IncludeAnnotations": [
+        {
+          "$TermNamespace": "org.example.validation"
+        },
+        {
+          "$TermNamespace": "org.example.display",
+          "$Qualifier": "Tablet"
+        },
+        {
+          "$TermNamespace": "org.example.hcm",
+          "$TargetNamespace": "com.example.Sales"
+        },
+        {
+          "$TermNamespace": "org.example.hcm",
+          "$Qualifier": "Tablet",
+          "$TargetNamespace": "com.example.Person"
+        }
+      ]
+    }
+  },
+  ...
+}
+
+
+

The following annotations from http://odata.org/ann/b are included:

+ +
+
+

5 Schema

+

One or more schemas describe the entity model exposed by an OData service. The schema acts as a namespace for elements of the entity model such as entity types, complex types, enumerations and terms.

+

A schema is identified by a namespace. Schema namespaces MUST be unique within the scope of a document and SHOULD be globally unique. A schema cannot span more than one document.

+

The schema's namespace is combined with the name of elements in the schema to create unique qualified names, so identifiers that are used to name types MUST be unique within a namespace to prevent ambiguity.

+

Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

+

The namespace MUST NOT be one of the reserved values Edm, odata, System, or Transient.

+
+

Schema Object

+

A schema is represented as a member of the document object whose name is the schema namespace. Its value is an object that MAY contain the members $Alias and $Annotations.

+

The schema object MAY contain members representing entity types, complex types, enumeration types, type definitions, actions, functions, terms, and an entity container.

+

The schema object MAY also contain annotations that apply to the schema itself.

+
+

5.1 Alias

+

A schema MAY specify an alias which MUST be a simple identifier.

+

If a schema specifies an alias, the alias MUST be used instead of the namespace within qualified names throughout the document to identify model elements of that schema. A mixed use of namespace-qualified names and alias-qualified names is not allowed.

+

Aliases are document-global, so all schemas defined within or included into a document MUST have different aliases, and aliases MUST differ from the namespaces of all schemas defined within or included into a document. Aliases defined by a schema can be used throughout the containing document and are not restricted to the schema that defines them.

+

The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

+
+

$Alias

+

The value of $Alias is a string containing the alias for the schema.

+
+
+

Example 6: document defining a schema org.example with an alias and a description for the schema

+
{
+  ...
+  "org.example": {
+    "$Alias": "self",
+    "@Core.Description": "Example schema",
+    ...
+  },
+  ...
+}
+
+

5.2 Annotations with External Targeting

+
+

$Annotations

+

The value of $Annotations is an object with one member per annotation target. The member name is a path identifying the annotation target, the member value is an object containing annotations for that target.

+
+
+

Example 7: annotations targeting the Person type with qualifier Tablet

+
"org.example": {
+  "$Alias": "self",
+  "$Annotations": {
+    "self.Person": {
+      "@Core.Description#Tablet": "Dummy",
+      ...
+    }
+  }
+}
+
+
+

6 Entity Type

+

Entity types are nominal structured types with a key that consists of one or more references to structural properties. An entity type is the template for an entity: any uniquely identifiable record such as a customer or order.

+

The entity type's name is a simple identifier that MUST be unique within its schema.

+

An entity type can define two types of properties. A structural property is a named reference to a primitive, complex, or enumeration type, or a collection of primitive, complex, or enumeration types. A navigation property is a named reference to another entity type or collection of entity types.

+

All properties MUST have a unique name within an entity type. Properties MUST NOT have the same name as the declaring entity type. They MAY have the same name as one of the direct or indirect base types or derived types.

+
+

Entity Type Object

+

An entity type is represented as a member of the schema object whose name is the unqualified name of the entity type and whose value is an object.

+

The entity type object MUST contain the member $Kind with a string value of EntityType.

+

It MAY contain the members $BaseType, $Abstract, $OpenType, $HasStream, and $Key.

+

It also MAY contain members representing structural properties and navigation properties as well as annotations.

+
+
+

Example 8: a simple entity type

+
"Employee": {
+  "$Kind": "EntityType",
+  "$Key": [
+    "ID"
+  ],
+  "ID": {},
+  "FirstName": {},
+  "LastName": {},
+  "Manager": {
+    "$Kind": "NavigationProperty",
+    "$Nullable": true,
+    "$Type": "self.Manager"
+  }
+}
+
+

6.1 Derived Entity Type

+

An entity type can inherit from another entity type by specifying it as its base type.

+

An entity type inherits the key as well as structural and navigation properties of its base type.

+

An entity type MUST NOT introduce an inheritance cycle by specifying a base type.

+
+

$BaseType

+

The value of $BaseType is the qualified name of the base type.

+
+
+

Example 9: a derived entity type based on the previous example

+
"Manager": {
+  "$Kind": "EntityType",
+  "$BaseType": "self.Employee",
+  "AnnualBudget": {
+    "$Nullable": true,
+    "$Type": "Edm.Decimal",
+    "$Scale": 0
+  },
+  "Employees": {
+    "$Kind": "NavigationProperty",
+    "$Collection": true,
+    "$Type": "self.Employee"
+  }
+}
+
+
+

Note: the derived type has the same name as one of the properties of its base type.

+
+

6.2 Abstract Entity Type

+

An entity type MAY indicate that it is abstract and cannot have instances.

+

For OData 4.0 responses a non-abstract entity type MUST define a key or derive from a base type with a defined key.

+

An abstract entity type MUST NOT inherit from a non-abstract entity type.

+
+

$Abstract

+

The value of $Abstract is one of the Boolean literals true or false. Absence of the member means false.

+
+

6.3 Open Entity Type

+

An entity type MAY indicate that it is open and allows clients to add properties dynamically to instances of the type by specifying uniquely named property values in the payload used to insert or update an instance of the type.

+

An entity type derived from an open entity type MUST indicate that it is also open.

+

Note: structural and navigation properties MAY be returned by the service on instances of any structured type, whether or not the type is marked as open. Clients MUST always be prepared to deal with additional properties on instances of any structured type, see OData-Protocol.

+
+

$OpenType

+

The value of $OpenType is one of the Boolean literals true or false. Absence of the member means false.

+
+

6.4 Media Entity Type

+

An entity type that does not specify a base type MAY indicate that it is a media entity type. Media entities are entities that represent a media stream, such as a photo. Use a media entity if the out-of-band stream is the main topic of interest and the media entity is just additional structured information attached to the stream. Use a normal entity with one or more properties of type Edm.Stream if the structured data of the entity is the main topic of interest and the stream data is just additional information attached to the structured data. For more information on media entities see OData-Protocol.

+

An entity type derived from a media entity type MUST indicate that it is also a media entity type.

+

Media entity types MAY specify a list of acceptable media types using an annotation with term Core.AcceptableMediaTypes, see OData-VocCore.

+
+

$HasStream

+

The value of $HasStream is one of the Boolean literals true or false. Absence of the member means false.

+
+

6.5 Key

+

An entity is uniquely identified within an entity set by its key. A key MAY be specified if the entity type does not specify a base type that already has a key declared.

+

In order to be specified as the type of an entity set or a collection-valued containment navigation property, the entity type MUST either specify a key or inherit its key from its base type.

+

In OData 4.01 responses entity types used for singletons or single-valued navigation properties do not require a key. In OData 4.0 responses entity types used for singletons or single-valued navigation properties MUST have a key defined.

+

An entity type (whether or not it is marked as abstract) MAY define a key only if it doesn't inherit one.

+

An entity type's key refers to the set of properties whose values uniquely identify an instance of the entity type within an entity set. The key MUST consist of at least one property.

+

Key properties MUST NOT be nullable and MUST be typed with an enumeration type, one of the following primitive types, or a type definition based on one of these primitive types:

+ +

Key property values MAY be language-dependent, but their values MUST be unique across all languages and the entity ids (defined in OData-Protocol) MUST be language independent.

+

A key property MUST be a non-nullable primitive property of the entity type itself, including non-nullable primitive properties of non-nullable single-valued complex properties, recursively.

+

In OData 4.01 the key properties of a directly related entity type MAY also be part of the key if the navigation property is single-valued and not nullable. This includes navigation properties of non-nullable single-valued complex properties (recursively) of the entity type. If a key property of a related entity type is part of the key, all key properties of the related entity type MUST also be part of the key.

+

If the key property is a property of a complex property (recursively) or of a directly related entity type, the key MUST specify an alias for that property that MUST be a simple identifier and MUST be unique within the set of aliases, structural and navigation properties of the declaring entity type and any of its base types.

+

An alias MUST NOT be defined if the key property is a primitive property of the entity type itself.

+

For key properties that are a property of a complex or navigation property, the alias MUST be used in the key predicate of URLs instead of the path to the property because the required percent-encoding of the forward slash separating segments of the path to the property would make URL construction and parsing rather complicated. The alias MUST NOT be used in the query part of URLs, where paths to properties don't require special encoding and are a standard constituent of expressions anyway.

+
+

$Key

+

The value of $Key is an array with one item per key property.

+

Key properties without a key alias are represented as strings containing the property name.

+

Key properties with a key alias are represented as objects with one member whose name is the key alias and whose value is a string containing the path to the property.

+
+
+

Example 10: entity type with a simple key

+
"Category": {
+  "$Kind": "EntityType",
+  "$Key": [
+    "ID"
+  ],
+  "ID": {
+    "$Type": "Edm.Int32"
+  },
+  "Name": {
+    "$Nullable": true,
+    "@Core.IsLanguageDependent": true
+  }
+}
+
+
+

Example 11: entity type with a simple key referencing a property of a complex type

+
"Category": {
+  "$Kind": "EntityType",
+  "$Key": [
+    {
+      "EntityInfoID": "Info/ID"
+    }
+  ],
+  "Info": {
+    "$Type": "self.EntityInfo"
+  },
+  "Name": {
+    "$Nullable": true
+  }
+},
+"EntityInfo": {
+  "$Kind": "ComplexType",
+  "ID": {
+    "$Type": "Edm.Int32"
+  },
+  "Created": {
+    "$Type": "Edm.DateTimeOffset",
+    "$Precision": 0
+  }
+}
+
+
+

Example 12: entity type with a composite key

+
"OrderLine": {
+  "$Kind": "EntityType",
+  "$Key": [
+    "OrderID",
+    "LineNumber"
+  ],
+  "OrderID": {
+    "$Type": "Edm.Int32"
+  },
+  "LineNumber": {
+    "$Type": "Edm.Int32"
+  }
+}
+
+
+

Example 13 (based on example 11): requests to an entity set Categories of type Category must use the alias

+
GET http://host/service/Categories(EntityInfoID=1)
+
+
+

Example 14 (based on example 11): in a query part the value assigned to the name attribute must be used

+
GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100
+
+
+

7 Structural Property

+

A structural property is a property of a structured type that has one of the following types:

+ +

A structural property MUST specify a unique name as well as a type.

+

The property's name MUST be a simple identifier. It is used when referencing, serializing or deserializing the property. It MUST be unique within the set of structural and navigation properties of the declaring structured type, and MUST NOT match the name of any navigation property in any of its base types. If a structural property with the same name is defined in any of this type's base types, then the property's type MUST be a type derived from the type specified for the property of the base type and constrains this property to be of the specified subtype for instances of this structured type. The name MUST NOT match the name of any structural or navigation property of any of this type's base types for OData 4.0 responses.

+

Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

+
+

Property Object

+

Structural properties are represented as members of the object representing a structured type. The member name is the property name, the member value is an object.

+

The property object MAY contain the member $Kind with a string value of Property. This member SHOULD be omitted to reduce document size.

+

It MAY contain the member $Type, $Collection, $Nullable, $MaxLength, $Unicode, $Precision, $Scale, $SRID, and $DefaultValue.

+

It also MAY contain annotations.

+
+
+

Example 15: complex type with two properties Dimension and Length

+
"Measurement": {
+  "$Kind": "ComplexType",
+  "Dimension": {
+    "$MaxLength": 50,
+    "$DefaultValue": "Unspecified"
+  },
+  "Length": {
+    "$Type": "Edm.Decimal",
+    "$Precision": 18,
+    "$Scale": 2
+  }
+}
+
+

7.1 Type

+

The property's type MUST be a primitive type, complex type, or enumeration type in scope, or a collection of one of these types.

+

A collection-valued property MAY be annotated with the Core.Ordered term, defined in OData-VocCore, to specify that it supports a stable ordering.

+

A collection-valued property MAY be annotated with the Core.PositionalInsert term, defined in OData-VocCore, to specify that it supports inserting items into a specific ordinal position.

+
+

$Type and $Collection

+

For single-valued properties the value of $Type is the qualified name of the property's type.

+

For collection-valued properties the value of $Type is the qualified name of the property's item type, and the member $Collection MUST be present with the literal value true.

+

Absence of the $Type member means the type is Edm.String. This member SHOULD be omitted for string properties to reduce document size.

+
+
+

Example 16: property Units that can have zero or more strings as its value

+
"Units": {
+  "$Collection": true
+}
+
+

7.2 Type Facets

+

Facets modify or constrain the acceptable values of a property.

+

For single-valued properties the facets apply to the value of the property. For collection-valued properties the facets apply to the items in the collection.

+

7.2.1 Nullable

+

A Boolean value specifying whether the property can have the value null.

+
+

$Nullable

+

The value of $Nullable is one of the Boolean literals true or false. Absence of the member means false.

+

For single-valued properties the value true means that the property allows the null value.

+

For collection-valued properties the property value will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and specifies whether the collection MAY contain null values.

+
+

7.2.2 MaxLength

+

A positive integer value specifying the maximum length of a binary, stream or string value. For binary or stream values this is the octet length of the binary data, for string values it is the character length (number of code points for Unicode).

+

If no maximum length is specified, clients SHOULD expect arbitrary length.

+
+

$MaxLength

+

The value of $MaxLength is a positive integer.

+

Note: OData-CSDL-XML defines a symbolic value max that is only allowed in OData 4.0 responses. This symbolic value is not allowed in CDSL JSON documents at all. Services MAY instead specify the concrete maximum length supported for the type by the service or omit the member entirely.

+
+

7.2.3 Precision

+

For a decimal value: the maximum number of significant decimal digits of the property's value; it MUST be a positive integer.

+

For a temporal value (datetime-with-timezone-offset, duration, or time-of-day): the number of decimal places allowed in the seconds portion of the value; it MUST be a non-negative integer between zero and twelve.

+

Note: service authors SHOULD be aware that some clients are unable to support a precision greater than 28 for decimal properties and 7 for temporal properties. Client developers MUST be aware of the potential for data loss when round-tripping values of greater precision. Updating via PATCH and exclusively specifying modified properties will reduce the risk for unintended data loss.

+

Note: duration properties supporting a granularity less than seconds (e.g. minutes, hours, days) can be annotated with term Measures.DurationGranularity, see OData-VocMeasures.

+
+

$Precision

+

The value of $Precision is a number.

+

Absence of $Precision means arbitrary precision.

+
+
+

Example 17: Precision facet applied to the DateTimeOffset type

+
"SuggestedTimes": {
+  "$Type": "Edm.DateTimeOffset",
+  "$Collection": true,
+  "$Precision": 6
+}
+
+

7.2.4 Scale

+

A non-negative integer value specifying the maximum number of digits allowed to the right of the decimal point, or one of the symbolic values floating or variable.

+

The value floating means that the decimal property represents a decimal floating-point number whose number of significant digits is the value of the Precision facet. OData 4.0 responses MUST NOT specify the value floating.

+

The value variable means that the number of digits to the right of the decimal point can vary from zero to the value of the Precision facet.

+

An integer value means that the number of digits to the right of the decimal point may vary from zero to the value of the Scale facet, and the number of digits to the left of the decimal point may vary from one to the value of the Precision facet minus the value of the Scale facet. If Precision is equal to Scale, a single zero MUST precede the decimal point.

+

The value of Scale MUST be less than or equal to the value of Precision.

+

Note: if the underlying data store allows negative scale, services may use a Precision with the absolute value of the negative scale added to the actual number of significant decimal digits, and client-provided values may have to be rounded before being stored.

+
+

$Scale

+

The value of $Scale is a number or a string with one of the symbolic values floating or variable.

+

Services SHOULD use lower-case values; clients SHOULD accept values in a case-insensitive manner.

+

Absence of $Scale means variable.

+
+
+

Example 18: Precision=3 and Scale=2.
+Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3

+
"Amount32": {
+  "$Nullable": true,
+  "$Type": "Edm.Decimal",
+  "$Precision": 3,
+  "$Scale": 2
+}
+
+
+

Example 19: Precision=2 equals Scale.
+Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2

+
"Amount22": {
+  "$Nullable": true,
+  "$Type": "Edm.Decimal",
+  "$Precision": 2,
+  "$Scale": 2
+}
+
+
+

Example 20: Precision=3 and a variable Scale.
+Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed values: 12.34, 1234 and 123.4 due to the limited precision.

+
"Amount3v": {
+  "$Nullable": true,
+  "$Type": "Edm.Decimal",
+  "$Precision": 3
+}
+
+
+

Example 21: Precision=7 and a floating Scale.
+Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: 1e-102 and 1e97 due to the limited precision.

+
"Amount7f": {
+  "$Nullable": true,
+  "$Type": "Edm.Decimal",
+  "$Precision": 7,
+  "$Scale": "floating"
+}
+
+

7.2.5 Unicode

+

For a string property the Unicode facet indicates whether the property might contain and accept string values with Unicode characters (code points) beyond the ASCII character set. The value false indicates that the property will only contain and accept string values with characters limited to the ASCII character set.

+

If no value is specified, the Unicode facet defaults to true.

+
+

$Unicode

+

The value of $Unicode is one of the Boolean literals true or false. Absence of the member means true.

+
+

7.2.6 SRID

+

For a geometry or geography property the SRID facet identifies which spatial reference system is applied to values of the property on type instances.

+

The value of the SRID facet MUST be a non-negative integer or the special value variable. If no value is specified, the facet defaults to 0 for Geometry types or 4326 for Geography types.

+

The valid values of the SRID facet and their meanings are as defined by the European Petroleum Survey Group EPSG.

+
+

$SRID

+

The value of $SRID is a string containing a number or the symbolic value variable.

+
+

7.2.7 Default Value

+

A primitive or enumeration property MAY define a default value that is used if the property is not explicitly represented in an annotation or the body of a request or response.

+

If no value is specified, the client SHOULD NOT assume a default value.

+
+

$DefaultValue

+

The value of $DefaultValue is the type-specific JSON representation of the default value of the property, see OData-JSON. For properties of type Edm.Decimal and Edm.Int64 the representation depends on the media type parameter IEEE754Compatible.

+
+
+

8 Navigation Property

+

A navigation property allows navigation to related entities. It MUST specify a unique name as well as a type.

+

The navigation property's name MUST be a simple identifier. It is used when referencing, serializing or deserializing the navigation property. It MUST be unique within the set of structural and navigation properties of the declaring structured type, and MUST NOT match the name of any structural property in any of its base types. If a navigation property with the same name is defined in any of this type's base types, then the navigation property's type MUST be a type derived from the type specified for the navigation property of the base type, and constrains this navigation property to be of the specified subtype for instances of this structured type. The name MUST NOT match the name of any structural or navigation property of any of this type's base types for OData 4.0 responses.

+

Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

+
+

Navigation Property Object

+

Navigation properties are represented as members of the object representing a structured type. The member name is the property name, the member value is an object.

+

The navigation property object MUST contain the member $Kind with a string value of NavigationProperty.

+

It MUST contain the member $Type, and it MAY contain the members $Collection, $Nullable, $Partner, $ContainsTarget, $ReferentialConstraint, and $OnDelete.

+

It also MAY contain annotations.

+
+
+

Example 22: the Product entity type has a navigation property to a Category, which has a navigation link back to one or more products

+
"Product": {
+  "$Kind": "EntityType",
+  ...
+  "Category": {
+    "$Kind": "NavigationProperty",
+    "$Type": "self.Category",
+    "$Partner": "Products",
+    "$ReferentialConstraint": {
+      "CategoryID": "ID"
+    }
+  },
+  "Supplier": {
+    "$Kind": "NavigationProperty",
+    "$Type": "self.Supplier"
+  }
+},
+"Category": {
+  "$Kind": "EntityType",
+  ...
+  "Products": {
+    "$Kind": "NavigationProperty",
+    "$Collection": true,
+    "$Type": "self.Product",
+    "$Partner": "Category",
+    "$OnDelete": "Cascade",
+    "$OnDelete@Core.Description": "Delete all related entities"
+  }
+}
+
+

8.1 Navigation Property Type

+

The navigation property's type MUST be an entity type in scope, the abstract type Edm.EntityType, or a collection of one of these types.

+

If the type is a collection, an arbitrary number of entities can be related. Otherwise there is at most one related entity.

+

The related entities MUST be of the specified entity type or one of its subtypes.

+

For a collection-valued containment navigation property the specified entity type MUST have a key defined.

+

A collection-valued navigation property MAY be annotated with the Core.Ordered term, defined in OData-VocCore, to specify that it supports a stable ordering.

+

A collection-valued navigation property MAY be annotated with the Core.PositionalInsert term, defined in OData-VocCore, to specify that it supports inserting items into a specific ordinal position.

+
+

$Type and $Collection

+

For single-valued navigation properties the value of $Type is the qualified name of the navigation property's type.

+

For collection-valued navigation properties the value of $Type is the qualified name of the navigation property's item type, and the member $Collection MUST be present with the literal value true.

+
+

8.2 Nullable Navigation Property

+

A Boolean value specifying whether the declaring type MAY have no related entity. If false, instances of the declaring structured type MUST always have a related entity.

+

Nullable MUST NOT be specified for a collection-valued navigation property, a collection is allowed to have zero items.

+
+

$Nullable

+

The value of $Nullable is one of the Boolean literals true or false. Absence of the member means false.

+
+

8.3 Partner Navigation Property

+

A navigation property of an entity type MAY specify a partner navigation property. Navigation properties of complex types MUST NOT specify a partner.

+

If specified, the partner navigation property is identified by a path relative to the entity type specified as the type of the navigation property. This path MUST lead to a navigation property defined on that type or a derived type. The path MAY traverse complex types, including derived complex types, but MUST NOT traverse any navigation properties. The type of the partner navigation property MUST be the declaring entity type of the current navigation property or one of its parent entity types.

+

If the partner navigation property is single-valued, it MUST lead back to the source entity from all related entities. If the partner navigation property is collection-valued, the source entity MUST be part of that collection.

+

If no partner navigation property is specified, no assumptions can be made as to whether one of the navigation properties on the target type will lead back to the source entity.

+

If a partner navigation property is specified, this partner navigation property MUST either specify the current navigation property as its partner to define a bi-directional relationship or it MUST NOT specify a partner navigation property. The latter can occur if the partner navigation property is defined on a complex type, or if the current navigation property is defined on a type derived from the type of the partner navigation property.

+
+

$Partner

+

The value of $Partner is a string containing the path to the partner navigation property.

+
+

8.4 Containment Navigation Property

+

A navigation property MAY indicate that instances of its declaring structured type contain the targets of the navigation property, in which case the navigation property is called a containment navigation property.

+

Containment navigation properties define an implicit entity set for each instance of its declaring structured type. This implicit entity set is identified by the read URL of the navigation property for that structured type instance.

+

Instances of the structured type that declares the navigation property, either directly or indirectly via a property of complex type, contain the entities referenced by the containment navigation property. The canonical URL for contained entities is the canonical URL of the containing instance, followed by the path segment of the navigation property and the key of the contained entity, see OData-URL.

+

Entity types used in collection-valued containment navigation properties MUST have a key defined.

+

For items of an ordered collection of complex types (those annotated with the Core.Ordered term defined in OData-VocCore the canonical URL of the item is the canonical URL of the collection appended with a segment containing the zero-based ordinal of the item. Items within in an unordered collection of complex types do not have a canonical URL. Services that support unordered collections of complex types declaring a containment navigation property, either directly or indirectly via a property of complex type, MUST specify the URL for the navigation link within a payload representing that item, according to format-specific rules.

+

OData 4.0 responses MUST NOT specify a complex type declaring a containment navigation property as the type of a collection-valued property.

+

An entity cannot be referenced by more than one containment relationship, and cannot both belong to an entity set declared within the entity container and be referenced by a containment relationship.

+

Containment navigation properties MUST NOT be specified as the last path segment in the path of a navigation property binding.

+

When a containment navigation property navigates between entity types in the same inheritance hierarchy, the containment is called recursive.

+

Containment navigation properties MAY specify a partner navigation property. If the containment is recursive, the relationship defines a tree, thus the partner navigation property MUST be nullable (for the root of the tree) and single-valued (for the parent of a non-root entity). If the containment is not recursive, the partner navigation property MUST NOT be nullable.

+

An entity type inheritance chain MUST NOT contain more than one navigation property with a partner navigation property that is a containment navigation property.

+

Note: without a partner navigation property, there is no reliable way for a client to determine which entity contains a given contained entity. This may lead to problems for clients if the contained entity can also be reached via a non-containment navigation path.

+
+

$ContainsTarget

+

The value of $ContainsTarget is one of the Boolean literals true or false. Absence of the member means false.

+
+

8.5 Referential Constraint

+

A single-valued navigation property MAY define one or more referential constraints. A referential constraint asserts that the dependent property (the property defined on the structured type declaring the navigation property) MUST have the same value as the principal property (the referenced property declared on the entity type that is the target of the navigation).

+

The type of the dependent property MUST match the type of the principal property, or both types MUST be complex types.

+

If the principle property references an entity, then the dependent property must reference the same entity.

+

If the principle property's value is a complex type instance, then the dependent property's value must be a complex type instance with the same properties, each with the same values.

+

If the navigation property on which the referential constraint is defined is nullable, or the principal property is nullable, then the dependent property MUST also be nullable. If both the navigation property and the principal property are not nullable, then the dependent property MUST NOT be nullable.

+
+

$ReferentialConstraint

+

The value of $ReferentialConstraint is an object with one member per referential constraint. The member name is the path to the dependent property, this path is relative to the structured type declaring the navigation property. The member value is a string containing the path to the principal property, this path is relative to the entity type that is the target of the navigation property.

+

It also MAY contain annotations. These are prefixed with the path of the dependent property of the annotated referential constraint.

+
+
+

Example 23: the category must exist for a product in that category to exist. The CategoryID of the product is identical to the ID of the category, and the CategoryKind property of the product is identical to the Kind property of the category.

+
"Product": {
+  "$Kind": "EntityType",
+  ...
+  "CategoryID": {},
+  "CategoryKind": {},
+  "Category": {
+    "$Kind": "NavigationProperty",
+    "$Type": "self.Category",
+    "$Partner": "Products",
+    "$ReferentialConstraint": {
+      "CategoryID": "ID",
+      "CategoryKind": "Kind",
+      "CategoryKind@Core.Description": "Referential Constraint to non-key property"
+    }
+  }
+},
+"Category": {
+  "$Kind": "EntityType",
+  "$Key": [
+    "ID"
+  ],
+  "ID": {},
+  "Kind": {
+    "$Nullable": true
+  },
+  ...
+}
+
+

8.6 On-Delete Action

+

A navigation property MAY define an on-delete action that describes the action the service will take on related entities when the entity on which the navigation property is defined is deleted.

+

The action can have one of the following values:

+ +

If no on-delete action is specified, the action taken by the service is not predictable by the client and could vary per entity.

+
+

$OnDelete

+

The value of $OnDelete is a string with one of the values Cascade, None, SetNull, or SetDefault.

+

Annotations for $OnDelete are prefixed with $OnDelete.

+
+
+

Example 24: deletion of a category implies deletion of the related products in that category

+
"Category": {
+  "$Kind": "EntityType",
+  ...
+  "Products": {
+    "$Kind": "NavigationProperty",
+    "$Collection": true,
+    "$Type": "self.Product",
+    "$Partner": "Category",
+    "$OnDelete": "Cascade",
+    "$OnDelete@Core.Description": "Delete all products in this category"
+  }
+}
+
+
+

9 Complex Type

+

Complex types are keyless nominal structured types. The lack of a key means that instances of complex types cannot be referenced, created, updated or deleted independently of an entity type. Complex types allow entity models to group properties into common structures.

+

The complex type's name is a simple identifier that MUST be unique within its schema.

+

A complex type can define two types of properties. A structural property is a named reference to a primitive, complex, or enumeration type, or a collection of primitive, complex, or enumeration types. A navigation property is a named reference to an entity type or a collection of entity types.

+

All properties MUST have a unique name within a complex type. Properties MUST NOT have the same name as the declaring complex type. They MAY have the same name as one of the direct or indirect base types or derived types.

+
+

Complex Type Object

+

A complex type is represented as a member of the schema object whose name is the unqualified name of the complex type and whose value is an object.

+

The complex type object MUST contain the member $Kind with a string value of ComplexType. It MAY contain the members $BaseType, $Abstract, and $OpenType. It also MAY contain members representing structural properties and navigation properties as well as annotations.

+
+
+

Example 25: a complex type used by two entity types

+
"Dimensions": {
+  "$Kind": "ComplexType",
+  "Height": {
+    "$Type": "Edm.Decimal",
+    "$Scale": 0
+  },
+  "Weight": {
+    "$Type": "Edm.Decimal",
+    "$Scale": 0
+  },
+  "Length": {
+    "$Type": "Edm.Decimal",
+    "$Scale": 0
+  }
+},
+"Product": {
+  ...
+  "ProductDimensions": {
+    "$Nullable": true,
+    "$Type": "self.Dimensions"
+  },
+  "ShippingDimensions": {
+    "$Nullable": true,
+    "$Type": "self.Dimensions"
+  }
+},
+"ShipmentBox": {
+  ...
+  "Dimensions": {
+    "$Nullable": true,
+    "$Type": "self.Dimensions"
+  }
+}
+
+

9.1 Derived Complex Type

+

A complex type can inherit from another complex type by specifying it as its base type.

+

A complex type inherits the structural and navigation properties of its base type.

+

A complex type MUST NOT introduce an inheritance cycle by specifying a base type.

+

The rules for annotations of derived complex types are described in section 14.2.

+
+

$BaseType

+

The value of $BaseType is the qualified name of the base type.

+
+

9.2 Abstract Complex Type

+

A complex type MAY indicate that it is abstract and cannot have instances.

+
+

$Abstract

+

The value of $Abstract is one of the Boolean literals true or false. Absence of the member means false.

+
+

9.3 Open Complex Type

+

A complex type MAY indicate that it is open and allows clients to add properties dynamically to instances of the type by specifying uniquely named property values in the payload used to insert or update an instance of the type.

+

A complex type derived from an open complex type MUST indicate that it is also open.

+

Note: structural and navigation properties MAY be returned by the service on instances of any structured type, whether or not the type is marked as open. Clients MUST always be prepared to deal with additional properties on instances of any structured type, see OData‑Protocol.

+
+

$OpenType

+

The value of $OpenType is one of the Boolean literals true or false. Absence of the member means false.

+
+
+

10 Enumeration Type

+

Enumeration types are nominal types that represent a non-empty series of related values. Enumeration types expose these related values as members of the enumeration.

+

The enumeration type's name is a simple identifier that MUST be unique within its schema.

+

Although enumeration types have an underlying numeric value, the preferred representation for an enumeration value is the member name. Discrete sets of numeric values should be represented as numeric values annotated with the AllowedValues annotation defined in OData-VocCore.

+

Enumeration types marked as flags allow values that consist of more than one enumeration member at a time.

+
+

Enumeration Type Object

+

An enumeration type is represented as a member of the schema object whose name is the unqualified name of the enumeration type and whose value is an object.

+

The enumeration type object MUST contain the member $Kind with a string value of EnumType.

+

It MAY contain the members $UnderlyingType and $IsFlags.

+

The enumeration type object MUST contain members representing the enumeration type members.

+

The enumeration type object MAY contain annotations.

+
+
+

Example 26: a simple flags-enabled enumeration

+
"FileAccess": {
+  "$Kind": "EnumType",
+  "$UnderlyingType": "Edm.Int32",
+  "$IsFlags": true,
+  "Read": 1,
+  "Write": 2,
+  "Create": 4,
+  "Delete": 8
+}
+
+

10.1 Underlying Integer Type

+

An enumeration type MAY specify one of Edm.Byte, Edm.SByte, Edm.Int16, Edm.Int32, or Edm.Int64 as its underlying type.

+

If not explicitly specified, Edm.Int32 is used as the underlying type.

+
+

$UnderlyingType

+

The value of $UnderlyingType is the qualified name of the underlying type.

+
+

10.2 Flags Enumeration Type

+

An enumeration type MAY indicate that the enumeration type allows multiple members to be selected simultaneously.

+

If not explicitly specified, only one enumeration type member MAY be selected simultaneously.

+
+

$IsFlags

+

The value of $IsFlags is one of the Boolean literals true or false. Absence of the member means false.

+
+
+

Example 27: pattern values can be combined, and some combined values have explicit names

+
"Pattern": {
+  "$Kind": "EnumType",
+  "$UnderlyingType": "Edm.Int32",
+  "$IsFlags": true,
+  "Plain": 0,
+  "Red": 1,
+  "Blue": 2,
+  "Yellow": 4,
+  "Solid": 8,
+  "Striped": 16,
+  "SolidRed": 9,
+  "SolidBlue": 10,
+  "SolidYellow": 12,
+  "RedBlueStriped": 19,
+  "RedYellowStriped": 21,
+  "BlueYellowStriped": 22
+}
+
+

10.3 Enumeration Type Member

+

Enumeration type values consist of discrete members.

+

Each member is identified by its name, a simple identifier that MUST be unique within the enumeration type. Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

+

Each member MUST specify an associated numeric value that MUST be a valid value for the underlying type of the enumeration type.

+

Enumeration types can have multiple members with the same value. Members with the same numeric value compare as equal, and members with the same numeric value can be used interchangeably.

+

Enumeration members are sorted by their numeric value.

+

For flag enumeration types the combined numeric value of simultaneously selected members is the bitwise OR of the discrete numeric member values.

+
+

Enumeration Member Object

+

Enumeration type members are represented as JSON object members, where the object member name is the enumeration member name and the object member value is the enumeration member value.

+

For members of flags enumeration types a combined enumeration member value is equivalent to the bitwise OR of the discrete values.

+

Annotations for enumeration members are prefixed with the enumeration member name.

+
+
+

Example 28: FirstClass has a value of 0, TwoDay a value of 1, and Overnight a value of 2.

+
"ShippingMethod": {
+  "$Kind": "EnumType",
+  "FirstClass": 0,
+  "FirstClass@Core.Description": "Shipped with highest priority",
+  "TwoDay": 1,
+  "TwoDay@Core.Description": "Shipped within two days",
+  "Overnight": 2,
+  "Overnight@Core.Description": "Shipped overnight",
+  "@Core.Description": "Method of shipping"
+}
+
+
+

11 Type Definition

+

A type definition defines a specialization of one of the primitive types or of the built-in abstract type Edm.PrimitiveType.

+

The type definition's name is a simple identifier that MUST be unique within its schema.

+

Type definitions can be used wherever a primitive type is used (other than as the underlying type in a new type definition) and are type-comparable with their underlying types and any type definitions defined using the same underlying type.

+

It is up to the definition of a term to specify whether and how annotations with this term propagate to places where the annotated type definition is used, and whether they can be overridden.

+
+

Type Definition Object

+

A type definition is represented as a member of the schema object whose name is the unqualified name of the type definition and whose value is an object.

+

The type definition object MUST contain the member $Kind with a string value of TypeDefinition and the member $UnderlyingType. It MAY contain the members $MaxLength, $Unicode, $Precision, $Scale, and $SRID, and it MAY contain annotations.

+
+
+

Example 29:

+
"Length": {
+  "$Kind": "TypeDefinition",
+  "$UnderlyingType": "Edm.Int32",
+  "@Measures.Unit": "Centimeters"
+},
+"Weight": {
+  "$Kind": "TypeDefinition",
+  "$UnderlyingType": "Edm.Int32",
+  "@Measures.Unit": "Kilograms"
+},
+"Size": {
+  "$Kind": "ComplexType",
+  "Height": {
+    "$Nullable": true,
+    "$Type": "self.Length"
+  },
+  "Weight": {
+    "$Nullable": true,
+    "$Type": "self.Weight"
+  }
+}
+
+

11.1 Underlying Primitive Type

+

The underlying type of a type definition MUST be a primitive type that MUST NOT be another type definition.

+
+

$UnderlyingType

+

The value of $UnderlyingType is the qualified name of the underlying type.

+
+

The type definition MAY specify facets applicable to the underlying type. Possible facets are: $MaxLength, $Unicode, $Precision, $Scale, or $SRID.

+

Additional facets appropriate for the underlying type MAY be specified when the type definition is used but the facets specified in the type definition MUST NOT be re-specified.

+

For a type definition with underlying type Edm.PrimitiveType no facets are applicable, neither in the definition itself nor when the type definition is used, and these should be ignored by the client.

+

Where type definitions are used, the type definition is returned in place of the primitive type wherever the type is specified in a response.

+
+

12 Action and Function

+

12.1 Action

+

Actions are service-defined operations that MAY have observable side effects and MAY return a single instance or a collection of instances of any type.

+

The action's name is a simple identifier that MUST be unique within its schema.

+

Actions cannot be composed with additional path segments.

+

An action MAY specify a return type that MUST be a primitive, entity or complex type, or a collection of primitive, entity or complex types in scope.

+

An action MAY define parameters used during the execution of the action.

+

12.2 Action Overloads

+

Bound actions support overloading (multiple actions having the same name within the same schema) by binding parameter type. The combination of action name and the binding parameter type MUST be unique within a schema.

+

Unbound actions do not support overloads. The names of all unbound actions MUST be unique within a schema.

+

An unbound action MAY have the same name as a bound action.

+
+

Action Overload Object

+

An action is represented as a member of the schema object whose name is the unqualified name of the action and whose value is an array. The array contains one object per action overload.

+

The action overload object MUST contain the member $Kind with a string value of Action.

+

It MAY contain the members $IsBound, $EntitySetPath, $Parameter, and $ReturnType, and it MAY contain annotations.

+
+

12.3 Function

+

Functions are service-defined operations that MUST NOT have observable side effects and MUST return a single instance or a collection of instances of any type.

+

The function's name is a simple identifier that MUST be unique within its schema.

+

Functions MAY be composable.

+

The function MUST specify a return type which MUST be a primitive, entity or complex type, or a collection of primitive, entity or complex types in scope.

+

A function MAY define parameters used during the execution of the function.

+

12.4 Function Overloads

+

Bound functions support overloading (multiple functions having the same name within the same schema) subject to the following rules:

+ +

Unbound functions support overloading subject to the following rules:

+ +

An unbound function MAY have the same name as a bound function.

+

Note that type definitions can be used to disambiguate overloads for both bound and unbound functions, even if they specify the same underlying type.

+
+

Function Overload Object

+

A function is represented as a member of the schema object whose name is the unqualified name of the function and whose value is an array. The array contains one object per function overload.

+

The function overload object MUST contain the member $Kind with a string value of Function.

+

It MUST contain the member $ReturnType, and it MAY contain the members $IsBound, $EntitySetPath, and $Parameter, and it MAY contain annotations.

+
+

12.5 Bound or Unbound Action or Function Overloads

+

An action or function overload MAY indicate that it is bound. If not explicitly indicated, it is unbound.

+

Bound actions or functions are invoked on resources matching the type of the binding parameter. The binding parameter can be of any type, and it MAY be nullable.

+

Unbound actions are invoked from the entity container through an action import.

+

Unbound functions are invoked as static functions within a filter or orderby expression, or from the entity container through a function import.

+
+

$IsBound

+

The value of $IsBound is one of the Boolean literals true or false. Absence of the member means false.

+
+

12.6 Entity Set Path

+

Bound actions and functions that return an entity or a collection of entities MAY specify an entity set path if the entity set of the returned entities depends on the entity set of the binding parameter value.

+

The entity set path consists of a series of segments joined together with forward slashes.

+

The first segment of the entity set path MUST be the name of the binding parameter. The remaining segments of the entity set path MUST represent navigation segments or type casts.

+

A navigation segment names the simple identifier of the navigation property to be traversed. A type-cast segment names the qualified name of the entity type that should be returned from the type cast.

+
+

$EntitySetPath

+

The value of $EntitySetPath is a string containing the entity set path.

+
+

12.7 Composable Function

+

A function MAY indicate that it is composable. If not explicitly indicated, it is not composable.

+

A composable function can be invoked with additional path segments or key predicates appended to the resource path that identifies the composable function, and with system query options as appropriate for the type returned by the composable function.

+
+

$IsComposable

+

The value of $IsComposable is one of the Boolean literals true or false. Absence of the member means false.

+
+

12.8 Return Type

+

The return type of an action or function overload MAY be any type in scope, or a collection of any type in scope.

+

The facets Nullable, MaxLength, Precision, Scale, and SRID can be used as appropriate to specify value restrictions of the return type, as well as the Unicode facet for 4.01 and greater payloads.

+

For a single-valued return type the facets apply to the returned value. For a collection-valued return type the facets apply to the items in the returned collection.

+
+

$ReturnType

+

The value of $ReturnType is an object. It MAY contain the members $Type, $Collection, $Nullable, $MaxLength, $Unicode, $Precision, $Scale, and $SRID.

+

It also MAY contain annotations.

+

$Type and $Collection

+

For single-valued return types the value of $Type is the qualified name of the returned type.

+

For collection-valued return types the value of $Type is the qualified name of the returned item type, and the member $Collection MUST be present with the literal value true.

+

Absence of the $Type member means the type is Edm.String.

+

$Nullable

+

The value of $Nullable is one of the Boolean literals true or false. Absence of the member means false.

+

If the return type is a collection of entity types, the $Nullable member has no meaning and MUST NOT be specified.

+

For other collection-valued return types the result will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and specifies whether the collection MAY contain null values.

+

For single-valued return types the value true means that the action or function MAY return a single null value. The value false means that the action or function will never return a null value and instead will fail with an error response if it cannot compute a result.

+
+

12.9 Parameter

+

An action or function overload MAY specify parameters.

+

A bound action or function overload MUST specify at least one parameter; the first parameter is its binding parameter. The order of parameters MUST NOT change unless the schema version changes.

+

Each parameter MUST have a name that is a simple identifier. The parameter name MUST be unique within the action or function overload.

+

The parameter MUST specify a type. It MAY be any type in scope, or a collection of any type in scope.

+

The facets MaxLength, Precision, Scale, or SRID can be used as appropriate to specify value restrictions of the parameter, as well as the Unicode facet for 4.01 and greater payloads.

+

For single-valued parameters the facets apply to the parameter value. If the parameter value is a collection, the facets apply to the items in the collection.

+
+

$Parameter

+

The value of $Parameter is an array. The array contains one object per parameter.

+

Parameter Object

+

A parameter object MUST contain the member $Name, and it MAY contain the members $Type, $Collection, $Nullable, $MaxLength, $Unicode, $Precision, $Scale, and $SRID.

+

Parameter objects MAY also contain annotations.

+

$Name

+

The value of $Name is a string containing the parameter name.

+

$Type and $Collection

+

For single-valued parameters the value of $Type is the qualified name of the accepted type.

+

For collection-valued parameters the value of $Type is the qualified name of the accepted item type, and the member $Collection MUST be present with the literal value true.

+

Absence of the $Type member means the type is Edm.String.

+

$Nullable

+

The value of $Nullable is one of the Boolean literals true or false. Absence of the member means false.

+

For single-valued parameters the value true means that the parameter accepts a null value.

+

For collection-valued parameters the parameter value will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and specifies whether the collection MAY contain null values.

+
+
+

Example 30: a function returning the top-selling products for a given year. In this case the year must be specified as a parameter of the function with the $Parameter member.

+
"TopSellingProducts": [
+  {
+    "$Kind": "Function",
+    "$Parameter": [
+      {
+        "$Name": "Year",
+        "$Nullable": true,
+        "$Type": "Edm.Decimal",
+        "$Precision": 4,
+        "$Scale": 0
+      }
+    ],
+    "$ReturnType": {
+      "$Collection": true,
+      "$Type": "self.Product"
+    }
+  }
+]
+
+
+

13 Entity Container

+

Each metadata document used to describe an OData service MUST define exactly one entity container.

+

The entity container's name is a simple identifier that MUST be unique within its schema.

+

Entity containers define the entity sets, singletons, function and action imports exposed by the service.

+

Entity set, singleton, action import, and function import names MUST be unique within an entity container.

+

An entity set allows access to entity type instances. Simple entity models frequently have one entity set per entity type.

+
+

Example 31: one entity set per entity type

+
"Products": {
+  "$Collection": true,
+  "$Type": "self.Product"
+},
+"Categories": {
+  "$Collection": true,
+  "$Type": "self.Category"
+}
+
+

Other entity models may expose multiple entity sets per type.

+
+

Example 32: three entity sets referring to the two entity types

+
"StandardCustomers": {
+  "$Collection": true,
+  "$Type": "self.Customer",
+  "$NavigationPropertyBinding": {
+    "Orders": "Orders"
+  }
+},
+"PreferredCustomers": {
+  "$Collection": true,
+  "$Type": "self.Customer",
+  "$NavigationPropertyBinding": {
+    "Orders": "Orders"
+  }
+},
+"Orders": {
+  "$Collection": true,
+  "$Type": "self.Order"
+}
+
+

There are separate entity sets for standard customers and preferred customers, but only one entity set for orders. The entity sets for standard customers and preferred customers both have navigation property bindings to the orders entity set, but the orders entity set does not have a navigation property binding for the Customer navigation property, since it could lead to either set of customers.

+

An entity set can expose instances of the specified entity type as well as any entity type inherited from the specified entity type.

+

A singleton allows addressing a single entity directly from the entity container without having to know its key, and without requiring an entity set.

+

A function import or an action import is used to expose a function or action defined in an entity model as a top level resource.

+
+

Entity Container Object

+

An entity container is represented as a member of the schema object whose name is the unqualified name of the entity container and whose value is an object.

+

The entity container object MUST contain the member $Kind with a string value of EntityContainer.

+

The entity container object MAY contain the member $Extends, members representing entity sets, singletons, action imports, and function imports, as well as annotations.

+
+
+

Example 33: An entity container aggregates entity sets, singletons, action imports, and function imports.

+
"DemoService": {
+  "$Kind": "EntityContainer",
+  "Products": {
+    "$Collection": true,
+    "$Type": "self.Product",
+    "$NavigationPropertyBinding": {
+      "Category": "Categories",
+      "Supplier": "Suppliers"
+    },
+    "@UI.DisplayName": "Product Catalog"
+  },
+  "Categories": {
+    "$Collection": true,
+    "$Type": "self.Category",
+    "$NavigationPropertyBinding": {
+      "Products": "Products"
+    }
+  },
+  "Suppliers": {
+    "$Collection": true,
+    "$Type": "self.Supplier",
+    "$NavigationPropertyBinding": {
+      "Products": "Products"
+    },
+    "@UI.DisplayName": "Supplier Directory"
+  },
+  "MainSupplier": {
+    "$Type": "self.Supplier"
+  },
+  "LeaveRequestApproval": {
+    "$Action": "self.Approval"
+  },
+  "ProductsByRating": {
+    "$EntitySet": "Products",
+    "$Function": "self.ProductsByRating"
+  }
+}
+
+

13.1 Extending an Entity Container

+

An entity container MAY specify that it extends another entity container in scope. All children of the "base" entity container are added to the "extending" entity container.

+

If the "extending" entity container defines an entity set with the same name as defined in any of its "base" containers, then the entity set's type MUST specify an entity type derived from the entity type specified for the identically named entity set in the "base" container. The same holds for singletons. Action imports and function imports cannot be redefined, nor can the "extending" container define a child with the same name as a child of a different kind in a "base" container.

+

Note: services should not introduce cycles by extending entity containers. Clients should be prepared to process cycles introduced by extending entity containers.

+
+

$Extends

+

The value of $Extends is the qualified name of the entity container to be extended.

+
+
+

Example 34: the entity container Extending will contain all child elements that it defines itself, plus all child elements of the Base entity container located in SomeOtherSchema

+
"Extending": {
+  "$Kind": "EntityContainer",
+  "$Extends": "Some.Other.Schema.Base",
+   ...
+}
+
+

13.2 Entity Set

+

Entity sets are top-level collection-valued resources.

+

An entity set is identified by its name, a simple identifier that MUST be unique within its entity container.

+

An entity set MUST specify a type that MUST be an entity type in scope.

+

An entity set MUST contain only instances of its specified entity type or its subtypes. The entity type MAY be abstract but MUST have a key defined.

+

An entity set MAY indicate whether it is included in the service document. If not explicitly indicated, it is included.

+

Entity sets that cannot be queried without specifying additional query options SHOULD NOT be included in the service document.

+
+

Entity Set Object

+

An entity set is represented as a member of the entity container object whose name is the name of the entity set and whose value is an object.

+

The entity set object MUST contain the members $Collection and $Type.

+

It MAY contain the members $IncludeInServiceDocument and $NavigationPropertyBinding as well as annotations.

+

$Collection

+

The value of $Collection is the Booelan value true.

+

$Type

+

The value of $Type is the qualified name of an entity type.

+

$IncludeInServiceDocument

+

The value of $IncludeInServiceDocument is one of the Boolean literals true or false. Absence of the member means true.

+
+

13.3 Singleton

+

Singletons are top-level single-valued resources.

+

A singleton is identified by its name, a simple identifier that MUST be unique within its entity container.

+

A singleton MUST specify a type that MUST be an entity type in scope.

+

A singleton MUST reference an instance its entity type.

+
+

Singleton Object

+

A singleton is represented as a member of the entity container object whose name is the name of the singleton and whose value is an object.

+

The singleton object MUST contain the member $Type and it MAY contain the member $Nullable.

+

It MAY contain the member $NavigationPropertyBinding as well as annotations.

+

$Type

+

The value of $Type is the qualified name of an entity type.

+

$Nullable

+

The value of $Nullable is one of the Boolean literals true or false. Absence of the member means false.In OData 4.0 responses this member MUST NOT be specified.

+
+

13.4 Navigation Property Binding

+

If the entity type of an entity set or singleton declares navigation properties, a navigation property binding allows describing which entity set or singleton will contain the related entities.

+

An entity set or a singleton SHOULD specify a navigation property binding for each navigation property of its entity type, including navigation properties defined on complex typed properties or derived types.

+

If omitted, clients MUST assume that the target entity set or singleton can vary per related entity.

+

13.4.1 Navigation Property Path Binding

+

A navigation property binding MUST specify a path to a navigation property of the entity set's or singleton's declared entity type, or a navigation property reached through a chain of type casts, complex properties, or containment navigation properties. If the navigation property is defined on a subtype, the path MUST contain the qualified name of the subtype, followed by a forward slash, followed by the navigation property name. If the navigation property is defined on a complex type used in the definition of the entity set's entity type, the path MUST contain a forward-slash separated list of complex property names and qualified type names that describe the path leading to the navigation property.

+

The path can traverse one or more containment navigation properties, but the last navigation property segment MUST be a non-containment navigation property and there MUST NOT be any non-containment navigation properties prior to the final navigation property segment.

+

If the path traverses collection-valued complex properties or collection-valued containment navigation properties, the binding applies to all items of these collections.

+

If the path contains a recursive sub-path (i.e. a path leading back to the same structured type, the binding applies recursively to any positive number of cycles through that sub-path.

+

OData 4.01 services MAY have a type-cast segment as the last path segment, allowing to bind instances of different sub-types to different targets.

+

The same navigation property path MUST NOT be specified in more than one navigation property binding; navigation property bindings are only used when all related entities are known to come from a single entity set. Note that it is possible to have navigation property bindings for paths that differ only in a type-cast segment, allowing to bind instances of different sub-types to different targets. If paths differ only in type-cast segments, the most specific path applies.

+

13.4.2 Binding Target

+

A navigation property binding MUST specify a target via a simple identifier or target path. It specifies the entity set, singleton, or containment navigation property that contains the related entities.

+

If the target is a simple identifier, it MUST resolve to an entity set or singleton defined in the same entity container.

+

If the target is a target path, it MUST resolve to an entity set, singleton, or direct or indirect containment navigation property of a singleton in scope. The path can traverse single-valued containment navigation properties or single-valued complex properties before ending in a containment navigation property, and there MUST NOT be any non-containment navigation properties prior to the final segment.

+
+

$NavigationPropertyBinding

+

The value of $NavigationPropertyBinding is an object. It consists of members whose name is the navigation property binding path and whose value is a string containing the navigation property binding target. If the target is in the same entity container, the target MUST NOT be prefixed with the qualified entity container name.

+
+
+

Example 35: for an entity set in the same container as the enclosing entity set Categories

+
"Categories": {
+  "$Collection": true,
+  "$Type": "self.Category",
+  "$NavigationPropertyBinding": {
+    "Products": "SomeSet"
+  }
+}
+
+
+

Example 36: for an entity set in any container in scope

+
"Categories": {
+  "$Collection": true,
+  "$Type": "self.Category",
+  "$NavigationPropertyBinding": {
+    "Products": "SomeModel.SomeContainer/SomeSet"
+  }
+}
+
+
+

Example 37: binding Supplier on Products contained within Categories – binding applies to all suppliers of all products of all categories

+
"Categories": {
+  "$Collection": true,
+  "$Type": "self.Category",
+  "$NavigationPropertyBinding": {
+    "Products/Supplier": "Suppliers"
+  }
+}
+
+

13.5 Action Import

+

Action imports sets are top-level resources that are never included in the service document.

+

An action import is identified by its name, a simple identifier that MUST be unique within its entity container.

+

An action import MUST specify the name of an unbound action in scope.

+

If the imported action returns an entity or a collection of entities, a simple identifier or target path value MAY be specified to identify the entity set that contains the returned entities. If a simple identifier is specified, it MUST resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an entity set in scope.

+
+

Action Import Object

+

An action import is represented as a member of the entity container object whose name is the name of the action import and whose value is an object.

+

The action import object MUST contain the member $Action.

+

It MAY contain the member $EntitySet.

+

It MAY also contain annotations.

+

$Action

+

The value of $Action is a string containing the qualified name of an unbound action.

+

$EntitySet

+

The value of $EntitySet is a string containing either the unqualified name of an entity set in the same entity container or a path to an entity set in a different entity container.

+
+

13.6 Function Import

+

Function imports sets are top-level resources.

+

A function import is identified by its name, a simple identifier that MUST be unique within its entity container.

+

A function import MUST specify the name of an unbound function in scope. All unbound overloads of the imported function can be invoked from the entity container.

+

If the imported function returns an entity or a collection of entities, a simple identifier or target path value MAY be specified to identify the entity set that contains the returned entities. If a simple identifier is specified, it MUST resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an entity set in scope.

+

A function import for a parameterless function MAY indicate whether it is included in the service document. If not explicitly indicated, it is not included.

+
+

Function Import Object

+

A function import is represented as a member of the entity container object whose name is the name of the function import and whose value is an object.

+

The function import object MUST contain the member $Function.

+

It MAY contain the members $EntitySet and $IncludeInServiceDocument.

+

It MAY also contain annotations.

+

$Function

+

The value of $Function is a string containing the qualified name of an unbound function.

+

$EntitySet

+

The value of $EntitySet is a string containing either the unqualified name of an entity set in the same entity container or a path to an entity set in a different entity container.

+

$IncludeInServiceDocument

+

The value of $IncludeInServiceDocument is one of the Boolean literals true or false. Absence of the member means false.

+
+
+

14 Vocabulary and Annotation

+

Vocabularies and annotations provide the ability to annotate metadata as well as instance data, and define a powerful extensibility point for OData. An annotation applies a term to a model element and defines how to calculate a value for the applied term.

+

Metadata annotations are terms applied to model elements. Behaviors or constraints described by a metadata annotation must be consistent with the annotated model element. Such annotations define additional behaviors or constraints on the model element, such as a service, entity type, property, function, action, or parameter. For example, a metadata annotation may define ranges of valid values for a particular property. Metadata annotations are applied in CSDL documents describing or referencing an entity model.

+

Instance annotations are terms applied to a particular instance within an OData payload, such as described in OData-JSON. An instance annotation can be used to define additional information associated with a particular result, entity, property, or error. For example, whether a property is read-only for a particular instance. Where the same annotation is defined at both the metadata and instance level, the instance-level annotation overrides the annotation specified at the metadata level. Annotations that apply across instances should be specified as metadata annotations.

+

A vocabulary is a schema containing a set of terms where each term is a named metadata extension. Anyone can define a vocabulary (a set of terms) that is scenario-specific or company-specific; more commonly used terms can be published as shared vocabularies such as the OData Core vocabulary OData-VocCore.

+

A term can be used to:

+ +

A service SHOULD NOT require a client to interpret annotations. Clients SHOULD ignore invalid or unknown terms and silently treat unexpected or invalid values (including invalid type, invalid literal expression, invalid targets, etc.) as an unknown value for the term. Unknown or invalid annotations should never result in an error, as long as the payload remains well-formed.

+
+

Example 38: the Product entity type is extended with a DisplayName by a metadata annotation that binds the term DisplayName to the value of the property Name. The Product entity type also includes an annotation that allows its instances to be viewed as instances of the type specified by the term SearchResult

+
"Product": {
+  "$Kind": "EntityType",
+  "$Key": [
+    "ID"
+  ],
+  "ID": {
+    "$Type": "Edm.Int32"
+  },
+  "Name": {
+    "$Nullable": true
+  },
+  "Description": {
+    "$Nullable": true
+  },
+  "@UI.DisplayName": {
+    "$Path": "Name"
+  },
+  "@SearchVocabulary.SearchResult": {
+    "Title": {
+      "$Path": "Name"
+    },
+    "Abstract": {
+      "$Path": "Description"
+    },
+    "Url": {
+      "$Apply": [
+        "Products(",
+        {
+          "$Path": "ID"
+        },
+        ")"
+      ],
+      "$Function": "odata.concat"
+    }
+  }
+}
+
+

14.1 Term

+

A term allows annotating a model element or OData resource representation with additional data.

+

The term's name is a simple identifier that MUST be unique within its schema.

+

The term's type MUST be a type in scope, or a collection of a type in scope.

+
+

Term Object

+

A term is represented as a member of the schema object whose name is the unqualified name of the term and whose value is an object.

+

The term object MUST contain the member $Kind with a string value of Term.

+

It MAY contain the members $Type, $Collection, $AppliesTo, $Nullable, $MaxLength, $Precision, $Scale, $SRID, and $DefaultValue, as well as $Unicode for 4.01 and greater payloads.

+

It MAY contain annotations.

+

$Type and $Collection

+

For single-valued terms the value of $Type is the qualified name of the term's type.

+

For collection-valued terms the value of $Type is the qualified name of the term's item type, and the member $Collection MUST be present with the literal value true.

+

Absence of the $Type member means the type is Edm.String.

+

$DefaultValue

+

The value of $DefaultValue is the type-specific JSON representation of the default value of the term, see OData-JSON.

+

Note: the $DefaultValue member is purely for documentation and isomorphy to OData-CSDLXML. Annotations in CSDL JSON documents MUST always specify an explicit value.

+
+

14.1.1 Specialized Term

+

A term MAY specialize another term in scope by specifying it as its base term.

+

When applying a specialized term, the base term MUST also be applied with the same qualifier, and so on until a term without a base term is reached.

+
+

$BaseTerm

+

The value of $BaseTerm is the qualified name of the base term.

+
+

14.1.2 Applicability

+

The applicability of a term MAY be restricted to a list of model elements. If no list is supplied, the term is not intended to be restricted in its application. The list of model elements MAY be extended in future versions of the vocabulary. As the intended usage may evolve over time, clients SHOULD be prepared for any term to be applied to any model element and SHOULD be prepared to handle unknown values within the list of model constructs. Applicability is expressed using the following symbolic values:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Symbolic ValueModel Element
ActionAction
ActionImportAction Import
AnnotationAnnotation
ApplyApplication of a client-side function in an annotation
CastType Cast annotation expression
CollectionEntity Set or collection-valued Property or Navigation Property
ComplexTypeComplex Type
EntityContainerEntity Container
EntitySetEntity Set
EntityTypeEntity Type
EnumTypeEnumeration Type
FunctionFunction
FunctionImportFunction Import
IfConditional annotation expression
IncludeReference to an Included Schema
IsOfType Check annotation expression
LabeledElementLabeled Element expression
MemberEnumeration Member
NavigationPropertyNavigation Property
NullNull annotation expression
OnDeleteOn-Delete Action of a navigation property
ParameterAction of Function Parameter
PropertyProperty of a structured type
PropertyValueProperty value of a Record annotation expression
RecordRecord annotation expression
ReferenceReference to another CSDL document
ReferentialConstraintReferential Constraint of a navigation property
ReturnTypeReturn Type of an Action or Function
SchemaSchema
SingletonSingleton
TermTerm
TypeDefinitionType Definition
UrlRefUrlRef annotation expression
+
+

$AppliesTo

+

The value of $AppliesTo is an array whose items are strings containing symbolic values from the table above that identify model elements the term is intended to be applied to.

+
+
+

Example 39: the IsURL term can be applied to properties and terms that are of type Edm.String (the Core.Tag type and the two Core terms are defined in OData-VocCore)

+
"IsURL": {
+  "$Kind": "Term",
+  "$Type": "Core.Tag",
+  "$DefaultValue": true,
+  "$AppliesTo": [
+    "Property"
+  ],
+  "@Core.Description": "Properties and terms annotated with this term
+MUST contain a valid URL",
+  "@Core.RequiresType": "Edm.String"
+}
+
+

14.2 Annotation

+

An annotation applies a term to a model element and defines how to calculate a value for the term application. Both term and model element MUST be in scope. Section 14.1.2 specifies which model elements MAY be annotated with a term.

+

The value of an annotation is specified as an annotation expression, which is either a constant expression representing a constant value, or a dynamic expression. The most common construct for assigning an annotation value is a path expression that refers to a property of the same or a related structured type.

+
+

Annotation Member

+

An annotation is represented as a member whose name consists of an at (@) character, followed by the qualified name of a term, optionally followed by a hash (#) and a qualifier.

+

The value of the annotation MUST be a constant expression or dynamic expression.

+

The annotation can be a member of the object representing the model element it annotates, or a second-level member of the $Annotations member of a schema object.

+

An annotation can itself be annotated. Annotations on annotations are represented as a member whose name consists of the annotation name (including the optional qualifier), followed by an at (@) character, followed by the qualified name of a term, optionally followed by a hash (#) and a qualifier.

+
+
+

Example 40: term Measures.ISOCurrency, once applied with a constant value, once with a path value

+
"AmountInReportingCurrency": {
+  "$Nullable": true,
+  "$Type": "Edm.Decimal",
+  "$Scale": 0,
+  "@Measures.ISOCurrency": "USD",
+  "@Measures.ISOCurrency@Core.Description": "The parent company's currency"
+},
+"AmountInTransactionCurrency": {
+  "$Nullable": true,
+  "$Type": "Edm.Decimal",
+  "$Scale": 0,
+  "@Measures.ISOCurrency": {
+    "$Path": "Currency"
+  }
+},
+"Currency": {
+  "$Nullable": true,
+  "$MaxLength": 3
+}
+
+

If an entity type or complex type is annotated with a term that itself has a structured type, an instance of the annotated type may be viewed as an "instance" of the term, and the qualified term name may be used as a term-cast segment in path expressions.

+

Structured types "inherit" annotations from their direct or indirect base types. If both the type and one of its base types is annotated with the same term and qualifier, the annotation on the type completely replaces the annotation on the base type; structured or collection-valued annotation values are not merged. Similarly, properties of a structured type inherit annotations from identically named properties of a base type.

+

It is up to the definition of a term to specify whether and how annotations with this term propagate to places where the annotated model element is used, and whether they can be overridden. E.g. a "Label" annotation for a UI can propagate from a type definition to all properties using that type definition and may be overridden at each property with a more specific label, whereas an annotation marking a type definition as containing a phone number will propagate to all using properties but may not be overridden.

+

14.2.1 Qualifier

+

A term can be applied multiple times to the same model element by providing a qualifier to distinguish the annotations. The qualifier is a simple identifier.

+

The combination of target model element, term, and qualifier uniquely identifies an annotation.

+
+

Example 41: annotation should only be applied to tablet devices

+
"@UI.DisplayName#Tablet": {
+  "$Path": "FirstName"
+}
+
+

14.2.2 Target

+

The target of an annotation is the model element the term is applied to.

+

The target of an annotation MAY be specified indirectly by "nesting" the annotation within the model element. Whether and how this is possible is described per model element in this specification.

+

The target of an annotation MAY also be specified directly; this allows defining an annotation in a different schema than the targeted model element.

+

This external targeting is only possible for model elements that are uniquely identified within their parent, and all their ancestor elements are uniquely identified within their parent:

+ +

These are the direct children of a schema with a unique name (i.e. except actions and functions whose overloads to not possess a natural identifier), and all direct children of an entity container.

+

External targeting is possible for actions, functions, their parameters, and their return type, either in a way that applies to all overloads of the action or function or all parameters of that name across all overloads, or in a way that identifies a single overload.

+

External targeting is also possible for properties and navigation properties of singletons or entities in a particular entity set. These annotations override annotations on the properties or navigation properties targeted via the declaring structured type.

+

The allowed path expressions are:

+ +

All qualified names used in a target path MUST be in scope.

+
+

Example 42: Target expressions

+
MySchema.MyEntityType
+MySchema.MyEntityType/MyProperty
+MySchema.MyEntityType/MyNavigationProperty
+MySchema.MyComplexType
+MySchema.MyComplexType/MyProperty
+MySchema.MyComplexType/MyNavigationProperty
+MySchema.MyEnumType
+MySchema.MyEnumType/MyMember
+MySchema.MyTypeDefinition
+MySchema.MyTerm
+MySchema.MyEntityContainer
+MySchema.MyEntityContainer/MyEntitySet
+MySchema.MyEntityContainer/MySingleton
+MySchema.MyEntityContainer/MyActionImport
+MySchema.MyEntityContainer/MyFunctionImport
+MySchema.MyAction
+MySchema.MyAction(MySchema.MyBindingType)
+MySchema.MyAction()
+MySchema.MyFunction
+MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType)
+MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType)
+MySchema.MyFunction/MyParameter
+MySchema.MyEntityContainer/MyEntitySet/MyProperty
+MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty
+MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty
+MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty
+MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty
+MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty
+MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty
+
+

14.3 Constant Expression

+

Constant expressions allow assigning a constant value to an applied term.

+

14.3.1 Binary

+
+

Binary expressions are represented as a string containing the base64url-encoded binary value.

+
+
+

Example 43: base64url-encoded binary value (OData)

+
"@UI.Thumbnail": "T0RhdGE"
+
+

14.3.2 Boolean

+
+

Boolean expressions are represented as the literals true or false.

+
+
+

Example 44:

+
"@UI.ReadOnly": true
+
+

14.3.3 Date

+
+

Date expressions are represented as a string containing the date value. The value MUST conform to type xs:date, see XML-Schema-2, section 3.3.9. The value MUST also conform to rule dateValue in OData-ABNF, i.e. it MUST NOT contain a time-zone offset.

+
+
+

Example 45:

+
"@vCard.birthDay": "2000-01-01"
+
+

14.3.4 DateTimeOffset

+
+

Datetimestamp expressions are represented as a string containing the timestamp value. The value MUST conform to type xs:dateTimeStamp, see XML-Schema-2, section 3.4.28. The value MUST also conform to rule dateTimeOffsetValue in OData-ABNF, i.e. it MUST NOT contain an end-of-day fragment (24:00:00).

+
+
+

Example 46:

+
"@UI.LastUpdated": "2000-01-01T16:00:00.000Z"
+
+

14.3.5 Decimal

+
+

Decimal expressions are represented as either a number or a string. The special values INF, -INF, or NaN are represented as strings. Numeric values are represented as numbers or strings depending on the media type parameter IEEE754Compatible.

+
+
+

Example 47: default representation as a number

+
"@UI.Width": 3.14
+
+
+

Example 48: "safe" representation as a string

+
"@UI.Width": "3.14"
+
+

14.3.6 Duration

+
+

Duration expressions are represented as a string containing the duration value. The value MUST conform to type xs:dayTimeDuration, see XML-Schema-2, section 3.4.27.

+
+
+

Example 49:

+
"@task.duration": "P7D"
+
+

14.3.7 Enumeration Member

+
+

Enumeration member expressions are represented as a string containing the numeric or symbolic enumeration value.

+
+
+

Example 50: single value Red with numeric value and symbolic value

+
"@self.HasPattern": "1"
+
"@self.HasPattern": "Red"
+
+
+

Example 51: combined value Red,Striped with numeric value 1 + 16 and symbolic value

+
"@self.HasPattern": "17"
+
"@self.HasPattern": "Red,Striped"
+
+

14.3.8 Floating-Point Number

+
+

Floating-point expressions are represented as a number or as a string containing one of the special values INF, -INF, or NaN.

+
+
+

Example 52:

+
"@UI.FloatWidth": 3.14
+
"@UI.FloatWidth": "INF"
+
+

14.3.9 Guid

+
+

Guid expressions are represented as a string containing the uuid value. The value MUST conform to the rule guidValue in OData-ABNF.

+
+
+

Example 53:

+
"@UI.Id": "21EC2020-3AEA-1069-A2DD-08002B30309D"
+
+

14.3.10 Integer

+
+

Integer expressions are represented as either a number or a string, depending on the media type parameter IEEE754Compatible.

+
+
+

Example 54: default representation as a number

+
"@An.Int": 42
+
+
+

Example 55: "safe" representation as a string

+
"@A.Very.Long.Int": "9007199254740992"
+
+

14.3.11 String

+
+

String expressions are represented as a JSON string.

+
+
+

Example 56:

+
"@UI.DisplayName": "Product Catalog"
+
+

14.3.12 Time of Day

+
+

Time-of-day expressions are represented as a string containing the time-of-day value. The value MUST conform to the rule timeOfDayValue in OData-ABNF.

+
+
+

Example 57:

+
"@UI.EndTime": "21:45:00"
+
+

14.4 Dynamic Expression

+

Dynamic expressions allow assigning a calculated value to an applied term.

+

14.4.1 Path Expressions

+

Path expressions allow assigning a value to an applied term or term component. There are two kinds of path expressions:

+ +

14.4.1.1 Path Syntax

+

Model paths and instance paths share a common syntax which is derived from the path expression syntax of URLs, see OData-URL.

+

A path MUST be composed of zero or more path segments joined together by forward slashes (/).

+

Paths starting with a forward slash (/) are absolute paths, and the first path segment MUST be the qualified name of a model element, e.g. an entity container. The remaining path after the second forward slash is interpreted relative to that model element.

+
+

Example 58: absolute path to an entity set

+
/My.Schema.MyEntityContainer/MyEntitySet
+
+

Paths not starting with a forward slash are interpreted relative to the annotation target, following the rules specified in section "Path Evaluation".

+
+

Example 59: relative path to a property

+
Address/City
+
+

If a path segment is a qualified name, it represents a type cast, and the segment MUST be the name of a type in scope. If the type or instance identified by the preceding path part cannot be cast to the specified type, the path expression evaluates to the null value.

+
+

Example 60: type-cast segment

+
.../self.Manager/...
+
+

If a path segment starts with an at (@) character, it represents a term cast. The at (@) character MUST be followed by a qualified name that MAY be followed by a hash (#) character and a simple identifier. The qualified name preceding the hash character MUST resolve to a term that is in scope, the simple identifier following the hash sign is interpreted as a qualifier for the term. If the model element or instance identified by the preceding path part has not been annotated with that term (and if present, with that qualifier), the term cast evaluates to the null value. Four special terms are implicitly "annotated" for media entities and stream properties:

+ +
+

Example 61: term-cast segments

+
.../@Capabilities.SortRestrictions/...
+
+

If a path segment is a simple identifier, it MUST be the name of a child model element of the model element identified by the preceding path part, or a structural or navigation property of the instance identified by the preceding path part. A sequence of navigation segments can traverse multiple CSDL documents. The document containing the path expression only needs to reference the next traversed document to bring the navigation target type into scope, and each traversed document in turn needs to reference only its next document.

+

A model path MAY contain any number of segments representing collection-valued structural or navigation properties. The result of the expression is the model element reached via this path.

+
+

Example 62: property segments in model path

+
.../Orders/Items/Product/...
+
+

An instance path MUST NOT contain more than one segment representing a collection-valued construct, e.g. an entity set or a collection-valued navigation property that is not followed by a key predicate, or a collection-valued structural property that is not followed by an index segment. The result of the expression is the collection of instances resulting from applying any remaining path segments that operate on a single-valued expression to each instance in the collection-valued segment.

+

An instance path MAY terminate in a $count segment if the previous segment is collection-valued, in which case the path evaluates to the number of items in the collection identified by the preceding segment.

+
+

Example 63: property segments in instance path

+
.../Addresses/Street
+
.../Addresses/$count
+
+

A model path MAY contain path segments starting with a navigation property, then followed by an at (@) character, then followed by the qualified name of a term in scope, and optionally followed by a hash (#) character and a simple identifier which is interpreted as a qualifier for the term. If the navigation property has not been annotated with that term (and if present, with that qualifier), the path segment evaluates to the null value. This allows addressing annotations on the navigation property itself; annotations on the entity type specified by the navigation property are addressed via a term-cast segment.

+
+

Example 64: model path addressing an annotation on a navigation property

+
.../Items@Capabilities.InsertRestrictions/Insertable
+
+

An instance path MAY contain path segments starting with an entity set or a collection-valued navigation property, then followed by a key predicate using parentheses-style convention, see OData-URL. The key values are either primitive literals or instance paths. If the key value is a relative instance path, it is interpreted according to the same rule below as the instance path it is part of, not relative to the instance identified by the preceding path part.

+
+

Example 65: instance path with entity set and key predicate

+
/self.container/SettingsCollection('FeatureXxx')/IsAvailable
+
/self.container/Products(ID=ProductID)/Name
+
+

An instance path MAY contain an index segment immediately following a path segment representing an ordered collection-valued structural property. The index is zero-based and MUST be an integer literal. Negative integers count from the end of the collection, with -1 representing the last item in the collection. Remaining path segments are evaluated relative to the identified item of the collection.

+
+

Example 66: instance path with collection-valued structural property and index segment

+
Addresses/1
+
Addresses/-1/Street
+
+

14.4.1.2 Path Evaluation

+

Annotations MAY be embedded within their target, or specified separately, e.g. as part of a different schema, and specify a path to their target model element. The latter situation is referred to as targeting in the remainder of this section.

+

For annotations embedded within or targeting an entity container, the path is evaluated starting at the entity container, i.e. an empty path resolves to the entity container, and non-empty paths MUST start with a segment identifying a container child (entity set, function import, action import, or singleton). The subsequent segments follow the rules for paths targeting the corresponding child element.

+

For annotations embedded within or targeting an entity set or a singleton, the path is evaluated starting at the entity set or singleton, i.e. an empty path resolves to the entity set or singleton, and non-empty paths MUST follow the rules for annotations targeting the declared entity type of the entity set or singleton.

+

For annotations embedded within or targeting an entity type or complex type, the path is evaluated starting at the type, i.e. an empty path resolves to the type, and the first segment of a non-empty path MUST be a structural or navigation property of the type, a type cast, or a term cast.

+

For annotations embedded within a structural or navigation property of an entity type or complex type, the path is evaluated starting at the directly enclosing type. This allows e.g. specifying the value of an annotation on one property to be calculated from values of other properties of the same type. An empty path resolves to the enclosing type, and non-empty paths MUST follow the rules for annotations targeting the directly enclosing type.

+

For annotations targeting a structural or navigation property of an entity type or complex type, the path is evaluated starting at the outermost entity type or complex type named in the target of the annotation, i.e. an empty path resolves to the outermost type, and the first segment of a non-empty path MUST be a structural or navigation property of the outermost type, a type cast, or a term cast.

+

For annotations embedded within or targeting an action, action import, function, function import, parameter, or return type, the first segment of the path MUST be a parameter name or $ReturnType.

+

14.4.1.3 Annotation Path

+

The annotation path expression provides a value for terms or term properties that specify the built-in types Edm.AnnotationPath or Edm.ModelElementPath. Its argument is a model path with the following restriction:

+ +

A term or term property of type Edm.AnnotationPath can be annotated with term Validation.AllowedTerms (see OData-VocValidation) if its intended value is an annotation path that ends in a term cast with one of the listed terms.

+

The value of the annotation path expression is the path itself, not the value of the annotation identified by the path. This is useful for terms that reuse or refer to other terms.

+
+

Annotation path expressions are represented as a string containing a path.

+
+
+

Example 67:

+
"@UI.ReferenceFacet": "Product/Supplier/@UI.LineItem",
+"@UI.CollectionFacet#Contacts": [
+  "Supplier/@Communication.Contact",
+  "Customer/@Communication.Contact"
+]
+
+

14.4.1.4 Model Element Path

+

The model element path expression provides a value for terms or term properties that specify the built-in type Edm.ModelElementPath. Its argument is a model path.

+

The value of the model element path expression is the path itself, not the instance(s) identified by the path.

+
+

Model element path expressions are represented as a string containing a path.

+
+
+

Example 68:

+
"@org.example.MyFavoriteModelElement": "/self.someAction"
+
+

14.4.1.5 Navigation Property Path

+

The navigation property path expression provides a value for terms or term properties that specify the built-in types Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

+ +

The value of the navigation property path expression is the path itself, not the entitiy or collection of entities identified by the path.

+
+

Navigation property path expressions are represented as a string containing a path.

+
+
+

Example 69:

+
"@UI.HyperLink": "Supplier",
+
+"@Capabilities.UpdateRestrictions": {
+  "NonUpdatableNavigationProperties": [
+    "Supplier",
+    "Category"
+  ]
+}
+
+

14.4.1.6 Property Path

+

The property path expression provides a value for terms or term properties that specify one of the built-in types Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

+ +

The value of the property path expression is the path itself, not the value of the structural property or the value of the term cast identified by the path.

+
+

Property path expressions are represented as a string containing a path.

+
+
+

Example 70:

+
"@UI.RefreshOnChangeOf": "ChangedAt",
+
+"@Capabilities.UpdateRestrictions": {
+  "NonUpdatableProperties": [
+    "CreatedAt",
+    "ChangedAt"
+  ]
+}
+
+

14.4.1.7 Value Path

+

The value path expression allows assigning a value by traversing an object graph. It can be used in annotations that target entity containers, entity sets, entity types, complex types, navigation properties of structured types, and structural properties of structured types. Its argument is an instance path.

+

The value of the path expression is the instance or collection of instances identified by the path.

+
+

$Path

+

Path expressions are represented as an object with a single member $Path whose value is a string containing a path.

+
+
+

Example 71:

+
"@UI.DisplayName": {
+  "$Path": "FirstName"
+},
+
+"@UI.DisplayName#second": {
+  "$Path": "@vCard.Address#work/FullName"
+}
+
+

14.4.2 Comparison and Logical Operators

+

Annotations MAY use the following logical and comparison expressions which evaluate to a Boolean value. These expressions MAY be combined and they MAY be used anywhere instead of a Boolean expression.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperatorDescription
Logical Operators
AndLogical and
OrLogical or
NotLogical negation
Comparison Operators
EqEqual
NeNot equal
GtGreater than
GeGreater than or equal
LtLess than
LeLess than or equal
HasHas enumeration flag(s) set
InIs in collection
+

The And and Or operators require two operand expressions that evaluate to Boolean values. The Not operator requires a single operand expression that evaluates to a Boolean value. For details on null handling for comparison operators see OData-URL.

+

The other comparison operators require two operand expressions that evaluate to comparable values.

+
+

$And and $Or

+

The And and Or logical expressions are represented as an object with a single member whose value is an array with two annotation expressions. The member name is one of $And, or $Or.

+

It MAY contain annotations.

+

$Not

+

Negation expressions are represented as an object with a single member $Not whose value is an annotation expression.

+

It MAY contain annotations.

+

$Eq, $Ne, $Gt, $Ge, $Lt, $Le, $Has, and $In

+

All comparison expressions are represented as an object with a single member whose value is an array with two annotation expressions. The member name is one of $Eq, $Ne, $Gt, $Ge, $Lt, $Le, $Has, or $In.

+

They MAY contain annotations.

+
+
+

Example 72:

+
{
+  "$And": [
+    {
+      "$Path": "IsMale"
+    },
+    {
+      "$Path": "IsMarried"
+    }
+  ]
+},
+{
+  "$Or": [
+    {
+      "$Path": "IsMale"
+    },
+    {
+      "$Path": "IsMarried"
+    }
+  ]
+},
+{
+  "$Not": {
+    "$Path": "IsMale"
+  }
+},
+{
+  "$Eq": [
+    null,
+    {
+      "$Path": "IsMale"
+    }
+  ]
+},
+{
+  "$Ne": [
+    null,
+    {
+      "$Path": "IsMale"
+    }
+  ]
+},
+{
+  "$Gt": [
+    {
+      "$Path": "Price"
+    },
+    20
+  ]
+},
+{
+  "$Ge": [
+    {
+      "$Path": "Price"
+    },
+    10
+  ]
+},
+{
+  "$Lt": [
+    {
+      "$Path": "Price"
+    },
+    20
+  ]
+},
+{
+  "$Le": [
+    {
+      "$Path": "Price"
+    },
+    100
+  ]
+},
+{
+  "$Has": [
+    {
+      "$Path": "Fabric"
+    },
+    "Red"
+  ]
+},
+{
+  "$In": [
+    {
+      "$Path": "Size"
+    },
+    [
+      "XS",
+      "S"
+    ]
+  ]
+} ```
+
+

14.4.3 Arithmetic Operators

+

Annotations MAY use the following arithmetic expressions which evaluate to a numeric value. These expressions MAY be combined, and they MAY be used anywhere instead of a numeric expression of the appropriate type. The semantics and evaluation rules for each arithmetic expression is identical to the corresponding arithmetic operator defined in OData-URL.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperatorDescription
AddAddition
SubSubtraction
NegNegation
MulMultiplication
DivDivision (with integer result for integer operands)
DivByDivision (with fractional result also for integer operands)
ModModulo
+

The Neg operator requires a single operand expression that evaluates to a numeric value. The other arithmetic operators require two operand expressions that evaluate to numeric values.

+
+

$Neg

+

Negation expressions are represented as an object with a single member $Neg whose value is an annotation expression.

+

It MAY contain annotations.

+

$Add, $Sub, $Mul, $Div, $DivBy, and $Mod

+

These arithmetic expressions are represented as an object with as single member whose value is an array with two annotation expressions. The member name is one of $Add, $Sub, $Neg, $Mul, $Div, $DivBy, or $Mod.

+

They MAY contain annotations.

+
+
+

Example 73:

+
{
+  "$Add": [
+    {
+      "$Path": "StartDate"
+    },
+    {
+      "$Path": "Duration"
+    }
+  ]
+},
+{
+  "$Sub": [
+    {
+      "$Path": "Revenue"
+    },
+    {
+      "$Path": "Cost"
+    }
+  ]
+},
+{
+  "$Neg": {
+    "$Path": "Height"
+  }
+},
+{
+  "$Mul": [
+    {
+      "$Path": "NetPrice"
+    },
+    {
+      "$Path": "TaxRate"
+    }
+  ]
+},
+{
+  "$Div": [
+    {
+      "$Path": "Quantity"
+    },
+    {
+      "$Path": "QuantityPerParcel"
+    }
+  ]
+},
+{
+  "$DivBy": [
+    {
+      "$Path": "Quantity"
+    },
+    {
+      "$Path": "QuantityPerParcel"
+    }
+  ]
+},
+{
+  "$Mod": [
+    {
+      "$Path": "Quantity"
+    },
+    {
+      "$Path": "QuantityPerParcel"
+    }
+  ]
+}
+
+

14.4.4 Apply Client-Side Functions

+

The apply expression enables a value to be obtained by applying a client-side function. The apply expression MAY have operand expressions. The operand expressions are used as parameters to the client-side function.

+
+

$Apply

+

Apply expressions are represented as an object with a member $Apply whose value is an array of annotation expressions, and a member $Function whose value is a string containing the qualified name of the client-side function to be applied.

+

It MAY contain annotations.

+
+

OData defines the following functions. Services MAY support additional functions that MUST be qualified with a namespace other than odata. Function names qualified with odata are reserved for this specification and its future versions.

+

14.4.4.1 Canonical Functions

+

All canonical functions defined in OData-URL can be used as client-side functions, qualified with the namespace odata. The semantics of these client-side functions is identical to their counterpart function defined in OData-URL.

+

For example, the odata.concat client-side function takes two or more expressions as arguments. Each argument MUST evaluate to a primitive or enumeration type. It returns a value of type Edm.String that is the concatenation of the literal representations of the results of the argument expressions. Values of primitive types other than Edm.String are represented according to the appropriate alternative in the primitiveValue rule of OData-ABNF, i.e. Edm.Binary as binaryValue, Edm.Boolean as booleanValue etc.

+
+

Example 74:

+
"@UI.DisplayName": {
+  "$Apply": [
+    "Product: ",
+    {
+      "$Path": "ProductName"
+    },
+    " (",
+    {
+      "$Path": "Available/Quantity"
+    },
+    " ",
+    {
+      "$Path": "Available/Unit"
+    },
+    " available)"
+  ],
+  "$Function": "odata.concat"
+}
+
+

ProductName is of type String, Quantity in complex type Available is of type Decimal, and Unit in Available is of type enumeration, so the result of the Path expression is represented as the member name of the enumeration value.

+

14.4.4.2 Function odata.fillUriTemplate

+

The odata.fillUriTemplate client-side function takes two or more expressions as arguments and returns a value of type Edm.String.

+

The first argument MUST be of type Edm.String and specifies a URI template according to RFC6570, the other arguments MUST be labeled element expressions. Each labeled element expression specifies the template parameter name as its name and evaluates to the template parameter value.

+

RFC6570 defines three kinds of template parameters: simple values, lists of values, and key-value maps.

+

Simple values are represented as labeled element expressions that evaluate to a single primitive value. The literal representation of this value according to OData-ABNF is used to fill the corresponding template parameter.

+

Lists of values are represented as labeled element expressions that evaluate to a collection of primitive values.

+

Key-value maps are represented as labeled element expressions that evaluate to a collection of complex types with two properties that are used in lexicographic order. The first property is used as key, the second property as value.

+
+

Example 75: assuming there are no special characters in values of the Name property of the Actor entity

+
{
+  "$Apply": [
+    "http://host/someAPI/Actors/{actorName}/CV",
+    {
+      "$LabeledElement": {
+        "$Path": "Actor/Name"
+      },
+      "$Name": "self.actorName"
+    }
+  ],
+  "$Function": "odata.fillUriTemplate"
+}
+
+

14.4.4.3 Function odata.matchesPattern

+

The odata.matchesPattern client-side function takes two string expressions as arguments and returns a Boolean value.

+

The function returns true if the second expression evaluates to an ECMAScript (JavaScript) regular expression and the result of the first argument expression matches that regular expression, using syntax and semantics of ECMAScript regular expressions.

+
+

Example 76: all non-empty FirstName values not containing the letters b, c, or d evaluate to true

+
{
+  "$Apply": [
+    {
+      "$Path": "FirstName"
+    },
+    "^[^b-d]+$"
+  ],
+  "$Function": "odata.matchesPattern"
+}
+
+

14.4.4.4 Function odata.uriEncode

+

The odata.uriEncode client-side function takes one argument of primitive type and returns the URL-encoded OData literal that can be used as a key value in OData URLs or in the query part of OData URLs.

+

Note: string literals are surrounded by single quotes as required by the paren-style key syntax.

+
+

Example 77:

+
{
+  "$Apply": [
+    "http://host/service/Genres({genreName})",
+    {
+      "$LabeledElement": {
+        "$Apply": [
+          {
+            "$Path": "NameOfMovieGenre"
+          }
+        ],
+        "$Function": "odata.uriEncode"
+      },
+      "$Name": "self.genreName"
+    }
+  ],
+  "$Function": "odata.fillUriTemplate"
+}
+
+

14.4.5 Cast

+

The cast expression casts the value obtained from its single child expression to the specified type. The cast expression follows the same rules as the cast canonical function defined in OData-URL.

+
+

$Cast

+

Cast expressions are represented as an object with a member $Cast whose value is an annotation expression, a member $Type whose value is a string containing the qualified type name, and optionally a member $Collection with a value of true.

+

It MAY contain annotations.

+

If the specified type is a primitive type or a collection of primitive types, the facet members $MaxLength, $Unicode, $Precision, $Scale, and $SRID MAY be specified if applicable to the specified primitive type. If the facet members are not specified, their values are considered unspecified.

+
+
+

Example 78:

+
"@UI.Threshold": {
+  "$Cast": {
+    "$Path": "Average"
+  },
+  "$Type": "Edm.Decimal"
+}
+
+

14.4.6 Collection

+

The collection expression enables a value to be obtained from zero or more item expressions. The value calculated by the collection expression is the collection of the values calculated by each of the item expressions. The values of the child expressions MUST all be type compatible.

+
+

Collection expressions are represented as arrays with one array item per item expression within the collection expression.

+
+
+

Example 79:

+
"@seo.SeoTerms": [
+  "Product",
+  "Supplier",
+  "Customer"
+]
+
+

14.4.7 If-Then-Else

+

The if-then-else expression enables a value to be obtained by evaluating a condition expression. It MUST contain exactly three child expressions. There is one exception to this rule: if and only if the if-then-else expression is an item of a collection expression, the third child expression MAY be omitted, reducing it to an if-then expression. This can be used to conditionally add an element to a collection.

+

The first child expression is the condition and MUST evaluate to a Boolean result, e.g. the comparison and logical operators can be used.

+

The second and third child expressions are evaluated conditionally. The result MUST be type compatible with the type expected by the surrounding expression.

+

If the first expression evaluates to true, the second expression MUST be evaluated and its value MUST be returned as the result of the if-then-else expression. If the first expression evaluates to false and a third child element is present, it MUST be evaluated and its value MUST be returned as the result of the if-then-else expression. If no third expression is present, nothing is added to the surrounding collection.

+
+

$If

+

Conditional expressions are represented as an object with a member $If whose value is an array of two or three annotation expressions.

+

It MAY contain annotations.

+
+
+

Example 80: the condition is a value path expression referencing the Boolean property IsFemale, whose value then determines the value of the $If expression (or so it was long ago)

+
"@person.Gender": {
+  "$If": [
+    {
+      "$Path": "IsFemale"
+    },
+    "Female",
+    "Male"
+  ]
+}
+
+

14.4.8 Is-Of

+

The is-of expression checks whether the value obtained from its single child expression is compatible with the specified type. It returns true if the child expression returns a type that is compatible with the specified type, and false otherwise.

+
+

$IsOf

+

Is-of expressions are represented as an object with a member $IsOf whose value is an annotation expression, a member $Type whose value is a string containing an qualified type name, and optionally a member $Collection with a value of true.

+

It MAY contain annotations.

+

If the specified type is a primitive type or a collection of primitive types, the facet members $MaxLength, $Unicode, $Precision, $Scale, and $SRID MAY be specified if applicable to the specified primitive type. If the facet members are not specified, their values are considered unspecified.

+
+
+

Example 81:

+
"@Self.IsPreferredCustomer": {
+  "$IsOf": {
+    "$Path": "Customer"
+  },
+  "$Type": "self.PreferredCustomer"
+}
+
+

14.4.9 Labeled Element

+

The labeled element expression assigns a name to its single child expression. The value of the child expression can then be reused elsewhere with a labeled element reference expression.

+

A labeled element expression MUST contain exactly one child expression. The value of the child expression is also the value of the labeled element expression.

+

A labeled element expression MUST provide a simple identifier value as its name that MUST be unique within the schema containing the expression.

+
+

$LabeledElement

+

Labeled element expressions are represented as an object with a member $LabeledElement whose value is an annotation expression, and a member $Name whose value is a string containing the labeled element's name.

+

It MAY contain annotations.

+
+
+

Example 82:

+
"@UI.DisplayName": {
+  "$LabeledElement": {
+    "$Path": "FirstName"
+  },
+  "$Name": "CustomerFirstName"
+}
+
+

14.4.10 Labeled Element Reference

+

The labeled element reference expression MUST specify the qualified name of a labeled element expression in scope and returns the value of the identified labeled element expression as its value.

+
+

$LabeledElementReference

+

Labeled element reference expressions are represented as an object with a member $LabeledElementReference whose value is a string containing an qualified name.

+
+
+

Example 83:

+
"@UI.DisplayName": {
+  "$LabeledElementReference": "self.CustomerFirstName"
+}
+
+

14.4.11 Null

+

The null expression indicates the absence of a value. The null expression MAY be annotated.

+
+

Null expressions that do not contain annotations are represented as the literal null.

+
+
+

Example 84:

+
"@UI.DisplayName": null,
+
+
+

$Null

+

Null expression containing annotations are represented as an object with a member $Null whose value is the literal null.

+
+
+

Example 85:

+
"@UI.Address": {
+  "$Null": null,
+  "@self.Reason": "Private"
+}
+
+

14.4.12 Record

+

The record expression enables a new entity type or complex type instance to be constructed.

+

A record expression MAY specify the structured type of its result, which MUST be an entity type or complex type in scope. If not explicitly specified, the type is derived from the expression's context.

+

A record expression contains zero or more property value expressions. For each single-valued structural or navigation property of the record expression's type that is neither nullable nor specifies a default value a property value expression MUST be provided. The only exception is if the record expression is the value of an annotation for a term that has a base term whose type is structured and directly or indirectly inherits from the type of its base term. In this case, property values that already have been specified in the annotation for the base term or its base term etc. need not be specified again.

+

For collection-valued properties the absence of a property value expression is equivalent to specifying an empty collection as its value.

+
+

Record expressions are represented as objects with one member per property value expression. The member name is the property name, and the member value is the property value expression.

+

The type of a record expression is represented as the @type control information, see OData-JSON.

+

It MAY contain annotations for itself and its members. Annotations for record members are prefixed with the member name.

+
+
+

Example 86: this annotation "morphs" the entity type from example 8 into a structured type with two structural properties GivenName and Surname and two navigation properties DirectSupervisor and CostCenter. The first three properties simply rename properties of the annotated entity type, the fourth adds a calculated navigation property that is pointing to a different service

+
"@person.Employee": {
+  "@type": "https://example.org/vocabs/person#org.example.person.Manager",
+  "@Core.Description": "Annotation on record",
+  "GivenName": {
+    "$Path": "FirstName"
+  },
+  "GivenName@Core.Description": "Annotation on record member",
+  "Surname": {
+    "$Path": "LastName"
+  },
+  "DirectSupervisor": {
+    "$Path": "Manager"
+  },
+  "CostCenter": {
+    "$UrlRef": {
+      "$Apply": [
+        "http://host/anotherservice/CostCenters('{ccid}')",
+        {
+          "$LabeledElement": {
+            "$Path": "CostCenterID"
+          },
+          "$Name": "ccid"
+        }
+      ],
+      "$Function": "odata.fillUriTemplate"
+    }
+  }
+}
+
+

14.4.13 URL Reference

+

The URL reference expression enables a value to be obtained by sending a GET request.

+

The URL reference expression MUST contain exactly one expression of type Edm.String. Its value is treated as a URL that MAY be relative or absolute; relative URLs are relative to the URL of the document containing the URL reference expression, or relative to a base URL specified in a format-specific way.

+

The response body of the GET request MUST be returned as the result of the URL reference expression. The result of the URL reference expression MUST be type compatible with the type expected by the surrounding expression.

+
+

$UrlRef

+

URL reference expressions are represented as an object with a single member $UrlRef whose value is an annotation expression.

+

It MAY contain annotations.

+
+
+

Example 87:

+
"@org.example.person.Supplier": {
+  "$UrlRef": {
+    "$Apply": [
+      "http://host/service/Suppliers({suppID})",
+      {
+        "$LabeledElement": {
+          "$Apply": [
+            {
+              "$Path": "SupplierId"
+            }
+          ],
+          "$Function": "odata.uriEncode"
+        },
+        "$Name": "suppID"
+      }
+    ],
+    "$Function": "odata.fillUriTemplate"
+  }
+},
+ 
+"@Core.LongDescription#element": {
+  "$UrlRef": "http://host/wiki/HowToUse"
+}
+
+
+

15 Identifier and Path Values

+

15.1 Namespace

+

A namespace is a dot-separated sequence of simple identifiers with a maximum length of 511 Unicode characters (code points).

+

15.2 Simple Identifier

+

A simple identifier is a Unicode character sequence with the following restrictions:

+ +

Non-normatively speaking it starts with a letter or underscore, followed by at most 127 letters, underscores or digits.

+

15.3 Qualified Name

+

For model elements that are direct children of a schema: the namespace or alias of the schema that defines the model element, followed by a dot and the name of the model element, see rule qualifiedTypeName in OData‑ABNF.

+

For built-in primitive types: the name of the type, prefixed with Edm followed by a dot.

+

15.4 Target Path

+

Target paths are used to refer to other model elements.

+

The allowed path expressions are:

+ +
+

Example 88: Target expressions

+
MySchema.MyEntityContainer/MyEntitySet
+MySchema.MyEntityContainer/MySingleton
+MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty
+MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty
+MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp
+
+
+

16 CSDL Examples

+

Following are two basic examples of valid EDM models as represented in CSDL JSON. These examples demonstrate many of the topics covered above.

+

16.1 Products and Categories Example

+
+

Example 89:

+
{
+  "$Version": "4.0",
+  "$EntityContainer": "ODataDemo.DemoService",
+  "$Reference": {
+    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": {
+      "$Include": [
+        {
+          "$Namespace": "Org.OData.Core.V1",
+          "$Alias": "Core",
+          "@Core.DefaultNamespace": true
+        }
+      ]
+    },
+    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.json": {
+      "$Include": [
+        {
+          "$Namespace": "Org.OData.Measures.V1",
+          "$Alias": "Measures"
+        }
+      ]
+    }
+  },
+  "ODataDemo": {
+    "$Alias": "self",
+    "@Core.DefaultNamespace": true,
+    "Product": {
+      "$Kind": "EntityType",
+      "$HasStream": true,
+      "$Key": [
+        "ID"
+      ],
+      "ID": {},
+      "Description": {
+        "$Nullable": true,
+        "@Core.IsLanguageDependent": true
+      },
+      "ReleaseDate": {
+        "$Nullable": true,
+        "$Type": "Edm.Date"
+      },
+      "DiscontinuedDate": {
+        "$Nullable": true,
+        "$Type": "Edm.Date"
+      },
+      "Rating": {
+        "$Nullable": true,
+        "$Type": "Edm.Int32"
+      },
+      "Price": {
+        "$Nullable": true,
+        "$Type": "Edm.Decimal",
+        "@Measures.ISOCurrency": {
+          "$Path": "Currency"
+        }
+      },
+      "Currency": {
+        "$Nullable": true,
+        "$MaxLength": 3
+      },
+      "Category": {
+        "$Kind": "NavigationProperty",
+        "$Type": "self.Category",
+        "$Partner": "Products"
+      },
+      "Supplier": {
+        "$Kind": "NavigationProperty",
+        "$Nullable": true,
+        "$Type": "self.Supplier",
+        "$Partner": "Products"
+      }
+    },
+    "Category": {
+      "$Kind": "EntityType",
+      "$Key": [
+        "ID"
+      ],
+      "ID": {
+        "$Type": "Edm.Int32"
+      },
+      "Name": {
+        "@Core.IsLanguageDependent": true
+      },
+      "Products": {
+        "$Kind": "NavigationProperty",
+        "$Partner": "Category",
+        "$Collection": true,
+        "$Type": "self.Product",
+        "$OnDelete": "Cascade"
+      }
+    },
+    "Supplier": {
+      "$Kind": "EntityType",
+      "$Key": [
+        "ID"
+      ],
+      "ID": {},
+      "Name": {
+        "$Nullable": true
+      },
+      "Address": {
+        "$Type": "self.Address"
+      },
+      "Concurrency": {
+        "$Type": "Edm.Int32"
+      },
+      "Products": {
+        "$Kind": "NavigationProperty",
+        "$Partner": "Supplier",
+        "$Collection": true,
+        "$Type": "self.Product"
+      }
+    },
+    "Country": {
+      "$Kind": "EntityType",
+      "$Key": [
+        "Code"
+      ],
+      "Code": {
+        "$MaxLength": 2
+      },
+      "Name": {
+        "$Nullable": true
+      }
+    },
+    "Address": {
+      "$Kind": "ComplexType",
+      "Street": {
+        "$Nullable": true
+      },
+      "City": {
+        "$Nullable": true
+      },
+      "State": {
+        "$Nullable": true
+      },
+      "ZipCode": {
+        "$Nullable": true
+      },
+      "CountryName": {
+        "$Nullable": true
+      },
+      "Country": {
+        "$Kind": "NavigationProperty",
+        "$Nullable": true,
+        "$Type": "self.Country",
+        "$ReferentialConstraint": {
+          "CountryName": "Name"
+        }
+      }
+    },
+    "ProductsByRating": [
+      {
+        "$Kind": "Function",
+        "$Parameter": [
+          {
+            "$Name": "Rating",
+            "$Nullable": true,
+            "$Type": "Edm.Int32"
+          }
+        ],
+        "$ReturnType": {
+          "$Collection": true,
+          "$Type": "self.Product"
+        }
+      }
+    ],
+    "DemoService": {
+      "$Kind": "EntityContainer",
+      "Products": {
+        "$Collection": true,
+        "$Type": "self.Product",
+        "$NavigationPropertyBinding": {
+          "Category": "Categories"
+        }
+      },
+      "Categories": {
+        "$Collection": true,
+        "$Type": "self.Category",
+        "$NavigationPropertyBinding": {
+          "Products": "Products"
+        },
+        "@Core.Description": "Product Categories"
+      },
+      "Suppliers": {
+        "$Collection": true,
+        "$Type": "self.Supplier",
+        "$NavigationPropertyBinding": {
+          "Products": "Products",
+          "Address/Country": "Countries"
+        },
+        "@Core.OptimisticConcurrency": [
+          "Concurrency"
+        ]
+      },
+      "Countries": {
+        "$Collection": true,
+        "$Type": "self.Country"
+      },
+      "MainSupplier": {
+        "$Type": "self.Supplier",
+        "$NavigationPropertyBinding": {
+          "Products": "Products"
+        },
+        "@Core.Description": "Primary Supplier"
+      },
+      "ProductsByRating": {
+        "$EntitySet": "Products",
+        "$Function": "self.ProductsByRating"
+      }
+    }
+  }
+}
+
+

16.2 Annotations for Products and Categories Example

+
+

Example 90:

+
{
+  "$Version": "4.01",
+  "$Reference": {
+    "http://host/service/$metadata": {
+      "$Include": [
+        {
+          "$Namespace": "ODataDemo",
+          "$Alias": "target"
+        }
+      ]
+    },
+    "http://somewhere/Vocabulary/V1": {
+      "$Include": [
+        {
+          "$Namespace": "Some.Vocabulary.V1",
+          "$Alias": "Vocabulary1"
+        }
+      ]
+    }
+  },
+  "External.Annotations": {
+    "$Annotations": {
+      "target.Supplier": {
+        "@Vocabulary1.EMail": null,
+        "@Vocabulary1.AccountID": {
+          "$Path": "ID"
+        },
+        "@Vocabulary1.Title": "Supplier Info",
+        "@Vocabulary1.DisplayName": {
+          "$Apply": [
+            {
+              "$Path": "Name"
+            },
+            " in ",
+            {
+              "$Path": "Address/CountryName"
+            }
+          ],
+          "$Function": "odata.concat"
+        }
+      },
+      "target.Product": {
+        "@Vocabulary1.Tags": [
+          "MasterData"
+        ]
+      }
+    }
+  }
+} ```
+
+
+

17 Conformance

+

Conforming services MUST follow all rules of this specification document for the types, sets, functions, actions, containers and annotations they expose.

+

In addition, conforming services MUST NOT return 4.01 CSDL constructs for requests made with OData-MaxVersion:4.0.

+

Specifically, they

+
    +
  1. MUST NOT include properties in derived types that overwrite a property defined in the base type

  2. +
  3. MUST NOT include Edm.Untyped

  4. +
  5. MUST NOT use path syntax added with 4.01

  6. +
  7. MUST NOT use Edm.ModelElementPath and Edm.AnyPropertyPath

  8. +
  9. MUST NOT specify referential constraints to complex types and navigation properties

  10. +
  11. MUST NOT include a non-abstract entity type with no inherited or defined entity key

  12. +
  13. MUST NOT include the Core.DefaultNamespace annotation on included schemas

  14. +
  15. MUST NOT return the Unicode facet for terms, parameters, and return types

  16. +
  17. MUST NOT include collections of Edm.ComplexType or Edm.Untyped

  18. +
  19. MUST NOT specify a key as a property of a related entity

  20. +
  21. SHOULD NOT include new/unknown values for $AppliesTo

  22. +
  23. MAY include new CSDL annotations

  24. +
+

In addition, OData 4.01 services:

+
    +
  1. SHOULD NOT have identifiers within a uniqueness scope (e.g. a schema, a structural type, or an entity container) that differ only by case
  2. +
+

Conforming clients MUST be prepared to consume a model that uses any or all constructs defined in this specification, including custom annotations, and MUST ignore constructs not defined in this version of the specification.

+
+

Appendix A. References

+ + +

This appendix contains the normative and informative references that are used in this document.

+

While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity.

+

A.1 Normative References

+

The following documents are referenced in such a way that some or all of their content constitutes requirements of this document.

+
[OData-v4.02]
+ +
[ECMAScript]
+

ECMAScript 2016 Language Specification, 7th Edition. June 2016. Standard ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm.

+
[EPSG]
+

European Petroleum Survey Group (EPSG). http://www.epsg.org/.

+
[OData-ABNF]
+

OData ABNF Construction Rules Version 4.01.
+See link in "Additional artifacts" section on cover page.

+
[OData-CSDL-Schema]
+

OData CSDL JSON Schema.
+See link in "Related work" section on cover page.

+
[OData-CSDL-JSON]
+

OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01.
+See link in "Related work" section on cover page.

+
[OData-CSDL-XML]
+

OData Common Schema Definition Language (CSDL) XML Representation Version 4.01.
+See link in "Related work" section on cover page.

+
[OData-EDM]
+

OData EDM XML Schema.
+See link in "Additional artifacts" section on cover page.

+
[OData-EDMX]
+

OData EDM XML Schema.
+See link in "Additional artifacts" section on cover page.

+
[OData-JSON]
+

OData JSON Format Version 4.01.
+See link in "Related work" section on cover page.

+
[OData-Protocol]
+

OData Version 4.01 Part 1: Protocol.
+See link in "Related work" section on cover page.

+
[OData-URL]
+

OData Version 4.01 Part 2: URL Conventions.
+See link in "Related work" section on cover page.

+
[OData-VocCore]
+

OData Vocabularies Version 4.0: Core Vocabulary.
+See link in "Related work" section on cover page.

+
[OData-VocMeasures]
+

OData Vocabularies Version 4.0: Measures Vocabulary.
+See link in "Related work" section on cover page.

+
[OData-VocValidation]
+

OData Vocabularies Version 4.0: Validation Vocabulary.
+See link in "Related work" section on cover page.

+
[RFC2119]
+

Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
+https://www.rfc-editor.org/info/rfc2119.

+
[RFC6570]
+

Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template”, RFC 6570, March 2012.
+http://tools.ietf.org/html/rfc6570.

+
[RFC7493]
+

Bray, T., Ed., "The I-JSON Message Format", RFC7493, March 2015.
+https://tools.ietf.org/html/rfc7493.

+
[RFC8174]
+

Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017.
+http://www.rfc-editor.org/info/rfc8174.

+
[RFC8259]
+

Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, December 2017.
+http://tools.ietf.org/html/rfc8259.

+
[XML-1.1]
+

Extensible Markup Language (XML) 1.1 (Second Edition). F. Yergeau, E. Maler, J. Cowan, T. Bray, C. M. Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August 2006.
+http://www.w3.org/TR/2006/REC-xml11-20060816. Latest version available at http://www.w3.org/TR/xml11/.

+
[XML-Base]
+

XML Base (Second Edition). J. Marsh, R. Tobin, Editors, W3C Recommendation, 28 January 2009.
+http://www.w3.org/TR/2009/REC-xmlbase-20090128/. Latest version available at http://www.w3.org/TR/xmlbase/.

+
[XML-Schema-1]
+

W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures. D. Beech, M. Maloney, C. M. Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, Editors, W3C Recommendation, 5 April 2012.
+http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-1/.

+
[XML-Schema-2]
+

W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes. D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April 2012.
+http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-2/.

+

A.2 Informative References

+
[OpenUI5]
+

OpenUI5 Version 1.40.10 - OData V4 Metadata JSON Format.
+https://openui5.hana.ondemand.com/1.40.10/#docs/guide/87aac894a40640f89920d7b2a414499b.html.

+
+

Appendix B. Table of JSON Objects and Members

+
+ +
+
+

Appendix C. Acknowledgments

+

C.1 Special Thanks

+

The work of the OpenUI5 team on the OData V4 Metadata JSON Format, see OpenUI5, is gratefully acknowledged, especially the contributions of

+ +

The contributions of the OASIS OData Technical Committee members, enumerated in ODataProtocol, are gratefully acknowledged.

+

C.2 Participants

+ + +

The following individuals have participated in the creation of this specification and are gratefully acknowledged:

+

OpenC2 TC Members:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First NameLast NameCompany
PhilippeAlmanSomething Networks
AlexAmirnovmanCompany B
KrisAndermanMini Micro
DarrenAnstmanBig Networks
+
+

Appendix D. Revision History

+ + + + + + + + + + + + + + + + + + + +
RevisionDateEditorChanges Made
Committee Specification Draft 012023-07-14Michael Pizzo
Ralf Handl
Heiko Theißen
+ + +

Appendix E. Notices

+ + +

Copyright © OASIS Open 2023. All Rights Reserved.-------------- Michael Pizzo All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
+Ralf Handl
+This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English.

+

The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.

+

This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.-------------- Michael Pizzo As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata).
+Ralf Handl
+[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.]-------------- Michael Pizzo [OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.]
+Ralf Handl
+[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.]

+

The name "OASIS" is a trademark of OASIS, the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance.

+
+

Michael Pizzo
+Ralf Handl

+
+

Michael Pizzo
+Ralf Handl

+

Michael Pizzo
+Ralf Handl

diff --git a/docs/odata-csdl-json/odata-csdl-json.md b/docs/odata-csdl-json/odata-csdl-json.md index fd96cb301..77cc71f29 100644 --- a/docs/odata-csdl-json/odata-csdl-json.md +++ b/docs/odata-csdl-json/odata-csdl-json.md @@ -9,7 +9,7 @@ ## 14 July 2023 -  +$\hbox{}$ #### This stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-json-v4.02-csd01.md (Authoritative) \ @@ -38,20 +38,22 @@ Ralf Handl (ralf.handl@sap.com), [SAP SE](http://www.sap.com/) \ Michael Pizzo (mikep@microsoft.com), [Microsoft](http://www.microsoft.com/) \ Heiko Theißen (heiko.theissen@sap.com), [SAP SE](http://www.sap.com/) -#### Additional artifacts: +#### Additional artifacts: This prose specification is one component of a Work Product that also includes: -* XML schemas: (list file names or directory name) -* Other parts (list titles and/or file names) -* `(Note: Any normative computer language definitions that are part of the Work Product, such as XML instances, schemas and Java(TM) code, including fragments of such, must be (a) well formed and valid, (b) provided in separate plain text files, (c) referenced from the Work Product; and (d) where any definition in these separate files disagrees with the definition found in the specification, the definition in the separate file prevails. Remove this note before submitting for publication.)` +* XML schemas: _OData EDMX XML Schema and OData EDM XML Schema_. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/schemas/ -#### Related work: +#### Related work: This specification replaces or supersedes: * _OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. OASIS Standard. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html. This specification is related to: * _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + * _OData Version 4.02 Part 1: Protocol_. Latest stage: https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html + * _OData Version 4.02 Part 2: URL Conventions_. Latest stage: https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + * _ABNF components: OData ABNF Construction Rules Version 4.01 and OData ABNF Test Cases_. https://docs.oasis-open.org/odata/odata/v4.01/os/abnf/ +* _OData Vocabularies Version 4.0_. Edited by Michael Pizzo, Ralf Handl, and Ram Jeyaraman. Latest stage: https://docs.oasis-open.org/odata/odata-vocabularies/v4.0/odata-vocabularies-v4.0.html +* _OData Common Schema Definition Language (CSDL) XML Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html +* _OData JSON Format Version 4.01_. Edited by Ralf Handl, Mike Pizzo, and Mark Biamonte. Latest stage: https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html #### Abstract: OData services are described by an Entity Model (EDM). The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service, using XML, JSON, and other formats. This document (OData CSDL JSON Representation) specifically defines the JSON representation of CSDL. @@ -66,7 +68,7 @@ This specification is provided under the [RF on RAND Terms Mode](https://www.oas Note that any machine-readable content ([Computer Language Definitions](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsCompLang)) declared Normative for this Work Product is provided in separate plain text files. In the event of a discrepancy between any such plain text file and display content in the Work Product's prose narrative document(s), the content in the separate plain text file prevails. #### Key words: -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [[RFC2119](#rfc2119)] and [[RFC8174](#rfc8174)] when, and only when, they appear in all capitals, as shown here. +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119](#rfc2119) and [RFC8174](#rfc8174) when, and only when, they appear in all capitals, as shown here. #### Citation format: When referencing this specification the following citation format should be used: @@ -93,38 +95,177 @@ For complete copyright information please see the full Notices section in an App ::: toc - [1 Introduction](#Introduction) - - [1.1 Changes from earlier Versions](#ChangesfromearlierVersions) + - [1.1 Changes from Earlier Versions](#ChangesfromEarlierVersions) - [1.2 Glossary](#Glossary) - [1.2.1 Definitions of terms](#Definitionsofterms) - [1.2.2 Acronyms and abbreviations](#Acronymsandabbreviations) - [1.2.3 Document conventions](#Documentconventions) +- [2 JSON Representation](#JSONRepresentation) + - [2.1 Requesting the JSON Representation](#RequestingtheJSONRepresentation) + - [2.1.1 Controlling the Representation of Numbers](#ControllingtheRepresentationofNumbers) + - [2.1.2 Controlling the Amount of Control Information](#ControllingtheAmountofControlInformation) + - [2.1.2.1 `metadata=minimal`](#metadataminimal) + - [2.1.2.2 `metadata=full`](#metadatafull) + - [2.1.2.3 `metadata=none`](#metadatanone) + - [2.2 Design Considerations](#DesignConsiderations) + - [2.3 JSON Schema Definition](#JSONSchemaDefinition) +- [3 Entity Model](#EntityModel) + - [3.1 Nominal Types](#NominalTypes) + - [3.2 Structured Types](#StructuredTypes) + - [3.3 Primitive Types](#PrimitiveTypes) + - [3.4 Built-In Abstract Types](#BuiltInAbstractTypes) + - [3.5 Built-In Types for defining Vocabulary Terms](#BuiltInTypesfordefiningVocabularyTerms) + - [3.6 Annotations](#Annotations) +- [4 CSDL JSON Document](#CSDLJSONDocument) + - [4.1 Reference](#Reference) + - [4.2 Included Schema](#IncludedSchema) + - [4.3 Included Annotations](#IncludedAnnotations) +- [5 Schema](#Schema) + - [5.1 Alias](#Alias) + - [5.2 Annotations with External Targeting](#AnnotationswithExternalTargeting) +- [6 Entity Type](#EntityType) + - [6.1 Derived Entity Type](#DerivedEntityType) + - [6.2 Abstract Entity Type](#AbstractEntityType) + - [6.3 Open Entity Type](#OpenEntityType) + - [6.4 Media Entity Type](#MediaEntityType) + - [6.5 Key](#Key) +- [7 Structural Property](#StructuralProperty) + - [7.1 Type](#Type) + - [7.2 Type Facets](#TypeFacets) + - [7.2.1 Nullable](#Nullable) + - [7.2.2 MaxLength](#MaxLength) + - [7.2.3 Precision](#Precision) + - [7.2.4 Scale](#Scale) + - [7.2.5 Unicode](#Unicode) + - [7.2.6 SRID](#SRID) + - [7.2.7 Default Value](#DefaultValue) +- [8 Navigation Property](#NavigationProperty) + - [8.1 Navigation Property Type](#NavigationPropertyType) + - [8.2 Nullable Navigation Property](#NullableNavigationProperty) + - [8.3 Partner Navigation Property](#PartnerNavigationProperty) + - [8.4 Containment Navigation Property](#ContainmentNavigationProperty) + - [8.5 Referential Constraint](#ReferentialConstraint) + - [8.6 On-Delete Action](#OnDeleteAction) +- [9 Complex Type](#ComplexType) + - [9.1 Derived Complex Type](#DerivedComplexType) + - [9.2 Abstract Complex Type](#AbstractComplexType) + - [9.3 Open Complex Type](#OpenComplexType) +- [10 Enumeration Type](#EnumerationType) + - [10.1 Underlying Integer Type](#UnderlyingIntegerType) + - [10.2 Flags Enumeration Type](#FlagsEnumerationType) + - [10.3 Enumeration Type Member](#EnumerationTypeMember) +- [11 Type Definition](#TypeDefinition) + - [11.1 Underlying Primitive Type](#UnderlyingPrimitiveType) +- [12 Action and Function](#ActionandFunction) + - [12.1 Action](#Action) + - [12.2 Action Overloads](#ActionOverloads) + - [12.3 Function](#Function) + - [12.4 Function Overloads](#FunctionOverloads) + - [12.5 Bound or Unbound Action or Function Overloads](#BoundorUnboundActionorFunctionOverloads) + - [12.6 Entity Set Path](#EntitySetPath) + - [12.7 Composable Function](#ComposableFunction) + - [12.8 Return Type](#ReturnType) + - [12.9 Parameter](#Parameter) +- [13 Entity Container](#EntityContainer) + - [13.1 Extending an Entity Container](#ExtendinganEntityContainer) + - [13.2 Entity Set](#EntitySet) + - [13.3 Singleton](#Singleton) + - [13.4 Navigation Property Binding](#NavigationPropertyBinding) + - [13.4.1 Navigation Property Path Binding](#NavigationPropertyPathBinding) + - [13.4.2 Binding Target](#BindingTarget) + - [13.5 Action Import](#ActionImport) + - [13.6 Function Import](#FunctionImport) +- [14 Vocabulary and Annotation](#VocabularyandAnnotation) + - [14.1 Term](#Term) + - [14.1.1 Specialized Term](#SpecializedTerm) + - [14.1.2 Applicability](#Applicability) + - [14.2 Annotation](#Annotation) + - [14.2.1 Qualifier](#Qualifier) + - [14.2.2 Target](#Target) + - [14.3 Constant Expression](#ConstantExpression) + - [14.3.1 Binary](#Binary) + - [14.3.2 Boolean](#Boolean) + - [14.3.3 Date](#Date) + - [14.3.4 DateTimeOffset](#DateTimeOffset) + - [14.3.5 Decimal](#Decimal) + - [14.3.6 Duration](#Duration) + - [14.3.7 Enumeration Member](#EnumerationMember) + - [14.3.8 Floating-Point Number](#FloatingPointNumber) + - [14.3.9 Guid](#Guid) + - [14.3.10 Integer](#Integer) + - [14.3.11 String](#String) + - [14.3.12 Time of Day](#TimeofDay) + - [14.4 Dynamic Expression](#DynamicExpression) + - [14.4.1 Path Expressions](#PathExpressions) + - [14.4.1.1 Path Syntax](#PathSyntax) + - [14.4.1.2 Path Evaluation](#PathEvaluation) + - [14.4.1.3 Annotation Path](#AnnotationPath) + - [14.4.1.4 Model Element Path](#ModelElementPath) + - [14.4.1.5 Navigation Property Path](#NavigationPropertyPath) + - [14.4.1.6 Property Path](#PropertyPath) + - [14.4.1.7 Value Path](#ValuePath) + - [14.4.2 Comparison and Logical Operators](#ComparisonandLogicalOperators) + - [14.4.3 Arithmetic Operators](#ArithmeticOperators) + - [14.4.4 Apply Client-Side Functions](#ApplyClientSideFunctions) + - [14.4.4.1 Canonical Functions](#CanonicalFunctions) + - [14.4.4.2 Function `odata.fillUriTemplate`](#FunctionodatafillUriTemplate) + - [14.4.4.3 Function `odata.matchesPattern`](#FunctionodatamatchesPattern) + - [14.4.4.4 Function `odata.uriEncode`](#FunctionodatauriEncode) + - [14.4.5 Cast](#Cast) + - [14.4.6 Collection](#Collection) + - [14.4.7 If-Then-Else](#IfThenElse) + - [14.4.8 Is-Of](#IsOf) + - [14.4.9 Labeled Element](#LabeledElement) + - [14.4.10 Labeled Element Reference](#LabeledElementReference) + - [14.4.11 Null](#Null) + - [14.4.12 Record](#Record) + - [14.4.13 URL Reference](#URLReference) +- [15 Identifier and Path Values](#IdentifierandPathValues) + - [15.1 Namespace](#Namespace) + - [15.2 Simple Identifier](#SimpleIdentifier) + - [15.3 Qualified Name](#QualifiedName) + - [15.4 Target Path](#TargetPath) +- [16 CSDL Examples](#CSDLExamples) + - [16.1 Products and Categories Example](#ProductsandCategoriesExample) + - [16.2 Annotations for Products and Categories Example](#AnnotationsforProductsandCategoriesExample) +- [17 Conformance](#Conformance) +- [A References](#References) + - [A.1 Normative References](#NormativeReferences) + - [A.2 Informative References](#InformativeReferences) +- [B Table of JSON Objects and Members](#TableofJSONObjectsandMembers) +- [C Acknowledgments](#Acknowledgments) + - [C.1 Special Thanks](#SpecialThanks) + - [C.2 Participants](#Participants) +- [D Revision History](#RevisionHistory) +- [E Notices ](#Notices) ::: ------- # 1 Introduction - +OData services are described in terms of an [Entity +Model](#EntityModel). The Common Schema Definition Language (CSDL) +defines a representation of the entity model exposed by an OData service +using the JavaScript Object Notation (JSON), see [RFC8259](#rfc8259). -## 1.1 Changes from earlier Versions +This format is based on the OpenUI5 OData V4 Metadata JSON Format, see +[OpenUI5](#_OpenUI5), with some extensions and +modifications made necessary to fully cover OData CSDL Version 4.01. - - +## 1.1 Changes from Earlier Versions ## 1.2 Glossary ### 1.2.1 Definitions of terms - -TODO: find out why we need a $dummy$ formula to get `monospace` look as we want it. - ### 1.2.2 Acronyms and abbreviations ### 1.2.3 Document conventions -Keywords defined by this specification use `this monospaced font`. +Keywords defined by this specification use `this monospaced font`. Some sections of this specification are illustrated with non-normative examples. @@ -137,6 +278,14 @@ Non-normative examples use this paragraph style. All examples in this document are non-normative and informative only. Examples labeled with ⚠ contain advanced concepts or make use of keywords that are defined only later in the text, they can be skipped at first reading. +Representation-specific text is indented and marked with vertical lines. + +::: rep +### Representation-Specific Headline + +Normative representation-specific text +::: + All other text is normative unless otherwise labeled. ::: example @@ -159,169 +308,5852 @@ pandoc -f gfm+tex_math_dollars+fenced_divs This uses pandoc 3.1.2 from https://github.com/jgm/pandoc/releases/tag/3.1.2. ::: -------- + +# 2 JSON Representation -# 2 Section Heading -text. +OData CSDL JSON is a full representation of the OData Common Schema +Definition Language in the JavaScript Object Notation (JSON) defined in +[RFC8259](#rfc8259). It additionally follows the rules +for "Internet JSON" (I-JSON) defined in +[RFC7493](#rfc7493) for e.g. objects, numbers, date +values, and duration values. -## 2.1 Level 2 Heading -text. +It is an alternative to the CSDL XML representation defined in +[OData-CSDLXML](#ODataCSDL) and neither adds nor removes +features. -### 2.1.1 Level 3 Heading -text. +## 2.1 Requesting the JSON Representation -#### 2.1.1.1 Level 4 Heading -text. +The OData CSDL JSON representation can be requested using the `$format` +query option in the request URL with the media type `application/json`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `json` which MUST NOT be followed by media type parameters. -##### 2.1.1.1.1 Level 5 Heading -This is the deepest level, because six # gets transformed into a Reference tag. +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/json`, optionally followed by +media type parameters. +If specified, `$format` overrides any value specified in the `Accept` +header. -## 2.2 Next Heading -text. +The response MUST contain the `Content-Type` header with a value of +`application/json`, optionally followed by media type parameters. -------- +Possible media type parameters are: +- [`IEEE754Compatible`](#ControllingtheRepresentationofNumbers) +- [`metadata`](#ControllingtheAmountofControlInformation) -# 3 Conformance - +The names and values of these parameters are case-insensitive. -`(Note: The [OASIS TC Process](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsConfClause) requires that a specification approved by the TC at the Committee Specification Public Review Draft, Committee Specification or OASIS Standard level must include a separate section, listing a set of numbered conformance clauses, to which any implementation of the specification must adhere in order to claim conformance to the specification (or any optional portion thereof). This is done by listing the conformance clauses here.` -`For the definition of "conformance clause," see [OASIS Defined Terms](https://www.oasis-open.org/policies-guidelines/oasis-defined-terms-2018-05-22/#dConformanceClause).` +### 2.1.1 Controlling the Representation of Numbers -`See "Guidelines to Writing Conformance Clauses": -https://docs.oasis-open.org/templates/TCHandbook/ConformanceGuidelines.html.` +The `IEEE754Compatible=true` parameter indicates that the service MUST +serialize `Edm.Int64` and `Edm.Decimal` numbers as strings. This is in +conformance with [RFC7493](#rfc7493). If not specified, or specified as +`IEEE754Compatible=false`, all numbers MUST be serialized as JSON +numbers. -`Remove this note before submitting for publication.)` +This enables support for JavaScript numbers that are defined to be +64-bit binary format IEEE 754 values [ECMAScript](#_ECMAScript) +(see [section +4.3.1.9](http://www.ecma-international.org/ecma-262/5.1/#sec-4.3.19)) +resulting in integers losing precision past 15 digits, and decimals +losing precision due to the conversion from base 10 to base 2. +Responses that format `Edm.Int64` and `Edm.Decimal` values as strings +MUST specify this parameter in the media type returned in the +`Content-Type` header. -------- +### 2.1.2 Controlling the Amount of Control Information -# Appendix A. References +The representation of constant annotation values in CSDL JSON documents +closely follows the representation of data defined in +[OData-JSON](#ODataJSON). - +A client application can use the `metadata` format parameter in the +`Accept` header when requesting a CSDL JSON document to influence how +much control information will be included in the response. -This appendix contains the normative and informative references that are used in this document. +Other `Accept` header parameters are orthogonal to the `metadata` +parameter and are therefore not mentioned in this section. -While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity. +#### 2.1.2.1 `metadata=minimal` -## A.1 Normative References +The `metadata=minimal` format parameter indicates that the service +SHOULD remove computable control information from the payload wherever +possible. -The following documents are referenced in such a way that some or all of their content constitutes requirements of this document. +This means that the `@type` control information is only included if the +type of the containing object or targeted property cannot be +heuristically determined, e.g. for +- Terms or term properties with an abstract declared type, +- Terms or term properties with a declared type that has derived +types, or +- Dynamic properties of open types. -`(Reference sources: -For references to IETF RFCs, use the approved citation formats at: -https://docs.oasis-open.org/templates/ietf-rfc-list/ietf-rfc-list.html. -For references to W3C Recommendations, use the approved citation formats at: -https://docs.oasis-open.org/templates/w3c-recommendations-list/w3c-recommendations-list.html. -Remove this note before submitting for publication.)` +See [OData-JSON](#ODataJSON) for the exact rules. -###### [OData-v4.02] -* _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html +#### 2.1.2.2 `metadata=full` -##### [RFC2119] -_Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997_ -http://www.rfc-editor.org/info/rfc2119. +The `metadata=full` format parameter indicates that the service MUST +include all control information explicitly in the payload. -###### [RFC8174] -_Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017_ -http://www.rfc-editor.org/info/rfc8174. +This means that the `@type` control information is included in +annotation values except for primitive values whose type can be +heuristically determined from the representation of the value, see +[OData-JSON](#ODataJSON) for the exact rules. -## A.2 Informative References +#### 2.1.2.3 `metadata=none` -###### [RFC3552] -_Rescorla, E. and B. Korver, "Guidelines for Writing RFC Text on Security Considerations", BCP 72, RFC 3552, DOI 10.17487/RFC3552, July 2003_ -https://www.rfc-editor.org/info/rfc3552. +The `metadata=none` format parameter indicates that the service SHOULD +omit all control information. -------- +## 2.2 Design Considerations -# Appendix B. Safety, Security and Privacy Considerations +CSDL JSON documents are designed for easy and efficient lookup of model +constructs by their name without having to know or guess what kind of +model element it is. Thus, all primary model elements (entity types, +complex types, type definitions, enumeration types, terms, actions, +functions, and the entity container) are direct members of their schema, +using the schema-unique name as the member name. Similarly, child +elements of primary model elements (properties, navigation properties, +enumeration type members, entity sets, singletons, action imports, and +function imports) are direct members of the objects describing their +parent model element, using their locally unique name as the member +name. - +To avoid name collisions, all fixed member names are prefixed with a +dollar (`$`) sign and otherwise have the same name and capitalization as +their counterparts in the CSDL XML representation +[OData-CSDLXML](#ODataCSDL) (with one exception: the +counterpart of the `EntitySet` element's `EntityType` member is +[`$Type`](#EntitySet), to harmonize it with all other type references). -`(Note: OASIS strongly recommends that Technical Committees consider issues that might affect safety, security, privacy, and/or data protection in implementations of their specification and document them for implementers and adopters. For some purposes, you may find it required, e.g. if you apply for IANA registration.` +Additional fixed members introduced by this specification and without +counterpart in [OData-CSDLXML](#ODataCSDL) are also +prefixed with a dollar (`$`) sign and use upper-camel-case names. One of +these is `$Kind` which represents the kind of model element. Its value +is the upper-camel-case local name of the XML element representing this +kind of model element in [OData-CSDLXML](#ODataCSDL), +e.g. `EntityType` or `NavigationProperty`. -`While it may not be immediately obvious how your specification might make systems vulnerable to attack, most specifications, because they involve communications between systems, message formats, or system settings, open potential channels for exploit. For example, IETF [[RFC3552](#rfc3552)] lists “eavesdropping, replay, message insertion, deletion, modification, and man-in-the-middle” as well as potential denial of service attacks as threats that must be considered and, if appropriate, addressed in IETF RFCs.` +While the XML representation of CSDL allows referencing model elements +with alias-qualified names as well as with namespace-qualified names, +this JSON representation requires the use of alias-qualified names if an +alias is specified for an included or document-defined schema. Aliases +are usually shorter than namespaces, so this reduces text size of the +JSON document. Text size matters even if the actual HTTP messages are +sent in compressed form because the decompressed form needs to be +reconstructed, and clients not using a streaming JSON parser have to +materialize the full JSON document before parsing. -`In addition to considering and describing foreseeable risks, this section should include guidance on how implementers and adopters can protect against these risks.` +To further reduce size the member `$Kind` is optional for [structural +properties](#StructuralProperty) as these are more common than +[navigation properties](#NavigationProperty), and the member +[`$Type`](#Type) is optional for string properties, parameters, and +return types, as this type is more common than other primitive types. -`We encourage editors and TC members concerned with this subject to read _Guidelines for Writing RFC Text on Security Considerations_, IETF [[RFC3552](#rfc3552)], for more information.` +In general, all members that have a default value SHOULD be omitted if +they have the default value. -`Remove this note before submitting for publication.)` +## 2.3 JSON Schema Definition -------- +The structure of CSDL JSON documents can be verified with the JSON +Schema [OData-CSDL-Schema](#ODataCSDL) provided as an +additional artifact of this prose specification. This schema only +defines the shape of a well-formed CSDL JSON document but is not +descriptive enough to define what a correct CSDL JSON document MUST be +in every imaginable use case. This specification document defines +additional rules that correct CSDL JSON documents MUST fulfill. In case +of doubt on what makes a CSDL JSON document correct the rules defined in +this specification document take precedence. -# Appendix C. Acknowledgments + - +# 3 Entity Model -`Note: A Work Product approved by the TC must include a list of people who participated in the development of the Work Product. This is generally done by collecting the list of names in this appendix. This list shall be initially compiled by the Chair, and any Member of the TC may add or remove their names from the list by request. Remove this note before submitting for publication.` +An OData service exposes a single entity model. This model may be +distributed over several [schemas](#Schema), and these schemas may be +distributed over several documents. -## C.1 Special Thanks +A service is defined by a single CSDL document which can be accessed by +sending a `GET` request to `/$metadata`. This document is +called the metadata document. It MAY [reference](#Reference) other CSDL +documents. - +The metadata document contains a single [entity +container](#EntityContainer) that defines the resources exposed by this +service. This entity container MAY [extend](#ExtendinganEntityContainer) +an entity container defined in a [referenced document](#Reference). -Substantial contributions to this document from the following individuals are gratefully acknowledged: +The *model* of the service consists of all CSDL constructs used in its +entity containers. -Participant Name, Affiliation or "Individual Member" +The *scope* of a CSDL document is the document itself and all schemas +[included](#IncludedSchema) from directly [referenced +documents](#Reference). All entity types, complex types and other named +model elements *in scope* (that is, defined in the document itself or a +schema of a directly referenced document) can be accessed from a +referencing document by their qualified names. This includes the +[built-in primitive](#PrimitiveTypes) and [abstract +types](#BuiltInAbstractTypes). -## C.2 Participants +Referencing another document may alter the model defined by the +referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, +then an [entity set](#EntitySet) of the service defined by the +referencing document may return entities of the derived type. This is +identical to the behavior if the derived type had been defined directly +in the referencing document. - +Note: referencing documents is not recursive. Only named model elements +defined in directly referenced documents can be used within the schema. +However, those elements may in turn include or reference model elements +defined in schemas referenced by their defining schema. -The following individuals have participated in the creation of this specification and are gratefully acknowledged: +## 3.1 Nominal Types -**OpenC2 TC Members:** +A nominal type has a name that MUST be a [simple +identifier](#SimpleIdentifier). Nominal types are referenced using their +[qualified name](#QualifiedName). The qualified type name MUST be unique +within a model as it facilitates references to the element from other +parts of the model. -| First Name | Last Name | Company | -| :--- | :--- | :--- | -Philippe | Alman | Something Networks -Alex | Amirnovman | Company B -Kris | Anderman | Mini Micro -Darren | Anstman | Big Networks +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +## 3.2 Structured Types + +Structured types are composed of other model elements. Structured types +are common in entity models as the means of representing entities and +structured properties in an OData service. [Entity types](#EntityType) +and [complex types](#ComplexType) are both structured types. + +Structured Types are composed of zero or more [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty). + +[Open entity types](#OpenEntityType) and [open complex +types](#OpenComplexType) allow properties to be added dynamically to +instances of the open type. + +## 3.3 Primitive Types + +Structured types are composed of other structured types and primitive +types. OData defines the following primitive types: + +Type|Meaning +----|------- +`Edm.Binary` |Binary data +`Edm.Boolean` |Binary-valued logic +`Edm.Byte` |Unsigned 8-bit integer +`Edm.Date` |Date without a time-zone offset +`Edm.DateTimeOffset` |Date and time with a time-zone offset, no leap seconds +`Edm.Decimal` |Numeric values with decimal representation +`Edm.Double` |IEEE 754 binary64 floating-point number (15-17 decimal digits) +`Edm.Duration` |Signed duration in days, hours, minutes, and (sub)seconds +`Edm.Guid` |16-byte (128-bit) unique identifier +`Edm.Int16` |Signed 16-bit integer +`Edm.Int32` |Signed 32-bit integer +`Edm.Int64` |Signed 64-bit integer +`Edm.SByte` |Signed 8-bit integer +`Edm.Single` |IEEE 754 binary32 floating-point number (6-9 decimal digits) +`Edm.Stream` |Binary data stream +`Edm.String` |Sequence of characters +`Edm.TimeOfDay` |Clock time 00:00-23:59:59.999999999999 +`Edm.Geography` |Abstract base type for all Geography types +`Edm.GeographyPoint` |A point in a round-earth coordinate system +`Edm.GeographyLineString` |Line string in a round-earth coordinate system +`Edm.GeographyPolygon` |Polygon in a round-earth coordinate system +`Edm.GeographyMultiPoint` |Collection of points in a round-earth coordinate system +`Edm.GeographyMultiLineString` |Collection of line strings in a round-earth coordinate system +`Edm.GeographyMultiPolygon` |Collection of polygons in a round-earth coordinate system +`Edm.GeographyCollection` |Collection of arbitrary Geography values +`Edm.Geometry` |Abstract base type for all Geometry types +`Edm.GeometryPoint` |Point in a flat-earth coordinate system +`Edm.GeometryLineString` |Line string in a flat-earth coordinate system +`Edm.GeometryPolygon` |Polygon in a flat-earth coordinate system +`Edm.GeometryMultiPoint` |Collection of points in a flat-earth coordinate system +`Edm.GeometryMultiLineString` |Collection of line strings in a flat-earth coordinate system +`Edm.GeometryMultiPolygon` |Collection of polygons in a flat-earth coordinate system +`Edm.GeometryCollection` |Collection of arbitrary Geometry values + +`Edm.Date` and `Edm.DateTimeOffset` follow +[XML-Schema-2](#XML-Schema2) and use the proleptic Gregorian +calendar, allowing the year `0000` (equivalent to 1 BCE) and negative +years (year `-0001` being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying +persistency layer, e.g. SQL only supports years `0001` to `9999`. + +`Edm.Decimal` with a [`Scale`](#Scale) value of `floating`, +`Edm.Double`, and `Edm.Single` allow the special numeric values `-INF`, +`INF`, and `NaN`. + +`Edm.Stream` is a primitive type that can be used as a property of an +[entity type](#EntityType) or [complex type](#ComplexType), the +underlying type for a [type definition](#TypeDefinition), or the binding +parameter or return type of an [action](#Action) or +[function](#Function). `Edm.Stream`, or a type definition whose +underlying type is `Edm.Stream`, cannot be used in collections or for +non-binding parameters to functions or actions. + +Some of these types allow [facets](#TypeFacets), defined in section +"[Type Facets](#TypeFacets)". + +See rule `primitiveLiteral` in [OData-ABNF](#ODataABNF) for the +representation of primitive type values in URLs and +[OData-JSON](#ODataJSON) for the representation in requests and +responses. + +## 3.4 Built-In Abstract Types + +The following built-in abstract types can be used within a model: +- `Edm.PrimitiveType` +- `Edm.ComplexType` +- `Edm.EntityType` +- `Edm.Untyped` + +Conceptually, these are the abstract base types for primitive types +(including type definitions and enumeration types), complex types, +entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except: +- `Edm.EntityType` + - cannot be used as the type of a singleton in an entity container + because it doesn't define a structure, which defeats the purpose + of a singleton. + - cannot be used as the type of an entity set because all entities + in an entity set must have the same key fields to uniquely + identify them within the set. + - cannot be the base type of an entity type or complex type. +- `Edm.ComplexType` + - cannot be the base type of an entity type or complex type. +- `Edm.PrimitiveType` + - cannot be used as the type of a key property of an entity type + or as the underlying type of an enumeration type. + - cannot be used as the underlying type of a type definition in a + CSDL document with a version of `4.0`. + - can be used as the underlying type of a type definition in a + CSDL document with a version of `4.01` or greater. +- `Edm.Untyped` + - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + - cannot be used as the type of a key property of an entity type. + - cannot be the base type of an entity type or complex type. + - cannot be used as the underlying type of a type definition or + enumeration type. +- `Collection(Edm.PrimitiveType)` + - cannot be used as the type of a property or term. + - cannot be used as the type of a parameter or the return type of + an action or function. +- `Collection(Edm.Untyped)` + - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + +## 3.5 Built-In Types for defining Vocabulary Terms + +[Vocabulary terms](#VocabularyandAnnotation) can, in addition, use +- `Edm.AnnotationPath` +- `Edm.PropertyPath` +- `Edm.NavigationPropertyPath` +- `Edm.AnyPropertyPath` (`Edm.PropertyPath` or `Edm.NavigationPropertyPath`) +- `Edm.ModelElementPath` (any model element, including +`Edm.AnnotationPath`, `Edm.NavigationPropertyPath`, and +`Edm.PropertyPath`) + +as the type of a primitive term, or the type of a property of a complex +type (recursively) that is exclusively used as the type of a term. See +section "[Path Expressions](#PathExpressions)" for details. + +## 3.6 Annotations + +Many parts of the model can be decorated with additional information +using [annotations](#Annotation). Annotations are identified by their +term name and an optional qualifier that allows applying the same term +multiple times to the same model element. + +A model element MUST NOT specify more than one annotation for a given +combination of term and qualifier. ------- -# Appendix D. Revision History +# 4 CSDL JSON Document - + +::: {.varjson .rep} +### Document Object -| Revision | Date | Editor | Changes Made | -| :--- | :--- | :--- | :--- | -| specname-v1.0-wd01 | yyyy-mm-dd | Editor Name | Initial working draft | +A CSDL JSON document consists of a single JSON object. This document object MUST contain the member `$Version`. + +The document object MAY contain the member [`$Reference`](#Reference) to reference other CSDL documents. + +It also MAY contain members for schemas. + +If the CSDL JSON document is the metadata document of an OData service, the document object MUST contain the member `$EntityContainer`. + +### `$Version` + +The value of `$Version` is a string containing either `4.0` or `4.01`. + +### `$EntityContainer` + +The value of `$EntityContainer` is value is the namespace-qualified name of the entity container of that service. This is the only place where a model element MUST be referenced with its namespace-qualified name and use of the alias-qualified name is not allowed. +::: + +::: {.varjson .example} +Example 2: +```json +{ + "$Version": "4.01", + "$EntityContainer": "org.example.DemoService", + ... +} +``` +::: + + + + +## 4.1 Reference + +A reference to an external CSDL document allows to bring part of the +referenced document's content into the scope of the referencing +document. + +A reference MUST specify a URI that uniquely identifies the referenced +document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be +absolute or relative URI; relative URLs are relative to the URL of the +document containing the reference, or relative to a base URL specified +in a format-specific way. + +A reference MAY be annotated. + +The +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation, defined in [OData-VocCore](#ODataVocCore), MAY be used to +indicate a particular version of the referenced document. If the +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation is present, the `$schemaversion` system query option, defined +[OData-Protocol](#ODataProtocol), SHOULD be used when retrieving the +referenced schema document. + +::: {.varjson .rep} +### `$Reference` + +The value of `$Reference` is an object that contains one member per +referenced CSDL document. The name of the pair is a URI for the +referenced document. The URI MAY be relative to the document containing +the `$Reference`. The value of each member is a reference object. + +### Reference Object + +The reference object MAY contain the members +[`$Include`](#IncludedSchema) and +[`$IncludeAnnotations`](#IncludedAnnotations) as well as +[annotations](#Annotation). +::: + +::: {.varjson .example} +Example 3: references to other CSDL documents +```json +{ + ... + "$Reference": { + "http://vocabs.odata.org/capabilities/v1": { + ... + }, + "http://vocabs.odata.org/core/v1": { + ... + }, + "http://example.org/display/v1": { + ... + } + }, + ... +} +``` +::: + + + +## 4.2 Included Schema + +A reference MAY include zero or more schemas from the referenced +document. + +The included schemas are identified via their [namespace](#Namespace). +The same namespace MUST NOT be included more than once, even if it is +declared in more than one referenced document. + +When including a schema, a [simple identifier](#SimpleIdentifier) value +MAY be specified as an alias for the schema that is used in qualified +names instead of the namespace. For example, an alias of `display` might +be assigned to the namespace `org.example.vocabularies.display`. An +alias-qualified name is resolved to a fully qualified name by examining +aliases for included schemas and schemas defined within the document. + +::: {.varjson .rep} +If an included schema specifies an alias, the alias MUST be used in +qualified names throughout the document to identify model elements of +the included schema. A mixed use of namespace-qualified names and +alias-qualified names is not allowed. +::: + + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +An alias is only valid within the document in which it is declared; a +referencing document may define its own aliases for included schemas. + +::: {.varjson .rep} +### `$Include` + +The value of `$Include` is an array. Array items are objects that MUST +contain the member `$Namespace` and MAY contain the member `$Alias`. + +The item objects MAY contain [annotations](#Annotation). + +### `$Namespace` + +The value of `$Namespace` is a string containing the namespace of the +included schema. + +### `$Alias` + +The value of `$Alias` is a string containing the alias for the included +schema. +::: + +::: {.varjson .example} +Example 4: references to entity models containing definitions of +vocabulary terms +```json +{ + ... + "$Reference": { + "http://vocabs.odata.org/capabilities/v1": { + "$Include": [ + { + "$Namespace": "Org.OData.Capabilities.V1", + "$Alias": "Capabilities" + } + ] + }, + "http://vocabs.odata.org/core/v1": { + "$Include": [ + { + "$Namespace": "Org.OData.Core.V1", + "$Alias": "Core", + "@Core.DefaultNamespace": true + } + ] + }, + "http://example.org/display/v1": { + "$Include": [ + { + "$Namespace": "org.example.display", + "$Alias": "UI" + } + ] + } + }, + ... +} +``` +::: + + + +## 4.3 Included Annotations + +In addition to including whole schemas with all model constructs defined +within that schema, annotations can be included with more flexibility. + +Annotations are selectively included by specifying the +[namespace](#Namespace) of the annotations' term. Consumers can opt not +to inspect the referenced document if none of the term namespaces is of +interest for the consumer. + +In addition, the [qualifier](#Qualifier) of annotations to be included +MAY be specified. For instance, a service author might want to supply a +different set of annotations for various device form factors. If a +qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of +the target namespace, if present) SHOULD be included. If no qualifier is +specified, all annotations within the referenced document from the +specified term namespace (taking into account the target namespace, if +present) SHOULD be included. + +The qualifier also provides consumers insight about what qualifiers are +present in the referenced document. If the consumer is not interested in +that particular qualifier, the consumer can opt not to inspect the +referenced document. + +In addition, the namespace of the annotations' [target](#Target) MAY be +specified. If a target namespace is specified, only those annotations +which apply a term form the specified term namespace to a model element +of the target namespace (with the specified qualifier, if present) +SHOULD be included. If no target namespace is specified, all annotations +within the referenced document from the specified term namespace (taking +into account the qualifier, if present) SHOULD be included. + +The target namespace also provides consumers insight about what +namespaces are present in the referenced document. If the consumer is +not interested in that particular target namespace, the consumer can opt +not to inspect the referenced document. + +::: {.varjson .rep} +### `$IncludeAnnotations` + +The value of `$IncludeAnnotations` is an array. Array items are objects +that MUST contain the member `$TermNamespace` and MAY contain the +members `$Qualifier` and `$TargetNamespace`. + +### `$TermNamespace` + +The value of `$TermNamespace` is a namespace. + +### `$Qualifier` + +The value of `$Qualifier` is a simple identifier. + +### `$TargetNamespace` + +The value of `$TargetNamespace` is a namespace. +::: + +::: {.varjson .example} +Example 5: reference documents that contain annotations +```json +{ + ... + "$Reference": { + "http://odata.org/ann/b": { + "$IncludeAnnotations": [ + { + "$TermNamespace": "org.example.validation" + }, + { + "$TermNamespace": "org.example.display", + "$Qualifier": "Tablet" + }, + { + "$TermNamespace": "org.example.hcm", + "$TargetNamespace": "com.example.Sales" + }, + { + "$TermNamespace": "org.example.hcm", + "$Qualifier": "Tablet", + "$TargetNamespace": "com.example.Person" + } + ] + } + }, + ... +} +``` +::: + + + +::: example +The following annotations from `http://odata.org/ann/b` are included: +- Annotations that use a +term from the `org.example.validation` namespace, and +- Annotations that use a +term from the `org.example.display` namespace and specify a `Tablet` +qualifier and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Sales` namespace and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Person` namespace and specify a `Tablet` qualifier. +::: ------- -# Appendix E. Example Appendix with subsections +# 5 Schema + +One or more schemas describe the entity model exposed by an OData +service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms. + +A schema is identified by a [namespace](#Namespace). Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally +unique. A schema cannot span more than one document. + +The schema's namespace is combined with the name of elements in the +schema to create unique [qualified names](#QualifiedName), so +identifiers that are used to name types MUST be unique within a +namespace to prevent ambiguity. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +The namespace MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {.varjson .rep} +### Schema Object + +A schema is represented as a member of the document object whose name is +the schema namespace. Its value is an object that MAY contain the +members [`$Alias`](#Alias) and +[`$Annotations`](#AnnotationswithExternalTargeting). + +The schema object MAY contain members representing [entity +types](#EntityType), [complex types](#ComplexType), [enumeration +types](#EnumerationType), [type definitions](#TypeDefinition), +[actions](#Action), [functions](#Function), [terms](#Term), and an +[entity container](#EntityContainer). + +The schema object MAY also contain [annotations](#Annotation) that apply +to the schema itself. +::: + + +## 5.1 Alias + +A schema MAY specify an alias which MUST be a [simple +identifier](#SimpleIdentifier). + +If a schema specifies an alias, the alias MUST be used instead of the +namespace within qualified names throughout the document to identify +model elements of that schema. A mixed use of namespace-qualified names +and alias-qualified names is not allowed. + + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the +containing document and are not restricted to the schema that defines +them. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {.varjson .rep} +### `$Alias` + +The value of `$Alias` is a string containing the alias for the schema. +::: + +::: {.varjson .example} +Example 6: document defining a schema `org.example` with an alias and a +description for the schema +```json +{ + ... + "org.example": { + "$Alias": "self", + "@Core.Description": "Example schema", + ... + }, + ... +} +``` +::: + + + +## 5.2 Annotations with External Targeting + +::: {.varjson .rep} +### `$Annotations` + +The value of `$Annotations` is an object with one member per [annotation +target](#Target). The member name is a path identifying the [annotation +target](#Target), the member value is an object containing +[annotations](#Annotation) for that target. +::: + +::: {.varjson .example} +Example 7: annotations targeting the `Person` type with qualifier +`Tablet` +```json +"org.example": { + "$Alias": "self", + "$Annotations": { + "self.Person": { + "@Core.Description#Tablet": "Dummy", + ... + } + } +} +``` +::: -## E.1 Subsection title -### E.1.1 Sub-subsection ------- -# Appendix F. Notices +# 6 Entity Type - +Entity types are [nominal](#NominalTypes) [structured +types](#StructuredTypes) with a key that consists of one or more +references to [structural properties](#StructuralProperty). An entity +type is the template for an entity: any uniquely identifiable record +such as a customer or order. -Copyright © OASIS Open 2023. All Rights Reserved. +The entity type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +An entity type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to another entity type or collection of entity types. + +All properties MUST have a unique name within an entity type. Properties +MUST NOT have the same name as the declaring entity type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {.varjson .rep} +### Entity Type Object + +An entity type is represented as a member of the schema object whose +name is the unqualified name of the entity type and whose value is an +object. + +The entity type object MUST contain the member `$Kind` with a string +value of `EntityType`. + +It MAY contain the members [`$BaseType`](#DerivedEntityType), +[`$Abstract`](#AbstractEntityType), [`$OpenType`](#OpenEntityType), +[`$HasStream`](#MediaEntityType), and [`$Key`](#Key). + +It also MAY contain members representing [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty) as well as [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 8: a simple entity type +```json +"Employee": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": {}, + "FirstName": {}, + "LastName": {}, + "Manager": { + "$Kind": "NavigationProperty", + "$Nullable": true, + "$Type": "self.Manager" + } +} +``` +::: + + + +## 6.1 Derived Entity Type + +An entity type can inherit from another entity type by specifying it as +its base type. + +An entity type inherits the [key](#Key) as well as structural and +navigation properties of its base type. + +An entity type MUST NOT introduce an inheritance cycle by specifying a +base type. + +::: {.varjson .rep} +### `$BaseType` + +The value of `$BaseType` is the qualified name of the base type. +::: + +::: {.varjson .example} +Example 9: a derived entity type based on the previous example +```json +"Manager": { + "$Kind": "EntityType", + "$BaseType": "self.Employee", + "AnnualBudget": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Scale": 0 + }, + "Employees": { + "$Kind": "NavigationProperty", + "$Collection": true, + "$Type": "self.Employee" + } +} +``` +::: + + + +::: example +Note: the derived type has the same name as one of the properties of its +base type. +::: + +## 6.2 Abstract Entity Type -All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full [Policy](https://www.oasis-open.org/policies-guidelines/ipr/) may be found at the OASIS website. +An entity type MAY indicate that it is abstract and cannot have +instances. -This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. +For OData 4.0 responses a non-abstract entity type MUST define a +[key](#Key) or derive from a [base type](#DerivedEntityType) with a +defined key. -The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. +An abstract entity type MUST NOT inherit from a non-abstract entity +type. + +::: {.varjson .rep} +### `$Abstract` + +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 6.3 Open Entity Type + +An entity type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +An entity type derived from an open entity type MUST indicate that it is +also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData-Protocol](#ODataProtocol). + +::: {.varjson .rep} +### `$OpenType` + +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 6.4 Media Entity Type + +An entity type that does not specify a base type MAY indicate that it is +a media entity type. *Media entities* are entities that represent a +media stream, such as a photo. Use a media entity if the out-of-band +stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal +entity with one or more properties of type `Edm.Stream` if the +structured data of the entity is the main topic of interest and the +stream data is just additional information attached to the structured +data. For more information on media entities see +[OData-Protocol](#ODataProtocol). + +An entity type derived from a media entity type MUST indicate that it is +also a media entity type. + +Media entity types MAY specify a list of acceptable media types using an +annotation with term +[`Core.AcceptableMediaTypes`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#AcceptableMediaTypes), +see [OData-VocCore](#ODataVocCore). + +::: {.varjson .rep} +### `$HasStream` + +The value of `$HasStream `is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 6.5 Key + +An entity is uniquely identified within an entity set by its key. A key +MAY be specified if the entity type does not specify a [base +type](#DerivedEntityType) that already has a key declared. + +In order to be specified as the type of an [entity set](#EntitySet) or a +collection-valued [containment navigation +property](#ContainmentNavigationProperty), the entity type MUST either +specify a key or inherit its key from its [base +type](#DerivedEntityType). + +In OData 4.01 responses entity types used for [singletons](#Singleton) +or single-valued [navigation properties](#NavigationProperty) do not +require a key. In OData 4.0 responses entity types used for +[singletons](#Singleton) or single-valued [navigation +properties](#NavigationProperty) MUST have a key defined. + +An entity type (whether or not it is marked as abstract) MAY define a +key only if it doesn't inherit one. + +An entity type's key refers to the set of properties whose values +uniquely identify an instance of the entity type within an entity set. +The key MUST consist of at least one property. + +Key properties MUST NOT be nullable and MUST be typed with an +[enumeration type](#EnumerationType), one of the following [primitive +types](#PrimitiveTypes), or a [type definition](#TypeDefinition) based +on one of these primitive types: + +- `Edm.Boolean` +- `Edm.Byte` +- `Edm.Date` +- `Edm.DateTimeOffset` +- `Edm.Decimal` +- `Edm.Duration` +- `Edm.Guid` +- `Edm.Int16` +- `Edm.Int32` +- `Edm.Int64` +- `Edm.SByte` +- `Edm.String` +- `Edm.TimeOfDay` + +Key property values MAY be language-dependent, but their values MUST be +unique across all languages and the entity ids (defined in +[OData-Protocol](#ODataProtocol)) MUST be language independent. + +A key property MUST be a non-nullable primitive property of the entity +type itself, including non-nullable primitive properties of non-nullable +single-valued complex properties, recursively. + +In OData 4.01 the key properties of a directly related entity type MAY +also be part of the key if the navigation property is single-valued and +not nullable. This includes navigation properties of non-nullable +single-valued complex properties (recursively) of the entity type. If a +key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key. + +If the key property is a property of a complex property (recursively) or +of a directly related entity type, the key MUST specify an alias for +that property that MUST be a [simple identifier](#SimpleIdentifier) and +MUST be unique within the set of aliases, structural and navigation +properties of the declaring entity type and any of its base types. + +An alias MUST NOT be defined if the key property is a primitive property +of the entity type itself. + +For key properties that are a property of a complex or navigation +property, the alias MUST be used in the key predicate of URLs instead of +the path to the property because the required percent-encoding of the +forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be +used in the query part of URLs, where paths to properties don't require +special encoding and are a standard constituent of expressions anyway. + +::: {.varjson .rep} +### `$Key` + +The value of `$Key` is an array with one item per key property. + +Key properties without a key alias are represented as strings containing +the property name. + +Key properties with a key alias are represented as objects with one +member whose name is the key alias and whose value is a string +containing the path to the property. +::: + +::: {.varjson .example} +Example 10: entity type with a simple key +```json +"Category": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": { + "$Type": "Edm.Int32" + }, + "Name": { + "$Nullable": true, + "@Core.IsLanguageDependent": true + } +} +``` +::: + +::: {.varjson .example} +Example 11: entity type with a simple key referencing a property of a +[complex type](#ComplexType) +```json +"Category": { + "$Kind": "EntityType", + "$Key": [ + { + "EntityInfoID": "Info/ID" + } + ], + "Info": { + "$Type": "self.EntityInfo" + }, + "Name": { + "$Nullable": true + } +}, +"EntityInfo": { + "$Kind": "ComplexType", + "ID": { + "$Type": "Edm.Int32" + }, + "Created": { + "$Type": "Edm.DateTimeOffset", + "$Precision": 0 + } +} +``` +::: + +::: {.varjson .example} +Example 12: entity type with a composite key +```json +"OrderLine": { + "$Kind": "EntityType", + "$Key": [ + "OrderID", + "LineNumber" + ], + "OrderID": { + "$Type": "Edm.Int32" + }, + "LineNumber": { + "$Type": "Edm.Int32" + } +} +``` +::: + + + + + +::: example +Example 13 (based on [example 11](#complexkey)): requests to an entity set `Categories` +of type `Category` must use the alias +``` +GET http://host/service/Categories(EntityInfoID=1) +``` +::: + +::: example +Example 14 (based on [example 11](#complexkey)): in a query part the value assigned to +the name attribute must be used +``` +GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100 +``` +::: + +------- -This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# 7 Structural Property -As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata). +A structural property is a property of a structured type that has one of +the following types: +- [Primitive type](#PrimitiveTypes) +- [Complex type](#ComplexType) +- [Enumeration type](#EnumerationType) +- A collection of one of the above -[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.] +A structural property MUST specify a unique name as well as a +[type](#Type). -[OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.] +The property's name MUST be a [simple identifier](#SimpleIdentifier). It +is used when referencing, serializing or deserializing the property. It +MUST be unique within the set of structural and navigation properties of +the declaring [structured type](#StructuredTypes), and MUST NOT match +the name of any navigation property in any of its base types. If a +structural property with the same name is defined in any of this type's +base types, then the property's type MUST be a type derived from the +type specified for the property of the base type and constrains this +property to be of the specified subtype for instances of this structured +type. The name MUST NOT match the name of any structural or navigation +property of any of this type's base types for OData 4.0 responses. -[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.] +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {.varjson .rep} +### Property Object + +Structural properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The property object MAY contain the member `$Kind` with a string value +of `Property`. This member SHOULD be omitted to reduce document size. + +It MAY contain the member [`$Type`](#Type), [`$Collection`](#Type), +[`$Nullable`](#Nullable), [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +[`$SRID`](#SRID), and [`$DefaultValue`](#DefaultValue). + +It also MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 15: complex type with two properties `Dimension` and `Length` +```json +"Measurement": { + "$Kind": "ComplexType", + "Dimension": { + "$MaxLength": 50, + "$DefaultValue": "Unspecified" + }, + "Length": { + "$Type": "Edm.Decimal", + "$Precision": 18, + "$Scale": 2 + } +} +``` +::: + + + +## 7.1 Type + +The property's type MUST be a [primitive type](#PrimitiveTypes), +[complex type](#ComplexType), or [enumeration type](#EnumerationType) in +scope, or a collection of one of these types. + +A collection-valued property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in +[OData-VocCore](#ODataVocCore), to specify that it supports a +stable ordering. + +A collection-valued property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports inserting items into a specific ordinal position. + +::: {.varjson .rep} +### `$Type` and `$Collection` + +For single-valued properties the value of `$Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `$Type` is the qualified +name of the property's item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. This +member SHOULD be omitted for string properties to reduce document size. +::: + +::: {.varjson .example} +Example 16: property `Units` that can have zero or more strings as its +value +```json +"Units": { + "$Collection": true +} +``` +::: + + + +## 7.2 Type Facets + +Facets modify or constrain the acceptable values of a property. + +For single-valued properties the facets apply to the value of the +property. For collection-valued properties the facets apply to the items +in the collection. + +### 7.2.1 Nullable + +A Boolean value specifying whether the property can have the value +`null`. + +::: {.varjson .rep} +### `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + + +### 7.2.2 MaxLength + +A positive integer value specifying the maximum length of a binary, +stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length +(number of code points for Unicode). + +If no maximum length is specified, clients SHOULD expect arbitrary +length. + +::: {.varjson .rep} +### `$MaxLength` + +The value of `$MaxLength` is a positive integer. + +Note: [OData-CSDL-XML](#ODataCSDLXML) defines a symbolic +value `max` that is only allowed in OData 4.0 responses. This symbolic +value is not allowed in CDSL JSON documents at all. Services MAY instead +specify the concrete maximum length supported for the type by the +service or omit the member entirely. +::: + + +### 7.2.3 Precision + +For a decimal value: the maximum number of significant decimal digits of +the property's value; it MUST be a positive integer. + +For a temporal value (datetime-with-timezone-offset, duration, or +time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve. + +Note: service authors SHOULD be aware that some clients are unable to +support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential +for data loss when round-tripping values of greater precision. Updating +via `PATCH` and exclusively specifying modified properties will reduce +the risk for unintended data loss. + +Note: duration properties supporting a granularity less than seconds +(e.g. minutes, hours, days) can be annotated with term +[`Measures.DurationGranularity`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Measures.V1.md#DurationGranularity), +see [OData-VocMeasures](#ODataVocMeasures). + +::: {.varjson .rep} +### `$Precision` + +The value of `$Precision` is a number. + +Absence of `$Precision` means arbitrary precision. +::: + +::: {.varjson .example} +Example 17: `Precision` facet applied to the `DateTimeOffset` type +```json +"SuggestedTimes": { + "$Type": "Edm.DateTimeOffset", + "$Collection": true, + "$Precision": 6 +} +``` +::: + + + +### 7.2.4 Scale + +A non-negative integer value specifying the maximum number of digits +allowed to the right of the decimal point, or one of the symbolic values +`floating` or `variable`. + +The value `floating` means that the decimal property represents a +decimal floating-point number whose number of significant digits is the +value of the [`Precision`](#Precision) facet. OData 4.0 responses MUST +NOT specify the value `floating`. + +The value `variable` means that the number of digits to the right of the +decimal point can vary from zero to the value of the +[`Precision`](#Precision) facet. + +An integer value means that the number of digits to the right of the +decimal point may vary from zero to the value of the `Scale` facet, and +the number of digits to the left of the decimal point may vary from one +to the value of the `Precision` facet minus the value of the `Scale` +facet. If `Precision` is equal to `Scale`, a single zero MUST precede +the decimal point. + +The value of `Scale` MUST be less than or equal to the value of +[`Precision`](#Precision). + +Note: if the underlying data store allows negative scale, services may +use a [`Precision`](#Precision) with the absolute value of the negative +scale added to the actual number of significant decimal digits, and +client-provided values may have to be rounded before being stored. + +::: {.varjson .rep} +### `$Scale` + +The value of `$Scale` is a number or a string with one of the symbolic +values `floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +Absence of `$Scale` means `variable`. +::: + +::: {.varjson .example} +Example 18: [`Precision`](#Precision)`=3` and `Scale=2`. +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 +```json +"Amount32": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 3, + "$Scale": 2 +} +``` +::: + +::: {.varjson .example} +Example 19: `Precision=2` equals `Scale`. +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 +```json +"Amount22": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 2, + "$Scale": 2 +} +``` +::: + +::: {.varjson .example} +Example 20: `Precision=3` and a variable `Scale`. +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. +```json +"Amount3v": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 3 +} +``` +::: + +::: {.varjson .example} +Example 21: `Precision=7` and a floating `Scale`. +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. +```json +"Amount7f": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 7, + "$Scale": "floating" +} +``` +::: + + + + + + +### 7.2.5 Unicode + +For a string property the `Unicode` facet indicates whether the property +might contain and accept string values with Unicode characters (code +points) beyond the ASCII character set. The value `false` indicates that +the property will only contain and accept string values with characters +limited to the ASCII character set. + +If no value is specified, the `Unicode` facet defaults to `true`. + +::: {.varjson .rep} +### `$Unicode` + +The value of `$Unicode` is one of the Boolean literals `true` or +`false`. Absence of the member means `true`. +::: + + +### 7.2.6 SRID + +For a geometry or geography property the `SRID` facet identifies which +spatial reference system is applied to values of the property on type +instances. + +The value of the `SRID` facet MUST be a non-negative integer or the +special value `variable`. If no value is specified, the facet defaults +to `0` for `Geometry` types or `4326` for `Geography` types. + +The valid values of the `SRID` facet and their meanings are as defined +by the European Petroleum Survey Group [EPSG](#_EPSG). + +::: {.varjson .rep} +### `$SRID` + +The value of `$SRID` is a string containing a number or the symbolic +value `variable`. +::: + + +### 7.2.7 Default Value + +A primitive or enumeration property MAY define a default value that is +used if the property is not explicitly represented in an annotation or +the body of a request or response. + +If no value is specified, the client SHOULD NOT assume a default value. + +::: {.varjson .rep} +### `$DefaultValue` + +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the property, see +[OData-JSON](#ODataJSON). For properties of type +`Edm.Decimal` and `Edm.Int64` the representation depends on the media +type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumbers). +::: + + +------- + +# 8 Navigation Property + +A navigation property allows navigation to related entities. It MUST +specify a unique name as well as a type. + +The navigation property's name MUST be a [simple +identifier](#SimpleIdentifier). It is used when referencing, serializing +or deserializing the navigation property. It MUST be unique within the +set of structural and navigation properties of the declaring [structured +type](#StructuredTypes), and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the +same name is defined in any of this type's base types, then the +navigation property's type MUST be a type derived from the type +specified for the navigation property of the base type, and constrains +this navigation property to be of the specified subtype for instances of +this structured type. The name MUST NOT match the name of any structural +or navigation property of any of this type's base types for OData 4.0 +responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {.varjson .rep} +### Navigation Property Object + +Navigation properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The navigation property object MUST contain the member `$Kind` with a +string value of `NavigationProperty`. + +It MUST contain the member [`$Type`](#NavigationPropertyType), and it +MAY contain the members [`$Collection`](#NavigationPropertyType), +[`$Nullable`](#NullableNavigationProperty), +[`$Partner`](#PartnerNavigationProperty), +[`$ContainsTarget`](#ContainmentNavigationProperty), +[`$ReferentialConstraint`](#ReferentialConstraint), and +[`$OnDelete`](#OnDeleteAction). + +It also MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 22: the `Product` entity type has a navigation property to a +`Category`, which has a navigation link back to one or more products +```json +"Product": { + "$Kind": "EntityType", + ... + "Category": { + "$Kind": "NavigationProperty", + "$Type": "self.Category", + "$Partner": "Products", + "$ReferentialConstraint": { + "CategoryID": "ID" + } + }, + "Supplier": { + "$Kind": "NavigationProperty", + "$Type": "self.Supplier" + } +}, +"Category": { + "$Kind": "EntityType", + ... + "Products": { + "$Kind": "NavigationProperty", + "$Collection": true, + "$Type": "self.Product", + "$Partner": "Category", + "$OnDelete": "Cascade", + "$OnDelete@Core.Description": "Delete all related entities" + } +} +``` +::: + + + +## 8.1 Navigation Property Type + +The navigation property's type MUST be an [entity type](#EntityType) in +scope, the [abstract type](#BuiltInAbstractTypes) `Edm.EntityType`, or a +collection of one of these types. + +If the type is a collection, an arbitrary number of entities can be +related. Otherwise there is at most one related entity. + +The related entities MUST be of the specified entity type or one of its +subtypes. + +For a collection-valued containment navigation property the specified +entity type MUST have a [key](#Key) defined. + +A collection-valued navigation property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports a stable ordering. + +A collection-valued navigation property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports inserting items into a specific ordinal position. + +::: {.varjson .rep} +### `$Type` and `$Collection` + +For single-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's item type, and the member +`$Collection` MUST be present with the literal value `true`. +::: + + +## 8.2 Nullable Navigation Property + +A Boolean value specifying whether the declaring type MAY have no +related entity. If false, instances of the declaring structured type +MUST always have a related entity. + +Nullable MUST NOT be specified for a collection-valued navigation +property, a collection is allowed to have zero items. + +::: {.varjson .rep} +### `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 8.3 Partner Navigation Property + +A navigation property of an [entity type](#EntityType) MAY specify a +partner navigation property. Navigation properties of complex types MUST +NOT specify a partner. + +If specified, the partner navigation property is identified by a path +relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that +type or a derived type. The path MAY traverse complex types, including +derived complex types, but MUST NOT traverse any navigation properties. +The type of the partner navigation property MUST be the declaring entity +type of the current navigation property or one of its parent entity +types. + +If the partner navigation property is single-valued, it MUST lead back +to the source entity from all related entities. If the partner +navigation property is collection-valued, the source entity MUST be part +of that collection. + +If no partner navigation property is specified, no assumptions can be +made as to whether one of the navigation properties on the target type +will lead back to the source entity. + +If a partner navigation property is specified, this partner navigation +property MUST either specify the current navigation property as its +partner to define a bi-directional relationship or it MUST NOT specify a +partner navigation property. The latter can occur if the partner +navigation property is defined on a complex type, or if the current +navigation property is defined on a type derived from the type of the +partner navigation property. + +::: {.varjson .rep} +### `$Partner` + +The value of `$Partner` is a string containing the path to the partner +navigation property. +::: + + +## 8.4 Containment Navigation Property + +A navigation property MAY indicate that instances of its declaring +structured type contain the targets of the navigation property, in which +case the navigation property is called a *containment navigation +property*. + +Containment navigation properties define an implicit entity set for each +instance of its declaring structured type. This implicit entity set is +identified by the read URL of the navigation property for that +structured type instance. + +Instances of the structured type that declares the navigation property, +either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The +canonical URL for contained entities is the canonical URL of the +containing instance, followed by the path segment of the navigation +property and the key of the contained entity, see +[OData-URL](#ODataURL). + +Entity types used in collection-valued containment navigation properties +MUST have a [key](#Key) defined. + +For items of an ordered collection of complex types (those annotated +with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term defined in [OData-VocCore](#ODataVocCore) the canonical URL +of the item is the canonical URL of the collection appended with a +segment containing the zero-based ordinal of the item. Items within in +an unordered collection of complex types do not have a canonical URL. +Services that support unordered collections of complex types declaring a +containment navigation property, either directly or indirectly via a +property of complex type, MUST specify the URL for the navigation link +within a payload representing that item, according to format-specific +rules. + +OData 4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued +property. + +An entity cannot be referenced by more than one containment +relationship, and cannot both belong to an entity set declared within +the entity container and be referenced by a containment relationship. + +Containment navigation properties MUST NOT be specified as the last path +segment in the path of a [navigation property +binding](#NavigationPropertyBinding). + +When a containment navigation property navigates between entity types in +the same inheritance hierarchy, the containment is called *recursive*. + +Containment navigation properties MAY specify a partner navigation +property. If the containment is recursive, the relationship defines a +tree, thus the partner navigation property MUST be +[nullable](#NullableNavigationProperty) (for the root of the tree) and +single-valued (for the parent of a non-root entity). If the containment +is not recursive, the partner navigation property MUST NOT be nullable. + +An entity type inheritance chain MUST NOT contain more than one +navigation property with a partner navigation property that is a +containment navigation property. + +Note: without a partner navigation property, there is no reliable way +for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity +can also be reached via a non-containment navigation path. + +::: {.varjson .rep} +### `$ContainsTarget` + +The value of `$ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 8.5 Referential Constraint + +A single-valued navigation property MAY define one or more referential +constraints. A referential constraint asserts that the *dependent +property* (the property defined on the structured type declaring the +navigation property) MUST have the same value as the *principal +property* (the referenced property declared on the entity type that is +the target of the navigation). + +The type of the dependent property MUST match the type of the principal +property, or both types MUST be complex types. + +If the principle property references an entity, then the dependent +property must reference the same entity. + +If the principle property's value is a complex type instance, then the +dependent property's value must be a complex type instance with the same +properties, each with the same values. + +If the navigation property on which the referential constraint is +defined is nullable, or the principal property is nullable, then the +dependent property MUST also be nullable. If both the navigation +property and the principal property are not nullable, then the dependent +property MUST NOT be nullable. + +::: {.varjson .rep} +### `$ReferentialConstraint` + +The value of `$ReferentialConstraint` is an object with one member per +referential constraint. The member name is the path to the dependent +property, this path is relative to the structured type declaring the +navigation property. The member value is a string containing the path to +the principal property, this path is relative to the entity type that is +the target of the navigation property. + +It also MAY contain [annotations](#Annotation). These are prefixed with +the path of the dependent property of the annotated referential +constraint. +::: + +::: {.varjson .example} +Example 23: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. +```json +"Product": { + "$Kind": "EntityType", + ... + "CategoryID": {}, + "CategoryKind": {}, + "Category": { + "$Kind": "NavigationProperty", + "$Type": "self.Category", + "$Partner": "Products", + "$ReferentialConstraint": { + "CategoryID": "ID", + "CategoryKind": "Kind", + "CategoryKind@Core.Description": "Referential Constraint to non-key property" + } + } +}, +"Category": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": {}, + "Kind": { + "$Nullable": true + }, + ... +} +``` +::: + + + +## 8.6 On-Delete Action + +A navigation property MAY define an on-delete action that describes the +action the service will take on related entities when the entity on +which the navigation property is defined is deleted. + +The action can have one of the following values: + +- `Cascade`, meaning the related entities will be deleted if the + source entity is deleted, +- `None`, meaning a `DELETE` request on a source entity with related + entities will fail, +- `SetNull`, meaning all properties of related entities that are tied + to properties of the source entity via a referential constraint and + that do not participate in other referential constraints will be set + to null, +- `SetDefault`, meaning all properties of related entities that are + tied to properties of the source entity via a referential constraint + and that do not participate in other referential constraints will be + set to their default value. + +If no on-delete action is specified, the action taken by the service is +not predictable by the client and could vary per entity. + +::: {.varjson .rep} +### `$OnDelete` + +The value of `$OnDelete` is a string with one of the values `Cascade`, +`None`, `SetNull`, or `SetDefault`. + +[Annotations](#Annotation) for `$OnDelete` are prefixed with +`$OnDelete`. +::: + +::: {.varjson .example} +Example 24: deletion of a category implies deletion of the related +products in that category +```json +"Category": { + "$Kind": "EntityType", + ... + "Products": { + "$Kind": "NavigationProperty", + "$Collection": true, + "$Type": "self.Product", + "$Partner": "Category", + "$OnDelete": "Cascade", + "$OnDelete@Core.Description": "Delete all products in this category" + } +} +``` +::: + + + +------- + +# 9 Complex Type + +Complex types are keyless [nominal](#NominalTypes) [structured +types](#StructuredTypes). The lack of a key means that instances of +complex types cannot be referenced, created, updated or deleted +independently of an entity type. Complex types allow entity models to +group properties into common structures. + +The complex type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +A complex type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to an entity type or a collection of entity types. + +All properties MUST have a unique name within a complex type. Properties +MUST NOT have the same name as the declaring complex type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {.varjson .rep} +### Complex Type Object + +A complex type is represented as a member of the schema object whose +name is the unqualified name of the complex type and whose value is an +object. + +The complex type object MUST contain the member `$Kind` with a string +value of `ComplexType`. It MAY contain the members +[`$BaseType`](#DerivedComplexType), [`$Abstract`](#AbstractComplexType), +and [`$OpenType`](#OpenComplexType). It also MAY contain members +representing [structural properties](#StructuralProperty) and +[navigation properties](#NavigationProperty) as well as +[annotations](#Annotation). +::: + +::: {.varjson .example} +Example 25: a complex type used by two entity types +```json +"Dimensions": { + "$Kind": "ComplexType", + "Height": { + "$Type": "Edm.Decimal", + "$Scale": 0 + }, + "Weight": { + "$Type": "Edm.Decimal", + "$Scale": 0 + }, + "Length": { + "$Type": "Edm.Decimal", + "$Scale": 0 + } +}, +"Product": { + ... + "ProductDimensions": { + "$Nullable": true, + "$Type": "self.Dimensions" + }, + "ShippingDimensions": { + "$Nullable": true, + "$Type": "self.Dimensions" + } +}, +"ShipmentBox": { + ... + "Dimensions": { + "$Nullable": true, + "$Type": "self.Dimensions" + } +} +``` +::: + + + +## 9.1 Derived Complex Type + +A complex type can inherit from another complex type by specifying it as +its base type. + +A complex type inherits the structural and navigation properties of its +base type. + +A complex type MUST NOT introduce an inheritance cycle by specifying a +base type. + +The rules for annotations of derived complex types are described in +[section 14.2](#Annotation). + +::: {.varjson .rep} +### `$BaseType` + +The value of `$BaseType` is the qualified name of the base type. +::: + + +## 9.2 Abstract Complex Type + +A complex type MAY indicate that it is abstract and cannot have +instances. + +::: {.varjson .rep} +### `$Abstract` + +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 9.3 Open Complex Type + +A complex type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +A complex type derived from an open complex type MUST indicate that it +is also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {.varjson .rep} +### `$OpenType` + +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +------- + +# 10 Enumeration Type + +Enumeration types are [nominal](#NominalTypes) types that represent a +non-empty series of related values. Enumeration types expose these +related values as members of the enumeration. + +The enumeration type's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Although enumeration types have an underlying numeric value, the +preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the `AllowedValues` annotation defined in +[OData-VocCore](#ODataVocCore). + +Enumeration types marked as flags allow values that consist of more than +one enumeration member at a time. + +::: {.varjson .rep} +### Enumeration Type Object + +An enumeration type is represented as a member of the schema object +whose name is the unqualified name of the enumeration type and whose +value is an object. + +The enumeration type object MUST contain the member `$Kind` with a +string value of `EnumType`. + +It MAY contain the members [`$UnderlyingType`](#UnderlyingIntegerType) +and [`$IsFlags`](#FlagsEnumerationType). + +The enumeration type object MUST contain members representing [the +enumeration type members](#EnumerationTypeMember). + +The enumeration type object MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 26: a simple flags-enabled enumeration +```json +"FileAccess": { + "$Kind": "EnumType", + "$UnderlyingType": "Edm.Int32", + "$IsFlags": true, + "Read": 1, + "Write": 2, + "Create": 4, + "Delete": 8 +} +``` +::: + + + +## 10.1 Underlying Integer Type + +An enumeration type MAY specify one of `Edm.Byte`, `Edm.SByte`, +`Edm.Int16`, `Edm.Int32`, or `Edm.Int64` as its underlying type. + +If not explicitly specified, `Edm.Int32` is used as the underlying type. + +::: {.varjson .rep} +### `$UnderlyingType` + +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + + +## 10.2 Flags Enumeration Type + +An enumeration type MAY indicate that the enumeration type allows +multiple members to be selected simultaneously. + +If not explicitly specified, only one enumeration type member MAY be +selected simultaneously. + +::: {.varjson .rep} +### `$IsFlags` + +The value of `$IsFlags` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varjson .example} +Example 27: pattern values can be combined, and some combined values +have explicit names +```json +"Pattern": { + "$Kind": "EnumType", + "$UnderlyingType": "Edm.Int32", + "$IsFlags": true, + "Plain": 0, + "Red": 1, + "Blue": 2, + "Yellow": 4, + "Solid": 8, + "Striped": 16, + "SolidRed": 9, + "SolidBlue": 10, + "SolidYellow": 12, + "RedBlueStriped": 19, + "RedYellowStriped": 21, + "BlueYellowStriped": 22 +} +``` +::: + + + +## 10.3 Enumeration Type Member + +Enumeration type values consist of discrete members. + +Each member is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within the +enumeration type. Names are case-sensitive, but service authors SHOULD +NOT choose names that differ only in case. + +Each member MUST specify an associated numeric value that MUST be a +valid value for the underlying type of the enumeration type. + +Enumeration types can have multiple members with the same value. Members +with the same numeric value compare as equal, and members with the same +numeric value can be used interchangeably. + +Enumeration members are sorted by their numeric value. + +For flag enumeration types the combined numeric value of simultaneously +selected members is the bitwise OR of the discrete numeric member +values. + +::: {.varjson .rep} +### Enumeration Member Object + +Enumeration type members are represented as JSON object members, where +the object member name is the enumeration member name and the object +member value is the enumeration member value. + +For members of [flags enumeration types](#FlagsEnumerationType) a +combined enumeration member value is equivalent to the bitwise OR of the +discrete values. + +Annotations for enumeration members are prefixed with the enumeration +member name. +::: + +::: {.varjson .example} +Example 28: `FirstClass` has a value of 0, `TwoDay` a value of 1, and +`Overnight` a value of 2. +```json +"ShippingMethod": { + "$Kind": "EnumType", + "FirstClass": 0, + "FirstClass@Core.Description": "Shipped with highest priority", + "TwoDay": 1, + "TwoDay@Core.Description": "Shipped within two days", + "Overnight": 2, + "Overnight@Core.Description": "Shipped overnight", + "@Core.Description": "Method of shipping" +} +``` +::: + + + +------- + +# 11 Type Definition + +A type definition defines a specialization of one of the [primitive +types](#PrimitiveTypes) or of the built-in abstract type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes). + +The type definition's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Type definitions can be used wherever a primitive type is used (other +than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions +defined using the same underlying type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden. + +::: {.varjson .rep} +### Type Definition Object + +A type definition is represented as a member of the schema object whose +name is the unqualified name of the type definition and whose value is +an object. + +The type definition object MUST contain the member `$Kind` with a string +value of `TypeDefinition` and the member +[`$UnderlyingType`](#UnderlyingPrimitiveType). It MAY contain the +members [`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID), +and it MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 29: +```json +"Length": { + "$Kind": "TypeDefinition", + "$UnderlyingType": "Edm.Int32", + "@Measures.Unit": "Centimeters" +}, +"Weight": { + "$Kind": "TypeDefinition", + "$UnderlyingType": "Edm.Int32", + "@Measures.Unit": "Kilograms" +}, +"Size": { + "$Kind": "ComplexType", + "Height": { + "$Nullable": true, + "$Type": "self.Length" + }, + "Weight": { + "$Nullable": true, + "$Type": "self.Weight" + } +} +``` +::: + + + +## 11.1 Underlying Primitive Type + +The underlying type of a type definition MUST be a primitive type that +MUST NOT be another type definition. + +::: {.varjson .rep} +### `$UnderlyingType` + +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), +[`$Scale`](#Scale), or [`$SRID`](#SRID). + + + +Additional facets appropriate for the underlying type MAY be specified +when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified. + +For a type definition with underlying type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes) no facets are applicable, +neither in the definition itself nor when the type definition is used, +and these should be ignored by the client. + +Where type definitions are used, the type definition is returned in +place of the primitive type wherever the type is specified in a +response. + +------- + +# 12 Action and Function + +## 12.1 Action + +Actions are service-defined operations that MAY have observable side +effects and MAY return a single instance or a collection of instances of +any type. + +The action's name is a [simple identifier](#SimpleIdentifier) that MUST +be unique within its schema. + +Actions cannot be composed with additional path segments. + +An action MAY specify a [return type](#ReturnType) that MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +An action MAY define [parameters](#Parameter) used during the execution +of the action. + +## 12.2 Action Overloads + +[Bound](#BoundorUnboundActionorFunctionOverloads) actions support +overloading (multiple actions having the same name within the same +schema) by binding parameter type. The combination of action name and +the binding parameter type MUST be unique within a schema. + +[Unbound](#BoundorUnboundActionorFunctionOverloads) actions do not support +overloads. The names of all unbound actions MUST be unique within a +schema. + +An unbound action MAY have the same name as a bound action. + +::: {.varjson .rep} +### Action Overload Object + +An action is represented as a member of the schema object whose name is +the unqualified name of the action and whose value is an array. The +array contains one object per action overload. + +The action overload object MUST contain the member `$Kind` with a string +value of `Action`. + +It MAY contain the members +[`$IsBound`](#BoundorUnboundActionorFunctionOverloads), +[`$EntitySetPath`](#EntitySetPath), [`$Parameter`](#Parameter), and +[`$ReturnType`](#ReturnType), and it MAY contain +[annotations](#Annotation). +::: + + +## 12.3 Function + +Functions are service-defined operations that MUST NOT have observable +side effects and MUST return a single instance or a collection of +instances of any type. + +The function's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +Functions MAY be [composable](#ComposableFunction). + +The function MUST specify a [return type](#ReturnType) which MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +A function MAY define [parameters](#Parameter) used during the execution +of the function. + +## 12.4 Function Overloads + +[Bound](#BoundorUnboundActionorFunctionOverloads) functions support +overloading (multiple functions having the same name within the same +schema) subject to the following rules: +- The combination of function name, +binding parameter type, and unordered set of non-binding parameter names +MUST be unique within a schema. +- The combination of function name, +binding parameter type, and ordered set of parameter types MUST be +unique within a schema. +- All bound functions with the same +function name and binding parameter type within a schema MUST specify +the same return type. + +[Unbound](#BoundorUnboundActionorFunctionOverloads) functions support +overloading subject to the following rules: +- The combination of function name and +unordered set of parameter names MUST be unique within a schema. +- The combination of function name and +ordered set of parameter types MUST be unique within a schema. +- All unbound functions with the same +function name within a schema MUST specify the same return type. + +An unbound function MAY have the same name as a bound function. + +Note that [type definitions](#TypeDefinition) can be used to +disambiguate overloads for both bound and unbound functions, even if +they specify the same underlying type. + +::: {.varjson .rep} +### Function Overload Object + +A function is represented as a member of the schema object whose name is +the unqualified name of the function and whose value is an array. The +array contains one object per function overload. + +The function overload object MUST contain the member `$Kind` with a +string value of `Function`. + +It MUST contain the member [`$ReturnType`](#ReturnType), and it MAY +contain the members [`$IsBound`](#BoundorUnboundActionorFunctionOverloads), +[`$EntitySetPath`](#EntitySetPath), and [`$Parameter`](#Parameter), +and it MAY contain [annotations](#Annotation). +::: + + +## 12.5 Bound or Unbound Action or Function Overloads + +An action or function overload MAY indicate that it is bound. If not +explicitly indicated, it is unbound. + +Bound actions or functions are invoked on resources matching the type of +the binding parameter. The binding parameter can be of any type, and it +MAY be [nullable](#Nullable). + +Unbound actions are invoked from the entity container through an [action +import](#ActionImport). + +Unbound functions are invoked as static functions within a filter or +orderby expression, or from the entity container through a [function +import](#FunctionImport). + +::: {.varjson .rep} +### `$IsBound` + +The value of `$IsBound` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 12.6 Entity Set Path + +Bound actions and functions that return an entity or a collection of +entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter +value. + +The entity set path consists of a series of segments joined together +with forward slashes. + +The first segment of the entity set path MUST be the name of the binding +parameter. The remaining segments of the entity set path MUST represent +navigation segments or type casts. + +A navigation segment names the [simple identifier](#SimpleIdentifier) of +the [navigation property](#NavigationProperty) to be traversed. A +type-cast segment names the [qualified name](#QualifiedName) of the +entity type that should be returned from the type cast. + +::: {.varjson .rep} +### `$EntitySetPath` + +The value of `$EntitySetPath` is a string containing the entity set +path. +::: + + +## 12.7 Composable Function + +A function MAY indicate that it is composable. If not explicitly +indicated, it is not composable. + +A composable function can be invoked with additional path segments or +key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for +the type returned by the composable function. + +::: {.varjson .rep} +### `$IsComposable` + +The value of `$IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + + +## 12.8 Return Type + +The return type of an action or function overload MAY be any type in +scope, or a collection of any type in scope. + +The facets [`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID) can be +used as appropriate to specify value restrictions of the return type, as +well as the [`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For a single-valued return type the facets apply to the returned value. +For a collection-valued return type the facets apply to the items in the +returned collection. + +::: {.varjson .rep} +### `$ReturnType` + +The value of `$ReturnType` is an object. It MAY contain the members +`$Type`, `$Collection`, `$Nullable`, [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID). + +It also MAY contain [annotations](#Annotation). + +### `$Type` and `$Collection` + +For single-valued return types the value of `$Type` is the qualified +name of the returned type. + +For collection-valued return types the value of `$Type` is the qualified +name of the returned item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. + +### `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +If the return type is a collection of entity types, the `$Nullable` +member has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + + +## 12.9 Parameter + +An action or function overload MAY specify parameters. + +A bound action or function overload MUST specify at least one parameter; +the first parameter is its binding parameter. The order of parameters +MUST NOT change unless the schema version changes. + +Each parameter MUST have a name that is a [simple +identifier](#SimpleIdentifier). The parameter name MUST be unique within +the action or function overload. + +The parameter MUST specify a type. It MAY be any type in scope, or a +collection of any type in scope. + +The facets [`MaxLength`](#MaxLength), [`Precision`](#Precision), +[`Scale`](#Scale), or [`SRID`](#SRID) can be used as appropriate to +specify value restrictions of the parameter, as well as the +[`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For single-valued parameters the facets apply to the parameter value. If +the parameter value is a collection, the facets apply to the items in +the collection. + +::: {.varjson .rep} +### `$Parameter` + +The value of `$Parameter` is an array. The array contains one object per +parameter. + +### Parameter Object + +A parameter object MUST contain the member `$Name`, and it MAY contain +the members `$Type`, `$Collection`, `$Nullable`, +[`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID). + +Parameter objects MAY also contain [annotations](#Annotation). + +### `$Name` + +The value of `$Name` is a string containing the parameter name. + +### `$Type` and `$Collection` + +For single-valued parameters the value of `$Type` is the qualified name +of the accepted type. + +For collection-valued parameters the value of `$Type` is the qualified +name of the accepted item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. + +### `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued parameters the value `true` means that the parameter +accepts a `null` value. + +For collection-valued parameters the parameter value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + +::: {.varjson .example} +Example 30: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `$Parameter` member. +```json +"TopSellingProducts": [ + { + "$Kind": "Function", + "$Parameter": [ + { + "$Name": "Year", + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 4, + "$Scale": 0 + } + ], + "$ReturnType": { + "$Collection": true, + "$Type": "self.Product" + } + } +] +``` +::: + + + +------- + +# 13 Entity Container + +Each metadata document used to describe an OData service MUST define +exactly one entity container. + +The entity container's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Entity containers define the entity sets, singletons, function and +action imports exposed by the service. + +Entity set, singleton, action import, and function import names MUST be +unique within an entity container. + +An [*entity set*](#EntitySet) allows access to entity type instances. +Simple entity models frequently have one entity set per entity type. + +::: {.varjson .example} +Example 31: one entity set per entity type +```json +"Products": { + "$Collection": true, + "$Type": "self.Product" +}, +"Categories": { + "$Collection": true, + "$Type": "self.Category" +} +``` +::: + + +Other entity models may expose multiple entity sets per type. + +::: {.varjson .example} +Example 32: three entity sets referring to the two entity types +```json +"StandardCustomers": { + "$Collection": true, + "$Type": "self.Customer", + "$NavigationPropertyBinding": { + "Orders": "Orders" + } +}, +"PreferredCustomers": { + "$Collection": true, + "$Type": "self.Customer", + "$NavigationPropertyBinding": { + "Orders": "Orders" + } +}, +"Orders": { + "$Collection": true, + "$Type": "self.Order" +} +``` +::: + + +There are separate entity sets for standard customers and preferred +customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have [navigation +property bindings](#NavigationPropertyBinding) to the orders entity set, +but the orders entity set does not have a navigation property binding +for the Customer navigation property, since it could lead to either set +of customers. + +An entity set can expose instances of the specified entity type as well +as any entity type inherited from the specified entity type. + +A [*singleton*](#Singleton) allows addressing a single entity directly +from the entity container without having to know its key, and without +requiring an entity set. + +A [*function import*](#FunctionImport) or an [*action +import*](#ActionImport) is used to expose a function or action defined +in an entity model as a top level resource. + +::: {.varjson .rep} +### Entity Container Object + +An entity container is represented as a member of the schema object +whose name is the unqualified name of the entity container and whose +value is an object. + +The entity container object MUST contain the member `$Kind` with a +string value of `EntityContainer`. + +The entity container object MAY contain the member +[`$Extends`](#ExtendinganEntityContainer), members representing [entity +sets](#EntitySet), [singletons](#Singleton), [action +imports](#ActionImport), and [function imports](#FunctionImport), as +well as [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 33: An entity container aggregates entity sets, singletons, +action imports, and function imports. +```json +"DemoService": { + "$Kind": "EntityContainer", + "Products": { + "$Collection": true, + "$Type": "self.Product", + "$NavigationPropertyBinding": { + "Category": "Categories", + "Supplier": "Suppliers" + }, + "@UI.DisplayName": "Product Catalog" + }, + "Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "Products" + } + }, + "Suppliers": { + "$Collection": true, + "$Type": "self.Supplier", + "$NavigationPropertyBinding": { + "Products": "Products" + }, + "@UI.DisplayName": "Supplier Directory" + }, + "MainSupplier": { + "$Type": "self.Supplier" + }, + "LeaveRequestApproval": { + "$Action": "self.Approval" + }, + "ProductsByRating": { + "$EntitySet": "Products", + "$Function": "self.ProductsByRating" + } +} +``` +::: + + + +## 13.1 Extending an Entity Container + +An entity container MAY specify that it extends another entity container +in scope. All children of the "base" entity container are added to the +"extending" entity container. + +If the "extending" entity container defines an entity set with the same +name as defined in any of its "base" containers, then the entity set's +type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the "base" container. The same +holds for singletons. Action imports and function imports cannot be +redefined, nor can the "extending" container define a child with the +same name as a child of a different kind in a "base" container. + +Note: services should not introduce cycles by extending entity +containers. Clients should be prepared to process cycles introduced by +extending entity containers. + +::: {.varjson .rep} +### `$Extends` + +The value of `$Extends` is the qualified name of the entity container to +be extended. +::: + +::: {.varjson .example} +Example 34: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` +```json +"Extending": { + "$Kind": "EntityContainer", + "$Extends": "Some.Other.Schema.Base", + ... +} +``` +::: + + + +## 13.2 Entity Set + +Entity sets are top-level collection-valued resources. + +An entity set is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An entity set MUST specify a type that MUST be an entity type in scope. + +An entity set MUST contain only instances of its specified entity type +or its subtypes. The entity type MAY be [abstract](#AbstractEntityType) +but MUST have a [key](#Key) defined. + +An entity set MAY indicate whether it is included in the service +document. If not explicitly indicated, it is included. + +Entity sets that cannot be queried without specifying additional query +options SHOULD NOT be included in the service document. + +::: {.varjson .rep} +### Entity Set Object + +An entity set is represented as a member of the entity container object +whose name is the name of the entity set and whose value is an object. + +The entity set object MUST contain the members `$Collection` and +`$Type`. + +It MAY contain the members `$IncludeInServiceDocument` and +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). + +### `$Collection` + +The value of `$Collection` is the Booelan value `true`. + +### `$Type` + +The value of `$Type` is the qualified name of an entity type. + +### `$IncludeInServiceDocument` + +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `true`. +::: + + +## 13.3 Singleton + +Singletons are top-level single-valued resources. + +A singleton is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A singleton MUST specify a type that MUST be an entity type in scope. + +A singleton MUST reference an instance its entity type. + +::: {.varjson .rep} +### Singleton Object + +A singleton is represented as a member of the entity container object +whose name is the name of the singleton and whose value is an object. + +The singleton object MUST contain the member `$Type` and it MAY contain +the member `$Nullable`. + +It MAY contain the member +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). + +### `$Type` + +The value of `$Type` is the qualified name of an entity type. + +### `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`.In OData 4.0 responses this +member MUST NOT be specified. +::: + + +## 13.4 Navigation Property Binding + +If the entity type of an entity set or singleton declares navigation +properties, a navigation property binding allows describing which entity +set or singleton will contain the related entities. + +An [entity set](#EntitySet) or a [singleton](#Singleton) SHOULD specify +a navigation property binding for each [navigation +property](#NavigationProperty) of its entity type, including navigation +properties defined on complex typed properties or derived types. + +If omitted, clients MUST assume that the target entity set or singleton +can vary per related entity. + +### 13.4.1 Navigation Property Path Binding + +A navigation property binding MUST specify a path to a navigation +property of the entity set's or singleton's declared entity type, or a +navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation +property is defined on a subtype, the path MUST contain the [qualified +name](#QualifiedName) of the subtype, followed by a forward slash, +followed by the navigation property name. If the navigation property is +defined on a complex type used in the definition of the entity set's +entity type, the path MUST contain a forward-slash separated list of +complex property names and qualified type names that describe the path +leading to the navigation property. + +The path can traverse one or more containment navigation properties, but +the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment. + +If the path traverses collection-valued complex properties or +collection-valued containment navigation properties, the binding applies +to all items of these collections. + +If the path contains a recursive sub-path (i.e. a path leading back to +the same structured type, the binding applies recursively to any +positive number of cycles through that sub-path. + +OData 4.01 services MAY have a type-cast segment as the last path +segment, allowing to bind instances of different sub-types to different +targets. + +The same navigation property path MUST NOT be specified in more than one +navigation property binding; navigation property bindings are only used +when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths +that differ only in a type-cast segment, allowing to bind instances of +different sub-types to different targets. If paths differ only in +type-cast segments, the most specific path applies. + +### 13.4.2 Binding Target + +A navigation property binding MUST specify a target via a [simple +identifier](#SimpleIdentifier) or [target path](#TargetPath). It +specifies the entity set, singleton, or containment navigation property +that contains the related entities. + +If the target is a [simple identifier](#SimpleIdentifier), it MUST +resolve to an entity set or singleton defined in the same entity +container. + +If the target is a [target path](#TargetPath), it MUST resolve to an +entity set, singleton, or direct or indirect containment navigation +property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties +before ending in a containment navigation property, and there MUST NOT +be any non-containment navigation properties prior to the final segment. + +::: {.varjson .rep} +### `$NavigationPropertyBinding` + +The value of `$NavigationPropertyBinding` is an object. It consists of +members whose name is the navigation property binding path and whose +value is a string containing the navigation property binding target. If +the target is in the same entity container, the target MUST NOT be +prefixed with the qualified entity container name. +::: + +::: {.varjson .example} +Example 35: for an entity set in the same container as the enclosing +entity set `Categories` +```json +"Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "SomeSet" + } +} +``` +::: + +::: {.varjson .example} +Example 36: for an entity set in any container in scope +```json +"Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "SomeModel.SomeContainer/SomeSet" + } +} +``` +::: + +::: {.varjson .example} +Example 37: binding `Supplier` on `Products` contained within +`Categories` – binding applies to all suppliers of all products of all categories +```json +"Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products/Supplier": "Suppliers" + } +} +``` +::: + + + + + +## 13.5 Action Import + +Action imports sets are top-level resources that are never included in +the service document. + +An action import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An action import MUST specify the name of an unbound action in scope. + +If the imported action returns an entity or a collection of entities, a +[simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +::: {.varjson .rep} +### Action Import Object + +An action import is represented as a member of the entity container +object whose name is the name of the action import and whose value is an +object. + +The action import object MUST contain the member `$Action`. + +It MAY contain the member `$EntitySet`. + +It MAY also contain [annotations](#Annotation). + +### `$Action` + +The value of `$Action` is a string containing the qualified name of an +unbound action. + +### `$EntitySet` + +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. +::: + + +## 13.6 Function Import + +Function imports sets are top-level resources. + +A function import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A function import MUST specify the name of an unbound function in scope. +All [unbound overloads](#BoundorUnboundActionorFunctionOverloads) of the +imported function can be invoked from the entity container. + +If the imported function returns an entity or a collection of entities, +a [simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +A function import for a parameterless function MAY indicate whether it +is included in the service document. If not explicitly indicated, it is +not included. + +::: {.varjson .rep} +### Function Import Object + +A function import is represented as a member of the entity container +object whose name is the name of the function import and whose value is +an object. + +The function import object MUST contain the member `$Function`. + +It MAY contain the members `$EntitySet` and `$IncludeInServiceDocument`. + +It MAY also contain [annotations](#Annotation). + +### `$Function` + +The value of `$Function` is a string containing the qualified name of an +unbound function. + +### `$EntitySet` + +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. + +### `$IncludeInServiceDocument` + +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `false`. +::: + + +------- + +# 14 Vocabulary and Annotation + +Vocabularies and annotations provide the ability to annotate metadata as +well as instance data, and define a powerful extensibility point for +OData. An [*annotation*](#Annotation) applies a [*term*](#Term) to a +model element and defines how to calculate a value for the applied term. + +*Metadata annotations* are terms applied to model elements. Behaviors or +constraints described by a metadata annotation must be consistent with +the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity +type, property, function, action, or parameter. For example, a metadata +annotation may define ranges of valid values for a particular property. +Metadata annotations are applied in CSDL documents describing or +referencing an entity model. + +*Instance annotations* are terms applied to a particular instance within +an OData payload, such as described in [OData-JSON](#ODataJSON). An +instance annotation can be used to define additional information +associated with a particular result, entity, property, or error. For +example, whether a property is read-only for a particular instance. +Where the same annotation is defined at both the metadata and instance +level, the instance-level annotation overrides the annotation specified +at the metadata level. Annotations that apply across instances should be +specified as metadata annotations. + +A *vocabulary* is a schema containing a set of terms where each +[term](#Term) is a named metadata extension. Anyone can define a +vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary +[OData-VocCore](#ODataVocCore). + +A [term](#Term) can be used to: +- Extend model elements and type instances +with additional information. +- Map instances of annotated structured +types to an interface defined by the term type; i.e. annotations allow +viewing instances of a structured type as instances of a differently +structured type specified by the applied term. + +A service SHOULD NOT require a client to interpret annotations. Clients +SHOULD ignore invalid or unknown terms and silently treat unexpected or +invalid values (including invalid type, invalid literal expression, +invalid targets, etc.) as an unknown value for the term. Unknown or +invalid annotations should never result in an error, as long as the +payload remains well-formed. + +::: {.varjson .example} +Example 38: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` +```json +"Product": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": { + "$Type": "Edm.Int32" + }, + "Name": { + "$Nullable": true + }, + "Description": { + "$Nullable": true + }, + "@UI.DisplayName": { + "$Path": "Name" + }, + "@SearchVocabulary.SearchResult": { + "Title": { + "$Path": "Name" + }, + "Abstract": { + "$Path": "Description" + }, + "Url": { + "$Apply": [ + "Products(", + { + "$Path": "ID" + }, + ")" + ], + "$Function": "odata.concat" + } + } +} +``` +::: + + +## 14.1 Term + +A term allows annotating a model element or OData resource +representation with additional data. + +The term's name is a [simple identifier](#SimpleIdentifier) that MUST be +unique within its schema. + +The term's type MUST be a type in scope, or a collection of a type in +scope. + +::: {.varjson .rep} +### Term Object + +A term is represented as a member of the schema object whose name is the +unqualified name of the term and whose value is an object. + +The term object MUST contain the member `$Kind` with a string value of +`Term`. + +It MAY contain the members `$Type`, `$Collection`, +[`$AppliesTo`](#Applicability), [`$Nullable`](#Nullable), +[`$MaxLength`](#MaxLength), [`$Precision`](#Precision), +[`$Scale`](#Scale), [`$SRID`](#SRID), and `$DefaultValue`, as well as +[`$Unicode`](#Unicode) for 4.01 and greater payloads. + +It MAY contain [annotations](#Annotation). + +### `$Type` and `$Collection` + +For single-valued terms the value of `$Type` is the qualified name of +the term's type. + +For collection-valued terms the value of `$Type` is the qualified name +of the term's item type, and the member `$Collection` MUST be present +with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. + +### `$DefaultValue` + +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the term, see +[OData-JSON](#ODataJSON). + +Note: the `$DefaultValue` member is purely for documentation and +isomorphy to [OData-CSDLXML](#ODataCSDL). Annotations in +CSDL JSON documents MUST always specify an explicit value. +::: + + +### 14.1.1 Specialized Term + +A term MAY specialize another term in scope by specifying it as its base +term. + +When applying a specialized term, the base term MUST also be applied +with the same qualifier, and so on until a term without a base term is +reached. + +::: {.varjson .rep} +### `$BaseTerm` + +The value of `$BaseTerm` is the qualified name of the base term. +::: + + +### 14.1.2 Applicability + +The applicability of a term MAY be restricted to a list of model +elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be +extended in future versions of the vocabulary. As the intended usage may +evolve over time, clients SHOULD be prepared for any term to be applied +to any model element and SHOULD be prepared to handle unknown values +within the list of model constructs. Applicability is expressed using +the following symbolic values: + +Symbolic Value|Model Element +--------------|------------- +`Action` |Action +`ActionImport` |Action Import +`Annotation` |Annotation +`Apply` |Application of a client-side function in an annotation +`Cast` |Type Cast annotation expression +`Collection` |Entity Set or collection-valued Property or Navigation Property +`ComplexType` |Complex Type +`EntityContainer` |Entity Container +`EntitySet` |Entity Set +`EntityType` |Entity Type +`EnumType` |Enumeration Type +`Function` |Function +`FunctionImport` |Function Import +`If` |Conditional annotation expression +`Include` |Reference to an Included Schema +`IsOf` |Type Check annotation expression +`LabeledElement` |Labeled Element expression +`Member` |Enumeration Member +`NavigationProperty` |Navigation Property +`Null` |Null annotation expression +`OnDelete` |On-Delete Action of a navigation property +`Parameter` |Action of Function Parameter +`Property` |Property of a structured type +`PropertyValue` |Property value of a Record annotation expression +`Record` |Record annotation expression +`Reference` |Reference to another CSDL document +`ReferentialConstraint` |Referential Constraint of a navigation property +`ReturnType` |Return Type of an Action or Function +`Schema` |Schema +`Singleton` |Singleton +`Term` |Term +`TypeDefinition` |Type Definition +`UrlRef` |UrlRef annotation expression + +::: {.varjson .rep} +### `$AppliesTo` + +The value of `$AppliesTo` is an array whose items are strings containing +symbolic values from the table above that identify model elements the +term is intended to be applied to. +::: + +::: {.varjson .example} +Example 39: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData-VocCore](#ODataVocCore)) +```json +"IsURL": { + "$Kind": "Term", + "$Type": "Core.Tag", + "$DefaultValue": true, + "$AppliesTo": [ + "Property" + ], + "@Core.Description": "Properties and terms annotated with this term +MUST contain a valid URL", + "@Core.RequiresType": "Edm.String" +} +``` +::: + + + +## 14.2 Annotation + +An annotation applies a [term](#Term) to a model element and defines how +to calculate a value for the term application. Both term and model +element MUST be in scope. Section 14.1.2 specifies which model elements +MAY be annotated with a term. + +The value of an annotation is specified as an *annotation expression*, +which is either a [constant expression](#ConstantExpression) +representing a constant value, or a [dynamic +expression](#DynamicExpression). The most common construct for assigning +an annotation value is a [path expression](#ValuePath) that refers to a +property of the same or a related structured type. + +::: {.varjson .rep} +### Annotation Member + +An annotation is represented as a member whose name consists of an at +(`@`) character, followed by the qualified name of a term, optionally +followed by a hash (`#`) and a [qualifier](#Qualifier). + +The value of the annotation MUST be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +The annotation can be a member of the object representing the model +element it annotates, or a second-level member of the +[`$Annotations`](#AnnotationswithExternalTargeting) member of a schema +object. + +An annotation can itself be annotated. Annotations on annotations are +represented as a member whose name consists of the annotation name +(including the optional qualifier), followed by an at (`@`) character, +followed by the qualified name of a term, optionally followed by a hash +(`#`) and a [qualifier](#Qualifier). +::: + +::: {.varjson .example} +Example 40: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value +```json +"AmountInReportingCurrency": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Scale": 0, + "@Measures.ISOCurrency": "USD", + "@Measures.ISOCurrency@Core.Description": "The parent company's currency" +}, +"AmountInTransactionCurrency": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Scale": 0, + "@Measures.ISOCurrency": { + "$Path": "Currency" + } +}, +"Currency": { + "$Nullable": true, + "$MaxLength": 3 +} +``` +::: + + + +If an entity type or complex type is annotated with a term that itself +has a structured type, an instance of the annotated type may be viewed +as an "instance" of the term, and the qualified term name may be used as +a [term-cast segment](#TermCast) in path expressions. + +Structured types "inherit" annotations from their direct or indirect +base types. If both the type and one of its base types is annotated with +the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or +collection-valued annotation values are not merged. Similarly, +properties of a structured type inherit annotations from identically +named properties of a base type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a "Label" +annotation for a UI can propagate from a type definition to all +properties using that type definition and may be overridden at each +property with a more specific label, whereas an annotation marking a +type definition as containing a phone number will propagate to all using +properties but may not be overridden. + +### 14.2.1 Qualifier + +A term can be applied multiple times to the same model element by +providing a qualifier to distinguish the annotations. The qualifier is a +[simple identifier](#SimpleIdentifier). + +The combination of target model element, term, and qualifier uniquely +identifies an annotation. + +::: {.varjson .example} +Example 41: annotation should only be applied to tablet devices +```json +"@UI.DisplayName#Tablet": { + "$Path": "FirstName" +} +``` +::: + + + +### 14.2.2 Target + +The target of an annotation is the model element the term is applied to. + +The target of an annotation MAY be specified indirectly by "nesting" the +annotation within the model element. Whether and how this is possible is +described per model element in this specification. + +The target of an annotation MAY also be specified directly; this allows +defining an annotation in a different schema than the targeted model +element. + +This external targeting is only possible for model elements that are +uniquely identified within their parent, and all their ancestor elements +are uniquely identified within their parent: + +- [Action](#Action) (single or all overloads) +- [Action Import](#ActionImport) +- [Complex Type](#ComplexType) +- [Entity Container](#EntityContainer) +- [Entity Set](#EntitySet) +- [Entity Type](#EntityType) +- [Enumeration Type](#EnumerationType) +- [Enumeration Type Member](#EnumerationTypeMember) +- [Function](#Function) (single or all overloads) +- [Function Import](#FunctionImport) +- [Navigation Property](#NavigationProperty) (via type, entity set, or + singleton) +- [Parameter](#Parameter) of an action or function (single overloads + or all overloads defining the + parameter) +- [Property](#StructuralProperty) (via type, entity set, or singleton) +- [Return Type](#ReturnType) of an action or function (single or all + overloads) +- [Singleton](#Singleton) +- [Type Definition](#TypeDefinition) + +These are the direct children of a schema with a unique name (i.e. +except actions and functions whose overloads to not possess a natural +identifier), and all direct children of an entity container. + +External targeting is possible for actions, functions, their parameters, +and their return type, either in a way that applies to all overloads of +the action or function or all parameters of that name across all +overloads, or in a way that identifies a single overload. + +External targeting is also possible for properties and navigation +properties of singletons or entities in a particular entity set. These +annotations override annotations on the properties or navigation +properties targeted via the declaring structured type. + +The allowed path expressions are: +- [qualified name](#QualifiedName) +of schema child +- [qualified +name](#QualifiedName) of schema child followed by a forward slash and +name of child element +- [qualified +name](#QualifiedName) of structured type followed by zero or more +property, navigation property, or type-cast segments, each segment +starting with a forward slash +- [qualified name](#QualifiedName) +of an entity container followed by a segment containing a singleton or +entity set name and zero or more property, navigation property, or +type-cast segments +- [qualified +name](#QualifiedName) of an action followed by parentheses containing +the [qualified name](#QualifiedName) of the binding parameter *type* of +a bound action overload to identify that bound overload, or by empty +parentheses to identify the unbound overload +- [qualified name](#QualifiedName) of a +function followed by parentheses containing the comma-separated list of +[qualified names](#QualifiedName) of the parameter *types* of a bound +or unbound function overload in the order of their definition in the +function overload +- [qualified +name](#QualifiedName) of an action or function, optionally followed by +parentheses as described in the two previous bullet points to identify a +single overload, followed by a forward slash and either a parameter name +or `$ReturnType` +- [qualified +name](#QualifiedName) of an entity container followed by a segment +containing an action or function import name, optionally followed by a +forward slash and either a parameter name or `$ReturnType` + +- One of the preceding, followed by a forward slash, an at (`@`), the + [qualified name](#QualifiedName) of a term, and optionally a hash + (`#`) and the qualifier of an + annotation + +All [qualified names](#QualifiedName) used in a target path MUST be in +scope. + +::: example +Example 42: Target expressions +``` +MySchema.MyEntityType +MySchema.MyEntityType/MyProperty +MySchema.MyEntityType/MyNavigationProperty +MySchema.MyComplexType +MySchema.MyComplexType/MyProperty +MySchema.MyComplexType/MyNavigationProperty +MySchema.MyEnumType +MySchema.MyEnumType/MyMember +MySchema.MyTypeDefinition +MySchema.MyTerm +MySchema.MyEntityContainer +MySchema.MyEntityContainer/MyEntitySet +MySchema.MyEntityContainer/MySingleton +MySchema.MyEntityContainer/MyActionImport +MySchema.MyEntityContainer/MyFunctionImport +MySchema.MyAction +MySchema.MyAction(MySchema.MyBindingType) +MySchema.MyAction() +MySchema.MyFunction +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType) +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType) +MySchema.MyFunction/MyParameter +MySchema.MyEntityContainer/MyEntitySet/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty +``` +::: + +## 14.3 Constant Expression + +Constant expressions allow assigning a constant value to an applied +term. + +### 14.3.1 Binary + +::: {.varjson .rep} +Binary expressions are represented as a string containing the +base64url-encoded binary value. +::: + +::: {.varjson .example} +Example 43: base64url-encoded binary value (OData) +```json +"@UI.Thumbnail": "T0RhdGE" +``` +::: + + + +### 14.3.2 Boolean + +::: {.varjson .rep} +Boolean expressions are represented as the literals `true` or `false`. +::: + +::: {.varjson .example} +Example 44: +```json +"@UI.ReadOnly": true +``` +::: + + + +### 14.3.3 Date + +::: {.varjson .rep} +Date expressions are represented as a string containing the date value. +The value MUST conform to type `xs:date`, see +[XML-Schema-2](#XML-Schema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData-ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. +::: + +::: {.varjson .example} +Example 45: +```json +"@vCard.birthDay": "2000-01-01" +``` +::: + + + +### 14.3.4 DateTimeOffset + +::: {.varjson .rep} +Datetimestamp expressions are represented as a string containing the +timestamp value. The value MUST conform to type `xs:dateTimeStamp`, see +[XML-Schema-2](#XML-Schema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData-ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). +::: + +::: {.varjson .example} +Example 46: +```json +"@UI.LastUpdated": "2000-01-01T16:00:00.000Z" +``` +::: + + + +### 14.3.5 Decimal + +::: {.varjson .rep} +Decimal expressions are represented as either a number or a string. The +special values `INF`, `-INF`, or `NaN` are represented as strings. +Numeric values are represented as numbers or strings depending on the +media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumbers). +::: + +::: {.varjson .example} +Example 47: default representation as a number +```json +"@UI.Width": 3.14 +``` +::: + +::: {.varjson .example} +Example 48: "safe" representation as a string +```json +"@UI.Width": "3.14" +``` +::: + + + + +### 14.3.6 Duration + +::: {.varjson .rep} +Duration expressions are represented as a string containing the duration +value. The value MUST conform to type `xs:dayTimeDuration`, see +[XML-Schema-2](#XML-Schema2), [section +3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). +::: + +::: {.varjson .example} +Example 49: +```json +"@task.duration": "P7D" +``` +::: + + + +### 14.3.7 Enumeration Member + +::: {.varjson .rep} +Enumeration member expressions are represented as a string containing +the numeric or symbolic enumeration value. +::: + +::: {.varjson .example} +Example 50: single value `Red` with numeric value and symbolic value +```json +"@self.HasPattern": "1" +``` + +```json +"@self.HasPattern": "Red" +``` +::: + +::: {.varjson .example} +Example 51: combined value `Red,Striped` with numeric value 1 + 16 and +symbolic value +```json +"@self.HasPattern": "17" +``` + +```json +"@self.HasPattern": "Red,Striped" +``` +::: + + + + +### 14.3.8 Floating-Point Number + +::: {.varjson .rep} +Floating-point expressions are represented as a number or as a string +containing one of the special values `INF`, `-INF`, or `NaN`. +::: + +::: {.varjson .example} +Example 52: +```json +"@UI.FloatWidth": 3.14 +``` + +```json +"@UI.FloatWidth": "INF" +``` +::: + + + +### 14.3.9 Guid + +::: {.varjson .rep} +Guid expressions are represented as a string containing the uuid value. +The value MUST conform to the rule `guidValue` in +[OData-ABNF](#ODataABNF). +::: + +::: {.varjson .example} +Example 53: +```json +"@UI.Id": "21EC2020-3AEA-1069-A2DD-08002B30309D" +``` +::: + + + +### 14.3.10 Integer + +::: {.varjson .rep} +Integer expressions are represented as either a number or a string, +depending on the media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumbers). +::: + +::: {.varjson .example} +Example 54: default representation as a number +```json +"@An.Int": 42 +``` +::: + +::: {.varjson .example} +Example 55: "safe" representation as a string +```json +"@A.Very.Long.Int": "9007199254740992" +``` +::: + + + + +### 14.3.11 String + +::: {.varjson .rep} +String expressions are represented as a JSON string. +::: + +::: {.varjson .example} +Example 56: +```json +"@UI.DisplayName": "Product Catalog" +``` +::: + + + +### 14.3.12 Time of Day + +::: {.varjson .rep} +Time-of-day expressions are represented as a string containing the +time-of-day value. The value MUST conform to the rule `timeOfDayValue` +in [OData-ABNF](#ODataABNF). +::: + +::: {.varjson .example} +Example 57: +```json +"@UI.EndTime": "21:45:00" +``` +::: + + + +## 14.4 Dynamic Expression + +Dynamic expressions allow assigning a calculated value to an applied +term. + +### 14.4.1 Path Expressions + +Path expressions allow assigning a value to an applied term or term +component. There are two kinds of path expressions: +- A *model path* is used within +[Annotation Path](#AnnotationPath), [Model Element Path](#ModelElementPath), +[Navigation Property Path](#NavigationPropertyPath), and [Property +Path](#PropertyPath) expressions to traverse the model of a service and +resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) `Edm.AnnotationPath`, +`Edm.NavigationPropertyPath`, `Edm.PropertyPath`, and their base types +`Edm.AnyPropertyPath` and `Edm.ModelElementPath`. +- An *instance path* is used within a +[Value Path](#ValuePath) expression to traverse a graph of type +instances and resolves to the value identified by the path. It allows +assigning values to terms or term properties of built-in types other +than the `Edm.*Path` types, or of any model-defined type. + +#### 14.4.1.1 Path Syntax + +Model paths and instance paths share a common syntax which is derived +from the path expression syntax of URLs, see [OData-URL](#ODataURL). + +A path MUST be composed of zero or more path segments joined together by +forward slashes (`/`). + +Paths starting with a forward slash (`/`) are absolute paths, and the +first path segment MUST be the qualified name of a model element, e.g. +an entity container. The remaining path after the second forward slash +is interpreted relative to that model element. + +::: example +Example 58: absolute path to an entity set +``` +/My.Schema.MyEntityContainer/MyEntitySet +``` +::: + +Paths not starting with a forward slash are interpreted relative to the +annotation target, following the rules specified in section "[Path +Evaluation](#PathEvaluation)". + +::: example +Example 59: relative path to a property +``` +Address/City +``` +::: + +If a path segment is a [qualified name](#QualifiedName), it represents a +*type cast*, and the segment MUST be the name of a type +in scope. If the type or instance identified by the preceding path part +cannot be cast to the specified type, the path expression evaluates to +the null value. + +::: example +Example 60: type-cast segment +``` +.../self.Manager/... +``` +::: + +If a path segment starts with an at (`@`) character, it represents a +*term cast*. The at (`@`) character MUST be followed by +a [qualified name](#QualifiedName) that MAY be followed by a hash (`#`) +character and a [simple identifier](#SimpleIdentifier). The [qualified +name](#QualifiedName) preceding the hash character MUST resolve to a +term that is in scope, the [simple identifier](#SimpleIdentifier) +following the hash sign is interpreted as a [qualifier](#Qualifier) for +the term. If the model element or instance identified by the preceding +path part has not been annotated with that term (and if present, with +that qualifier), the term cast evaluates to the null value. Four special +terms are implicitly "annotated" for media entities and stream +properties: + +- `odata.mediaEditLink` +- `odata.mediaReadLink` +- `odata.mediaContentType` +- `odata.mediaEtag` + +::: example +Example 61: term-cast segments +``` +.../@Capabilities.SortRestrictions/... +``` +::: + +If a path segment is a [simple identifier](#SimpleIdentifier), it MUST +be the name of a child model element of the model element identified by +the preceding path part, or a structural or navigation property of the +instance identified by the preceding path part. A sequence of navigation +segments can traverse multiple CSDL documents. The document containing +the path expression only needs to reference the next traversed document +to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document. + +A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path. + +::: example +Example 62: property segments in model path +``` +.../Orders/Items/Product/... +``` +::: + +An instance path MUST NOT contain more than one segment representing a +collection-valued construct, e.g. an entity set or a collection-valued +navigation property that is not followed by a key predicate, or a +collection-valued structural property that is not followed by an index +segment. The result of the expression is the collection of instances +resulting from applying any remaining path segments that operate on a +single-valued expression to each instance in the collection-valued +segment. + +An instance path MAY terminate in a `$count` segment if the previous +segment is collection-valued, in which case the path evaluates to the +number of items in the collection identified by the preceding segment. + +::: example +Example 63: property segments in instance path +``` +.../Addresses/Street +``` + +``` +.../Addresses/$count +``` +::: + +A model path MAY contain path segments starting with a navigation +property, then followed by an at (`@`) character, then followed by the +[qualified name](#QualifiedName) of a term in scope, and optionally +followed by a hash (`#`) character and a [simple +identifier](#SimpleIdentifier) which is interpreted as a +[qualifier](#Qualifier) for the term. If the navigation property has not +been annotated with that term (and if present, with that qualifier), the +path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity +type specified by the navigation property are addressed via a [term-cast +segment](#TermCast). + +::: example +Example 64: model path addressing an annotation on a navigation property +``` +.../Items@Capabilities.InsertRestrictions/Insertable +``` +::: + +An instance path MAY contain path segments starting with an entity set +or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see +[OData-URL](#ODataURL). The key values are either primitive literals or +instance paths. If the key value is a relative instance path, it is +interpreted according to the same rule below as the instance path it is +part of, *not* relative to the instance identified by the preceding path +part. + +::: example +Example 65: instance path with entity set and key predicate +``` +/self.container/SettingsCollection('FeatureXxx')/IsAvailable +``` + +``` +/self.container/Products(ID=ProductID)/Name +``` +::: + +An instance path MAY contain an index segment immediately following a +path segment representing an ordered collection-valued structural +property. The index is zero-based and MUST be an integer literal. +Negative integers count from the end of the collection, with -1 +representing the last item in the collection. Remaining path segments +are evaluated relative to the identified item of the collection. + +::: example +Example 66: instance path with collection-valued structural property and +index segment +``` +Addresses/1 +``` + +``` +Addresses/-1/Street +``` +::: + +#### 14.4.1.2 Path Evaluation + +Annotations MAY be embedded within their target, or specified +separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as +*targeting* in the remainder of this section. + +For annotations embedded within or targeting an entity container, the +path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a +segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules +for paths targeting the corresponding child element. + +For annotations embedded within or targeting an entity set or a +singleton, the path is evaluated starting at the entity set or +singleton, i.e. an empty path resolves to the entity set or singleton, +and non-empty paths MUST follow the rules for annotations targeting the +declared entity type of the entity set or singleton. + +For annotations embedded within or targeting an entity type or complex +type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be +a structural or navigation property of the type, a [type +cast](#TypeCast), or a [term cast](#TermCast). + +For annotations embedded within a structural or navigation property of +an entity type or complex type, the path is evaluated starting at the +directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other +properties of the same type. An empty path resolves to the enclosing +type, and non-empty paths MUST follow the rules for annotations +targeting the directly enclosing type. + +For annotations targeting a structural or navigation property of an +entity type or complex type, the path is evaluated starting at the +*outermost* entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the +first segment of a non-empty path MUST be a structural or navigation +property of the outermost type, a [type cast](#TypeCast), or a [term +cast](#TermCast). + +For annotations embedded within or targeting an action, action import, +function, function import, parameter, or return type, the first segment +of the path MUST be a parameter name or `$ReturnType`. + +#### 14.4.1.3 Annotation Path + +The annotation path expression provides a value for terms or term +properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.AnnotationPath or Edm.ModelElementPath`. Its argument is a [model +path](#PathExpressions) with the following restriction: +- A non-null path MUST resolve to an annotation. + +A term or term property of type `Edm.AnnotationPath` can be annotated +with term `Validation.AllowedTerms` (see +[OData-VocValidation](#ODataVocValidation)) if its intended value is an +annotation path that ends in a term cast with one of the listed terms. + +The value of the annotation path expression is the path itself, not the +value of the annotation identified by the path. This is useful for terms +that reuse or refer to other terms. + +::: {.varjson .rep} +Annotation path expressions are represented as a string containing a +path. +::: + +::: {.varjson .example} +Example 67: +```json +"@UI.ReferenceFacet": "Product/Supplier/@UI.LineItem", +"@UI.CollectionFacet#Contacts": [ + "Supplier/@Communication.Contact", + "Customer/@Communication.Contact" +] +``` +::: + + + +#### 14.4.1.4 Model Element Path + +The model element path expression provides a value for terms or term +properties that specify the [built-in +type](#BuiltInTypesfordefiningVocabularyTerms)` Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions). + +The value of the model element path expression is the path itself, not +the instance(s) identified by the path. + +::: {.varjson .rep} +Model element path expressions are represented as a string containing a +path. +::: + +::: {.varjson .example} +Example 68: +```json +"@org.example.MyFavoriteModelElement": "/self.someAction" +``` +::: + + + +#### 14.4.1.5 Navigation Property Path + +The navigation property path expression provides a value for terms or +term properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. +Its argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is an entity type, or a collection of entity types, +e.g. a navigation property. + +The value of the navigation property path expression is the path itself, +not the entitiy or collection of entities identified by the path. + +::: {.varjson .rep} +Navigation property path expressions are represented as a string +containing a path. +::: + +::: {.varjson .example} +Example 69: +```json +"@UI.HyperLink": "Supplier", + +"@Capabilities.UpdateRestrictions": { + "NonUpdatableNavigationProperties": [ + "Supplier", + "Category" + ] +} +``` +::: + + + +#### 14.4.1.6 Property Path + +The property path expression provides a value for terms or term +properties that specify one of the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is a primitive or complex type, an enumeration type, +a type definition, or a collection of one of these types. + +The value of the property path expression is the path itself, not the +value of the structural property or the value of the term cast +identified by the path. + +::: {.varjson .rep} +Property path expressions are represented as a string containing a path. +::: + +::: {.varjson .example} +Example 70: +```json +"@UI.RefreshOnChangeOf": "ChangedAt", + +"@Capabilities.UpdateRestrictions": { + "NonUpdatableProperties": [ + "CreatedAt", + "ChangedAt" + ] +} +``` +::: + + + +#### 14.4.1.7 Value Path + +The value path expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation +properties of structured types, and structural properties of structured +types. Its argument is an [instance path](#PathExpressions). + +The value of the path expression is the instance or collection of +instances identified by the path. + +::: {.varjson .rep} +### `$Path` + +Path expressions are represented as an object with a single member +`$Path` whose value is a string containing a path. +::: + +::: {.varjson .example} +Example 71: +```json +"@UI.DisplayName": { + "$Path": "FirstName" +}, + +"@UI.DisplayName#second": { + "$Path": "@vCard.Address#work/FullName" +} +``` +::: + + + +### 14.4.2 Comparison and Logical Operators + +Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and +they MAY be used anywhere instead of a Boolean expression. + +Operator|Description +--------|----------- +**Logical Operators**| +`And` |Logical and +`Or` |Logical or +`Not` |Logical negation +**Comparison Operators**| +`Eq` |Equal +`Ne` |Not equal +`Gt` |Greater than +`Ge` |Greater than or equal +`Lt` |Less than +`Le` |Less than or equal +`Has` |Has enumeration flag(s) set +`In` |Is in collection + +The `And` and `Or` operators require two operand expressions that +evaluate to Boolean values. The `Not` operator requires a single operand +expression that evaluates to a Boolean value. For details on null +handling for comparison operators see [OData-URL](#ODataURL). + +The other comparison operators require two operand expressions that +evaluate to comparable values. + +::: {.varjson .rep} +### `$And` and `$Or` + +The `And` and `Or` logical expressions are represented as an object with +a single member whose value is an array with two annotation expressions. +The member name is one of `$And`, or `$Or`. + +It MAY contain [annotations](#Annotation). + +### `$Not` + +Negation expressions are represented as an object with a single member +`$Not` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). + +### `$Eq`, `$Ne`, `$Gt`, `$Ge`, `$Lt`, `$Le`, `$Has`, and `$In` + +All comparison expressions are represented as an object with a single +member whose value is an array with two annotation expressions. The +member name is one of `$Eq`, `$Ne`, `$Gt`, `$Ge`, `$Lt`, `$Le`, `$Has`, +or `$In`. + +They MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 72: +```json +{ + "$And": [ + { + "$Path": "IsMale" + }, + { + "$Path": "IsMarried" + } + ] +}, +{ + "$Or": [ + { + "$Path": "IsMale" + }, + { + "$Path": "IsMarried" + } + ] +}, +{ + "$Not": { + "$Path": "IsMale" + } +}, +{ + "$Eq": [ + null, + { + "$Path": "IsMale" + } + ] +}, +{ + "$Ne": [ + null, + { + "$Path": "IsMale" + } + ] +}, +{ + "$Gt": [ + { + "$Path": "Price" + }, + 20 + ] +}, +{ + "$Ge": [ + { + "$Path": "Price" + }, + 10 + ] +}, +{ + "$Lt": [ + { + "$Path": "Price" + }, + 20 + ] +}, +{ + "$Le": [ + { + "$Path": "Price" + }, + 100 + ] +}, +{ + "$Has": [ + { + "$Path": "Fabric" + }, + "Red" + ] +}, +{ + "$In": [ + { + "$Path": "Size" + }, + [ + "XS", + "S" + ] + ] +} ``` +::: + + + +### 14.4.3 Arithmetic Operators + +Annotations MAY use the following arithmetic expressions which evaluate +to a numeric value. These expressions MAY be combined, and they MAY be +used anywhere instead of a numeric expression of the appropriate type. +The semantics and evaluation rules for each arithmetic expression is +identical to the corresponding arithmetic operator defined in +[OData-URL](#ODataURL). + +Operator|Description +--------|----------- +`Add` |Addition +`Sub` |Subtraction +`Neg` |Negation +`Mul` |Multiplication +`Div` |Division (with integer result for integer operands) +`DivBy` |Division (with fractional result also for integer operands) +`Mod` |Modulo + +The `Neg` operator requires a single operand expression that evaluates +to a numeric value. The other arithmetic operators require two operand +expressions that evaluate to numeric values. + +::: {.varjson .rep} +### `$Neg` + +Negation expressions are represented as an object with a single member +`$Neg` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). + +### `$Add`, `$Sub`, `$Mul`, `$Div`, `$DivBy`, and `$Mod` + +These arithmetic expressions are represented as an object with as single +member whose value is an array with two annotation expressions. The +member name is one of `$Add`, `$Sub`, `$Neg`, `$Mul`, `$Div`, `$DivBy`, +or `$Mod`. + +They MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 73: +```json +{ + "$Add": [ + { + "$Path": "StartDate" + }, + { + "$Path": "Duration" + } + ] +}, +{ + "$Sub": [ + { + "$Path": "Revenue" + }, + { + "$Path": "Cost" + } + ] +}, +{ + "$Neg": { + "$Path": "Height" + } +}, +{ + "$Mul": [ + { + "$Path": "NetPrice" + }, + { + "$Path": "TaxRate" + } + ] +}, +{ + "$Div": [ + { + "$Path": "Quantity" + }, + { + "$Path": "QuantityPerParcel" + } + ] +}, +{ + "$DivBy": [ + { + "$Path": "Quantity" + }, + { + "$Path": "QuantityPerParcel" + } + ] +}, +{ + "$Mod": [ + { + "$Path": "Quantity" + }, + { + "$Path": "QuantityPerParcel" + } + ] +} +``` +::: + + + +### 14.4.4 Apply Client-Side Functions + +The apply expression enables a value to be obtained by applying a +client-side function. The apply expression MAY have operand expressions. +The operand expressions are used as parameters to the client-side +function. + +::: {.varjson .rep} +### `$Apply` + +Apply expressions are represented as an object with a member `$Apply` +whose value is an array of annotation expressions, and a member +`$Function` whose value is a string containing the [qualified +name](#QualifiedName) of the client-side function to be applied. + +It MAY contain [annotations](#Annotation). +::: + + +OData defines the following functions. Services MAY support additional +functions that MUST be qualified with a namespace other than `odata`. +Function names qualified with `odata` are reserved for this +specification and its future versions. + +#### 14.4.4.1 Canonical Functions + +All canonical functions defined in [OData-URL](#ODataURL) can be used as +client-side functions, qualified with the namespace `odata`. The +semantics of these client-side functions is identical to their +counterpart function defined in [OData-URL](#ODataURL). + +For example, the `odata.concat` client-side function takes two or more +expressions as arguments. Each argument MUST evaluate to a primitive or +enumeration type. It returns a value of type `Edm.String` that is the +concatenation of the literal representations of the results of the +argument expressions. Values of primitive types other than `Edm.String` +are represented according to the appropriate alternative in the +`primitiveValue` rule of [OData-ABNF](#ODataABNF), i.e. `Edm.Binary` as +`binaryValue`, `Edm.Boolean` as `booleanValue` etc. + +::: {.varjson .example} +Example 74: +```json +"@UI.DisplayName": { + "$Apply": [ + "Product: ", + { + "$Path": "ProductName" + }, + " (", + { + "$Path": "Available/Quantity" + }, + " ", + { + "$Path": "Available/Unit" + }, + " available)" + ], + "$Function": "odata.concat" +} +``` +::: + + +`ProductName` is of type `String`, `Quantity` in complex type +`Available` is of type `Decimal`, and `Unit` in `Available` is of type +enumeration, so the result of the `Path` expression is represented as +the member name of the enumeration value. + +#### 14.4.4.2 Function `odata.fillUriTemplate` + +The `odata.fillUriTemplate` client-side function takes two or more +expressions as arguments and returns a value of type `Edm.String.` + +The first argument MUST be of type `Edm.String` and specifies a URI +template according to [RFC6570](#rfc6570), the other arguments MUST be +[labeled element expressions](#LabeledElement). Each [labeled element +expression](#LabeledElement) specifies the template parameter name as +its name and evaluates to the template parameter value. + +[RFC6570](#rfc6570) defines three kinds of template parameters: simple +values, lists of values, and key-value maps. + +Simple values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a single primitive value. +The literal representation of this value according to +[OData-ABNF](#ODataABNF) is used to fill the corresponding template +parameter. + +Lists of values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of primitive +values. + +Key-value maps are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of complex +types with two properties that are used in lexicographic order. The +first property is used as key, the second property as value. + +::: {.varjson .example} +Example 75: assuming there are no special characters in values of the +Name property of the Actor entity +```json +{ + "$Apply": [ + "http://host/someAPI/Actors/{actorName}/CV", + { + "$LabeledElement": { + "$Path": "Actor/Name" + }, + "$Name": "self.actorName" + } + ], + "$Function": "odata.fillUriTemplate" +} +``` +::: + + +#### 14.4.4.3 Function `odata.matchesPattern` + +The `odata.matchesPattern` client-side function takes two string +expressions as arguments and returns a Boolean value. + +The function returns true if the second expression evaluates to an +[ECMAScript](#_ECMAScript) (JavaScript) regular expression and +the result of the first argument expression matches that regular +expression, using syntax and semantics of +[ECMAScript](#_ECMAScript) regular expressions. + +::: {.varjson .example} +Example 76: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` +```json +{ + "$Apply": [ + { + "$Path": "FirstName" + }, + "^[^b-d]+$" + ], + "$Function": "odata.matchesPattern" +} +``` +::: + + +#### 14.4.4.4 Function `odata.uriEncode` + +The `odata.uriEncode `client-side function takes one argument of +primitive type and returns the URL-encoded OData literal that can be +used as a key value in OData URLs or in the query part of OData URLs. + +Note: string literals are surrounded by single quotes as required by the +paren-style key syntax. + +::: {.varjson .example} +Example 77: +```json +{ + "$Apply": [ + "http://host/service/Genres({genreName})", + { + "$LabeledElement": { + "$Apply": [ + { + "$Path": "NameOfMovieGenre" + } + ], + "$Function": "odata.uriEncode" + }, + "$Name": "self.genreName" + } + ], + "$Function": "odata.fillUriTemplate" +} +``` +::: + + +### 14.4.5 Cast + +The cast expression casts the value obtained from its single child +expression to the specified type. The cast expression follows the same +rules as the `cast` canonical function defined in +[OData-URL](#ODataURL). + +::: {.varjson .rep} +### `$Cast` + +Cast expressions are represented as an object with a member `$Cast` +whose value is an annotation expression, a member `$Type` whose value is +a string containing the qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +::: {.varjson .example} +Example 78: +```json +"@UI.Threshold": { + "$Cast": { + "$Path": "Average" + }, + "$Type": "Edm.Decimal" +} +``` +::: + + + +### 14.4.6 Collection + +The collection expression enables a value to be obtained from zero or +more item expressions. The value calculated by the collection expression +is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type +compatible. + +::: {.varjson .rep} +Collection expressions are represented as arrays with one array item per +item expression within the collection expression. +::: + +::: {.varjson .example} +Example 79: +```json +"@seo.SeoTerms": [ + "Product", + "Supplier", + "Customer" +] +``` +::: + + + +### 14.4.7 If-Then-Else + +The if-then-else expression enables a value to be obtained by evaluating +a *condition expression*. It MUST contain exactly three child +expressions. There is one exception to this rule: if and only if the +if-then-else expression is an item of a collection expression, the third +child expression MAY be omitted, reducing it to an if-then expression. +This can be used to conditionally add an element to a collection. + +The first child expression is the condition and MUST evaluate to a +Boolean result, e.g. the [comparison and logical +operators](#ComparisonandLogicalOperators) can be used. + +The second and third child expressions are evaluated conditionally. The +result MUST be type compatible with the type expected by the surrounding +expression. + +If the first expression evaluates to `true`, the second expression MUST +be evaluated and its value MUST be returned as the result of the +if-then-else expression. If the first expression evaluates to `false` +and a third child element is present, it MUST be evaluated and its value +MUST be returned as the result of the if-then-else expression. If no +third expression is present, nothing is added to the surrounding +collection. + +::: {.varjson .rep} +### `$If` + +Conditional expressions are represented as an object with a member `$If` +whose value is an array of two or three annotation expressions. + +It MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 80: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale`, whose value then determines +the value of the `$If` expression (or so it was long ago) +```json +"@person.Gender": { + "$If": [ + { + "$Path": "IsFemale" + }, + "Female", + "Male" + ] +} +``` +::: + + + +### 14.4.8 Is-Of + +The `is-of` expression checks whether the value obtained from its single +child expression is compatible with the specified type. It returns +`true` if the child expression returns a type that is compatible with +the specified type, and `false` otherwise. + +::: {.varjson .rep} +### `$IsOf` + +Is-of expressions are represented as an object with a member `$IsOf` +whose value is an annotation expression, a member `$Type` whose value is +a string containing an qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +::: {.varjson .example} +Example 81: +```json +"@Self.IsPreferredCustomer": { + "$IsOf": { + "$Path": "Customer" + }, + "$Type": "self.PreferredCustomer" +} +``` +::: + + + +### 14.4.9 Labeled Element + +The labeled element expression assigns a name to its single child +expression. The value of the child expression can then be reused +elsewhere with a [labeled element reference +expression](#LabeledElementReference). + +A labeled element expression MUST contain exactly one child expression. +The value of the child expression is also the value of the labeled +element expression. + +A labeled element expression MUST provide a [simple +identifier](#SimpleIdentifier) value as its name that MUST be unique +within the schema containing the expression. + +::: {.varjson .rep} +### `$LabeledElement` + +Labeled element expressions are represented as an object with a member +`$LabeledElement` whose value is an annotation expression, and a member +`$Name` whose value is a string containing the labeled element's name. + +It MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 82: +```json +"@UI.DisplayName": { + "$LabeledElement": { + "$Path": "FirstName" + }, + "$Name": "CustomerFirstName" +} +``` +::: + + + +### 14.4.10 Labeled Element Reference + +The labeled element reference expression MUST specify the [qualified +name](#QualifiedName) of a [labeled element expression](#LabeledElement) +in scope and returns the value of the identified labeled element +expression as its value. + +::: {.varjson .rep} +### `$LabeledElementReference` + +Labeled element reference expressions are represented as an object with +a member `$LabeledElementReference` whose value is a string containing +an qualified name. +::: + +::: {.varjson .example} +Example 83: +```json +"@UI.DisplayName": { + "$LabeledElementReference": "self.CustomerFirstName" +} +``` +::: + + + +### 14.4.11 Null + +The null expression indicates the absence of a value. The null +expression MAY be annotated. + +::: {.varjson .rep} +Null expressions that do not contain annotations are represented as the +literal `null`. +::: + +::: {.varjson .example} +Example 84: +```json +"@UI.DisplayName": null, +``` +::: + +::: {.varjson .rep} +### `$Null` + +Null expression containing [annotations](#Annotations) are represented +as an object with a member `$Null` whose value is the literal `null`. +::: + +::: {.varjson .example} +Example 85: +```json +"@UI.Address": { + "$Null": null, + "@self.Reason": "Private" +} +``` +::: + + + + +### 14.4.12 Record + +The record expression enables a new entity type or complex type instance +to be constructed. + +A record expression MAY specify the structured type of its result, which +MUST be an entity type or complex type in scope. If not explicitly +specified, the type is derived from the expression's context. + +A record expression contains zero or more property value expressions. +For each single-valued structural or navigation property of the record +expression's type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if +the record expression is the value of an annotation for a term that has +a [base term](#SpecializedTerm) whose type is structured and directly or +indirectly inherits from the type of its base term. In this case, +property values that already have been specified in the annotation for +the base term or its base term etc. need not be specified again. + +For collection-valued properties the absence of a property value +expression is equivalent to specifying an empty collection as its value. + +::: {.varjson .rep} +Record expressions are represented as objects with one member per +property value expression. The member name is the property name, and the +member value is the property value expression. + +The type of a record expression is represented as the `@type` control +information, see [OData-JSON](#ODataJSON). + +It MAY contain [annotations](#Annotation) for itself and its members. +Annotations for record members are prefixed with the member name. +::: + +::: {.varjson .example} +Example 86: this annotation "morphs" the entity type from [example 8](#entitytype) into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service +```json +"@person.Employee": { + "@type": "https://example.org/vocabs/person#org.example.person.Manager", + "@Core.Description": "Annotation on record", + "GivenName": { + "$Path": "FirstName" + }, + "GivenName@Core.Description": "Annotation on record member", + "Surname": { + "$Path": "LastName" + }, + "DirectSupervisor": { + "$Path": "Manager" + }, + "CostCenter": { + "$UrlRef": { + "$Apply": [ + "http://host/anotherservice/CostCenters('{ccid}')", + { + "$LabeledElement": { + "$Path": "CostCenterID" + }, + "$Name": "ccid" + } + ], + "$Function": "odata.fillUriTemplate" + } + } +} +``` +::: + + + +### 14.4.13 URL Reference + +The URL reference expression enables a value to be obtained by sending a +`GET` request. + +The URL reference expression MUST contain exactly one expression of type +`Edm.String`. Its value is treated as a URL that MAY be relative or +absolute; relative URLs are relative to the URL of the document +containing the URL reference expression, or relative to a base URL +specified in a format-specific way. + +The response body of the `GET` request MUST be returned as the result of +the URL reference expression. The result of the URL reference +expression MUST be type compatible with the type expected by the +surrounding expression. + +::: {.varjson .rep} +### `$UrlRef` + +URL reference expressions are represented as an object with a single +member `$UrlRef` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example 87: +```json +"@org.example.person.Supplier": { + "$UrlRef": { + "$Apply": [ + "http://host/service/Suppliers({suppID})", + { + "$LabeledElement": { + "$Apply": [ + { + "$Path": "SupplierId" + } + ], + "$Function": "odata.uriEncode" + }, + "$Name": "suppID" + } + ], + "$Function": "odata.fillUriTemplate" + } +}, + +"@Core.LongDescription#element": { + "$UrlRef": "http://host/wiki/HowToUse" +} +``` +::: + + + +------- + +# 15 Identifier and Path Values + +## 15.1 Namespace + +A namespace is a dot-separated sequence of [simple +identifier](#SimpleIdentifier)s with a maximum length of 511 Unicode +characters (code points). + +## 15.2 Simple Identifier + +A simple identifier is a Unicode character sequence with the following +restrictions: + +- It consists of at least one and at most 128 Unicode characters (code + points). +- The first character MUST be the underscore character (U+005F) or any + character in the Unicode category "Letter (L)" or "Letter number + (Nl)". +- The remaining characters MUST be the underscore character (U+005F) + or any character in the Unicode category "Letter (L)", "Letter + number (Nl)", "Decimal number (Nd)", "Non-spacing mark (Mn)", + "Combining spacing mark (Mc)", "Connector punctuation (Pc)", and + "Other, format (Cf)". + +Non-normatively speaking it starts with a letter or underscore, followed +by at most 127 letters, underscores or digits. + +## 15.3 Qualified Name + +For model elements that are direct children of a schema: the namespace +or alias of the schema that defines the model element, followed by a dot +and the name of the model element, see rule `qualifiedTypeName` in +[OData‑ABNF](#ODataABNF). + +For built-in [primitive types](#PrimitiveTypes): the name of the type, +prefixed with `Edm` followed by a dot. + +## 15.4 Target Path + +Target paths are used to refer to other model elements. + +The allowed path expressions are: +- The [qualified +name](#QualifiedName) of an entity container, followed by a forward +slash and the name of a container child element +- The target +path of a container child followed by a forward slash and one or more +forward-slash separated property, navigation property, or type-cast +segments + +::: example +Example 88: Target expressions +``` +MySchema.MyEntityContainer/MyEntitySet +MySchema.MyEntityContainer/MySingleton +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp +``` +::: + +------- + +# 16 CSDL Examples + +Following are two basic examples of valid EDM models as represented in +CSDL JSON. These examples demonstrate many of the topics covered above. + + +## 16.1 Products and Categories Example + +::: {.varjson .example} +Example 89: +```json +{ + "$Version": "4.0", + "$EntityContainer": "ODataDemo.DemoService", + "$Reference": { + "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": { + "$Include": [ + { + "$Namespace": "Org.OData.Core.V1", + "$Alias": "Core", + "@Core.DefaultNamespace": true + } + ] + }, + "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.json": { + "$Include": [ + { + "$Namespace": "Org.OData.Measures.V1", + "$Alias": "Measures" + } + ] + } + }, + "ODataDemo": { + "$Alias": "self", + "@Core.DefaultNamespace": true, + "Product": { + "$Kind": "EntityType", + "$HasStream": true, + "$Key": [ + "ID" + ], + "ID": {}, + "Description": { + "$Nullable": true, + "@Core.IsLanguageDependent": true + }, + "ReleaseDate": { + "$Nullable": true, + "$Type": "Edm.Date" + }, + "DiscontinuedDate": { + "$Nullable": true, + "$Type": "Edm.Date" + }, + "Rating": { + "$Nullable": true, + "$Type": "Edm.Int32" + }, + "Price": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "@Measures.ISOCurrency": { + "$Path": "Currency" + } + }, + "Currency": { + "$Nullable": true, + "$MaxLength": 3 + }, + "Category": { + "$Kind": "NavigationProperty", + "$Type": "self.Category", + "$Partner": "Products" + }, + "Supplier": { + "$Kind": "NavigationProperty", + "$Nullable": true, + "$Type": "self.Supplier", + "$Partner": "Products" + } + }, + "Category": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": { + "$Type": "Edm.Int32" + }, + "Name": { + "@Core.IsLanguageDependent": true + }, + "Products": { + "$Kind": "NavigationProperty", + "$Partner": "Category", + "$Collection": true, + "$Type": "self.Product", + "$OnDelete": "Cascade" + } + }, + "Supplier": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": {}, + "Name": { + "$Nullable": true + }, + "Address": { + "$Type": "self.Address" + }, + "Concurrency": { + "$Type": "Edm.Int32" + }, + "Products": { + "$Kind": "NavigationProperty", + "$Partner": "Supplier", + "$Collection": true, + "$Type": "self.Product" + } + }, + "Country": { + "$Kind": "EntityType", + "$Key": [ + "Code" + ], + "Code": { + "$MaxLength": 2 + }, + "Name": { + "$Nullable": true + } + }, + "Address": { + "$Kind": "ComplexType", + "Street": { + "$Nullable": true + }, + "City": { + "$Nullable": true + }, + "State": { + "$Nullable": true + }, + "ZipCode": { + "$Nullable": true + }, + "CountryName": { + "$Nullable": true + }, + "Country": { + "$Kind": "NavigationProperty", + "$Nullable": true, + "$Type": "self.Country", + "$ReferentialConstraint": { + "CountryName": "Name" + } + } + }, + "ProductsByRating": [ + { + "$Kind": "Function", + "$Parameter": [ + { + "$Name": "Rating", + "$Nullable": true, + "$Type": "Edm.Int32" + } + ], + "$ReturnType": { + "$Collection": true, + "$Type": "self.Product" + } + } + ], + "DemoService": { + "$Kind": "EntityContainer", + "Products": { + "$Collection": true, + "$Type": "self.Product", + "$NavigationPropertyBinding": { + "Category": "Categories" + } + }, + "Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "Products" + }, + "@Core.Description": "Product Categories" + }, + "Suppliers": { + "$Collection": true, + "$Type": "self.Supplier", + "$NavigationPropertyBinding": { + "Products": "Products", + "Address/Country": "Countries" + }, + "@Core.OptimisticConcurrency": [ + "Concurrency" + ] + }, + "Countries": { + "$Collection": true, + "$Type": "self.Country" + }, + "MainSupplier": { + "$Type": "self.Supplier", + "$NavigationPropertyBinding": { + "Products": "Products" + }, + "@Core.Description": "Primary Supplier" + }, + "ProductsByRating": { + "$EntitySet": "Products", + "$Function": "self.ProductsByRating" + } + } + } +} +``` +::: + + + +## 16.2 Annotations for Products and Categories Example + +::: {.varjson .example} +Example 90: +```json +{ + "$Version": "4.01", + "$Reference": { + "http://host/service/$metadata": { + "$Include": [ + { + "$Namespace": "ODataDemo", + "$Alias": "target" + } + ] + }, + "http://somewhere/Vocabulary/V1": { + "$Include": [ + { + "$Namespace": "Some.Vocabulary.V1", + "$Alias": "Vocabulary1" + } + ] + } + }, + "External.Annotations": { + "$Annotations": { + "target.Supplier": { + "@Vocabulary1.EMail": null, + "@Vocabulary1.AccountID": { + "$Path": "ID" + }, + "@Vocabulary1.Title": "Supplier Info", + "@Vocabulary1.DisplayName": { + "$Apply": [ + { + "$Path": "Name" + }, + " in ", + { + "$Path": "Address/CountryName" + } + ], + "$Function": "odata.concat" + } + }, + "target.Product": { + "@Vocabulary1.Tags": [ + "MasterData" + ] + } + } + } +} ``` +::: + + +------- + +# 17 Conformance + +Conforming services MUST follow all rules of this specification document +for the types, sets, functions, actions, containers and annotations they +expose. + +In addition, conforming services MUST NOT return 4.01 CSDL constructs +for requests made with `OData-MaxVersion:4.0`. + +Specifically, they + +1. MUST NOT include properties in derived types that overwrite a +property defined in the base type + +2. MUST NOT include `Edm.Untyped` + +3. MUST NOT use [path syntax](#PathSyntax) added with 4.01 + +4. MUST NOT use `Edm.ModelElementPath` and `Edm.AnyPropertyPath` + +5. MUST NOT specify [referential constraints](#ReferentialConstraint) +to complex types and navigation properties + +6. MUST NOT include a non-abstract entity type with no inherited or +defined [entity key](#Key) + +7. MUST NOT include the +[`Core.DefaultNamespace`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#DefaultNamespace) +annotation on [included schemas](#IncludedSchema) + +8. MUST NOT return the Unicode facet for terms, parameters, and return +types + +9. MUST NOT include collections of `Edm.ComplexType` or `Edm.Untyped` + +10. MUST NOT specify a key as a property of a related entity + +11. SHOULD NOT include new/unknown values for +[`$AppliesTo`](#Applicability) + + +12. MAY include new CSDL annotations + +In addition, OData 4.01 services: + +13. SHOULD NOT have identifiers within a uniqueness scope (e.g. a +schema, a structural type, or an entity container) that differ only by +case + +Conforming clients MUST be prepared to consume a model that uses any or +all constructs defined in this specification, including custom +annotations, and MUST ignore constructs not defined in this version of +the specification. + +------- + +# Appendix A. References + + + +This appendix contains the normative and informative references that are used in this document. + +While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity. + +## A.1 Normative References + +The following documents are referenced in such a way that some or all of their content constitutes requirements of this document. + +###### [OData-v4.02] +- _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: + - _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html + - _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + +###### [ECMAScript] +_ECMAScript 2016 Language Specification, 7th Edition_. June 2016. Standard ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm. + +###### [EPSG] +_European Petroleum Survey Group (EPSG)_. http://www.epsg.org/. + +###### [OData-ABNF] +_OData ABNF Construction Rules Version 4.01_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-CSDL-Schema] +_OData CSDL JSON Schema_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-CSDL-JSON] +_OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-CSDL-XML] +_OData Common Schema Definition Language (CSDL) XML Representation Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-EDM] +_OData EDM XML Schema_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-EDMX] +_OData EDM XML Schema_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-JSON] +_OData JSON Format Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-Protocol] +_OData Version 4.01 Part 1: Protocol_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-URL] +_OData Version 4.01 Part 2: URL Conventions_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocCore] +_OData Vocabularies Version 4.0: Core Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocMeasures] +_OData Vocabularies Version 4.0: Measures Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocValidation] +_OData Vocabularies Version 4.0: Validation Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [RFC2119] +_Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997_. +https://www.rfc-editor.org/info/rfc2119. + +###### [RFC6570] +_Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template”, RFC 6570, March 2012_. +http://tools.ietf.org/html/rfc6570. + +###### [RFC7493] +_Bray, T., Ed., "The I-JSON Message Format", RFC7493, March 2015_. +https://tools.ietf.org/html/rfc7493. + +###### [RFC8174] +_Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017_. +http://www.rfc-editor.org/info/rfc8174. + +###### [RFC8259] +_Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, December 2017_. +http://tools.ietf.org/html/rfc8259. + +###### [XML-1.1] +_Extensible Markup Language (XML) 1.1 (Second Edition)_. F. Yergeau, E. Maler, J. Cowan, T. Bray, C. M. Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August 2006. +http://www.w3.org/TR/2006/REC-xml11-20060816. Latest version available at http://www.w3.org/TR/xml11/. + +###### [XML-Base] +_XML Base (Second Edition)_. J. Marsh, R. Tobin, Editors, W3C Recommendation, 28 January 2009. +http://www.w3.org/TR/2009/REC-xmlbase-20090128/. Latest version available at http://www.w3.org/TR/xmlbase/. +###### [XML-Schema-1] +_W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures_. D. Beech, M. Maloney, C. M. Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, Editors, W3C Recommendation, 5 April 2012. +http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-1/. + +###### [XML-Schema-2] +_W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes_. D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April 2012. +http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-2/. + +## A.2 Informative References + +###### [OpenUI5] +_OpenUI5 Version 1.40.10 - OData V4 Metadata JSON Format_. +https://openui5.hana.ondemand.com/1.40.10/#docs/guide/87aac894a40640f89920d7b2a414499b.html. + +------- + +# Appendix B. Table of JSON Objects and Members + +::: toc +- [Document Object](#DocumentObject1) + - [`$Version`](#Version1.1) + - [`$EntityContainer`](#EntityContainer1.2) + - [`$Reference`](#Reference1.3) +- [Reference Object](#ReferenceObject2) + - [`$Include`](#Include2.1) + - [`$Namespace`](#Namespace2.2) + - [`$Alias`](#Alias2.3) + - [`$IncludeAnnotations`](#IncludeAnnotations2.4) + - [`$TermNamespace`](#TermNamespace2.5) + - [`$Qualifier`](#Qualifier2.6) + - [`$TargetNamespace`](#TargetNamespace2.7) +- [Schema Object](#SchemaObject3) + - [`$Alias`](#Alias3.1) + - [`$Annotations`](#Annotations3.2) +- [Entity Type Object](#EntityTypeObject4) + - [`$BaseType`](#BaseType4.1) + - [`$Abstract`](#Abstract4.2) + - [`$OpenType`](#OpenType4.3) + - [`$HasStream`](#HasStream4.4) + - [`$Key`](#Key4.5) +- [Property Object](#PropertyObject5) + - [`$Type`](#Type5.1) + - [`$Collection`](#Collection5.2) + - [`$Nullable`](#Nullable5.3) + - [`$MaxLength`](#MaxLength5.4) + - [`$Precision`](#Precision5.5) + - [`$Scale`](#Scale5.6) + - [`$Unicode`](#Unicode5.7) + - [`$SRID`](#SRID5.8) + - [`$DefaultValue`](#DefaultValue5.9) +- [Navigation Property Object](#NavigationPropertyObject6) + - [`$Type`](#Type6.1) + - [`$Collection`](#Collection6.2) + - [`$Nullable`](#Nullable6.3) + - [`$Partner`](#Partner6.4) + - [`$ContainsTarget`](#ContainsTarget6.5) + - [`$ReferentialConstraint`](#ReferentialConstraint6.6) + - [`$OnDelete`](#OnDelete6.7) +- [Complex Type Object](#ComplexTypeObject7) + - [`$BaseType`](#BaseType7.1) + - [`$Abstract`](#Abstract7.2) + - [`$OpenType`](#OpenType7.3) +- [Enumeration Type Object](#EnumerationTypeObject8) + - [`$UnderlyingType`](#UnderlyingType8.1) + - [`$IsFlags`](#IsFlags8.2) +- [Enumeration Member Object](#EnumerationMemberObject9) +- [Type Definition Object](#TypeDefinitionObject10) + - [`$UnderlyingType`](#UnderlyingType10.1) +- [Action Overload Object](#ActionOverloadObject11) +- [Function Overload Object](#FunctionOverloadObject12) + - [`$IsBound`](#IsBound12.1) + - [`$EntitySetPath`](#EntitySetPath12.2) + - [`$IsComposable`](#IsComposable12.3) + - [`$ReturnType`](#ReturnType12.4) + - [`$Type`](#Type12.5) + - [`$Collection`](#Collection12.6) + - [`$Nullable`](#Nullable12.7) + - [`$Parameter`](#Parameter12.8) +- [Parameter Object](#ParameterObject13) + - [`$Name`](#Name13.1) + - [`$Type`](#Type13.2) + - [`$Collection`](#Collection13.3) + - [`$Nullable`](#Nullable13.4) +- [Entity Container Object](#EntityContainerObject14) + - [`$Extends`](#Extends14.1) +- [Entity Set Object](#EntitySetObject15) + - [`$Collection`](#Collection15.1) + - [`$Type`](#Type15.2) + - [`$IncludeInServiceDocument`](#IncludeInServiceDocument15.3) +- [Singleton Object](#SingletonObject16) + - [`$Type`](#Type16.1) + - [`$Nullable`](#Nullable16.2) + - [`$NavigationPropertyBinding`](#NavigationPropertyBinding16.3) +- [Action Import Object](#ActionImportObject17) + - [`$Action`](#Action17.1) + - [`$EntitySet`](#EntitySet17.2) +- [Function Import Object](#FunctionImportObject18) + - [`$Function`](#Function18.1) + - [`$EntitySet`](#EntitySet18.2) + - [`$IncludeInServiceDocument`](#IncludeInServiceDocument18.3) +- [Term Object](#TermObject19) + - [`$Type`](#Type19.1) + - [`$Collection`](#Collection19.2) + - [`$DefaultValue`](#DefaultValue19.3) + - [`$BaseTerm`](#BaseTerm19.4) + - [`$AppliesTo`](#AppliesTo19.5) +- [Annotation Member](#AnnotationMember20) + - [`$Path`](#Path20.1) + - [`$And`](#And20.2) + - [`$Or`](#Or20.3) + - [`$Not`](#Not20.4) + - [`$Eq`](#Eq20.5) + - [`$Ne`](#Ne20.6) + - [`$Gt`](#Gt20.7) + - [`$Ge`](#Ge20.8) + - [`$Lt`](#Lt20.9) + - [`$Le`](#Le20.10) + - [`$Has`](#Has20.11) + - [`$In`](#In20.12) + - [`$Neg`](#Neg20.13) + - [`$Add`](#Add20.14) + - [`$Sub`](#Sub20.15) + - [`$Mul`](#Mul20.16) + - [`$Div`](#Div20.17) + - [`$DivBy`](#DivBy20.18) + - [`$Mod`](#Mod20.19) + - [`$Apply`](#Apply20.20) + - [`$Cast`](#Cast20.21) + - [`$If`](#If20.22) + - [`$IsOf`](#IsOf20.23) + - [`$LabeledElement`](#LabeledElement20.24) + - [`$LabeledElementReference`](#LabeledElementReference20.25) + - [`$Null`](#Null20.26) + - [`$UrlRef`](#UrlRef20.27) +::: + +------- + +# Appendix C. Acknowledgments + +## C.1 Special Thanks + +The work of the OpenUI5 team on the OData V4 Metadata JSON Format, see +[OpenUI5](#_OpenUI5), is gratefully acknowledged, +especially the contributions of +- Thomas Chadzelek (SAP SE) +- Jens Ittel (SAP SE) +- Patric Ksinsik (SAP SE) + +The contributions of the OASIS OData Technical Committee members, +enumerated in [ODataProtocol](#ODataProtocol), are gratefully +acknowledged. + +## C.2 Participants + + + +The following individuals have participated in the creation of this specification and are gratefully acknowledged: + +**OpenC2 TC Members:** + +| First Name | Last Name | Company | +| :--- | :--- | :--- | +Philippe | Alman | Something Networks +Alex | Amirnovman | Company B +Kris | Anderman | Mini Micro +Darren | Anstman | Big Networks + +------- + +# Appendix D. Revision History + + + +| Revision | Date | Editor | Changes Made | +| :--- | :--- | :--- | :--- | +Committee Specification Draft 01|2023-07-14|Michael Pizzo
Ralf Handl
Heiko Theißen| + -The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance. +# Appendix E. Notices + + + +Copyright © OASIS Open 2023. All Rights Reserved.-------------- +Michael Pizzo All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full [Policy](https://www.oasis-open.org/policies-guidelines/ipr/) may be found at the OASIS website. +Ralf Handl +This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. + +This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.-------------- +Michael Pizzo As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata). +Ralf Handl +[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.]-------------- +Michael Pizzo [OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.] +Ralf Handl +[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.] + +The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance. + + + + + + + + + + + + + + + + + + + +-------------- +Michael Pizzo +Ralf Handl + + + +-------------- +Michael Pizzo +Ralf Handl +-------------- +Michael Pizzo +Ralf Handl diff --git a/docs/odata-csdl-json/odata-csdl-json.pdf b/docs/odata-csdl-json/odata-csdl-json.pdf index 5712ba400..e6aa4a6e1 100644 Binary files a/docs/odata-csdl-json/odata-csdl-json.pdf and b/docs/odata-csdl-json/odata-csdl-json.pdf differ diff --git a/docs/odata-csdl-json/styles/odata.css b/docs/odata-csdl-json/styles/odata.css index 7144dbd23..6a591fb26 100644 --- a/docs/odata-csdl-json/styles/odata.css +++ b/docs/odata-csdl-json/styles/odata.css @@ -2,19 +2,25 @@ a:target { background-color: yellow; } +a[href^="#_"], a[href^="#OData"], -a[href^="#rfc"] { +a[href^="#rfc"], +a[href^="#XML-"] { font-weight: bold; } +a[href^="#_"]::before, a[href^="#OData"]::before, -a[href^="#rfc"]::before { +a[href^="#rfc"]::before, +a[href^="#XML-"]::before { content: "["; font-weight: bold; } +a[href^="#_"]::after, a[href^="#OData"]::after, -a[href^="#rfc"]::after { +a[href^="#rfc"]::after, +a[href^="#XML-"]::after { content: "]"; font-weight: bold; } @@ -33,6 +39,11 @@ a[href^="#rfc"]::after { font-style: italic; } +.rep { + border-left: solid windowtext 1pt; + padding-left: 8pt; +} + table { width: auto; } @@ -122,7 +133,8 @@ h2 code, h3 code, h4 code, h5 code, -h6 code { +h6 code, +td>code { font-family: MJXZERO, MJXTEX-T; font-size: 1em; line-height: 0; @@ -133,7 +145,8 @@ h6 code { font-style: initial; } -.example pre { +.example pre, +.rep { margin-left: 40px; } diff --git a/docs/odata-csdl-xml/odata-csdl-xml.html b/docs/odata-csdl-xml/odata-csdl-xml.html index 5d9db0923..17b75a4ed 100644 --- a/docs/odata-csdl-xml/odata-csdl-xml.html +++ b/docs/odata-csdl-xml/odata-csdl-xml.html @@ -17,6 +17,70 @@ margin: 0 0.8em 0.2em -1.6em; vertical-align: middle; } + /* CSS for syntax highlighting */ + pre > code.sourceCode { white-space: pre; position: relative; } + pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } + pre > code.sourceCode > span:empty { height: 1.2em; } + .sourceCode { overflow: visible; } + code.sourceCode > span { color: inherit; text-decoration: inherit; } + div.sourceCode { margin: 1em 0; } + pre.sourceCode { margin: 0; } + @media screen { + div.sourceCode { overflow: auto; } + } + @media print { + pre > code.sourceCode { white-space: pre-wrap; } + pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } + } + pre.numberSource code + { counter-reset: source-line 0; } + pre.numberSource code > span + { position: relative; left: -4em; counter-increment: source-line; } + pre.numberSource code > span > a:first-child::before + { content: counter(source-line); + position: relative; left: -1em; text-align: right; vertical-align: baseline; + border: none; display: inline-block; + -webkit-touch-callout: none; -webkit-user-select: none; + -khtml-user-select: none; -moz-user-select: none; + -ms-user-select: none; user-select: none; + padding: 0 4px; width: 4em; + color: #aaaaaa; + } + pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } + div.sourceCode + { } + @media screen { + pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } + } + code span.al { color: #ff0000; font-weight: bold; } /* Alert */ + code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ + code span.at { color: #7d9029; } /* Attribute */ + code span.bn { color: #40a070; } /* BaseN */ + code span.bu { color: #008000; } /* BuiltIn */ + code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ + code span.ch { color: #4070a0; } /* Char */ + code span.cn { color: #880000; } /* Constant */ + code span.co { color: #60a0b0; font-style: italic; } /* Comment */ + code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ + code span.do { color: #ba2121; font-style: italic; } /* Documentation */ + code span.dt { color: #902000; } /* DataType */ + code span.dv { color: #40a070; } /* DecVal */ + code span.er { color: #ff0000; font-weight: bold; } /* Error */ + code span.ex { } /* Extension */ + code span.fl { color: #40a070; } /* Float */ + code span.fu { color: #06287e; } /* Function */ + code span.im { color: #008000; font-weight: bold; } /* Import */ + code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ + code span.kw { color: #007020; font-weight: bold; } /* Keyword */ + code span.op { color: #666666; } /* Operator */ + code span.ot { color: #007020; } /* Other */ + code span.pp { color: #bc7a00; } /* Preprocessor */ + code span.sc { color: #4070a0; } /* SpecialChar */ + code span.ss { color: #bb6688; } /* SpecialString */ + code span.st { color: #4070a0; } /* String */ + code span.va { color: #19177c; } /* Variable */ + code span.vs { color: #4070a0; } /* VerbatimString */ + code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ @@ -32,17 +96,17 @@

OData Common Schema Definition Language (CSDL) XML Representation Version 4.02

Committee Specification Draft 01

14 July 2023

-

 

+

\(\hbox{}\)

This stage:

-

https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.md (Authoritative)
-https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html
-https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.pdf

+

https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.md (Authoritative)
+https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html
+https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.pdf

Previous stage:

N/A

Latest stage:

-

https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.md (Authoritative)
-https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.html
-https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.pdf

+

https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.md (Authoritative)
+https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.html
+https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.pdf

Technical Committee:

OASIS Open Data Protocol (OData) TC

Chairs:

@@ -52,39 +116,41 @@

Editors:

Ralf Handl (ralf.handl@sap.com), SAP SE
Michael Pizzo (mikep@microsoft.com), Microsoft
Heiko Theißen (heiko.theissen@sap.com), SAP SE

-

Additional artifacts:

+

Additional artifacts:

This prose specification is one component of a Work Product that also includes:

- +

This specification replaces or supersedes:

This specification is related to:

Abstract:

-

OData services are described by an Entity Model (EDM). The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service using, XML, JSON, and other formats. This document (OData CSDL XML Representation) specifically defines the XML representation of CSDL.

+

OData services are described by an Entity Model (EDM). The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service, using XML, JSON, and other formats. This document (OData CSDL JSON Representation) specifically defines the JSON representation of CSDL.

Status:

This document was last revised or approved by the OASIS Open Data Protocol (OData) TC on the above date. The level of approval is also listed above. Check the "Latest stage" location noted above for possible later revisions of this document. Any other numbered Versions and other technical work produced by the Technical Committee (TC) are listed at https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=odata#technical.

TC members should send comments on this specification to the TC's email list. Others should send comments to the TC's public comment list, after subscribing to it by following the instructions at the "Send A Comment" button on the TC's web page at https://www.oasis-open.org/committees/odata/.

This specification is provided under the RF on RAND Terms Mode of the OASIS IPR Policy, the mode chosen when the Technical Committee was established. For information on whether any patents have been disclosed that may be essential to implementing this specification, and any offers of patent licensing terms, please refer to the Intellectual Property Rights section of the TC's web page (https://www.oasis-open.org/committees/odata/ipr.php).

Note that any machine-readable content (Computer Language Definitions) declared Normative for this Work Product is provided in separate plain text files. In the event of a discrepancy between any such plain text file and display content in the Work Product's prose narrative document(s), the content in the separate plain text file prevails.

Key words:

-

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] and [RFC8174] when, and only when, they appear in all capitals, as shown here.

+

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 RFC2119 and RFC8174 when, and only when, they appear in all capitals, as shown here.

Citation format:

When referencing this specification the following citation format should be used:

-

[OData-CSDL-XML-v4.02]

-

OData Common Schema Definition Language (CSDL) XML Representation Version 4.02. Edited by Ralf Handl, Michael Pizzo, and Heiko Theißen. 14 July 2023. OASIS Committee Specification Draft 01. https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.html.

+

[OData-CSDL-JSON-v4.02]

+

OData Common Schema Definition Language (CSDL) JSON Representation Version 4.02. Edited by Ralf Handl, Michael Pizzo, and Heiko Theißen. 14 July 2023. OASIS Committee Specification Draft 01. https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.html.

Notices

Copyright © OASIS Open 2023. All Rights Reserved.

Distributed under the terms of the OASIS IPR Policy.

@@ -96,7 +162,7 @@

Table of Contents


1 Introduction

- - -

1.1 Changes from earlier Versions

- - - - +

OData services are described in terms of an Entity Model. The Common Schema Definition Language (CSDL) defines a representation of the entity model exposed by an OData service using the JavaScript Object Notation (JSON), see RFC8259.

+

This format is based on the OpenUI5 OData V4 Metadata JSON Format, see OpenUI5, with some extensions and modifications made necessary to fully cover OData CSDL Version 4.01.

+

1.1 Changes from Earlier Versions

1.2 Glossary

1.2.1 Definitions of terms

- - -

TODO: find out why we need a \(dummy\) formula to get monospace look as we want it.

1.2.2 Acronyms and abbreviations

1.2.3 Document conventions

-

Keywords defined by this specification use this monospaced font.

+

Keywords defined by this specification use this monospaced font.

Some sections of this specification are illustrated with non-normative examples.

Example 1: text describing an example uses this paragraph style

Non-normative examples use this paragraph style.

All examples in this document are non-normative and informative only. Examples labeled with ⚠ contain advanced concepts or make use of keywords that are defined only later in the text, they can be skipped at first reading.

+

Representation-specific text is indented and marked with vertical lines.

+
+

Representation-Specific Headline

+

Normative representation-specific text

+

All other text is normative unless otherwise labeled.

Here is a customized command line which will generate HTML from this markdown file (named odata-csdl-xml-v4.02-csd01.md). Line breaks are added for readability only:

@@ -147,144 +399,3171 @@

https://github.com/jgm/pandoc/releases/tag/3.1.2.

-
-

2 Section Heading

-

text.

-

2.1 Level 2 Heading

-

text.

-

2.1.1 Level 3 Heading

-

text.

-

2.1.1.1 Level 4 Heading

-

text.

-
2.1.1.1.1 Level 5 Heading
-

This is the deepest level, because six # gets transformed into a Reference tag.

-

2.2 Next Heading

-

text.

-
-

3 Conformance

- + -

(Note: The [OASIS TC Process](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsConfClause) requires that a specification approved by the TC at the Committee Specification Public Review Draft, Committee Specification or OASIS Standard level must include a separate section, listing a set of numbered conformance clauses, to which any implementation of the specification must adhere in order to claim conformance to the specification (or any optional portion thereof). This is done by listing the conformance clauses here. For the definition of "conformance clause," see [OASIS Defined Terms](https://www.oasis-open.org/policies-guidelines/oasis-defined-terms-2018-05-22/#dConformanceClause).

-

See "Guidelines to Writing Conformance Clauses": https://docs.oasis-open.org/templates/TCHandbook/ConformanceGuidelines.html.

-

Remove this note before submitting for publication.)

-
-

Appendix A. References

- + -

This appendix contains the normative and informative references that are used in this document.

-

While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity.

-

A.1 Normative References

-

The following documents are referenced in such a way that some or all of their content constitutes requirements of this document.

-

(Reference sources: For references to IETF RFCs, use the approved citation formats at: https://docs.oasis-open.org/templates/ietf-rfc-list/ietf-rfc-list.html. For references to W3C Recommendations, use the approved citation formats at: https://docs.oasis-open.org/templates/w3c-recommendations-list/w3c-recommendations-list.html. Remove this note before submitting for publication.)

-
[OData-v4.02]
+

2 XML Representation

+

OData CSDL XML is a full representation of the OData Common Schema Definition Language in the Extensible Markup Language (XML) 1.1 (Second Edition) XML-1.1 with further building blocks from the W3C XML Schema Definition Language (XSD) 1.1 as described in XML-Schema-1 and XML-Schema-2.

+

It is an alternative to the CSDL JSON representation defined in OData-CSDLJSON and neither adds nor removes features.

+

2.1 Requesting the XML Representation

+

The OData CSDL XML representation can be requested using the $format query option in the request URL with the media type application/xml, optionally followed by media type parameters, or the case-insensitive abbreviation xml which MUST NOT be followed by media type parameters.

+

Alternatively, this representation can be requested using the Accept header with the media type application/xml, optionally followed by media type parameters.

+

If specified, $format overrides any value specified in the Accept header.

+

The response MUST contain the Content-Type header with a value of application/xml, optionally followed by media type parameters.

+

This specification does not define additional parameters for the media type application/xml.

+

2.2 XML Namespaces

+

In addition to the default XML namespace, the elements and attributes used to describe the entity model of an OData service are defined in one of the following namespaces.

+

2.2.1 Namespace EDMX

+

Elements and attributes associated with the top-level wrapper that contains the CSDL used to define the entity model for an OData Service are qualified with the Entity Data Model for Data Services Packaging namespace:

+

Prior versions of OData used the following namespace for EDMX:

+
  • EDMX version 1.0: http://schemas.microsoft.com/ado/2007/06/edmx
  • -
    [RFC2119]
    -

    Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997 http://www.rfc-editor.org/info/rfc2119.

    -
    [RFC8174]
    -

    Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017 http://www.rfc-editor.org/info/rfc8174.

    -

    A.2 Informative References

    -
    [RFC3552]
    -

    Rescorla, E. and B. Korver, "Guidelines for Writing RFC Text on Security Considerations", BCP 72, RFC 3552, DOI 10.17487/RFC3552, July 2003 https://www.rfc-editor.org/info/rfc3552.

    -
    -

    Appendix B. Safety, Security and Privacy Considerations

    - - -

    (Note: OASIS strongly recommends that Technical Committees consider issues that might affect safety, security, privacy, and/or data protection in implementations of their specification and document them for implementers and adopters. For some purposes, you may find it required, e.g. if you apply for IANA registration.

    -

    While it may not be immediately obvious how your specification might make systems vulnerable to attack, most specifications, because they involve communications between systems, message formats, or system settings, open potential channels for exploit. For example, IETF [[RFC3552](#rfc3552)] lists “eavesdropping, replay, message insertion, deletion, modification, and man-in-the-middle” as well as potential denial of service attacks as threats that must be considered and, if appropriate, addressed in IETF RFCs.

    -

    In addition to considering and describing foreseeable risks, this section should include guidance on how implementers and adopters can protect against these risks.

    -

    We encourage editors and TC members concerned with this subject to read _Guidelines for Writing RFC Text on Security Considerations_, IETF [[RFC3552](#rfc3552)], for more information.

    -

    Remove this note before submitting for publication.)

    -
    -

    Appendix C. Acknowledgments

    - - -

    Note: A Work Product approved by the TC must include a list of people who participated in the development of the Work Product. This is generally done by collecting the list of names in this appendix. This list shall be initially compiled by the Chair, and any Member of the TC may add or remove their names from the list by request. Remove this note before submitting for publication.

    -

    C.1 Special Thanks

    - - -

    Substantial contributions to this document from the following individuals are gratefully acknowledged:

    -

    Participant Name, Affiliation or "Individual Member"

    -

    C.2 Participants

    - - -

    The following individuals have participated in the creation of this specification and are gratefully acknowledged:

    -

    OpenC2 TC Members:

    +

    They are non-normative for this specification.

    +

    In this specification the namespace prefix edmx is used to represent the Entity Data Model for Data Services Packaging namespace, however the prefix name is not prescriptive.

    +

    2.2.2 Namespace EDM

    +

    Elements and attributes that define the entity model exposed by the OData Service are qualified with the Entity Data Model namespace:

    + +

    Prior versions of CSDL used the following namespaces for EDM:

    + +

    They are non-normative for this specification.

    +

    In this specification the namespace prefix edm is used to represent the Entity Data Model namespace, however the prefix name is not prescriptive.

    +

    2.3 XML Schema Definitions

    +

    This specification contains normative XML schemas for the EDMX and EDM namespaces; see OData-EDMX and OData-EDM

    +

    These XML schemas only define the shape of a well-formed CSDL XML document and are not descriptive enough to define what a correct CSDL XML document MUST be in every imaginable use case. This specification document defines additional rules that correct CSDL XML documents MUST fulfill. In case of doubt on what makes a CSDL XML document correct the rules defined in this specification document take precedence.

    +

    2.4 XML Document Order

    +

    Client libraries MUST retain the document order of XML elements for CSDL XML documents because for some elements the order of child elements is significant. This includes, but is not limited to, members of enumeration types and items within a collection expression.

    +

    OData does not impose any ordering constraints on XML attributes within XML elements.

    +

    3 Entity Model

    +

    An OData service exposes a single entity model. This model may be distributed over several schemas, and these schemas may be distributed over several documents.

    +

    A service is defined by a single CSDL document which can be accessed by sending a GET request to <serviceRoot>/$metadata. This document is called the metadata document. It MAY reference other CSDL documents.

    +

    The metadata document contains a single entity container that defines the resources exposed by this service. This entity container MAY extend an entity container defined in a referenced document.

    +

    The model of the service consists of all CSDL constructs used in its entity containers.

    +

    The scope of a CSDL document is the document itself and all schemas included from directly referenced documents. All entity types, complex types and other named model elements in scope (that is, defined in the document itself or a schema of a directly referenced document) can be accessed from a referencing document by their qualified names. This includes the built-in primitive and abstract types.

    +

    Referencing another document may alter the model defined by the referencing document. For instance, if a referenced document defines an entity type derived from an entity type in the referencing document, then an entity set of the service defined by the referencing document may return entities of the derived type. This is identical to the behavior if the derived type had been defined directly in the referencing document.

    +

    Note: referencing documents is not recursive. Only named model elements defined in directly referenced documents can be used within the schema. However, those elements may in turn include or reference model elements defined in schemas referenced by their defining schema.

    +

    3.1 Nominal Types

    +

    A nominal type has a name that MUST be a simple identifier. Nominal types are referenced using their qualified name. The qualified type name MUST be unique within a model as it facilitates references to the element from other parts of the model.

    +

    Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

    +

    3.2 Structured Types

    +

    Structured types are composed of other model elements. Structured types are common in entity models as the means of representing entities and structured properties in an OData service. Entity types and complex types are both structured types.

    +

    Structured Types are composed of zero or more structural properties and navigation properties.

    +

    Open entity types and open complex types allow properties to be added dynamically to instances of the open type.

    +

    3.3 Primitive Types

    +

    Structured types are composed of other structured types and primitive types. OData defines the following primitive types:

    - - - + + - - - + + - - - + + - - - + + - - - + + - -
    First NameLast NameCompanyTypeMeaning
    PhilippeAlmanSomething NetworksEdm.BinaryBinary data
    AlexAmirnovmanCompany BEdm.BooleanBinary-valued logic
    KrisAndermanMini MicroEdm.ByteUnsigned 8-bit integer
    DarrenAnstmanBig NetworksEdm.DateDate without a time-zone offset
    -
    -

    Appendix D. Revision History

    - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    RevisionDateEditorChanges Made
    Edm.DateTimeOffsetDate and time with a time-zone offset, no leap seconds
    Edm.DecimalNumeric values with decimal representation
    Edm.DoubleIEEE 754 binary64 floating-point number (15-17 decimal digits)
    Edm.DurationSigned duration in days, hours, minutes, and (sub)seconds
    specname-v1.0-wd01yyyy-mm-ddEditor NameInitial working draftEdm.Guid16-byte (128-bit) unique identifier
    Edm.Int16Signed 16-bit integer
    Edm.Int32Signed 32-bit integer
    Edm.Int64Signed 64-bit integer
    Edm.SByteSigned 8-bit integer
    Edm.SingleIEEE 754 binary32 floating-point number (6-9 decimal digits)
    Edm.StreamBinary data stream
    Edm.StringSequence of characters
    Edm.TimeOfDayClock time 00:00-23:59:59.999999999999
    Edm.GeographyAbstract base type for all Geography types
    Edm.GeographyPointA point in a round-earth coordinate system
    Edm.GeographyLineStringLine string in a round-earth coordinate system
    Edm.GeographyPolygonPolygon in a round-earth coordinate system
    Edm.GeographyMultiPointCollection of points in a round-earth coordinate system
    Edm.GeographyMultiLineStringCollection of line strings in a round-earth coordinate system
    Edm.GeographyMultiPolygonCollection of polygons in a round-earth coordinate system
    Edm.GeographyCollectionCollection of arbitrary Geography values
    Edm.GeometryAbstract base type for all Geometry types
    Edm.GeometryPointPoint in a flat-earth coordinate system
    Edm.GeometryLineStringLine string in a flat-earth coordinate system
    Edm.GeometryPolygonPolygon in a flat-earth coordinate system
    Edm.GeometryMultiPointCollection of points in a flat-earth coordinate system
    Edm.GeometryMultiLineStringCollection of line strings in a flat-earth coordinate system
    Edm.GeometryMultiPolygonCollection of polygons in a flat-earth coordinate system
    Edm.GeometryCollectionCollection of arbitrary Geometry values
    +

    Edm.Date and Edm.DateTimeOffset follow XML-Schema-2 and use the proleptic Gregorian calendar, allowing the year 0000 (equivalent to 1 BCE) and negative years (year -0001 being equivalent to 2 BCE etc.). The supported date range is service-specific and typically depends on the underlying persistency layer, e.g. SQL only supports years 0001 to 9999.

    +

    Edm.Decimal with a Scale value of floating, Edm.Double, and Edm.Single allow the special numeric values -INF, INF, and NaN.

    +

    Edm.Stream is a primitive type that can be used as a property of an entity type or complex type, the underlying type for a type definition, or the binding parameter or return type of an action or function. Edm.Stream, or a type definition whose underlying type is Edm.Stream, cannot be used in collections or for non-binding parameters to functions or actions.

    +

    Some of these types allow facets, defined in section "Type Facets".

    +

    See rule primitiveLiteral in OData-ABNF for the representation of primitive type values in URLs and OData-JSON for the representation in requests and responses.

    +

    3.4 Built-In Abstract Types

    +

    The following built-in abstract types can be used within a model:

    + +

    Conceptually, these are the abstract base types for primitive types (including type definitions and enumeration types), complex types, entity types, or any type or collection of types, respectively, and can be used anywhere a corresponding concrete type can be used, except:

    + +

    3.5 Built-In Types for defining Vocabulary Terms

    +

    Vocabulary terms can, in addition, use

    + +

    as the type of a primitive term, or the type of a property of a complex type (recursively) that is exclusively used as the type of a term. See section "Path Expressions" for details.

    +

    3.6 Annotations

    +

    Many parts of the model can be decorated with additional information using annotations. Annotations are identified by their term name and an optional qualifier that allows applying the same term multiple times to the same model element.

    +

    A model element MUST NOT specify more than one annotation for a given combination of term and qualifier.


    -

    Appendix E. Example Appendix with subsections

    -

    E.1 Subsection title

    -

    E.1.1 Sub-subsection

    -
    -

    Appendix F. Notices

    - +

    4 CSDL XML Document

    + -

    Copyright © OASIS Open 2023. All Rights Reserved.

    -

    All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.

    -

    This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English.

    -

    The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.

    -

    This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

    -

    As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata).

    -

    [OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.]

    -

    [OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.]

    -

    [OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.]

    -

    The name "OASIS" is a trademark of OASIS, the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance.

    + + +
    +

    Element edmx:Edmx

    +

    The edmx:Edmx element is the root element of a CSDL XML document. It MUST contain the Version attribute and it MUST contain exactly one edmx:DataServices element.

    +

    It MAY contain edmx:Reference elements to reference other CSDL documents.

    +

    Attribute Version

    +

    The Version attribute specifies the OData protocol version of the service. For OData 4.0 responses the value of this attribute MUST be 4.0. For OData 4.01 responses the value of this attribute MUST be 4.01. Services MUST return an OData 4.0 response if the request was made with an OData-MaxVersion header with a value of 4.0.

    +

    Element edmx:DataServices

    +

    The edmx:DataServices element MUST contain one or more edm:Schema elements which define the schemas exposed by the OData service.

    +
    +
    +

    Example 2:

    +
    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    +           Version="4.01">
    +  <edmx:DataServices>
    +    ...
    +  </edmx:DataServices>
    +</edmx:Edmx>
    +
    +

    4.1 Reference

    +

    A reference to an external CSDL document allows to bring part of the referenced document's content into the scope of the referencing document.

    +

    A reference MUST specify a URI that uniquely identifies the referenced document, so two references MUST NOT specify the same URI. The URI SHOULD be a URL that locates the referenced document. If the URI is not dereferencable it SHOULD identify a well-known schema. The URI MAY be absolute or relative URI; relative URLs are relative to the URL of the document containing the reference, or relative to a base URL specified in a format-specific way.

    +

    A reference MAY be annotated.

    +

    The Core.SchemaVersion annotation, defined in OData-VocCore, MAY be used to indicate a particular version of the referenced document. If the Core.SchemaVersion annotation is present, the $schemaversion system query option, defined OData-Protocol, SHOULD be used when retrieving the referenced schema document.

    +
    +

    Element edmx:Reference

    +

    The edmx:Reference element specifies external CSDL documents referenced by the referencing document. The child elements edmx:Include and edmx:IncludeAnnotations specify which parts of the referenced document are available for use in the referencing document.

    +

    The edmx:Reference element MUST contain the Uri attribute, and it MUST contain at least one edmx:Include or edmx:IncludeAnnotations child element.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Uri

    +

    The value of Uri is an absolute or relative URI; relative URIs are relative to the xml:base attribute, see XML-Base.

    +
    +
    +

    Example 3: references to other CSDL documents

    +
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    +           Version="4.0">
    +  <edmx:Reference Uri="http://vocabs.odata.org/capabilities/v1">
    +   ...
    +  </edmx:Reference>
    +  <edmx:Reference Uri="http://vocabs.odata.org/core/v1">
    +    ...
    +  </edmx:Reference>
    +  <edmx:Reference Uri="http://example.org/display/v1">
    +    ...
    +  </edmx:Reference>
    +  <edmx:DataServices>...</edmx:DataServices>
    +</edmx:Edmx>
    +
    +

    4.2 Included Schema

    +

    A reference MAY include zero or more schemas from the referenced document.

    +

    The included schemas are identified via their namespace. The same namespace MUST NOT be included more than once, even if it is declared in more than one referenced document.

    +

    When including a schema, a simple identifier value MAY be specified as an alias for the schema that is used in qualified names instead of the namespace. For example, an alias of display might be assigned to the namespace org.example.vocabularies.display. An alias-qualified name is resolved to a fully qualified name by examining aliases for included schemas and schemas defined within the document.

    +
    +

    If an included schema specifies an alias, the alias MAY be used instead of the namespace within qualified names to identify model elements of the included schema. An alias only provides a more convenient notation, allowing a short string to be substituted for a long namespace. Every model element that can be identified via an alias-qualified name can alternatively be identified via its full namespace-qualified name.

    +
    +

    Aliases are document-global, so all schemas defined within or included into a document MUST have different aliases, and aliases MUST differ from the namespaces of all schemas defined within or included into a document.

    +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    +

    An alias is only valid within the document in which it is declared; a referencing document may define its own aliases for included schemas.

    +
    +

    Element edmx:Include

    +

    The edmx:Include element specifies a schema to include from the referenced CSDL document. It MUST provide the Namespace attribute and it MAY provide the Alias attribute.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Namespace

    +

    The value of Namespace is the namespace of a schema defined in the referenced CSDL document.

    +

    Attribute Alias

    +

    The value of Alias is a simple identifier that can be used in qualified names instead of the namespace.

    +
    +
    +

    Example 4: references to entity models containing definitions of vocabulary terms

    +
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    +           Version="4.0">
    +  <edmx:Reference Uri="http://vocabs.odata.org/capabilities/v1">
    +    <edmx:Include Namespace="Org.OData.Capabilities.V1" />
    +  </edmx:Reference>
    +  <edmx:Reference Uri="http://vocabs.odata.org/core/v1">
    +    <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core">
    +      <Annotation Term="Core.DefaultNamespace" />
    +    </edmx:Include>
    +  </edmx:Reference>
    +  <edmx:Reference Uri="http://example.org/display/v1">
    +    <edmx:Include Alias="UI" Namespace="org.example.display" />
    +  </edmx:Reference>
    +  <edmx:DataServices>...</edmx:DataServices>
    +</edmx:Edmx>
    +
    +

    4.3 Included Annotations

    +

    In addition to including whole schemas with all model constructs defined within that schema, annotations can be included with more flexibility.

    +

    Annotations are selectively included by specifying the namespace of the annotations' term. Consumers can opt not to inspect the referenced document if none of the term namespaces is of interest for the consumer.

    +

    In addition, the qualifier of annotations to be included MAY be specified. For instance, a service author might want to supply a different set of annotations for various device form factors. If a qualifier is specified, only those annotations from the specified term namespace with the specified qualifier (applied to a model element of the target namespace, if present) SHOULD be included. If no qualifier is specified, all annotations within the referenced document from the specified term namespace (taking into account the target namespace, if present) SHOULD be included.

    +

    The qualifier also provides consumers insight about what qualifiers are present in the referenced document. If the consumer is not interested in that particular qualifier, the consumer can opt not to inspect the referenced document.

    +

    In addition, the namespace of the annotations' target MAY be specified. If a target namespace is specified, only those annotations which apply a term form the specified term namespace to a model element of the target namespace (with the specified qualifier, if present) SHOULD be included. If no target namespace is specified, all annotations within the referenced document from the specified term namespace (taking into account the qualifier, if present) SHOULD be included.

    +

    The target namespace also provides consumers insight about what namespaces are present in the referenced document. If the consumer is not interested in that particular target namespace, the consumer can opt not to inspect the referenced document.

    +
    +

    Element edmx:IncludeAnnotations

    +

    The edmx:IncludeAnnotations element specifies the annotations to include from the referenced CSDL document. If no edmx:IncludeAnnotations element is specified, a client MAY ignore all annotations in the referenced document that are not explicitly used in an edm:Path expression of the referencing document.

    +

    The edmx:IncludeAnnotations element MUST provide the TermNamespace attribute, and it MAY provide the Qualifier and TargetNamespace attribute.

    +

    Attribute TermNamespace

    +

    The value of TermNamespace is a namespace.

    +

    Attribute Qualifier

    +

    The value of Qualifier is a simple identifier.

    +

    Attribute TargetNamespace

    +

    The value of TargetNamespace is a namespace.

    +
    +
    +

    Example 5: reference documents that contain annotations

    +
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    +           Version="4.0">
    +  <edmx:Reference Uri="http://odata.org/ann/b">
    +    <edmx:IncludeAnnotations TermNamespace="org.example.validation" />
    +    <edmx:IncludeAnnotations TermNamespace="org.example.display"
    +                             Qualifier="Tablet" />
    +    <edmx:IncludeAnnotations TermNamespace="org.example.hcm"
    +                             TargetNamespace="com.example.Sales" />
    +    <edmx:IncludeAnnotations TermNamespace="org.example.hcm"
    +                             Qualifier="Tablet"
    +                             TargetNamespace="com.example.Person" />
    +  </edmx:Reference>
    +  <edmx:DataServices>...</edmx:DataServices>
    +</edmx:Edmx>
    +
    +
    +

    The following annotations from http://odata.org/ann/b are included:

    + +
    +
    +

    5 Schema

    +

    One or more schemas describe the entity model exposed by an OData service. The schema acts as a namespace for elements of the entity model such as entity types, complex types, enumerations and terms.

    +

    A schema is identified by a namespace. Schema namespaces MUST be unique within the scope of a document and SHOULD be globally unique. A schema cannot span more than one document.

    +

    The schema's namespace is combined with the name of elements in the schema to create unique qualified names, so identifiers that are used to name types MUST be unique within a namespace to prevent ambiguity.

    +

    Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

    +

    The namespace MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    +
    +

    Element edm:Schema

    +

    The edm:Schema element defines a schema. It MUST contain the Namespace attribute and it MAY contain the Alias attribute.

    +

    It MAY contain elements edm:Action, edm:Annotations, edm:Annotation, edm:ComplexType, edm:EntityContainer, edm:EntityType, edm:EnumType, edm:Function, edm:Term, or edm:TypeDefinition.

    +

    Attribute Namespace

    +

    The value of Namespace is the namespace of the schema

    +
    +

    5.1 Alias

    +

    A schema MAY specify an alias which MUST be a simple identifier.

    +

    If a schema specifies an alias, the alias MAY be used instead of the namespace within qualified names to identify model elements of that schema. An alias only provides a more convenient notation, allowing a short string to be substituted for a long namespace. Every model element that can be identified via an alias-qualified name can alternatively be identified via its full namespace-qualified name.

    +

    Aliases are document-global, so all schemas defined within or included into a document MUST have different aliases, and aliases MUST differ from the namespaces of all schemas defined within or included into a document. Aliases defined by a schema can be used throughout the containing document and are not restricted to the schema that defines them.

    +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    +
    +

    Attribute Alias

    +

    The value of Alias is a simple identifier.

    +
    +
    +

    Example 6: schema org.example with an alias and a description for the schema

    +
    <Schema Namespace="org.example" Alias="self">
    +  <Annotation Term="Core.Description" String="Example schema" />
    +  ...
    +</Schema>
    +
    +

    5.2 Annotations with External Targeting

    +
    +

    Element edm:Annotations

    +

    The edm:Annotations element is used to apply a group of annotations to a single model element. It MUST contain the Target attribute and it MAY contain the Qualifier attribute.

    +

    It MUST contain at least one edm:Annotation element.

    +

    Attribute Target

    +

    The value of Target is a path expression identifying the annotation target. It MUST resolve to a model element in scope.

    +

    Attribute Qualifier

    +

    The value of Qualifier is a simple identifier.

    +
    +
    +

    Example 7: annotations should only be applied to tablet devices

    +
    <Annotations Target="org.example.Person" Qualifier="Tablet">
    +  <Annotation Term="Core.Description" String="Dummy" />
    +  ...
    +</Annotations>
    +
    +
    +

    6 Entity Type

    +

    Entity types are nominal structured types with a key that consists of one or more references to structural properties. An entity type is the template for an entity: any uniquely identifiable record such as a customer or order.

    +

    The entity type's name is a simple identifier that MUST be unique within its schema.

    +

    An entity type can define two types of properties. A structural property is a named reference to a primitive, complex, or enumeration type, or a collection of primitive, complex, or enumeration types. A navigation property is a named reference to another entity type or collection of entity types.

    +

    All properties MUST have a unique name within an entity type. Properties MUST NOT have the same name as the declaring entity type. They MAY have the same name as one of the direct or indirect base types or derived types.

    +
    +

    Element edm:EntityType

    +

    The edm:EntityType element MUST contain the Name attribute, and it MAY contain the BaseType, Abstract, OpenType, and HasStream attributes.

    +

    It MAY contain edm:Property and edm:NavigationProperty elements describing the properties of the entity type.

    +

    It MAY contain one edm:Key element.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the entity type's name.

    +
    +
    +

    Example 8: a simple entity type

    +
    <EntityType Name="Employee">
    +  <Key>
    +    <PropertyRef Name="ID" />
    +  </Key>
    +  <Property Name="ID" Type="Edm.String" Nullable="false" />
    +  <Property Name="FirstName" Type="Edm.String" Nullable="false" />
    +  <Property Name="LastName" Type="Edm.String" Nullable="false" />
    +  <NavigationProperty Name="Manager" Type="self.Manager" />
    +</EntityType>
    +
    +

    6.1 Derived Entity Type

    +

    An entity type can inherit from another entity type by specifying it as its base type.

    +

    An entity type inherits the key as well as structural and navigation properties of its base type.

    +

    An entity type MUST NOT introduce an inheritance cycle by specifying a base type.

    +
    +

    Attribute BaseType

    +

    The value of BaseType is the qualified name of the base type.

    +
    +
    +

    Example 9: a derived entity type based on the previous example

    +
    <EntityType Name="Manager" BaseType="self.Employee">
    +  <Property Name="AnnualBudget" Type="Edm.Decimal" />
    +  <NavigationProperty Name="Employees" Type="Collection(self.Employee)" />
    +</EntityType>
    +
    +
    +

    Note: the derived type has the same name as one of the properties of its base type.

    +
    +

    6.2 Abstract Entity Type

    +

    An entity type MAY indicate that it is abstract and cannot have instances.

    +

    For OData 4.0 responses a non-abstract entity type MUST define a key or derive from a base type with a defined key.

    +

    An abstract entity type MUST NOT inherit from a non-abstract entity type.

    +
    +

    Attribute Abstract

    +

    The value of Abstract is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +

    6.3 Open Entity Type

    +

    An entity type MAY indicate that it is open and allows clients to add properties dynamically to instances of the type by specifying uniquely named property values in the payload used to insert or update an instance of the type.

    +

    An entity type derived from an open entity type MUST indicate that it is also open.

    +

    Note: structural and navigation properties MAY be returned by the service on instances of any structured type, whether or not the type is marked as open. Clients MUST always be prepared to deal with additional properties on instances of any structured type, see OData-Protocol.

    +
    +

    Attribute OpenType

    +

    The value of OpenType is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +

    6.4 Media Entity Type

    +

    An entity type that does not specify a base type MAY indicate that it is a media entity type. Media entities are entities that represent a media stream, such as a photo. Use a media entity if the out-of-band stream is the main topic of interest and the media entity is just additional structured information attached to the stream. Use a normal entity with one or more properties of type Edm.Stream if the structured data of the entity is the main topic of interest and the stream data is just additional information attached to the structured data. For more information on media entities see OData-Protocol.

    +

    An entity type derived from a media entity type MUST indicate that it is also a media entity type.

    +

    Media entity types MAY specify a list of acceptable media types using an annotation with term Core.AcceptableMediaTypes, see OData-VocCore.

    +
    +

    Attribute HasStream

    +

    The value of HasStream is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +

    6.5 Key

    +

    An entity is uniquely identified within an entity set by its key. A key MAY be specified if the entity type does not specify a base type that already has a key declared.

    +

    In order to be specified as the type of an entity set or a collection-valued containment navigation property, the entity type MUST either specify a key or inherit its key from its base type.

    +

    In OData 4.01 responses entity types used for singletons or single-valued navigation properties do not require a key. In OData 4.0 responses entity types used for singletons or single-valued navigation properties MUST have a key defined.

    +

    An entity type (whether or not it is marked as abstract) MAY define a key only if it doesn't inherit one.

    +

    An entity type's key refers to the set of properties whose values uniquely identify an instance of the entity type within an entity set. The key MUST consist of at least one property.

    +

    Key properties MUST NOT be nullable and MUST be typed with an enumeration type, one of the following primitive types, or a type definition based on one of these primitive types:

    + +

    Key property values MAY be language-dependent, but their values MUST be unique across all languages and the entity ids (defined in OData-Protocol) MUST be language independent.

    +

    A key property MUST be a non-nullable primitive property of the entity type itself, including non-nullable primitive properties of non-nullable single-valued complex properties, recursively.

    +

    In OData 4.01 the key properties of a directly related entity type MAY also be part of the key if the navigation property is single-valued and not nullable. This includes navigation properties of non-nullable single-valued complex properties (recursively) of the entity type. If a key property of a related entity type is part of the key, all key properties of the related entity type MUST also be part of the key.

    +

    If the key property is a property of a complex property (recursively) or of a directly related entity type, the key MUST specify an alias for that property that MUST be a simple identifier and MUST be unique within the set of aliases, structural and navigation properties of the declaring entity type and any of its base types.

    +

    An alias MUST NOT be defined if the key property is a primitive property of the entity type itself.

    +

    For key properties that are a property of a complex or navigation property, the alias MUST be used in the key predicate of URLs instead of the path to the property because the required percent-encoding of the forward slash separating segments of the path to the property would make URL construction and parsing rather complicated. The alias MUST NOT be used in the query part of URLs, where paths to properties don't require special encoding and are a standard constituent of expressions anyway.

    +
    +

    Element edm:Key

    +

    The edm:Key element MUST contain at least one edm:PropertyRef element.

    +

    Element edm:PropertyRef

    +

    The edm:PropertyRef element MUST contain the Name attribute and MAY contain the Alias attribute.

    +

    Attribute Name

    +

    The value of Name is a path expression leading to a primitive property. The names of the properties in the path are joined together by forward slashes.

    +

    Attribute Alias

    +

    The value of Alias is a simple identifier.

    +
    +
    +

    Example 10: entity type with a simple key

    +
    <EntityType Name="Category">
    +  <Key>
    +    <PropertyRef Name="ID" />
    +  </Key>
    +  <Property Name="ID" Type="Edm.Int32" Nullable="false" />
    +  <Property Name="Name" Type="Edm.String" />
    +</EntityType>
    +
    +
    +

    Example 11: entity type with a simple key referencing a property of a complex type

    +
    <EntityType Name="Category">
    +  <Key>
    +    <PropertyRef Name="Info/ID" Alias="EntityInfoID" />
    +  </Key>
    +  <Property Name="Info" Type="Sales.EntityInfo" Nullable="false" />
    +  <Property Name="Name" Type="Edm.String" />
    +</EntityType>
    +
    +<ComplexType Name="EntityInfo">
    +  <Property Name="ID" Type="Edm.Int32" Nullable="false" />
    +  <Property Name="Created" Type="Edm.DateTimeOffset" />
    +</ComplexType>
    +
    +
    +

    Example 12: entity type with a composite key

    +
    <EntityType Name="OrderLine">
    +  <Key>
    +    <PropertyRef Name="OrderID" />
    +    <PropertyRef Name="LineNumber" />
    +  </Key>
    +  <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
    +  <Property Name="LineNumber" Type="Edm.Int32" Nullable="false" />
    +</EntityType>
    +
    +
    +

    Example 13 (based on example 11): requests to an entity set Categories of type Category must use the alias

    +
    GET http://host/service/Categories(EntityInfoID=1)
    +
    +
    +

    Example 14 (based on example 11): in a query part the value assigned to the name attribute must be used

    +
    GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100
    +
    +
    +

    7 Structural Property

    +

    A structural property is a property of a structured type that has one of the following types:

    + +

    A structural property MUST specify a unique name as well as a type.

    +

    The property's name MUST be a simple identifier. It is used when referencing, serializing or deserializing the property. It MUST be unique within the set of structural and navigation properties of the declaring structured type, and MUST NOT match the name of any navigation property in any of its base types. If a structural property with the same name is defined in any of this type's base types, then the property's type MUST be a type derived from the type specified for the property of the base type and constrains this property to be of the specified subtype for instances of this structured type. The name MUST NOT match the name of any structural or navigation property of any of this type's base types for OData 4.0 responses.

    +

    Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

    +
    +

    Element edm:Property

    +

    The edm:Property element MUST contain the Name and the Type attribute, and it MAY contain the facet attributes Nullable, MaxLength, Unicode, Precision, Scale, SRID, and DefaultValue.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the property's name.

    +
    +
    +

    Example 15: complex type with two properties

    +
    <ComplexType Name="Measurement">
    +  <Property Name="Dimension" Type="Edm.String" Nullable="false" MaxLength="50"
    +            DefaultValue="Unspecified" />
    +  <Property Name="Length" Type="Edm.Decimal" Nullable="false" Precision="18"
    +            Scale="2" />
    +</ComplexType>
    +
    +

    7.1 Type

    +

    The property's type MUST be a primitive type, complex type, or enumeration type in scope, or a collection of one of these types.

    +

    A collection-valued property MAY be annotated with the Core.Ordered term, defined in OData-VocCore, to specify that it supports a stable ordering.

    +

    A collection-valued property MAY be annotated with the Core.PositionalInsert term, defined in OData-VocCore, to specify that it supports inserting items into a specific ordinal position.

    +
    +

    Attribute Type

    +

    For single-valued properties the value of Type is the qualified name of the property's type.

    +

    For collection-valued properties the value of Type is the character sequence Collection( followed by the qualified name of the property's item type, followed by a closing parenthesis ).

    +
    +
    +

    Example 16: property Units that can have zero or more strings as its value

    +
    <Property Name="Units" Type="Collection(Edm.String)" />
    +
    +

    7.2 Type Facets

    +

    Facets modify or constrain the acceptable values of a property.

    +

    For single-valued properties the facets apply to the value of the property. For collection-valued properties the facets apply to the items in the collection.

    +

    7.2.1 Nullable

    +

    A Boolean value specifying whether the property can have the value null.

    +
    +

    Attribute Nullable

    +

    The value of Nullable is one of the Boolean literals true or false.

    +

    For single-valued properties the value true means that the property allows the null value.

    +

    For collection-valued properties the property value will always be a collection that MAY be empty. In this case the Nullable attribute applies to items of the collection and specifies whether the collection MAY contain null values.

    +

    If no value is specified for a single-valued property, the Nullable attribute defaults to true.

    +

    In OData 4.01 responses a collection-valued property MUST specify a value for the Nullable attribute.

    +

    If no value is specified for a collection-valued property, the client cannot assume any default value. Clients SHOULD be prepared for this situation even in OData 4.01 responses.

    +
    +

    7.2.2 MaxLength

    +

    A positive integer value specifying the maximum length of a binary, stream or string value. For binary or stream values this is the octet length of the binary data, for string values it is the character length (number of code points for Unicode).

    +

    If no maximum length is specified, clients SHOULD expect arbitrary length.

    +
    +

    Attribute MaxLength

    +

    The value of MaxLength is a positive integer or the symbolic value max as a shorthand for the maximum length supported for the type by the service.

    +

    Note: the symbolic value max is only allowed in OData 4.0 responses; it is deprecated in OData 4.01. While clients MUST be prepared for this symbolic value, OData 4.01 and greater services MUST NOT return the symbolic value max and MAY instead specify the concrete maximum length supported for the type by the service or omit the attribute entirely.

    +
    +

    7.2.3 Precision

    +

    For a decimal value: the maximum number of significant decimal digits of the property's value; it MUST be a positive integer.

    +

    For a temporal value (datetime-with-timezone-offset, duration, or time-of-day): the number of decimal places allowed in the seconds portion of the value; it MUST be a non-negative integer between zero and twelve.

    +

    Note: service authors SHOULD be aware that some clients are unable to support a precision greater than 28 for decimal properties and 7 for temporal properties. Client developers MUST be aware of the potential for data loss when round-tripping values of greater precision. Updating via PATCH and exclusively specifying modified properties will reduce the risk for unintended data loss.

    +

    Note: duration properties supporting a granularity less than seconds (e.g. minutes, hours, days) can be annotated with term Measures.DurationGranularity, see OData-VocMeasures.

    +
    +

    Attribute Precision

    +

    The value of Precision is a number.

    +

    If not specified for a decimal property, the decimal property has arbitrary precision.

    +

    If not specified for a temporal property, the temporal property has a precision of zero.

    +
    +
    +

    Example 17: Precision facet applied to the DateTimeOffset type

    +
    <Property Name="SuggestedTimes" Type="Collection(Edm.DateTimeOffset)"
    +          Precision="6" />
    +
    +

    7.2.4 Scale

    +

    A non-negative integer value specifying the maximum number of digits allowed to the right of the decimal point, or one of the symbolic values floating or variable.

    +

    The value floating means that the decimal property represents a decimal floating-point number whose number of significant digits is the value of the Precision facet. OData 4.0 responses MUST NOT specify the value floating.

    +

    The value variable means that the number of digits to the right of the decimal point can vary from zero to the value of the Precision facet.

    +

    An integer value means that the number of digits to the right of the decimal point may vary from zero to the value of the Scale facet, and the number of digits to the left of the decimal point may vary from one to the value of the Precision facet minus the value of the Scale facet. If Precision is equal to Scale, a single zero MUST precede the decimal point.

    +

    The value of Scale MUST be less than or equal to the value of Precision.

    +

    Note: if the underlying data store allows negative scale, services may use a Precision with the absolute value of the negative scale added to the actual number of significant decimal digits, and client-provided values may have to be rounded before being stored.

    +
    +

    Attribute Scale

    +

    The value of Scale is a number or one of the symbolic values floating or variable.

    +

    Services SHOULD use lower-case values; clients SHOULD accept values in a case-insensitive manner.

    +

    If not specified, the Scale facet defaults to zero.

    +
    +
    +

    Example 18: Precision=3 and Scale=2. Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3

    +
    <Property Name="Amount32" Type="Edm.Decimal" Precision="3" Scale="2" />
    +
    +
    +

    Example 19: Precision=2 equals Scale. Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2

    +
    <Property Name="Amount22" Type="Edm.Decimal" Precision="2" Scale="2" />
    +
    +
    +

    Example 20: Precision=3 and a variable Scale. Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed values: 12.34, 1234 and 123.4 due to the limited precision.

    +
    <Property Name="Amount3v" Type="Edm.Decimal" Precision="3" Scale="variable" />
    +
    +
    +

    Example 21: Precision=7 and a floating Scale. Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: 1e-102 and 1e97 due to the limited precision.

    +
    <Property Name="Amount7f" Type="Edm.Decimal" Precision="7" Scale="floating" />
    +
    +

    7.2.5 Unicode

    +

    For a string property the Unicode facet indicates whether the property might contain and accept string values with Unicode characters (code points) beyond the ASCII character set. The value false indicates that the property will only contain and accept string values with characters limited to the ASCII character set.

    +

    If no value is specified, the Unicode facet defaults to true.

    +
    +

    Attribute Unicode

    +

    The value of Unicode is one of the Boolean literals true or false. Absence of the attribute means true.

    +
    +

    7.2.6 SRID

    +

    For a geometry or geography property the SRID facet identifies which spatial reference system is applied to values of the property on type instances.

    +

    The value of the SRID facet MUST be a non-negative integer or the special value variable. If no value is specified, the facet defaults to 0 for Geometry types or 4326 for Geography types.

    +

    The valid values of the SRID facet and their meanings are as defined by the European Petroleum Survey Group EPSG.

    +
    +

    Attribute SRID

    +

    The value of SRID is a number or the symbolic value variable.

    +
    +

    7.2.7 Default Value

    +

    A primitive or enumeration property MAY define a default value that is used if the property is not explicitly represented in an annotation or the body of a request or response.

    +

    If no value is specified, the client SHOULD NOT assume a default value.

    +
    +

    Attribute DefaultValue

    +

    Default values of type Edm.String MUST be represented according to the XML escaping rules for character data in attribute values. Values of other primitive types MUST be represented according to the appropriate alternative in the primitiveValue rule defined in OData-ABNF, i.e. Edm.Binary as binaryValue, Edm.Boolean as booleanValue etc.

    +
    +
    +

    8 Navigation Property

    +

    A navigation property allows navigation to related entities. It MUST specify a unique name as well as a type.

    +

    The navigation property's name MUST be a simple identifier. It is used when referencing, serializing or deserializing the navigation property. It MUST be unique within the set of structural and navigation properties of the declaring structured type, and MUST NOT match the name of any structural property in any of its base types. If a navigation property with the same name is defined in any of this type's base types, then the navigation property's type MUST be a type derived from the type specified for the navigation property of the base type, and constrains this navigation property to be of the specified subtype for instances of this structured type. The name MUST NOT match the name of any structural or navigation property of any of this type's base types for OData 4.0 responses.

    +

    Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

    +
    +

    Element edm:NavigationProperty

    +

    The edm:NavigationProperty element MUST contain the Name and Type attributes, and it MAY contain the attributes Nullable, Partner, and ContainsTarget.

    +

    It MAY contain child elements edm:ReferentialConstraint and at most one child element edm:OnDelete.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the navigation property's name.

    +
    +
    +

    Example 22: the Product entity type has a navigation property to a Category, which has a navigation link back to one or more products

    +
    <EntityType Name="Product">
    +  ...
    +  <NavigationProperty Name="Category" Type="self.Category" Nullable="false"
    +                      Partner="Products" />
    +  <NavigationProperty Name="Supplier" Type="self.Supplier" />
    +</EntityType>
    +
    +<EntityType Name="Category">
    +  ...
    +  <NavigationProperty Name="Products" Type="Collection(self.Product)"
    +                      Partner="Category" />
    +</EntityType>
    +
    +

    8.1 Navigation Property Type

    +

    The navigation property's type MUST be an entity type in scope, the abstract type Edm.EntityType, or a collection of one of these types.

    +

    If the type is a collection, an arbitrary number of entities can be related. Otherwise there is at most one related entity.

    +

    The related entities MUST be of the specified entity type or one of its subtypes.

    +

    For a collection-valued containment navigation property the specified entity type MUST have a key defined.

    +

    A collection-valued navigation property MAY be annotated with the Core.Ordered term, defined in OData-VocCore, to specify that it supports a stable ordering.

    +

    A collection-valued navigation property MAY be annotated with the Core.PositionalInsert term, defined in OData-VocCore, to specify that it supports inserting items into a specific ordinal position.

    +
    +

    Attribute Type

    +

    For single-valued navigation properties the value of Type is the qualified name of the navigation property's type.

    +

    For collection-valued navigation properties the value of Type is the character sequence Collection( followed by the qualified name of the navigation property's item type, followed by a closing parenthesis ).

    +
    +

    8.2 Nullable Navigation Property

    +

    A Boolean value specifying whether the declaring type MAY have no related entity. If false, instances of the declaring structured type MUST always have a related entity.

    +

    Nullable MUST NOT be specified for a collection-valued navigation property, a collection is allowed to have zero items.

    +
    +

    Attribute Nullable

    +

    The value of Nullable is one of the Boolean literals true or false. Absence of the attribute means true.

    +
    +

    8.3 Partner Navigation Property

    +

    A navigation property of an entity type MAY specify a partner navigation property. Navigation properties of complex types MUST NOT specify a partner.

    +

    If specified, the partner navigation property is identified by a path relative to the entity type specified as the type of the navigation property. This path MUST lead to a navigation property defined on that type or a derived type. The path MAY traverse complex types, including derived complex types, but MUST NOT traverse any navigation properties. The type of the partner navigation property MUST be the declaring entity type of the current navigation property or one of its parent entity types.

    +

    If the partner navigation property is single-valued, it MUST lead back to the source entity from all related entities. If the partner navigation property is collection-valued, the source entity MUST be part of that collection.

    +

    If no partner navigation property is specified, no assumptions can be made as to whether one of the navigation properties on the target type will lead back to the source entity.

    +

    If a partner navigation property is specified, this partner navigation property MUST either specify the current navigation property as its partner to define a bi-directional relationship or it MUST NOT specify a partner navigation property. The latter can occur if the partner navigation property is defined on a complex type, or if the current navigation property is defined on a type derived from the type of the partner navigation property.

    +
    +

    Attribute Partner

    +

    The value of Partner is the path to the of the partner navigation property.

    +
    +

    8.4 Containment Navigation Property

    +

    A navigation property MAY indicate that instances of its declaring structured type contain the targets of the navigation property, in which case the navigation property is called a containment navigation property.

    +

    Containment navigation properties define an implicit entity set for each instance of its declaring structured type. This implicit entity set is identified by the read URL of the navigation property for that structured type instance.

    +

    Instances of the structured type that declares the navigation property, either directly or indirectly via a property of complex type, contain the entities referenced by the containment navigation property. The canonical URL for contained entities is the canonical URL of the containing instance, followed by the path segment of the navigation property and the key of the contained entity, see OData-URL.

    +

    Entity types used in collection-valued containment navigation properties MUST have a key defined.

    +

    For items of an ordered collection of complex types (those annotated with the Core.Ordered term defined in OData-VocCore the canonical URL of the item is the canonical URL of the collection appended with a segment containing the zero-based ordinal of the item. Items within in an unordered collection of complex types do not have a canonical URL. Services that support unordered collections of complex types declaring a containment navigation property, either directly or indirectly via a property of complex type, MUST specify the URL for the navigation link within a payload representing that item, according to format-specific rules.

    +

    OData 4.0 responses MUST NOT specify a complex type declaring a containment navigation property as the type of a collection-valued property.

    +

    An entity cannot be referenced by more than one containment relationship, and cannot both belong to an entity set declared within the entity container and be referenced by a containment relationship.

    +

    Containment navigation properties MUST NOT be specified as the last path segment in the path of a navigation property binding.

    +

    When a containment navigation property navigates between entity types in the same inheritance hierarchy, the containment is called recursive.

    +

    Containment navigation properties MAY specify a partner navigation property. If the containment is recursive, the relationship defines a tree, thus the partner navigation property MUST be nullable (for the root of the tree) and single-valued (for the parent of a non-root entity). If the containment is not recursive, the partner navigation property MUST NOT be nullable.

    +

    An entity type inheritance chain MUST NOT contain more than one navigation property with a partner navigation property that is a containment navigation property.

    +

    Note: without a partner navigation property, there is no reliable way for a client to determine which entity contains a given contained entity. This may lead to problems for clients if the contained entity can also be reached via a non-containment navigation path.

    +
    +

    Attribute ContainsTarget

    +

    The value of ContainsTarget is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +

    8.5 Referential Constraint

    +

    A single-valued navigation property MAY define one or more referential constraints. A referential constraint asserts that the dependent property (the property defined on the structured type declaring the navigation property) MUST have the same value as the principal property (the referenced property declared on the entity type that is the target of the navigation).

    +

    The type of the dependent property MUST match the type of the principal property, or both types MUST be complex types.

    +

    If the principle property references an entity, then the dependent property must reference the same entity.

    +

    If the principle property's value is a complex type instance, then the dependent property's value must be a complex type instance with the same properties, each with the same values.

    +

    If the navigation property on which the referential constraint is defined is nullable, or the principal property is nullable, then the dependent property MUST also be nullable. If both the navigation property and the principal property are not nullable, then the dependent property MUST NOT be nullable.

    +
    +

    Element edm:ReferentialConstraint

    +

    The edm:ReferentialConstraint element MUST contain the attributes Property and ReferencedProperty.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Property

    +

    The Property attribute specifies the property that takes part in the referential constraint on the dependent structured type. Its value MUST be a path expression resolving to a property of the dependent structured type itself or to a property of a complex property (recursively) of the dependent structured type. The names of the properties in the path are joined together by forward slashes. The path is relative to the dependent structured type declaring the navigation property.

    +

    Attribute ReferencedProperty

    +

    The ReferencedProperty attribute specifies the corresponding property of the principal entity type. Its value MUST be a path expression resolving to a property of the principal entity type itself or to a property of a complex property (recursively) of the principal entity type that MUST have the same type as the property of the dependent entity type. The path is relative to the entity type that is the target of the navigation property.

    +
    +
    +

    Example 23: the category must exist for a product in that category to exist. The CategoryID of the product is identical to the ID of the category, and the CategoryKind property of the product is identical to the Kind property of the category.

    +
    <EntityType Name="Product">
    +  ...
    +  <Property Name="CategoryID" Type="Edm.String" Nullable="false"/>
    +  <Property Name="CategoryKind" Type="Edm.String" Nullable="true" />
    +  <NavigationProperty Name="Category" Type="self.Category" Nullable="false">
    +    <ReferentialConstraint Property="CategoryID" ReferencedProperty="ID" />
    +    <ReferentialConstraint Property="CategoryKind" ReferencedProperty="Kind">
    +      <Annotation Term="Core.Description"
    +                  String="Referential Constraint to non-key property" />
    +    </ReferentialConstraint>
    +  </NavigationProperty>
    +</EntityType>
    +
    +<EntityType Name="Category">
    +  <Key>
    +    <PropertyRef Name="ID" />
    +  </Key>
    +  <Property Name="ID" Type="Edm.String" Nullable="false" />
    +  <Property Name="Kind" Type="Edm.String" Nullable="true" />
    +  ...
    +</EntityType>
    +
    +

    8.6 On-Delete Action

    +

    A navigation property MAY define an on-delete action that describes the action the service will take on related entities when the entity on which the navigation property is defined is deleted.

    +

    The action can have one of the following values:

    + +

    If no on-delete action is specified, the action taken by the service is not predictable by the client and could vary per entity.

    +
    +

    Element edm:OnDelete

    +

    The edm:OnDelete element MUST contain the Action attribute.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Action

    +

    The value of Action is one of the values Cascade, None, SetNull, or SetDefault.

    +
    +
    +

    Example 24: deletion of a category implies deletion of the related products in that category

    +
    <EntityType Name="Category">
    +  ...
    +  <NavigationProperty Name="Products" Type="Collection(self.Product)">
    +    <OnDelete Action="Cascade">
    +      <Annotation Term="Core.Description"
    +                  String="Delete all products in this category" />
    +    </OnDelete>
    +  </NavigationProperty>
    +</EntityType>
    +
    +
    +

    9 Complex Type

    +

    Complex types are keyless nominal structured types. The lack of a key means that instances of complex types cannot be referenced, created, updated or deleted independently of an entity type. Complex types allow entity models to group properties into common structures.

    +

    The complex type's name is a simple identifier that MUST be unique within its schema.

    +

    A complex type can define two types of properties. A structural property is a named reference to a primitive, complex, or enumeration type, or a collection of primitive, complex, or enumeration types. A navigation property is a named reference to an entity type or a collection of entity types.

    +

    All properties MUST have a unique name within a complex type. Properties MUST NOT have the same name as the declaring complex type. They MAY have the same name as one of the direct or indirect base types or derived types.

    +
    +

    Element edm:ComplexType

    +

    The edm:ComplexType element MUST contain the Name attribute, and it MAY contain the BaseType, Abstract, and OpenType attributes.

    +

    It MAY contain edm:Property and edm:NavigationProperty elements describing the properties of the complex type.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the complex type's name.

    +
    +
    +

    Example 25: a complex type used by two entity types

    +
    <ComplexType Name="Dimensions">
    +  <Property Name="Height" Nullable="false" Type="Edm.Decimal" />
    +  <Property Name="Weight" Nullable="false" Type="Edm.Decimal" />
    +  <Property Name="Length" Nullable="false" Type="Edm.Decimal" />
    +</ComplexType>
    +
    +<EntityType Name="Product">
    +  ...
    +  <Property Name="ProductDimensions" Type="self.Dimensions" />
    +  <Property Name="ShippingDimensions" Type="self.Dimensions" />
    +</EntityType>
    +
    +<EntityType Name="ShipmentBox">
    +  ...
    +  <Property Name="Dimensions" Type="self.Dimensions" />
    +</EntityType>
    +
    +

    9.1 Derived Complex Type

    +

    A complex type can inherit from another complex type by specifying it as its base type.

    +

    A complex type inherits the structural and navigation properties of its base type.

    +

    A complex type MUST NOT introduce an inheritance cycle by specifying a base type.

    +

    The rules for annotations of derived complex types are described in section 14.2.

    +
    +

    Attribute BaseType

    +

    The value of BaseType is the qualified name of the base type.

    +
    +

    9.2 Abstract Complex Type

    +

    A complex type MAY indicate that it is abstract and cannot have instances.

    +
    +

    Attribute Abstract

    +

    The value of Abstract is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +

    9.3 Open Complex Type

    +

    A complex type MAY indicate that it is open and allows clients to add properties dynamically to instances of the type by specifying uniquely named property values in the payload used to insert or update an instance of the type.

    +

    A complex type derived from an open complex type MUST indicate that it is also open.

    +

    Note: structural and navigation properties MAY be returned by the service on instances of any structured type, whether or not the type is marked as open. Clients MUST always be prepared to deal with additional properties on instances of any structured type, see OData‑Protocol.

    +
    +

    Attribute OpenType

    +

    The value of OpenType is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +
    +

    10 Enumeration Type

    +

    Enumeration types are nominal types that represent a non-empty series of related values. Enumeration types expose these related values as members of the enumeration.

    +

    The enumeration type's name is a simple identifier that MUST be unique within its schema.

    +

    Although enumeration types have an underlying numeric value, the preferred representation for an enumeration value is the member name. Discrete sets of numeric values should be represented as numeric values annotated with the AllowedValues annotation defined in OData-VocCore.

    +

    Enumeration types marked as flags allow values that consist of more than one enumeration member at a time.

    +
    +

    Element edm:EnumType

    +

    The edm:EnumType element MUST contain the Name attribute, and it MAY contain the UnderlyingType and IsFlags attributes.

    +

    It MUST contain one or more edm:Member elements defining the members of the enumeration type.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the enumeration type's name.

    +
    +
    +

    Example 26: a simple flags-enabled enumeration

    +
    <EnumType Name="FileAccess" UnderlyingType="Edm.Int32" IsFlags="true">
    +  <Member Name="Read"   Value="1" />
    +  <Member Name="Write"  Value="2" />
    +  <Member Name="Create" Value="4" />
    +  <Member Name="Delete" Value="8" />
    +</EnumType>
    +
    +

    10.1 Underlying Integer Type

    +

    An enumeration type MAY specify one of Edm.Byte, Edm.SByte, Edm.Int16, Edm.Int32, or Edm.Int64 as its underlying type.

    +

    If not explicitly specified, Edm.Int32 is used as the underlying type.

    +
    +

    Attribute UnderlyingType

    +

    The value of UnderlyingType is the qualified name of the underlying type.

    +
    +

    10.2 Flags Enumeration Type

    +

    An enumeration type MAY indicate that the enumeration type allows multiple members to be selected simultaneously.

    +

    If not explicitly specified, only one enumeration type member MAY be selected simultaneously.

    +
    +

    Attribute IsFlags

    +

    The value of IsFlags is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +
    +

    Example 27: pattern values can be combined, and some combined values have explicit names

    +
    <EnumType Name="Pattern" UnderlyingType="Edm.Int32" IsFlags="true">
    +  <Member Name="Plain"             Value="0" />
    +  <Member Name="Red"               Value="1" />
    +  <Member Name="Blue"              Value="2" />
    +  <Member Name="Yellow"            Value="4" />
    +  <Member Name="Solid"             Value="8" />
    +  <Member Name="Striped"           Value="16" />
    +  <Member Name="SolidRed"          Value="9" />
    +  <Member Name="SolidBlue"         Value="10" />
    +  <Member Name="SolidYellow"       Value="12" />
    +  <Member Name="RedBlueStriped"    Value="19" />
    +  <Member Name="RedYellowStriped"  Value="21" />
    +  <Member Name="BlueYellowStriped" Value="22" />
    +</EnumType>
    +
    +

    10.3 Enumeration Type Member

    +

    Enumeration type values consist of discrete members.

    +

    Each member is identified by its name, a simple identifier that MUST be unique within the enumeration type. Names are case-sensitive, but service authors SHOULD NOT choose names that differ only in case.

    +

    Each member MUST specify an associated numeric value that MUST be a valid value for the underlying type of the enumeration type.

    +

    Enumeration types can have multiple members with the same value. Members with the same numeric value compare as equal, and members with the same numeric value can be used interchangeably.

    +

    Enumeration members are sorted by their numeric value.

    +

    For flag enumeration types the combined numeric value of simultaneously selected members is the bitwise OR of the discrete numeric member values.

    +
    +

    Element edm:Member

    +

    The edm:Member element MUST contain the Name attribute and it MAY contain the Value attribute.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the enumeration member's name.

    +

    Attribute Value

    +

    If the IsFlags attribute has a value of false, either all members MUST specify an integer value for the Value attribute, or all members MUST NOT specify a value for the Value attribute. If no values are specified, the members are assigned consecutive integer values in the order of their appearance, starting with zero for the first member. Client libraries MUST preserve elements in document order.

    +

    If the IsFlags attribute has a value of true, a non-negative integer value MUST be specified for the Value attribute. A combined value is equivalent to the bitwise OR of the discrete values.

    +
    +
    +

    Example 28: FirstClass has a value of 0, TwoDay a value of 1, and Overnight a value of 2.

    +
    <EnumType Name="ShippingMethod">
    +  <Member Name="FirstClass">
    +    <Annotation Term="Core.Description"
    +                String="Shipped with highest priority" />
    +  </Member>
    +  <Member Name="TwoDay">
    +    <Annotation Term="Core.Description"
    +                String="Shipped within two days" />
    +  </Member>
    +  <Member Name="Overnight">
    +    <Annotation Term="Core.Description"
    +                String="Shipped overnight" />
    +  </Member>
    +</EnumType>
    +
    +
    +

    11 Type Definition

    +

    A type definition defines a specialization of one of the primitive types or of the built-in abstract type Edm.PrimitiveType.

    +

    The type definition's name is a simple identifier that MUST be unique within its schema.

    +

    Type definitions can be used wherever a primitive type is used (other than as the underlying type in a new type definition) and are type-comparable with their underlying types and any type definitions defined using the same underlying type.

    +

    It is up to the definition of a term to specify whether and how annotations with this term propagate to places where the annotated type definition is used, and whether they can be overridden.

    +
    +

    Element edm:TypeDefinition

    +

    The edm:TypeDefinition element MUST contain the Name and UnderlyingType attributes.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the type definition's name.

    +
    +
    +

    Example 29:

    +
    <TypeDefinition Name="Length" UnderlyingType="Edm.Int32">
    +  <Annotation Term="Org.OData.Measures.V1.Unit"
    +              String="Centimeters" />
    +</TypeDefinition>
    +
    +<TypeDefinition Name="Weight" UnderlyingType="Edm.Int32">
    +  <Annotation Term="Org.OData.Measures.V1.Unit"
    +              String="Kilograms" />
    +</TypeDefinition>
    +
    +<ComplexType Name="Size">
    +  <Property Name="Height" Type="self.Length" />
    +  <Property Name="Weight" Type="self.Weight" />
    +</ComplexType>
    +
    +

    11.1 Underlying Primitive Type

    +

    The underlying type of a type definition MUST be a primitive type that MUST NOT be another type definition.

    +
    +

    Attribute UnderlyingType

    +

    The value of UnderlyingType is the qualified name of the underlying type.

    +
    +

    The type definition MAY specify facets applicable to the underlying type. Possible facets are: MaxLength, Unicode, Precision, Scale, or SRID.

    +

    Additional facets appropriate for the underlying type MAY be specified when the type definition is used but the facets specified in the type definition MUST NOT be re-specified.

    +

    For a type definition with underlying type Edm.PrimitiveType no facets are applicable, neither in the definition itself nor when the type definition is used, and these should be ignored by the client.

    +

    Where type definitions are used, the type definition is returned in place of the primitive type wherever the type is specified in a response.

    +
    +

    12 Action and Function

    +

    12.1 Action

    +

    Actions are service-defined operations that MAY have observable side effects and MAY return a single instance or a collection of instances of any type.

    +

    The action's name is a simple identifier that MUST be unique within its schema.

    +

    Actions cannot be composed with additional path segments.

    +

    An action MAY specify a return type that MUST be a primitive, entity or complex type, or a collection of primitive, entity or complex types in scope.

    +

    An action MAY define parameters used during the execution of the action.

    +

    12.2 Action Overloads

    +

    Bound actions support overloading (multiple actions having the same name within the same schema) by binding parameter type. The combination of action name and the binding parameter type MUST be unique within a schema.

    +

    Unbound actions do not support overloads. The names of all unbound actions MUST be unique within a schema.

    +

    An unbound action MAY have the same name as a bound action.

    +
    +

    Element edm:Action

    +

    The edm:Action element MUST contain the Name attribute and it MAY contain the IsBound and EntitySetPath attributes.

    +

    It MAY contain at most one edm:ReturnType element and MAY contain edm:Parameter elements.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the action's name.

    +
    +

    12.3 Function

    +

    Functions are service-defined operations that MUST NOT have observable side effects and MUST return a single instance or a collection of instances of any type.

    +

    The function's name is a simple identifier that MUST be unique within its schema.

    +

    Functions MAY be composable.

    +

    The function MUST specify a return type which MUST be a primitive, entity or complex type, or a collection of primitive, entity or complex types in scope.

    +

    A function MAY define parameters used during the execution of the function.

    +

    12.4 Function Overloads

    +

    Bound functions support overloading (multiple functions having the same name within the same schema) subject to the following rules:

    + +

    Unbound functions support overloading subject to the following rules:

    + +

    An unbound function MAY have the same name as a bound function.

    +

    Note that type definitions can be used to disambiguate overloads for both bound and unbound functions, even if they specify the same underlying type.

    +
    +

    Element edm:Function

    +

    The edm:Function element MUST contain the Name attribute and it MAY contain the IsBound and EntitySetPath attributes.

    +

    It MUST contain one edm:ReturnType element, and it MAY contain edm:Parameter elements.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the action's name.

    +
    +

    12.5 Bound or Unbound Action or Function Overloads

    +

    An action or function overload MAY indicate that it is bound. If not explicitly indicated, it is unbound.

    +

    Bound actions or functions are invoked on resources matching the type of the binding parameter. The binding parameter can be of any type, and it MAY be nullable.

    +

    Unbound actions are invoked from the entity container through an action import.

    +

    Unbound functions are invoked as static functions within a filter or orderby expression, or from the entity container through a function import.

    +
    +

    Attribute IsBound

    +

    The value of IsBound is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +

    12.6 Entity Set Path

    +

    Bound actions and functions that return an entity or a collection of entities MAY specify an entity set path if the entity set of the returned entities depends on the entity set of the binding parameter value.

    +

    The entity set path consists of a series of segments joined together with forward slashes.

    +

    The first segment of the entity set path MUST be the name of the binding parameter. The remaining segments of the entity set path MUST represent navigation segments or type casts.

    +

    A navigation segment names the simple identifier of the navigation property to be traversed. A type-cast segment names the qualified name of the entity type that should be returned from the type cast.

    +
    +

    Attribute EntitySetPath

    +

    The value of EntitySetPath is the entity set path.

    +
    +

    12.7 Composable Function

    +

    A function MAY indicate that it is composable. If not explicitly indicated, it is not composable.

    +

    A composable function can be invoked with additional path segments or key predicates appended to the resource path that identifies the composable function, and with system query options as appropriate for the type returned by the composable function.

    +
    +

    Attribute IsComposable

    +

    The value of IsComposable is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +

    12.8 Return Type

    +

    The return type of an action or function overload MAY be any type in scope, or a collection of any type in scope.

    +

    The facets Nullable, MaxLength, Precision, Scale, and SRID can be used as appropriate to specify value restrictions of the return type, as well as the Unicode facet for 4.01 and greater payloads.

    +

    For a single-valued return type the facets apply to the returned value. For a collection-valued return type the facets apply to the items in the returned collection.

    +
    +

    Element edm:ReturnType

    +

    The edm:ReturnType element MUST contain the Type attribute, and it MAY contain the attributes Nullable, MaxLength, Unicode, Precision, Scale, and SRID.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Type

    +

    For single-valued return types the value of Type is the qualified name of the return type.

    +

    For collection-valued return types the value of Type is the character sequence Collection( followed by the qualified name of the return item type, followed by a closing parenthesis ).

    +

    Attribute Nullable

    +

    The value of Nullable is one of the Boolean literals true or false. Absence of the attribute means true.

    +

    If the return type is a collection of entity types, the Nullable attribute has no meaning and MUST NOT be specified.

    +

    For other collection-valued return types the result will always be a collection that MAY be empty. In this case the Nullable attribute applies to items of the collection and specifies whether the collection MAY contain null values.

    +

    For single-valued return types the value true means that the action or function MAY return a single null value. The value false means that the action or function will never return a null value and instead will fail with an error response if it cannot compute a result.

    +
    +

    12.9 Parameter

    +

    An action or function overload MAY specify parameters.

    +

    A bound action or function overload MUST specify at least one parameter; the first parameter is its binding parameter. The order of parameters MUST NOT change unless the schema version changes.

    +

    Each parameter MUST have a name that is a simple identifier. The parameter name MUST be unique within the action or function overload.

    +

    The parameter MUST specify a type. It MAY be any type in scope, or a collection of any type in scope.

    +

    The facets MaxLength, Precision, Scale, or SRID can be used as appropriate to specify value restrictions of the parameter, as well as the Unicode facet for 4.01 and greater payloads.

    +

    For single-valued parameters the facets apply to the parameter value. If the parameter value is a collection, the facets apply to the items in the collection.

    +
    +

    Element edm:Parameter

    +

    The edm:Parameter element MUST contain the Name and the Type attribute, and it MAY contain the attributes Nullable, MaxLength, Unicode, Precision, Scale, and SRID.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the parameter's name.

    +

    Attribute Type

    +

    For single-valued parameters the value of Type is the qualified name of the parameter.

    +

    For collection-valued parameters the value of Type is the character sequence Collection( followed by the qualified name of the parameter's type, followed by a closing parenthesis ).

    +

    Attribute Nullable

    +

    The value of Nullable is one of the Boolean literals true or false. Absence of the attribute means true.

    +

    The value true means that the parameter accepts a null value.

    +
    +
    +

    Example 30: a function returning the top-selling products for a given year. In this case the year must be specified as a parameter of the function with the edm:Parameter element.

    +
    <Function Name="TopSellingProducts">
    +  <Parameter Name="Year" Type="Edm.Decimal" Precision="4" Scale="0" />
    +  <ReturnType Type="Collection(self.Product)" />
    +</Function>
    +
    +
    +

    13 Entity Container

    +

    Each metadata document used to describe an OData service MUST define exactly one entity container.

    +

    The entity container's name is a simple identifier that MUST be unique within its schema.

    +

    Entity containers define the entity sets, singletons, function and action imports exposed by the service.

    +

    Entity set, singleton, action import, and function import names MUST be unique within an entity container.

    +

    An entity set allows access to entity type instances. Simple entity models frequently have one entity set per entity type.

    +
    +

    Example 31: one entity set per entity type

    +
    <EntitySet Name="Products"   EntityType="self.Product" />
    +<EntitySet Name="Categories" EntityType="self.Category" />
    +
    +

    Other entity models may expose multiple entity sets per type.

    +
    +

    Example 32: three entity sets referring to the two entity types

    +
    <EntitySet Name="StandardCustomers" EntityType="self.Customer">
    +  <NavigationPropertyBinding Path="Orders" Target="Orders" />
    +</EntitySet>
    +<EntitySet Name="PreferredCustomers" EntityType="self.Customer">
    +  <NavigationPropertyBinding Path="Orders" Target="Orders" />
    +</EntitySet>
    +<EntitySet Name="Orders" EntityType="self.Order" />
    +
    +

    There are separate entity sets for standard customers and preferred customers, but only one entity set for orders. The entity sets for standard customers and preferred customers both have navigation property bindings to the orders entity set, but the orders entity set does not have a navigation property binding for the Customer navigation property, since it could lead to either set of customers.

    +

    An entity set can expose instances of the specified entity type as well as any entity type inherited from the specified entity type.

    +

    A singleton allows addressing a single entity directly from the entity container without having to know its key, and without requiring an entity set.

    +

    A function import or an action import is used to expose a function or action defined in an entity model as a top level resource.

    +
    +

    Element edm:EntityContainer

    +

    The edm:EntityContainer MUST contain one or more edm:EntitySet, edm:Singleton, edm:ActionImport, or edm:FunctionImport elements.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the entity container's name.

    +
    +
    +

    Example 33: An entity container aggregates entity sets, singletons, action imports, and function imports.

    +
    <EntityContainer Name="DemoService">
    +  <EntitySet Name="Products" EntityType="self.Product">
    +    <NavigationPropertyBinding Path="Category" Target="Categories" />
    +    <NavigationPropertyBinding Path="Supplier" Target="Suppliers" />
    +  </EntitySet>
    +  <EntitySet Name="Categories" EntityType="self.Category">
    +    <NavigationPropertyBinding Path="Products" Target="Products" />
    +  </EntitySet>
    +  <EntitySet Name="Suppliers" EntityType="self.Supplier">
    +    <NavigationPropertyBinding Path="Products" Target="Products" />
    +  </EntitySet>
    +  <Singleton Name="MainSupplier" Type="self.Supplier" />
    +  <ActionImport Name="LeaveRequestApproval" Action="self.Approval" />
    +  <FunctionImport Name="ProductsByRating" Function="self.ProductsByRating"
    +                  EntitySet="Products" />
    +</EntityContainer>
    +
    +

    13.1 Extending an Entity Container

    +

    An entity container MAY specify that it extends another entity container in scope. All children of the "base" entity container are added to the "extending" entity container.

    +

    If the "extending" entity container defines an entity set with the same name as defined in any of its "base" containers, then the entity set's type MUST specify an entity type derived from the entity type specified for the identically named entity set in the "base" container. The same holds for singletons. Action imports and function imports cannot be redefined, nor can the "extending" container define a child with the same name as a child of a different kind in a "base" container.

    +

    Note: services should not introduce cycles by extending entity containers. Clients should be prepared to process cycles introduced by extending entity containers.

    +
    +

    Attribute Extends

    +

    The value of Extends is the qualified name of the entity container to be extended.

    +
    +
    +

    Example 34: the entity container Extending will contain all child elements that it defines itself, plus all child elements of the Base entity container located in SomeOtherSchema

    +
    <EntityContainer Name="Extending" Extends="Some.Other.Schema.Base">
    +  ...
    +</EntityContainer>
    +
    +

    13.2 Entity Set

    +

    Entity sets are top-level collection-valued resources.

    +

    An entity set is identified by its name, a simple identifier that MUST be unique within its entity container.

    +

    An entity set MUST specify a type that MUST be an entity type in scope.

    +

    An entity set MUST contain only instances of its specified entity type or its subtypes. The entity type MAY be abstract but MUST have a key defined.

    +

    An entity set MAY indicate whether it is included in the service document. If not explicitly indicated, it is included.

    +

    Entity sets that cannot be queried without specifying additional query options SHOULD NOT be included in the service document.

    +
    +

    Element edm:EntitySet

    +

    The edm:EntitySet element MUST contain the attributes Name and EntityType, and it MAY contain the IncludeInServiceDocument attribute.

    +

    It MAY contain edm:NavigationPropertyBinding elements.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the entity set's name.

    +

    Attribute EntityType

    +

    The value of EntityType is the qualified name of an entity type in scope.

    +

    Attribute IncludeInServiceDocument

    +

    The value of IncludeInServiceDocument is one of the Boolean literals true or false. Absence of the attribute means true.

    +
    +

    13.3 Singleton

    +

    Singletons are top-level single-valued resources.

    +

    A singleton is identified by its name, a simple identifier that MUST be unique within its entity container.

    +

    A singleton MUST specify a type that MUST be an entity type in scope.

    +

    A singleton MUST reference an instance its entity type.

    +
    +

    Element edm:Singleton

    +

    The edm:Singleton element MUST include the attributes Name and Type, and it MAY contain the Nullable attribute.

    +

    It MAY contain edm:NavigationPropertyBinding elements.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the singleton's name.

    +

    Attribute Type

    +

    The value of Type is whose value is the qualified name of an entity type in scope.

    +

    Attribute Nullable

    +

    The value of Nullable is one of the Boolean literals true or false.

    +

    If no value is specified, the Nullable attribute defaults to false.

    +

    In OData 4.0 responses this attribute MUST NOT be specified.

    +
    +

    13.4 Navigation Property Binding

    +

    If the entity type of an entity set or singleton declares navigation properties, a navigation property binding allows describing which entity set or singleton will contain the related entities.

    +

    An entity set or a singleton SHOULD specify a navigation property binding for each navigation property of its entity type, including navigation properties defined on complex typed properties or derived types.

    +

    If omitted, clients MUST assume that the target entity set or singleton can vary per related entity.

    +

    13.4.1 Navigation Property Path Binding

    +

    A navigation property binding MUST specify a path to a navigation property of the entity set's or singleton's declared entity type, or a navigation property reached through a chain of type casts, complex properties, or containment navigation properties. If the navigation property is defined on a subtype, the path MUST contain the qualified name of the subtype, followed by a forward slash, followed by the navigation property name. If the navigation property is defined on a complex type used in the definition of the entity set's entity type, the path MUST contain a forward-slash separated list of complex property names and qualified type names that describe the path leading to the navigation property.

    +

    The path can traverse one or more containment navigation properties, but the last navigation property segment MUST be a non-containment navigation property and there MUST NOT be any non-containment navigation properties prior to the final navigation property segment.

    +

    If the path traverses collection-valued complex properties or collection-valued containment navigation properties, the binding applies to all items of these collections.

    +

    If the path contains a recursive sub-path (i.e. a path leading back to the same structured type, the binding applies recursively to any positive number of cycles through that sub-path.

    +

    OData 4.01 services MAY have a type-cast segment as the last path segment, allowing to bind instances of different sub-types to different targets.

    +

    The same navigation property path MUST NOT be specified in more than one navigation property binding; navigation property bindings are only used when all related entities are known to come from a single entity set. Note that it is possible to have navigation property bindings for paths that differ only in a type-cast segment, allowing to bind instances of different sub-types to different targets. If paths differ only in type-cast segments, the most specific path applies.

    +

    13.4.2 Binding Target

    +

    A navigation property binding MUST specify a target via a simple identifier or target path. It specifies the entity set, singleton, or containment navigation property that contains the related entities.

    +

    If the target is a simple identifier, it MUST resolve to an entity set or singleton defined in the same entity container.

    +

    If the target is a target path, it MUST resolve to an entity set, singleton, or direct or indirect containment navigation property of a singleton in scope. The path can traverse single-valued containment navigation properties or single-valued complex properties before ending in a containment navigation property, and there MUST NOT be any non-containment navigation properties prior to the final segment.

    +
    +

    Element edm:NavigationPropertyBinding

    +

    The edm:NavigationPropertyBinding element MUST contain the attributes Path and Target.

    +

    Attribute Path

    +

    The value of Path is a path expression.

    +

    Attribute Target

    +

    The value of Target is a target path.

    +
    +
    +

    Example 35: for an entity set in the same container as the enclosing entity set Categories

    +
    <EntitySet Name="Categories" EntityType="self.Category">
    +  <NavigationPropertyBinding Path="Products"
    +                             Target="SomeSet" />
    +</EntitySet>
    +
    +
    +

    Example 36: for an entity set in any container in scope

    +
    <EntitySet Name="Categories" EntityType="self.Category">
    +  <NavigationPropertyBinding Path="Products"
    +                             Target="SomeModel.SomeContainer/SomeSet" />
    +</EntitySet>
    +
    +
    +

    Example 37: binding Supplier on Products contained within Categories – binding applies to all suppliers of all products of all categories

    +
    <EntitySet Name="Categories" EntityType="self.Category">
    +  <NavigationPropertyBinding Path="Products/Supplier"
    +                             Target="Suppliers" />
    +</EntitySet>
    +
    +

    13.5 Action Import

    +

    Action imports sets are top-level resources that are never included in the service document.

    +

    An action import is identified by its name, a simple identifier that MUST be unique within its entity container.

    +

    An action import MUST specify the name of an unbound action in scope.

    +

    If the imported action returns an entity or a collection of entities, a simple identifier or target path value MAY be specified to identify the entity set that contains the returned entities. If a simple identifier is specified, it MUST resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an entity set in scope.

    +
    +

    Element edm:ActionImport

    +

    The edm:ActionImport element MUST contain the attributes Name and Action, and it MAY contain the EntitySet attribute.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the action import's name.

    +

    Attribute Action

    +

    The value of Action is the qualified name of an unbound action.

    +

    Attribute EntitySet

    +

    The value of EntitySet is either the unqualified name of an entity set in the same entity container or a path to an entity set in a different entity container.

    +
    +

    13.6 Function Import

    +

    Function imports sets are top-level resources.

    +

    A function import is identified by its name, a simple identifier that MUST be unique within its entity container.

    +

    A function import MUST specify the name of an unbound function in scope. All unbound overloads of the imported function can be invoked from the entity container.

    +

    If the imported function returns an entity or a collection of entities, a simple identifier or target path value MAY be specified to identify the entity set that contains the returned entities. If a simple identifier is specified, it MUST resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an entity set in scope.

    +

    A function import for a parameterless function MAY indicate whether it is included in the service document. If not explicitly indicated, it is not included.

    +
    +

    Element edm:FunctionImport

    +

    The edm:FunctionImport element MUST contain the attributes Name and Function, and it MAY contain the attributes EntitySet and IncludeInServiceDocument.

    +

    Attribute Name

    +

    The value of Name is the function import's name.

    +

    Attribute Function

    +

    The value of Function is the qualified name of an unbound function.

    +

    Attribute EntitySet

    +

    The value of EntitySet is either the unqualified name of an entity set in the same entity container or a path to an entity set in a different entity container.

    +

    Attribute IncludeInServiceDocument

    +

    The value of IncludeInServiceDocument is one of the Boolean literals true or false. Absence of the attribute means false.

    +
    +
    +

    14 Vocabulary and Annotation

    +

    Vocabularies and annotations provide the ability to annotate metadata as well as instance data, and define a powerful extensibility point for OData. An annotation applies a term to a model element and defines how to calculate a value for the applied term.

    +

    Metadata annotations are terms applied to model elements. Behaviors or constraints described by a metadata annotation must be consistent with the annotated model element. Such annotations define additional behaviors or constraints on the model element, such as a service, entity type, property, function, action, or parameter. For example, a metadata annotation may define ranges of valid values for a particular property. Metadata annotations are applied in CSDL documents describing or referencing an entity model.

    +

    Instance annotations are terms applied to a particular instance within an OData payload, such as described in OData-JSON. An instance annotation can be used to define additional information associated with a particular result, entity, property, or error. For example, whether a property is read-only for a particular instance. Where the same annotation is defined at both the metadata and instance level, the instance-level annotation overrides the annotation specified at the metadata level. Annotations that apply across instances should be specified as metadata annotations.

    +

    A vocabulary is a schema containing a set of terms where each term is a named metadata extension. Anyone can define a vocabulary (a set of terms) that is scenario-specific or company-specific; more commonly used terms can be published as shared vocabularies such as the OData Core vocabulary OData-VocCore.

    +

    A term can be used to:

    + +

    A service SHOULD NOT require a client to interpret annotations. Clients SHOULD ignore invalid or unknown terms and silently treat unexpected or invalid values (including invalid type, invalid literal expression, invalid targets, etc.) as an unknown value for the term. Unknown or invalid annotations should never result in an error, as long as the payload remains well-formed.

    +
    +

    Example 38: the Product entity type is extended with a DisplayName by a metadata annotation that binds the term DisplayName to the value of the property Name. The Product entity type also includes an annotation that allows its instances to be viewed as instances of the type specified by the term SearchResult

    +
    <EntityType Name="Product">
    +  <Key>
    +    <PropertyRef Name="ID" />
    +  </Key>
    +  <Property Name="ID" Nullable="false" Type="Edm.Int32" />
    +  <Property Name="Name" Type="Edm.String" />
    +  <Property Name="Description" Type="Edm.String" />
    +  ...
    +  <Annotation Term="UI.DisplayName" Path="Name" />
    +  <Annotation Term="SearchVocabulary.SearchResult">
    +    <Record>
    +      <PropertyValue Property="Title" Path="Name" />
    +      <PropertyValue Property="Abstract" Path="Description" />
    +      <PropertyValue Property="Url">
    +        <Apply Function="odata.concat">
    +          <String>Products(</String>
    +          <Path>ID</Path>
    +          <String>)</String>
    +        </Apply>
    +      </PropertyValue>
    +    </Record>
    +  </Annotation>
    +</EntityType>
    +
    +

    14.1 Term

    +

    A term allows annotating a model element or OData resource representation with additional data.

    +

    The term's name is a simple identifier that MUST be unique within its schema.

    +

    The term's type MUST be a type in scope, or a collection of a type in scope.

    +
    +

    Element edm:Term

    +

    The edm:Term element MUST contain the attributes Name and Type. It MAY contain the attributes BaseTerm and AppliesTo.

    +

    It MAY specify values for the Nullable, [ ]{.apple-converted-space}MaxLength, Precision, Scale, or SRID facet attributes, as well as the Unicode facet attribute for 4.01 and greater payloads. These facets and their implications are described in section 7.2.

    +

    A edm:Term element whose Type attribute specifies a primitive or enumeration type MAY define a value for the DefaultValue attribute.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the term's name.

    +

    Attribute Type

    +

    For single-valued properties the value of Type is the qualified name of the property's type.

    +

    For collection-valued properties the value of Type is the character sequence Collection( followed by the qualified name of the property's item type, followed by a closing parenthesis ).

    +

    Attribute DefaultValue

    +

    The value of this attribute determines the value of the term when applied in an edm:Annotation without providing an expression.

    +

    Default values of type Edm.String MUST be represented according to the XML escaping rules for character data in attribute values. Values of other primitive types MUST be represented according to the appropriate alternative in the primitiveValue rule defined in OData-ABNF, i.e. Edm.Binary as binaryValue, Edm.Boolean as booleanValue etc.

    +

    If no value is specified, the DefaultValue attribute defaults to null.

    +
    +

    14.1.1 Specialized Term

    +

    A term MAY specialize another term in scope by specifying it as its base term.

    +

    When applying a specialized term, the base term MUST also be applied with the same qualifier, and so on until a term without a base term is reached.

    +
    +

    Attribute BaseTerm

    +

    The value of BaseTerm is the qualified name of the base term.

    +
    +

    14.1.2 Applicability

    +

    The applicability of a term MAY be restricted to a list of model elements. If no list is supplied, the term is not intended to be restricted in its application. The list of model elements MAY be extended in future versions of the vocabulary. As the intended usage may evolve over time, clients SHOULD be prepared for any term to be applied to any model element and SHOULD be prepared to handle unknown values within the list of model constructs. Applicability is expressed using the following symbolic values:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Symbolic ValueModel Element
    ActionAction
    ActionImportAction Import
    AnnotationAnnotation
    ApplyApplication of a client-side function in an annotation
    CastType Cast annotation expression
    CollectionEntity Set or collection-valued Property or Navigation Property
    ComplexTypeComplex Type
    EntityContainerEntity Container
    EntitySetEntity Set
    EntityTypeEntity Type
    EnumTypeEnumeration Type
    FunctionFunction
    FunctionImportFunction Import
    IfConditional annotation expression
    IncludeReference to an Included Schema
    IsOfType Check annotation expression
    LabeledElementLabeled Element expression
    MemberEnumeration Member
    NavigationPropertyNavigation Property
    NullNull annotation expression
    OnDeleteOn-Delete Action of a navigation property
    ParameterAction of Function Parameter
    PropertyProperty of a structured type
    PropertyValueProperty value of a Record annotation expression
    RecordRecord annotation expression
    ReferenceReference to another CSDL document
    ReferentialConstraintReferential Constraint of a navigation property
    ReturnTypeReturn Type of an Action or Function
    SchemaSchema
    SingletonSingleton
    TermTerm
    TypeDefinitionType Definition
    UrlRefUrlRef annotation expression
    +
    +

    Attribute AppliesTo

    +

    The value of AppliesTo is a whitespace-separated list of symbolic values from the table above that identify model elements the term is intended to be applied to.

    +
    +
    +

    Example 39: the IsURL term can be applied to properties and terms that are of type Edm.String (the Core.Tag type and the two Core terms are defined in OData-VocCore)

    +
    <Term Name="IsURL" Type="Core.Tag" Nullable="false" DefaultValue="true"
    +      AppliesTo="Property Term">
    +  <Annotation Term="Core.Description">
    +    <String>
    +      Properties and terms annotated with this term MUST contain a valid URL
    +    </String>
    +  </Annotation>
    +  <Annotation Term="Core.RequiresType" String="Edm.String" />
    +</Term>
    +
    +

    14.2 Annotation

    +

    An annotation applies a term to a model element and defines how to calculate a value for the term application. Both term and model element MUST be in scope. Section 14.1.2 specifies which model elements MAY be annotated with a term.

    +

    The value of an annotation is specified as an annotation expression, which is either a constant expression representing a constant value, or a dynamic expression. The most common construct for assigning an annotation value is a path expression that refers to a property of the same or a related structured type.

    +
    +

    Element edm:Annotation

    +

    The edm:Annotation element MUST contain the attribute Term, and it MAY contain the attribute Qualifier.

    +

    The value of the annotation MAY be a constant expression or dynamic expression.

    +

    If no expression is specified for a term with a primitive type, the annotation evaluates to the default value of the term definition. If no expression is specified for a term with a complex type, the annotation evaluates to a complex instance with default values for its properties. If no expression is specified for a collection-valued term, the annotation evaluates to an empty collection.

    +

    An edm:Annotation element can be used as a child of the model element it annotates, or as the child of an edm:Annotations element that targets the model element to be annotated.

    +

    An edm:Annotation element MAY contain edm:Annotation elements that annotate the annotation.

    +

    Attribute Term

    +

    The value of Term is the qualified name of a term in scope.

    +
    +
    +

    Example 40: term Measures.ISOCurrency, once applied with a constant value, once with a path value

    +
    <Property Name="AmountInReportingCurrency" Type="Edm.Decimal">
    +  <Annotation Term="Measures.ISOCurrency" String="USD">
    +    <Annotation Term="Core.Description"
    +                String="The parent company's currency" />
    +  </Annotation>
    +</Property>
    +<Property Name="AmountInTransactionCurrency" Type="Edm.Decimal">
    +  <Annotation Term="Measures.ISOCurrency" Path="Currency" />
    +</Property>
    +<Property Name="Currency" Type="Edm.String" MaxLength="3" />
    +
    +

    If an entity type or complex type is annotated with a term that itself has a structured type, an instance of the annotated type may be viewed as an "instance" of the term, and the qualified term name may be used as a term-cast segment in path expressions.

    +

    Structured types "inherit" annotations from their direct or indirect base types. If both the type and one of its base types is annotated with the same term and qualifier, the annotation on the type completely replaces the annotation on the base type; structured or collection-valued annotation values are not merged. Similarly, properties of a structured type inherit annotations from identically named properties of a base type.

    +

    It is up to the definition of a term to specify whether and how annotations with this term propagate to places where the annotated model element is used, and whether they can be overridden. E.g. a "Label" annotation for a UI can propagate from a type definition to all properties using that type definition and may be overridden at each property with a more specific label, whereas an annotation marking a type definition as containing a phone number will propagate to all using properties but may not be overridden.

    +

    14.2.1 Qualifier

    +

    A term can be applied multiple times to the same model element by providing a qualifier to distinguish the annotations. The qualifier is a simple identifier.

    +

    The combination of target model element, term, and qualifier uniquely identifies an annotation.

    +
    +

    Attribute Qualifier

    +

    Annotation elements that are children of an edm:Annotations element MUST NOT provide a value for the qualifier attribute if the parent edm:Annotations element provides a value for the qualifier attribute.

    +
    +
    +

    Example 41: annotation should only be applied to tablet devices

    +
    <Annotation Term="org.example.display.DisplayName" Path="FirstName"
    +            Qualifier="Tablet" />
    +
    +

    14.2.2 Target

    +

    The target of an annotation is the model element the term is applied to.

    +

    The target of an annotation MAY be specified indirectly by "nesting" the annotation within the model element. Whether and how this is possible is described per model element in this specification.

    +

    The target of an annotation MAY also be specified directly; this allows defining an annotation in a different schema than the targeted model element.

    +

    This external targeting is only possible for model elements that are uniquely identified within their parent, and all their ancestor elements are uniquely identified within their parent:

    + +

    These are the direct children of a schema with a unique name (i.e. except actions and functions whose overloads to not possess a natural identifier), and all direct children of an entity container.

    +

    External targeting is possible for actions, functions, their parameters, and their return type, either in a way that applies to all overloads of the action or function or all parameters of that name across all overloads, or in a way that identifies a single overload.

    +

    External targeting is also possible for properties and navigation properties of singletons or entities in a particular entity set. These annotations override annotations on the properties or navigation properties targeted via the declaring structured type.

    +

    The allowed path expressions are:

    + +

    All qualified names used in a target path MUST be in scope.

    +
    +

    Example 42: Target expressions

    +
    MySchema.MyEntityType
    +MySchema.MyEntityType/MyProperty
    +MySchema.MyEntityType/MyNavigationProperty
    +MySchema.MyComplexType
    +MySchema.MyComplexType/MyProperty
    +MySchema.MyComplexType/MyNavigationProperty
    +MySchema.MyEnumType
    +MySchema.MyEnumType/MyMember
    +MySchema.MyTypeDefinition
    +MySchema.MyTerm
    +MySchema.MyEntityContainer
    +MySchema.MyEntityContainer/MyEntitySet
    +MySchema.MyEntityContainer/MySingleton
    +MySchema.MyEntityContainer/MyActionImport
    +MySchema.MyEntityContainer/MyFunctionImport
    +MySchema.MyAction
    +MySchema.MyAction(MySchema.MyBindingType)
    +MySchema.MyAction()
    +MySchema.MyFunction
    +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType)
    +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType)
    +MySchema.MyFunction/MyParameter
    +MySchema.MyEntityContainer/MyEntitySet/MyProperty
    +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty
    +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty
    +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty
    +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty
    +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty
    +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty
    +
    +

    14.3 Constant Expression

    +

    Constant expressions allow assigning a constant value to an applied term.

    +

    14.3.1 Binary

    +
    +

    Expression edm:Binary

    +

    The edm:Binary expression evaluates to a primitive binary value. A binary expression MUST be assigned a value conforming to the rule binaryValue in OData-ABNF.

    +

    The binary expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 43: base64url-encoded binary value (OData)

    +
    <Annotation Term="org.example.display.Thumbnail" Binary="T0RhdGE" />
    +
    +<Annotation Term="org.example.display.Thumbnail">
    +  <Binary>T0RhdGE</Binary>
    +</Annotation>
    +
    +

    14.3.2 Boolean

    +
    +

    Expression edm:Bool

    +

    The edm:Bool expression evaluates to a primitive Boolean value. A Boolean expression MUST be assigned a Boolean value.

    +

    The Boolean expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 44:

    +
    <Annotation Term="org.example.display.ReadOnly" Bool="true" />
    +
    +<Annotation Term="org.example.display.ReadOnly">
    +  <Bool>true</Bool>
    +</Annotation>
    +
    +

    14.3.3 Date

    +
    +

    Expression edm:Date

    +

    The edm:Date expression evaluates to a primitive date value. A date expression MUST be assigned a value of type xs:date, see XML-Schema-2, section 3.3.9. The value MUST also conform to rule dateValue in OData-ABNF, i.e. it MUST NOT contain a time-zone offset.

    +

    The date expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 45:

    +
    <Annotation Term="org.example.vCard.birthDay" Date="2000-01-01" />
    +
    +<Annotation Term="org.example.vCard.birthDay">
    +  <Date>2000-01-01</Date>
    +</Annotation>
    +
    +

    14.3.4 DateTimeOffset

    +
    +

    Expression edm:DateTimeOffset

    +

    The edm:DateTimeOffset expression evaluates to a primitive datetimestamp value with a time-zone offset. A datetimestamp expression MUST be assigned a value of type xs:dateTimeStamp, see XML-Schema-2, section 3.4.28. The value MUST also conform to rule dateTimeOffsetValue in OData-ABNF, i.e. it MUST NOT contain an end-of-day fragment (24:00:00).

    +

    The datetimestamp expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 46:

    +
    <Annotation Term="org.example.display.LastUpdated"
    +
    +            DateTimeOffset="2000-01-01T16:00:00.000Z" />
    +
    +<Annotation Term="org.example.display.LastUpdated">
    +  <DateTimeOffset>2000-01-01T16:00:00.000-09:00</DateTimeOffset>
    +</Annotation>
    +
    +

    14.3.5 Decimal

    +
    +

    Expression edm:Decimal

    +

    The edm:Decimal expression evaluates to a primitive decimal value. A decimal expression MUST be assigned a value conforming to the rule decimalValue in OData-ABNF.

    +

    The decimal expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 47: attribute notation

    +
    <Annotation Term="org.example.display.Width" Decimal="3.14" />
    +
    +
    +

    Example 48: element notation

    +
    <Annotation Term="org.example.display.Width">
    +  <Decimal>3.14</Decimal>
    +</Annotation>
    +
    +

    14.3.6 Duration

    +
    +

    Expression edm:Duration

    +

    The edm:Duration expression evaluates to a primitive duration value. A duration expression MUST be assigned a value of type xs:dayTimeDuration, see XML-Schema-2, section 3.4.27.

    +

    The duration expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 49:

    +
    <Annotation Term="org.example.task.duration" Duration="P7D" />
    +
    +<Annotation Term="org.example.task.duration">
    +  <Duration>P11DT23H59M59.999999999999S</Duration>
    +</Annotation>
    +
    +

    14.3.7 Enumeration Member

    +
    +

    Expression edm:EnumMember

    +

    The edm:EnumMember expression references a member of an enumeration type. An enumeration member expression MUST be assigned a value that consists of the qualified name of the enumeration type, followed by a forward slash and the name of the enumeration member. If the enumeration type specifies an IsFlags attribute with value true, the expression MAY also be assigned a whitespace-separated list of values. Each of these values MUST resolve to the name of a member of the enumeration type of the specified term.

    +

    The enumeration member expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 50: single value

    +
    <Annotation Term="org.example.HasPattern"
    +             EnumMember="org.example.Pattern/Red" />
    +
    +<Annotation Term="org.example.HasPattern">
    +  <EnumMember>org.example.Pattern/Red</EnumMember>
    +</Annotation>
    +
    +
    +

    Example 51: combined value for IsFlags enumeration type

    +
    <Annotation Term="org.example.HasPattern"
    +           EnumMember="org.example.Pattern/Red org.example.Pattern/Striped" />
    +
    +<Annotation Term="org.example.HasPattern">
    +  <EnumMember>org.example.Pattern/Red org.example.Pattern/Striped</EnumMember>
    +</Annotation>
    +
    +

    14.3.8 Floating-Point Number

    +
    +

    Expression edm:Float

    +

    The edm:Float expression evaluates to a primitive floating point (or double) value. A float expression MUST be assigned a value conforming to the rule doubleValue in OData-ABNF.

    +

    The float expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 52:

    +
    <Annotation Term="org.example.display.Width" Float="3.14" />
    +
    +<Annotation Term="org.example.display.Width">
    +  <Float>3.14</Float>
    +</Annotation>
    +
    +

    14.3.9 Guid

    +
    +

    Expression edm:Guid

    +

    The edm:Guid expression evaluates to a primitive guid value. A guid expression MUST be assigned a value conforming to the rule guidValue in OData-ABNF.

    +

    The guid expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 53:

    +
    <Annotation Term="org.example.display.Id"
    +            Guid="21EC2020-3AEA-1069-A2DD-08002B30309D" />
    +
    +<Annotation Term="org.example.display.Id">
    +  <Guid>21EC2020-3AEA-1069-A2DD-08002B30309D</Guid>
    +</Annotation>
    +
    +

    14.3.10 Integer

    +
    +

    Expression edm:Int

    +

    The edm:Int expression evaluates to a primitive integer value. An integer MUST be assigned a value conforming to the rule int64Value in OData-ABNF.

    +

    The integer expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 54: attribute notation

    +
    <Annotation Term="org.example.display.Width" Int="42" />
    +
    +
    +

    Example 55: element notation

    +
    <Annotation Term="org.example.display.Width">
    +  <Int>42</Int>
    +</Annotation>
    +
    +

    14.3.11 String

    +
    +

    Expression edm:String

    +

    The edm:String expression evaluates to a primitive string value. A string expression MUST be assigned a value of the type xs:string, see XML-Schema-2, section 3.3.1.

    +

    The string expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 56:

    +
    <Annotation Term="org.example.display.DisplayName" String="Product Catalog" />
    +
    +<Annotation Term="org.example.display.DisplayName">
    +  <String>Product Catalog</String>
    +</Annotation>
    +
    +

    14.3.12 Time of Day

    +
    +

    Expression edm:TimeOfDay

    +

    The edm:TimeOfDay expression evaluates to a primitive time value. A time-of-day expression MUST be assigned a value conforming to the rule timeOfDayValue in OData-ABNF.

    +

    The time-of-day expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 57:

    +
    <Annotation Term="org.example.display.EndTime" TimeOfDay="21:45:00" />
    +
    +<Annotation Term="org.example.display.EndTime">
    +  <TimeOfDay>21:45:00</TimeOfDay>
    +</Annotation>
    +
    +

    14.4 Dynamic Expression

    +

    Dynamic expressions allow assigning a calculated value to an applied term.

    +

    14.4.1 Path Expressions

    +

    Path expressions allow assigning a value to an applied term or term component. There are two kinds of path expressions:

    + +

    14.4.1.1 Path Syntax

    +

    Model paths and instance paths share a common syntax which is derived from the path expression syntax of URLs, see OData-URL.

    +

    A path MUST be composed of zero or more path segments joined together by forward slashes (/).

    +

    Paths starting with a forward slash (/) are absolute paths, and the first path segment MUST be the qualified name of a model element, e.g. an entity container. The remaining path after the second forward slash is interpreted relative to that model element.

    +
    +

    Example 58: absolute path to an entity set

    +
    /My.Schema.MyEntityContainer/MyEntitySet
    +
    +

    Paths not starting with a forward slash are interpreted relative to the annotation target, following the rules specified in section "Path Evaluation".

    +
    +

    Example 59: relative path to a property

    +
    Address/City
    +
    +

    If a path segment is a qualified name, it represents a type cast, and the segment MUST be the name of a type in scope. If the type or instance identified by the preceding path part cannot be cast to the specified type, the path expression evaluates to the null value.

    +
    +

    Example 60: type-cast segment

    +
    .../self.Manager/...
    +
    +

    If a path segment starts with an at (@) character, it represents a term cast. The at (@) character MUST be followed by a qualified name that MAY be followed by a hash (#) character and a simple identifier. The qualified name preceding the hash character MUST resolve to a term that is in scope, the simple identifier following the hash sign is interpreted as a qualifier for the term. If the model element or instance identified by the preceding path part has not been annotated with that term (and if present, with that qualifier), the term cast evaluates to the null value. Four special terms are implicitly "annotated" for media entities and stream properties:

    + +
    +

    Example 61: term-cast segments

    +
    .../@Capabilities.SortRestrictions/...
    +
    +

    If a path segment is a simple identifier, it MUST be the name of a child model element of the model element identified by the preceding path part, or a structural or navigation property of the instance identified by the preceding path part. A sequence of navigation segments can traverse multiple CSDL documents. The document containing the path expression only needs to reference the next traversed document to bring the navigation target type into scope, and each traversed document in turn needs to reference only its next document.

    +

    A model path MAY contain any number of segments representing collection-valued structural or navigation properties. The result of the expression is the model element reached via this path.

    +
    +

    Example 62: property segments in model path

    +
    .../Orders/Items/Product/...
    +
    +

    An instance path MUST NOT contain more than one segment representing a collection-valued construct, e.g. an entity set or a collection-valued navigation property that is not followed by a key predicate, or a collection-valued structural property that is not followed by an index segment. The result of the expression is the collection of instances resulting from applying any remaining path segments that operate on a single-valued expression to each instance in the collection-valued segment.

    +

    An instance path MAY terminate in a $count segment if the previous segment is collection-valued, in which case the path evaluates to the number of items in the collection identified by the preceding segment.

    +
    +

    Example 63: property segments in instance path

    +
    .../Addresses/Street
    +
    .../Addresses/$count
    +
    +

    A model path MAY contain path segments starting with a navigation property, then followed by an at (@) character, then followed by the qualified name of a term in scope, and optionally followed by a hash (#) character and a simple identifier which is interpreted as a qualifier for the term. If the navigation property has not been annotated with that term (and if present, with that qualifier), the path segment evaluates to the null value. This allows addressing annotations on the navigation property itself; annotations on the entity type specified by the navigation property are addressed via a term-cast segment.

    +
    +

    Example 64: model path addressing an annotation on a navigation property

    +
    .../Items@Capabilities.InsertRestrictions/Insertable
    +
    +

    An instance path MAY contain path segments starting with an entity set or a collection-valued navigation property, then followed by a key predicate using parentheses-style convention, see OData-URL. The key values are either primitive literals or instance paths. If the key value is a relative instance path, it is interpreted according to the same rule below as the instance path it is part of, not relative to the instance identified by the preceding path part.

    +
    +

    Example 65: instance path with entity set and key predicate

    +
    /self.container/SettingsCollection('FeatureXxx')/IsAvailable
    +
    /self.container/Products(ID=ProductID)/Name
    +
    +

    An instance path MAY contain an index segment immediately following a path segment representing an ordered collection-valued structural property. The index is zero-based and MUST be an integer literal. Negative integers count from the end of the collection, with -1 representing the last item in the collection. Remaining path segments are evaluated relative to the identified item of the collection.

    +
    +

    Example 66: instance path with collection-valued structural property and index segment

    +
    Addresses/1
    +
    Addresses/-1/Street
    +
    +

    14.4.1.2 Path Evaluation

    +

    Annotations MAY be embedded within their target, or specified separately, e.g. as part of a different schema, and specify a path to their target model element. The latter situation is referred to as targeting in the remainder of this section.

    +

    For annotations embedded within or targeting an entity container, the path is evaluated starting at the entity container, i.e. an empty path resolves to the entity container, and non-empty paths MUST start with a segment identifying a container child (entity set, function import, action import, or singleton). The subsequent segments follow the rules for paths targeting the corresponding child element.

    +

    For annotations embedded within or targeting an entity set or a singleton, the path is evaluated starting at the entity set or singleton, i.e. an empty path resolves to the entity set or singleton, and non-empty paths MUST follow the rules for annotations targeting the declared entity type of the entity set or singleton.

    +

    For annotations embedded within or targeting an entity type or complex type, the path is evaluated starting at the type, i.e. an empty path resolves to the type, and the first segment of a non-empty path MUST be a structural or navigation property of the type, a type cast, or a term cast.

    +

    For annotations embedded within a structural or navigation property of an entity type or complex type, the path is evaluated starting at the directly enclosing type. This allows e.g. specifying the value of an annotation on one property to be calculated from values of other properties of the same type. An empty path resolves to the enclosing type, and non-empty paths MUST follow the rules for annotations targeting the directly enclosing type.

    +

    For annotations targeting a structural or navigation property of an entity type or complex type, the path is evaluated starting at the outermost entity type or complex type named in the target of the annotation, i.e. an empty path resolves to the outermost type, and the first segment of a non-empty path MUST be a structural or navigation property of the outermost type, a type cast, or a term cast.

    +

    For annotations embedded within or targeting an action, action import, function, function import, parameter, or return type, the first segment of the path MUST be a parameter name or $ReturnType.

    +

    14.4.1.3 Annotation Path

    +

    The annotation path expression provides a value for terms or term properties that specify the built-in types Edm.AnnotationPath or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    A term or term property of type Edm.AnnotationPath can be annotated with term Validation.AllowedTerms (see OData-VocValidation) if its intended value is an annotation path that ends in a term cast with one of the listed terms.

    +

    The value of the annotation path expression is the path itself, not the value of the annotation identified by the path. This is useful for terms that reuse or refer to other terms.

    +
    +

    Expression edm:AnnotationPath

    +

    The edm:AnnotationPath expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 67:

    +
    <Annotation Term="UI.ReferenceFacet"
    +            AnnotationPath="Product/Supplier/@UI.LineItem" />
    +
    +<Annotation Term="UI.CollectionFacet" Qualifier="Contacts">
    +  <Collection>
    +    <AnnotationPath>Supplier/@Communication.Contact</AnnotationPath>
    +    <AnnotationPath>Customer/@Communication.Contact</AnnotationPath>
    +  </Collection>
    +</Annotation>
    +
    +

    14.4.1.4 Model Element Path

    +

    The model element path expression provides a value for terms or term properties that specify the built-in type Edm.ModelElementPath. Its argument is a model path.

    +

    The value of the model element path expression is the path itself, not the instance(s) identified by the path.

    +
    +

    Expression edm:ModelElementPath

    +

    The edm:ModelElementPath expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 68:

    +
    <Annotation Term="org.example.MyFavoriteModelElement"
    +            ModelElementPath="/org.example.someAction" />
    +
    +<Annotation Term="org.example.MyFavoriteModelElement">
    +  <ModelElementPath>/org.example.someAction</ModelElementPath>
    +</Annotation>
    +
    +

    14.4.1.5 Navigation Property Path

    +

    The navigation property path expression provides a value for terms or term properties that specify the built-in types Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    The value of the navigation property path expression is the path itself, not the entitiy or collection of entities identified by the path.

    +
    +

    Expression edm:NavigationPropertyPath

    +

    The edm:NavigationPropertyPath expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 69:

    +
    <Annotation Term="UI.HyperLink" NavigationPropertyPath="Supplier" />
    +
    +<Annotation Term="Capabilities.UpdateRestrictions">
    +  <Record>
    +    <PropertyValue Property="NonUpdatableNavigationProperties">
    +      <Collection>
    +        <NavigationPropertyPath>Supplier</NavigationPropertyPath>
    +        <NavigationPropertyPath>Category</NavigationPropertyPath>
    +      </Collection>
    +    </PropertyValue>
    +  </Record>
    +</Annotation>
    +
    +

    14.4.1.6 Property Path

    +

    The property path expression provides a value for terms or term properties that specify one of the built-in types Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    The value of the property path expression is the path itself, not the value of the structural property or the value of the term cast identified by the path.

    +
    +

    Expression edm:PropertyPath

    +

    The edm:PropertyPath MAY be provided using either element notation or attribute notation.

    +
    +
    +

    Example 70:

    +
    <Annotation Term="UI.RefreshOnChangeOf" PropertyPath="ChangedAt" />
    +
    +<Annotation Term="Capabilities.UpdateRestrictions">
    +  <Record>
    +    <PropertyValue Property="NonUpdatableProperties">
    +      <Collection>
    +        <PropertyPath>CreatedAt</PropertyPath>
    +        <PropertyPath>ChangedAt</PropertyPath>
    +      </Collection>
    +    </PropertyValue>
    +  </Record>
    +</Annotation>
    +
    +

    14.4.1.7 Value Path

    +

    The value path expression allows assigning a value by traversing an object graph. It can be used in annotations that target entity containers, entity sets, entity types, complex types, navigation properties of structured types, and structural properties of structured types. Its argument is an instance path.

    +

    The value of the path expression is the instance or collection of instances identified by the path.

    +
    +

    Expression edm:Path

    +

    The edm:Path expression MAY be provided using element notation or attribute notation.

    +
    +
    +

    Example 71:

    +
    <Annotation Term="org.example.display.DisplayName" Path="FirstName" />
    +
    +<Annotation Term="org.example.display.DisplayName">
    +  <Path>@vCard.Address#work/FullName</Path>
    +</Annotation>
    +
    +

    14.4.2 Comparison and Logical Operators

    +

    Annotations MAY use the following logical and comparison expressions which evaluate to a Boolean value. These expressions MAY be combined and they MAY be used anywhere instead of a Boolean expression.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OperatorDescription
    Logical Operators
    AndLogical and
    OrLogical or
    NotLogical negation
    Comparison Operators
    EqEqual
    NeNot equal
    GtGreater than
    GeGreater than or equal
    LtLess than
    LeLess than or equal
    HasHas enumeration flag(s) set
    InIs in collection
    +

    The And and Or operators require two operand expressions that evaluate to Boolean values. The Not operator requires a single operand expression that evaluates to a Boolean value. For details on null handling for comparison operators see OData-URL.

    +

    The other comparison operators require two operand expressions that evaluate to comparable values.

    +
    +

    Expressions edm:And and edm:Or

    +

    The And and Or logical expressions are represented as elements edm:And and edm:Or that MUST contain two annotation expressions.

    +

    It MAY contain edm:Annotation elements.

    +

    Expression edm:Not

    +

    Negation expressions are represented as an element edm:Not that MUST contain a single annotation expression.

    +

    It MAY contain edm:Annotation elements.

    +

    Expressions edm:Eq, edm:Ne, edm:Gt, edm:Ge, edm:Lt, edm:Le, edm:Has, and edm:In

    +

    All comparison expressions are represented as an element that MUST contain two annotation expressions.

    +

    They MAY contain edm:Annotation elements.

    +
    +
    +

    Example 72:

    +
    <And>
    +  <Path>IsMale</Path>
    +  <Path>IsMarried</Path>
    +</And>
    +<Or>
    +  <Path>IsMale</Path>
    +  <Path>IsMarried</Path>
    +</Or>
    +<Not>
    +  <Path>IsMale</Path>
    +</Not>
    +<Eq>
    +  <Null />
    +  <Path>IsMale</Path>
    +</Eq>
    +<Ne>
    +  <Null />
    +  <Path>IsMale</Path>
    +</Ne>
    +<Gt>
    +  <Path>Price</Path>
    +  <Int>20</Int>
    +</Gt>
    +<Ge>
    +  <Path>Price</Path>
    +  <Int>10</Int>
    +</Ge>
    +<Lt>
    +  <Path>Price</Path>
    +  <Int>20</Int>
    +</Lt>
    +<Le>
    +  <Path>Price</Path>
    +  <Int>100</Int>
    +</Le>
    +<Has>
    +  <Path>Fabric</Path>
    +  <EnumMember>org.example.Pattern/Red</EnumMember>
    +</Has>
    +<In>
    +  <Path>Size</Path>
    +  <Collection>
    +    <String>XS</String>
    +    <String>S</String>
    +  </Collection>
    +</In>
    +
    +

    14.4.3 Arithmetic Operators

    +

    Annotations MAY use the following arithmetic expressions which evaluate to a numeric value. These expressions MAY be combined, and they MAY be used anywhere instead of a numeric expression of the appropriate type. The semantics and evaluation rules for each arithmetic expression is identical to the corresponding arithmetic operator defined in OData-URL.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OperatorDescription
    AddAddition
    SubSubtraction
    NegNegation
    MulMultiplication
    DivDivision (with integer result for integer operands)
    DivByDivision (with fractional result also for integer operands)
    ModModulo
    +

    The Neg operator requires a single operand expression that evaluates to a numeric value. The other arithmetic operators require two operand expressions that evaluate to numeric values.

    +
    +

    Expression edm:Neg

    +

    Negation expressions are represented as an element edm:Neg that MUST contain a single annotation expression.

    +

    It MAY contain edm:Annotation elements.

    +

    Expressions edm:Add, edm:Sub, edm:Mul, edm:Div, edm:DivBy, and edm:Mod

    +

    These arithmetic expressions are represented as an element that MUST contain two annotation expressions.

    +

    They MAY contain edm:Annotation elements.

    +
    +
    +

    Example 73:

    +
    <Add>
    +  <Path>StartDate</Path>
    +  <Path>Duration</Path>
    +</Add>
    +<Sub>
    +  <Path>Revenue</Path>
    +  <Path>Cost</Path>
    +</Sub>
    +<Neg>
    +  <Path>Height</Path>
    +</Neg>
    +<Mul>
    +  <Path>NetPrice</Path>
    +  <Path>TaxRate</Path>
    +</Mul>
    +<Div>
    +  <Path>Quantity</Path>
    +  <Path>QuantityPerParcel</Path>
    +</Div>
    +<DivBy>
    +  <Path>Quantity</Path>
    +  <Path>QuantityPerParcel</Path>
    +</DivBy>
    +<Mod>
    +  <Path>Quantity</Path>
    +  <Path>QuantityPerParcel</Path>
    +</Mod>
    +
    +

    14.4.4 Apply Client-Side Functions

    +

    The apply expression enables a value to be obtained by applying a client-side function. The apply expression MAY have operand expressions. The operand expressions are used as parameters to the client-side function.

    +
    +

    Expression edm:Apply

    +

    The edm:Apply element MUST contain the Function attribute and MAY contain annotation expressions as operands for the applied function.

    +

    It MAY contain more edm:Annotation elements.

    +

    Attribute Function

    +

    The value of Function is the qualified name of the client-side function to apply.

    +
    +

    OData defines the following functions. Services MAY support additional functions that MUST be qualified with a namespace other than odata. Function names qualified with odata are reserved for this specification and its future versions.

    +

    14.4.4.1 Canonical Functions

    +

    All canonical functions defined in OData-URL can be used as client-side functions, qualified with the namespace odata. The semantics of these client-side functions is identical to their counterpart function defined in OData-URL.

    +

    For example, the odata.concat client-side function takes two or more expressions as arguments. Each argument MUST evaluate to a primitive or enumeration type. It returns a value of type Edm.String that is the concatenation of the literal representations of the results of the argument expressions. Values of primitive types other than Edm.String are represented according to the appropriate alternative in the primitiveValue rule of OData-ABNF, i.e. Edm.Binary as binaryValue, Edm.Boolean as booleanValue etc.

    +
    +

    Example 74:

    +
    <Annotation Term="org.example.display.DisplayName">
    +  <Apply Function="odata.concat">
    +    <String>Product: </String>
    +    <Path>ProductName</Path>
    +    <String> (</String>
    +    <Path>Available/Quantity</Path>
    +    <String> </String>
    +    <Path>Available/Unit</Path>
    +    <String> available)</String>
    +  </Apply>
    +</Annotation>
    +
    +

    ProductName is of type String, Quantity in complex type Available is of type Decimal, and Unit in Available is of type enumeration, so the result of the Path expression is represented as the member name of the enumeration value.

    +

    14.4.4.2 Function odata.fillUriTemplate

    +

    The odata.fillUriTemplate client-side function takes two or more expressions as arguments and returns a value of type Edm.String.

    +

    The first argument MUST be of type Edm.String and specifies a URI template according to RFC6570, the other arguments MUST be labeled element expressions. Each labeled element expression specifies the template parameter name as its name and evaluates to the template parameter value.

    +

    RFC6570 defines three kinds of template parameters: simple values, lists of values, and key-value maps.

    +

    Simple values are represented as labeled element expressions that evaluate to a single primitive value. The literal representation of this value according to OData-ABNF is used to fill the corresponding template parameter.

    +

    Lists of values are represented as labeled element expressions that evaluate to a collection of primitive values.

    +

    Key-value maps are represented as labeled element expressions that evaluate to a collection of complex types with two properties that are used in lexicographic order. The first property is used as key, the second property as value.

    +
    +

    Example 75: assuming there are no special characters in values of the Name property of the Actor entity

    +
    <Apply Function="odata.fillUriTemplate">
    +  <String>http://host/someAPI/Actors/{actorName}/CV</String>
    +  <LabeledElement Name="actorName" Path="Actor/Name" />
    +</Apply>
    +
    +

    14.4.4.3 Function odata.matchesPattern

    +

    The odata.matchesPattern client-side function takes two string expressions as arguments and returns a Boolean value.

    +

    The function returns true if the second expression evaluates to an ECMAScript (JavaScript) regular expression and the result of the first argument expression matches that regular expression, using syntax and semantics of ECMAScript regular expressions.

    +
    +

    Example 76: all non-empty FirstName values not containing the letters b, c, or d evaluate to true

    +
    <Apply Function="odata.matchesPattern">
    +  <Path>FirstName</Path>
    +  <String>^[^b-d]+$</String>
    +</Apply>
    +
    +

    14.4.4.4 Function odata.uriEncode

    +

    The odata.uriEncode client-side function takes one argument of primitive type and returns the URL-encoded OData literal that can be used as a key value in OData URLs or in the query part of OData URLs.

    +

    Note: string literals are surrounded by single quotes as required by the paren-style key syntax.

    +
    +

    Example 77:

    +
    <Apply Function="odata.fillUriTemplate">
    +  <String>http://host/service/Genres({genreName})</String>
    +  <LabeledElement Name="genreName">
    +    <Apply Function="odata.uriEncode" >
    +      <Path>NameOfMovieGenre</Path>
    +    </Apply>
    +  </LabeledElement>
    +</Apply>
    +
    +

    14.4.5 Cast

    +

    The cast expression casts the value obtained from its single child expression to the specified type. The cast expression follows the same rules as the cast canonical function defined in OData-URL.

    +
    +

    Expression edm:Cast

    +

    The edm:Cast element MUST contain the Type attribute and MUST contain exactly one expression.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Type

    +

    The value of Type is a qualified type name in scope, or the character sequence Collection( followed by the qualified name of a type in scope, followed by a closing parenthesis ).

    +

    If the specified type is a primitive type or a collection of a primitive type, the facet attributes MaxLength, Unicode, Precision, Scale, and SRID MAY be specified if applicable to the specified primitive type. If the facet attributes are not specified, their values are considered unspecified.

    +
    +
    +

    Example 78:

    +
    <Annotation Term="org.example.display.Threshold">
    +  <Cast Type="Edm.Decimal">
    +    <Path>Average</Path>
    +  </Cast>
    +</Annotation>
    +
    +

    14.4.6 Collection

    +

    The collection expression enables a value to be obtained from zero or more item expressions. The value calculated by the collection expression is the collection of the values calculated by each of the item expressions. The values of the child expressions MUST all be type compatible.

    +
    +

    Expression edm:Collection

    +

    The edm:Collection element contains zero or more child expressions.

    +
    +
    +

    Example 79:

    +
    <Annotation Term="org.example.seo.SeoTerms">
    +  <Collection>
    +    <String>Product</String>
    +    <String>Supplier</String>
    +    <String>Customer</String>
    +  </Collection>
    +</Annotation>
    +
    +

    14.4.7 If-Then-Else

    +

    The if-then-else expression enables a value to be obtained by evaluating a condition expression. It MUST contain exactly three child expressions. There is one exception to this rule: if and only if the if-then-else expression is an item of a collection expression, the third child expression MAY be omitted, reducing it to an if-then expression. This can be used to conditionally add an element to a collection.

    +

    The first child expression is the condition and MUST evaluate to a Boolean result, e.g. the comparison and logical operators can be used.

    +

    The second and third child expressions are evaluated conditionally. The result MUST be type compatible with the type expected by the surrounding expression.

    +

    If the first expression evaluates to true, the second expression MUST be evaluated and its value MUST be returned as the result of the if-then-else expression. If the first expression evaluates to false and a third child element is present, it MUST be evaluated and its value MUST be returned as the result of the if-then-else expression. If no third expression is present, nothing is added to the surrounding collection.

    +
    +

    Expression edm:If

    +

    The edm:If element MUST contain two or three child expressions that MUST use element notation.

    +

    It MAY contain edm:Annotation elements.

    +
    +
    +

    Example 80: the condition is a value path expression referencing the Boolean property IsFemale, whose value then determines the value of the edm:If expression (or so it was long ago)

    +
    <Annotation Term="org.example.person.Gender">
    +  <If>
    +    <Path>IsFemale</Path>
    +    <String>Female</String>
    +    <String>Male</String>
    +  </If>
    +</Annotation>
    +
    +

    14.4.8 Is-Of

    +

    The is-of expression checks whether the value obtained from its single child expression is compatible with the specified type. It returns true if the child expression returns a type that is compatible with the specified type, and false otherwise.

    +
    +

    Expression edm:UrlRef

    +

    The edm:UrlRef expression MAY be provided using element notation or attribute notation.

    +

    Relative URLs are relative to the xml:base attribute, see XML-Base.

    +

    In element notation it MAY contain edm:Annotation elements.

    +
    +
    +

    Example 81:

    +
    <Annotation Term="self.IsPreferredCustomer">
    +  <IsOf Type="self.PreferredCustomer">
    +    <Path>Customer</Path>
    +  </IsOf>
    +</Annotation>
    +
    +

    14.4.9 Labeled Element

    +

    The labeled element expression assigns a name to its single child expression. The value of the child expression can then be reused elsewhere with a labeled element reference expression.

    +

    A labeled element expression MUST contain exactly one child expression. The value of the child expression is also the value of the labeled element expression.

    +

    A labeled element expression MUST provide a simple identifier value as its name that MUST be unique within the schema containing the expression.

    +
    +

    Expression edm:LabeledElement

    +

    The edm:LabeledElement element MUST contain the Name attribute.

    +

    It MUST contain a child expression written either in attribute notation or element notation.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Name

    +

    The value of Name is the labeled element's name.

    +
    +
    +

    Example 82:

    +
    <Annotation Term="org.example.display.DisplayName">
    +  <LabeledElement Name="CustomerFirstName" Path="FirstName" />
    +</Annotation>
    +
    +<Annotation Term="org.example.display.DisplayName">
    +  <LabeledElement Name="CustomerFirstName">
    +    <Path>FirstName</Path>
    +  </LabeledElement>
    +</Annotation>
    +
    +

    14.4.10 Labeled Element Reference

    +

    The labeled element reference expression MUST specify the qualified name of a labeled element expression in scope and returns the value of the identified labeled element expression as its value.

    +
    +

    Expression edm:LabeledElementReference

    +

    The edm:LabeledElementReference element MUST contain the qualified name of a labeled element expression in its body.

    +
    +
    +

    Example 83:

    +
    <Annotation Term="org.example.display.DisplayName">
    +  <LabeledElementReference>Model.CustomerFirstName</LabeledElementReference>
    +</Annotation>
    +
    +

    14.4.11 Null

    +

    The null expression indicates the absence of a value. The null expression MAY be annotated.

    +
    +

    Expression edm:Null

    +

    The edm:Null element MAY contain edm:Annotation elements.

    +
    +
    +

    Example 84:

    +
    <Annotation Term="org.example.display.DisplayName">
    +  <Null/>
    +</Annotation>
    +
    +
    +

    Example 85:

    +
    <Annotation Term="@UI.Address">
    +  <Null>
    +    <Annotation Term="self.Reason" String="Private" />
    +  </Null>
    +</Annotation>
    +
    +

    14.4.12 Record

    +

    The record expression enables a new entity type or complex type instance to be constructed.

    +

    A record expression MAY specify the structured type of its result, which MUST be an entity type or complex type in scope. If not explicitly specified, the type is derived from the expression's context.

    +

    A record expression contains zero or more property value expressions. For each single-valued structural or navigation property of the record expression's type that is neither nullable nor specifies a default value a property value expression MUST be provided. The only exception is if the record expression is the value of an annotation for a term that has a base term whose type is structured and directly or indirectly inherits from the type of its base term. In this case, property values that already have been specified in the annotation for the base term or its base term etc. need not be specified again.

    +

    For collection-valued properties the absence of a property value expression is equivalent to specifying an empty collection as its value.

    +
    +

    Expression edm:Record

    +

    The edm:Record element MAY contain the Type attribute and MAY contain edm:PropertyValue elements.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Type

    +

    The value of Type is the qualified name of a structured type in scope.

    +

    Element edm:PropertyValue

    +

    The edm:PropertyValue element MUST contain the Property attribute, and it MUST contain exactly one expression that MAY be provided using either element notation or attribute notation.

    +

    It MAY contain edm:Annotation elements.

    +

    Attribute Property

    +

    The value of Property is the name of a property of the type of the enclosing edm:Record expression.

    +
    +
    +

    Example 86: this annotation "morphs" the entity type from example 8 into a structured type with two structural properties GivenName and Surname and two navigation properties DirectSupervisor and CostCenter. The first three properties simply rename properties of the annotated entity type, the fourth adds a calculated navigation property that is pointing to a different service

    +
    <Annotation Term="org.example.person.Employee">
    +  <Record>
    +    <Annotation Term="Core.Description" String="Annotation on record" />
    +    <PropertyValue Property="GivenName" Path="FirstName">
    +      <Annotation Term="Core.Description"
    +                  String="Annotation on record member" />
    +    </PropertyValue>
    +    <PropertyValue Property="Surname" Path="LastName" />
    +    <PropertyValue Property="DirectSupervisor" Path="Manager" />
    +    <PropertyValue Property="CostCenter">
    +      <UrlRef>
    +        <Apply Function="odata.fillUriTemplate">
    +          <String>http://host/anotherservice/CostCenters('{ccid}')</String>
    +          <LabeledElement Name="ccid" Path="CostCenterID" />
    +        </Apply>
    +      </UrlRef>
    +    </PropertyValue>
    +  </Record>
    +</Annotation>
    +
    +

    14.4.13 URL Reference

    +

    The URL reference expression enables a value to be obtained by sending a GET request.

    +

    The URL reference expression MUST contain exactly one expression of type Edm.String. Its value is treated as a URL that MAY be relative or absolute; relative URLs are relative to the URL of the document containing the URL reference expression, or relative to a base URL specified in a format-specific way.

    +

    The response body of the GET request MUST be returned as the result of the URL reference expression. The result of the URL reference expression MUST be type compatible with the type expected by the surrounding expression.

    +
    +

    Expression edm:UrlRef

    +

    The edm:UrlRef expression MAY be provided using element notation or attribute notation.

    +

    Relative URLs are relative to the xml:base attribute, see XML-Base.

    +

    In element notation it MAY contain edm:Annotation elements.

    +
    +
    +

    Example 87:

    +
    <Annotation Term="org.example.person.Supplier">
    +  <UrlRef>
    +    <Apply Function="odata.fillUriTemplate">
    +      <String>http://host/service/Suppliers({suppID})</String>
    +      <LabeledElement Name="suppID">
    +      <Apply Function="odata.uriEncode">
    +        <Path>SupplierId</Path>
    +      </Apply>
    +      </LabeledElement>
    +     </Apply>
    +  </UrlRef>
    +</Annotation>
    +
    +<Annotation Term="Core.LongDescription">
    +  <UrlRef><String>http://host/wiki/HowToUse</String></UrlRef>
    +</Annotation>
    +
    +<Annotation Term="Core.LongDescription" UrlRef="http://host/wiki/HowToUse" />
    +
    +
    +

    15 Identifier and Path Values

    +

    15.1 Namespace

    +

    A namespace is a dot-separated sequence of simple identifiers with a maximum length of 511 Unicode characters (code points).

    +

    15.2 Simple Identifier

    +

    A simple identifier is a Unicode character sequence with the following restrictions:

    + +

    Non-normatively speaking it starts with a letter or underscore, followed by at most 127 letters, underscores or digits.

    +

    15.3 Qualified Name

    +

    For model elements that are direct children of a schema: the namespace or alias of the schema that defines the model element, followed by a dot and the name of the model element, see rule qualifiedTypeName in OData‑ABNF.

    +

    For built-in primitive types: the name of the type, prefixed with Edm followed by a dot.

    +

    15.4 Target Path

    +

    Target paths are used to refer to other model elements.

    +

    The allowed path expressions are:

    + +
    +

    Example 88: Target expressions

    +
    MySchema.MyEntityContainer/MyEntitySet
    +MySchema.MyEntityContainer/MySingleton
    +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty
    +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty
    +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp
    +
    +
    +

    16 CSDL Examples

    +

    Following are two basic examples of valid EDM models as represented in CSDL. These examples demonstrate many of the topics covered above.

    +

    16.1 Products and Categories Example

    +
    +

    Example 89:

    +
    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    +           xmlns="http://docs.oasis-open.org/odata/ns/edm" Version="4.0">
    +  <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml">
    +    <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core">
    +      <Annotation Term="Core.DefaultNamespace" />
    +    </edmx:Include>
    +  </edmx:Reference>
    +  <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.xml">
    +    <edmx:Include Alias="Measures" Namespace="Org.OData.Measures.V1" />
    +  </edmx:Reference>
    +  <edmx:DataServices>
    +    <Schema Namespace="ODataDemo">
    +      <EntityType Name="Product" HasStream="true">
    +        <Key>
    +          <PropertyRef Name="ID" />
    +        </Key>
    +        <Property Name="ID" Type="Edm.Int32" Nullable="false" />
    +        <Property Name="Description" Type="Edm.String" >
    +          <Annotation Term="Core.IsLanguageDependent" />
    +        </Property>
    +        <Property Name="ReleaseDate" Type="Edm.Date" />
    +        <Property Name="DiscontinuedDate" Type="Edm.Date" />
    +        <Property Name="Rating" Type="Edm.Int32" />
    +        <Property Name="Price" Type="Edm.Decimal" Scale="variable">
    +          <Annotation Term="Measures.ISOCurrency" Path="Currency" />
    +        </Property>
    +        <Property Name="Currency" Type="Edm.String" MaxLength="3" />
    +        <NavigationProperty Name="Category" Type="ODataDemo.Category"
    +                            Nullable="false" Partner="Products" />
    +        <NavigationProperty Name="Supplier" Type="ODataDemo.Supplier"
    +                            Partner="Products" />
    +      </EntityType>
    +      <EntityType Name="Category">
    +        <Key>
    +         <PropertyRef Name="ID" />
    +        </Key>
    +        <Property Name="ID" Type="Edm.Int32" Nullable="false" />
    +        <Property Name="Name" Type="Edm.String" Nullable="false">
    +          <Annotation Term="Core.IsLanguageDependent" />
    +        </Property>
    +        <NavigationProperty Name="Products" Partner="Category"
    +                            Type="Collection(ODataDemo.Product)">
    +          <OnDelete Action="Cascade" />
    +        </NavigationProperty>
    +      </EntityType>
    +      <EntityType Name="Supplier">
    +        <Key>
    +          <PropertyRef Name="ID" />
    +        </Key>
    +        <Property Name="ID" Type="Edm.String" Nullable="false" />
    +        <Property Name="Name" Type="Edm.String" />
    +        <Property Name="Address" Type="ODataDemo.Address" Nullable="false" />
    +        <Property Name="Concurrency" Type="Edm.Int32" Nullable="false" />
    +        <NavigationProperty Name="Products" Partner="Supplier"
    +                            Type="Collection(ODataDemo.Product)" />
    +      </EntityType>
    +      <EntityType Name="Country">
    +        <Key>
    +          <PropertyRef Name="Code" />
    +        </Key>
    +        <Property Name="Code" Type="Edm.String" MaxLength="2"
    +                              Nullable="false" />
    +        <Property Name="Name" Type="Edm.String" />
    +      </EntityType>
    +      <ComplexType Name="Address">
    +        <Property Name="Street" Type="Edm.String" />
    +        <Property Name="City" Type="Edm.String" />
    +        <Property Name="State" Type="Edm.String" />
    +        <Property Name="ZipCode" Type="Edm.String" />
    +        <Property Name="CountryName" Type="Edm.String" />
    +        <NavigationProperty Name="Country" Type="ODataDemo.Country">
    +          <ReferentialConstraint Property="CountryName"  
    +                                 ReferencedProperty="Name" />
    +        </NavigationProperty>
    +      </ComplexType>
    +      <Function Name="ProductsByRating">
    +        <Parameter Name="Rating" Type="Edm.Int32" />
    +        <ReturnType Type="Collection(ODataDemo.Product)" />
    +      </Function>
    +      <EntityContainer Name="DemoService">
    +        <EntitySet Name="Products" EntityType="ODataDemo.Product">
    +          <NavigationPropertyBinding Path="Category" Target="Categories" />
    +        </EntitySet>
    +        <EntitySet Name="Categories" EntityType="ODataDemo.Category">
    +          <NavigationPropertyBinding Path="Products" Target="Products" />
    +          <Annotation Term="Core.Description" String="Product Categories" />
    +        </EntitySet>
    +        <EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier">
    +          <NavigationPropertyBinding Path="Products" Target="Products" />
    +          <NavigationPropertyBinding Path="Address/Country"
    +                                     Target="Countries" />
    +          <Annotation Term="Core.OptimisticConcurrency">
    +            <Collection>
    +              <PropertyPath>Concurrency</PropertyPath>
    +            </Collection>
    +          </Annotation>
    +        </EntitySet>
    +        <Singleton Name="MainSupplier" Type="self.Supplier">
    +          <NavigationPropertyBinding Path="Products" Target="Products" />
    +          <Annotation Term="Core.Description" String="Primary Supplier" />
    +        </Singleton>
    +        <EntitySet Name="Countries" EntityType="ODataDemo.Country" />
    +        <FunctionImport Name="ProductsByRating" EntitySet="Products"
    +                        Function="ODataDemo.ProductsByRating" />
    +      </EntityContainer>
    +    </Schema>
    +  </edmx:DataServices>
    +</edmx:Edmx>
    +
    +

    16.2 Annotations for Products and Categories Example

    +
    +

    Example 90:

    +
    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    +           Version="4.01">
    +  <edmx:Reference Uri="http://host/service/$metadata">
    +    <edmx:Include Namespace="ODataDemo" Alias="target" />
    +  </edmx:Reference>
    +  <edmx:Reference Uri="http://somewhere/Vocabulary/V1">
    +    <edmx:Include Alias="Vocabulary1" Namespace="Some.Vocabulary.V1" />
    +  </edmx:Reference>
    +  <edmx:DataServices>
    +    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"
    +            Namespace="External.Annotations">
    +      <Annotations Target="ODataDemo.Supplier">
    +        <Annotation Term="Vocabulary1.EMail">
    +          <Null />
    +        </Annotation>
    +        <Annotation Term="Vocabulary1.AccountID" Path="ID" />
    +        <Annotation Term="Vocabulary1.Title" String="Supplier Info" />
    +        <Annotation Term="Vocabulary1.DisplayName">
    +        <Apply Function="odata.concat">
    +            <Path>Name</Path>
    +            <String> in </String>
    +            <Path>Address/CountryName</Path>
    +          </Apply>
    +        </Annotation>
    +      </Annotations>
    +      <Annotations Target="ODataDemo.Product">
    +        <Annotation Term="Vocabulary1.Tags">
    +          <Collection>
    +            <String>MasterData</String>
    +          </Collection>
    +        </Annotation>
    +      </Annotations>
    +  </Schema>
    +  </edmx:DataServices>
    +</edmx:Edmx>
    +
    +
    +

    17 Conformance

    +

    Conforming services MUST follow all rules of this specification document for the types, sets, functions, actions, containers and annotations they expose.

    +

    In addition, conforming services MUST NOT return 4.01 CSDL constructs for requests made with OData-MaxVersion:4.0.

    +

    Specifically, they

    +
      +
    1. MUST NOT include properties in derived types that overwrite a property defined in the base type

    2. +
    3. MUST NOT include Edm.Untyped

    4. +
    5. MUST NOT use path syntax added with 4.01

    6. +
    7. MUST NOT use Edm.ModelElementPath and Edm.AnyPropertyPath

    8. +
    9. MUST NOT specify referential constraints to complex types and navigation properties

    10. +
    11. MUST NOT include a non-abstract entity type with no inherited or defined entity key

    12. +
    13. MUST NOT include the Core.DefaultNamespace annotation on included schemas

    14. +
    15. MUST NOT return the Unicode facet for terms, parameters, and return types

    16. +
    17. MUST NOT include collections of Edm.ComplexType or Edm.Untyped

    18. +
    19. MUST NOT specify a key as a property of a related entity

    20. +
    21. SHOULD NOT include new/unknown values for the AppliesTo attribute

    22. +
    23. MAY include new CSDL annotations

    24. +
    +

    In addition, OData 4.01 services:

    +
      +
    1. SHOULD NOT have identifiers within a uniqueness scope (e.g. a schema, a structural type, or an entity container) that differ only by case
    2. +
    +

    Conforming clients MUST be prepared to consume a model that uses any or all constructs defined in this specification, including custom annotations, and MUST ignore constructs not defined in this version of the specification.

    +
    +

    Appendix A. References

    + + +

    This appendix contains the normative and informative references that are used in this document.

    +

    While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity.

    +

    A.1 Normative References

    +

    The following documents are referenced in such a way that some or all of their content constitutes requirements of this document.

    +
    [OData-v4.02]
    + +
    [ECMAScript]
    +

    ECMAScript 2016 Language Specification, 7th Edition. June 2016. Standard ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm.

    +
    [EPSG]
    +

    European Petroleum Survey Group (EPSG). http://www.epsg.org/.

    +
    [OData-ABNF]
    +

    OData ABNF Construction Rules Version 4.01.
    +See link in "Additional artifacts" section on cover page.

    +
    [OData-CSDL-Schema]
    +

    OData CSDL JSON Schema.
    +See link in "Related work" section on cover page.

    +
    [OData-CSDL-JSON]
    +

    OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01.
    +See link in "Related work" section on cover page.

    +
    [OData-CSDL-XML]
    +

    OData Common Schema Definition Language (CSDL) XML Representation Version 4.01.
    +See link in "Related work" section on cover page.

    +
    [OData-EDM]
    +

    OData EDM XML Schema.
    +See link in "Additional artifacts" section on cover page.

    +
    [OData-EDMX]
    +

    OData EDM XML Schema.
    +See link in "Additional artifacts" section on cover page.

    +
    [OData-JSON]
    +

    OData JSON Format Version 4.01.
    +See link in "Related work" section on cover page.

    +
    [OData-Protocol]
    +

    OData Version 4.01 Part 1: Protocol.
    +See link in "Related work" section on cover page.

    +
    [OData-URL]
    +

    OData Version 4.01 Part 2: URL Conventions.
    +See link in "Related work" section on cover page.

    +
    [OData-VocCore]
    +

    OData Vocabularies Version 4.0: Core Vocabulary.
    +See link in "Related work" section on cover page.

    +
    [OData-VocMeasures]
    +

    OData Vocabularies Version 4.0: Measures Vocabulary.
    +See link in "Related work" section on cover page.

    +
    [OData-VocValidation]
    +

    OData Vocabularies Version 4.0: Validation Vocabulary.
    +See link in "Related work" section on cover page.

    +
    [RFC2119]
    +

    Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
    +https://www.rfc-editor.org/info/rfc2119.

    +
    [RFC6570]
    +

    Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template”, RFC 6570, March 2012.
    +http://tools.ietf.org/html/rfc6570.

    +
    [RFC7493]
    +

    Bray, T., Ed., "The I-JSON Message Format", RFC7493, March 2015.
    +https://tools.ietf.org/html/rfc7493.

    +
    [RFC8174]
    +

    Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017.
    +http://www.rfc-editor.org/info/rfc8174.

    +
    [RFC8259]
    +

    Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, December 2017.
    +http://tools.ietf.org/html/rfc8259.

    +
    [XML-1.1]
    +

    Extensible Markup Language (XML) 1.1 (Second Edition). F. Yergeau, E. Maler, J. Cowan, T. Bray, C. M. Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August 2006.
    +http://www.w3.org/TR/2006/REC-xml11-20060816. Latest version available at http://www.w3.org/TR/xml11/.

    +
    [XML-Base]
    +

    XML Base (Second Edition). J. Marsh, R. Tobin, Editors, W3C Recommendation, 28 January 2009.
    +http://www.w3.org/TR/2009/REC-xmlbase-20090128/. Latest version available at http://www.w3.org/TR/xmlbase/.

    +
    [XML-Schema-1]
    +

    W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures. D. Beech, M. Maloney, C. M. Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, Editors, W3C Recommendation, 5 April 2012.
    +http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-1/.

    +
    [XML-Schema-2]
    +

    W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes. D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April 2012.
    +http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-2/.

    +

    A.2 Informative References

    +
    [OpenUI5]
    +

    OpenUI5 Version 1.40.10 - OData V4 Metadata JSON Format.
    +https://openui5.hana.ondemand.com/1.40.10/#docs/guide/87aac894a40640f89920d7b2a414499b.html.

    +
    +

    Appendix B. Table of XML Elements and Attributes

    +
    + +
    +
    +

    Appendix C. Acknowledgments

    +

    C.1 Special Thanks

    +

    The work of the OpenUI5 team on the OData V4 Metadata JSON Format, see OpenUI5, is gratefully acknowledged, especially the contributions of

    + +

    The contributions of the OASIS OData Technical Committee members, enumerated in ODataProtocol, are gratefully acknowledged.

    +

    C.2 Participants

    + + +

    The following individuals have participated in the creation of this specification and are gratefully acknowledged:

    +

    OpenC2 TC Members:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    First NameLast NameCompany
    PhilippeAlmanSomething Networks
    AlexAmirnovmanCompany B
    KrisAndermanMini Micro
    DarrenAnstmanBig Networks
    +
    +

    Appendix D. Revision History

    + + + + + + + + + + + + + + + + + + + +
    RevisionDateEditorChanges Made
    Committee Specification Draft 012023-07-14Michael Pizzo
    Ralf Handl
    Heiko Theißen
    + + +

    Appendix E. Notices

    + + +

    Copyright © OASIS Open 2023. All Rights Reserved.-------------- Michael Pizzo All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
    +Ralf Handl
    +This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English.

    +

    The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.

    +

    This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.-------------- Michael Pizzo As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata).
    +Ralf Handl
    +[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.]-------------- Michael Pizzo [OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.]
    +Ralf Handl
    +[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.]

    +

    The name "OASIS" is a trademark of OASIS, the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance.

    +
    +

    Michael Pizzo
    +Ralf Handl

    +
    +

    Michael Pizzo
    +Ralf Handl

    +

    Michael Pizzo
    +Ralf Handl

    diff --git a/docs/odata-csdl-xml/odata-csdl-xml.md b/docs/odata-csdl-xml/odata-csdl-xml.md index 6816e32dd..f7f703d90 100644 --- a/docs/odata-csdl-xml/odata-csdl-xml.md +++ b/docs/odata-csdl-xml/odata-csdl-xml.md @@ -9,20 +9,20 @@ ## 14 July 2023 -  +$\hbox{}$ #### This stage: -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.md (Authoritative) \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.pdf +https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.md (Authoritative) \ +https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html \ +https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.pdf #### Previous stage: N/A #### Latest stage: -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.md (Authoritative) \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.html \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.pdf +https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.md (Authoritative) \ +https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.html \ +https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.pdf #### Technical Committee: [OASIS Open Data Protocol (OData) TC](https://www.oasis-open.org/committees/odata/) @@ -38,23 +38,25 @@ Ralf Handl (ralf.handl@sap.com), [SAP SE](http://www.sap.com/) \ Michael Pizzo (mikep@microsoft.com), [Microsoft](http://www.microsoft.com/) \ Heiko Theißen (heiko.theissen@sap.com), [SAP SE](http://www.sap.com/) -#### Additional artifacts: +#### Additional artifacts: This prose specification is one component of a Work Product that also includes: -* XML schemas: (list file names or directory name) -* Other parts (list titles and/or file names) -* `(Note: Any normative computer language definitions that are part of the Work Product, such as XML instances, schemas and Java(TM) code, including fragments of such, must be (a) well formed and valid, (b) provided in separate plain text files, (c) referenced from the Work Product; and (d) where any definition in these separate files disagrees with the definition found in the specification, the definition in the separate file prevails. Remove this note before submitting for publication.)` +* XML schemas: _OData EDMX XML Schema and OData EDM XML Schema_. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/schemas/ -#### Related work: +#### Related work: This specification replaces or supersedes: -* _OData Common Schema Definition Language (CSDL) XML Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. OASIS Standard. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html. +* _OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. OASIS Standard. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html. This specification is related to: * _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + * _OData Version 4.02 Part 1: Protocol_. Latest stage: https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html + * _OData Version 4.02 Part 2: URL Conventions_. Latest stage: https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + * _ABNF components: OData ABNF Construction Rules Version 4.01 and OData ABNF Test Cases_. https://docs.oasis-open.org/odata/odata/v4.01/os/abnf/ +* _OData Vocabularies Version 4.0_. Edited by Michael Pizzo, Ralf Handl, and Ram Jeyaraman. Latest stage: https://docs.oasis-open.org/odata/odata-vocabularies/v4.0/odata-vocabularies-v4.0.html +* _OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html +* _OData JSON Format Version 4.01_. Edited by Ralf Handl, Mike Pizzo, and Mark Biamonte. Latest stage: https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html #### Abstract: -OData services are described by an Entity Model (EDM). The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service using, XML, JSON, and other formats. This document (OData CSDL XML Representation) specifically defines the XML representation of CSDL. +OData services are described by an Entity Model (EDM). The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service, using XML, JSON, and other formats. This document (OData CSDL JSON Representation) specifically defines the JSON representation of CSDL. #### Status: This document was last revised or approved by the OASIS Open Data Protocol (OData) TC on the above date. The level of approval is also listed above. Check the "Latest stage" location noted above for possible later revisions of this document. Any other numbered Versions and other technical work produced by the Technical Committee (TC) are listed at https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=odata#technical. @@ -66,17 +68,17 @@ This specification is provided under the [RF on RAND Terms Mode](https://www.oas Note that any machine-readable content ([Computer Language Definitions](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsCompLang)) declared Normative for this Work Product is provided in separate plain text files. In the event of a discrepancy between any such plain text file and display content in the Work Product's prose narrative document(s), the content in the separate plain text file prevails. #### Key words: -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [[RFC2119](#rfc2119)] and [[RFC8174](#rfc8174)] when, and only when, they appear in all capitals, as shown here. +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119](#rfc2119) and [RFC8174](#rfc8174) when, and only when, they appear in all capitals, as shown here. #### Citation format: When referencing this specification the following citation format should be used: -**[OData-CSDL-XML-v4.02]** +**[OData-CSDL-JSON-v4.02]** -_OData Common Schema Definition Language (CSDL) XML Representation Version 4.02_. +_OData Common Schema Definition Language (CSDL) JSON Representation Version 4.02_. Edited by Ralf Handl, Michael Pizzo, and Heiko Theißen. 14 July 2023. OASIS Committee Specification Draft 01. -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html. -Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.html. +https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/csd01/odata-csdl-xml-v4.02-csd01.html. +Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/odata-csdl-json-v4.02.html. #### Notices Copyright © OASIS Open 2023. All Rights Reserved. @@ -93,38 +95,175 @@ For complete copyright information please see the full Notices section in an App ::: toc - [1 Introduction](#Introduction) - - [1.1 Changes from earlier Versions](#ChangesfromearlierVersions) + - [1.1 Changes from Earlier Versions](#ChangesfromEarlierVersions) - [1.2 Glossary](#Glossary) - [1.2.1 Definitions of terms](#Definitionsofterms) - [1.2.2 Acronyms and abbreviations](#Acronymsandabbreviations) - [1.2.3 Document conventions](#Documentconventions) +- [2 XML Representation](#XMLRepresentation) + - [2.1 Requesting the XML Representation](#RequestingtheXMLRepresentation) + - [2.2 XML Namespaces](#XMLNamespaces) + - [2.2.1 Namespace EDMX](#NamespaceEDMX) + - [2.2.2 Namespace EDM](#NamespaceEDM) + - [2.3 XML Schema Definitions](#XMLSchemaDefinitions) + - [2.4 XML Document Order](#XMLDocumentOrder) +- [3 Entity Model](#EntityModel) + - [3.1 Nominal Types](#NominalTypes) + - [3.2 Structured Types](#StructuredTypes) + - [3.3 Primitive Types](#PrimitiveTypes) + - [3.4 Built-In Abstract Types](#BuiltInAbstractTypes) + - [3.5 Built-In Types for defining Vocabulary Terms](#BuiltInTypesfordefiningVocabularyTerms) + - [3.6 Annotations](#Annotations) +- [4 CSDL XML Document](#CSDLXMLDocument) + - [4.1 Reference](#Reference) + - [4.2 Included Schema](#IncludedSchema) + - [4.3 Included Annotations](#IncludedAnnotations) +- [5 Schema](#Schema) + - [5.1 Alias](#Alias) + - [5.2 Annotations with External Targeting](#AnnotationswithExternalTargeting) +- [6 Entity Type](#EntityType) + - [6.1 Derived Entity Type](#DerivedEntityType) + - [6.2 Abstract Entity Type](#AbstractEntityType) + - [6.3 Open Entity Type](#OpenEntityType) + - [6.4 Media Entity Type](#MediaEntityType) + - [6.5 Key](#Key) +- [7 Structural Property](#StructuralProperty) + - [7.1 Type](#Type) + - [7.2 Type Facets](#TypeFacets) + - [7.2.1 Nullable](#Nullable) + - [7.2.2 MaxLength](#MaxLength) + - [7.2.3 Precision](#Precision) + - [7.2.4 Scale](#Scale) + - [7.2.5 Unicode](#Unicode) + - [7.2.6 SRID](#SRID) + - [7.2.7 Default Value](#DefaultValue) +- [8 Navigation Property](#NavigationProperty) + - [8.1 Navigation Property Type](#NavigationPropertyType) + - [8.2 Nullable Navigation Property](#NullableNavigationProperty) + - [8.3 Partner Navigation Property](#PartnerNavigationProperty) + - [8.4 Containment Navigation Property](#ContainmentNavigationProperty) + - [8.5 Referential Constraint](#ReferentialConstraint) + - [8.6 On-Delete Action](#OnDeleteAction) +- [9 Complex Type](#ComplexType) + - [9.1 Derived Complex Type](#DerivedComplexType) + - [9.2 Abstract Complex Type](#AbstractComplexType) + - [9.3 Open Complex Type](#OpenComplexType) +- [10 Enumeration Type](#EnumerationType) + - [10.1 Underlying Integer Type](#UnderlyingIntegerType) + - [10.2 Flags Enumeration Type](#FlagsEnumerationType) + - [10.3 Enumeration Type Member](#EnumerationTypeMember) +- [11 Type Definition](#TypeDefinition) + - [11.1 Underlying Primitive Type](#UnderlyingPrimitiveType) +- [12 Action and Function](#ActionandFunction) + - [12.1 Action](#Action) + - [12.2 Action Overloads](#ActionOverloads) + - [12.3 Function](#Function) + - [12.4 Function Overloads](#FunctionOverloads) + - [12.5 Bound or Unbound Action or Function Overloads](#BoundorUnboundActionorFunctionOverloads) + - [12.6 Entity Set Path](#EntitySetPath) + - [12.7 Composable Function](#ComposableFunction) + - [12.8 Return Type](#ReturnType) + - [12.9 Parameter](#Parameter) +- [13 Entity Container](#EntityContainer) + - [13.1 Extending an Entity Container](#ExtendinganEntityContainer) + - [13.2 Entity Set](#EntitySet) + - [13.3 Singleton](#Singleton) + - [13.4 Navigation Property Binding](#NavigationPropertyBinding) + - [13.4.1 Navigation Property Path Binding](#NavigationPropertyPathBinding) + - [13.4.2 Binding Target](#BindingTarget) + - [13.5 Action Import](#ActionImport) + - [13.6 Function Import](#FunctionImport) +- [14 Vocabulary and Annotation](#VocabularyandAnnotation) + - [14.1 Term](#Term) + - [14.1.1 Specialized Term](#SpecializedTerm) + - [14.1.2 Applicability](#Applicability) + - [14.2 Annotation](#Annotation) + - [14.2.1 Qualifier](#Qualifier) + - [14.2.2 Target](#Target) + - [14.3 Constant Expression](#ConstantExpression) + - [14.3.1 Binary](#Binary) + - [14.3.2 Boolean](#Boolean) + - [14.3.3 Date](#Date) + - [14.3.4 DateTimeOffset](#DateTimeOffset) + - [14.3.5 Decimal](#Decimal) + - [14.3.6 Duration](#Duration) + - [14.3.7 Enumeration Member](#EnumerationMember) + - [14.3.8 Floating-Point Number](#FloatingPointNumber) + - [14.3.9 Guid](#Guid) + - [14.3.10 Integer](#Integer) + - [14.3.11 String](#String) + - [14.3.12 Time of Day](#TimeofDay) + - [14.4 Dynamic Expression](#DynamicExpression) + - [14.4.1 Path Expressions](#PathExpressions) + - [14.4.1.1 Path Syntax](#PathSyntax) + - [14.4.1.2 Path Evaluation](#PathEvaluation) + - [14.4.1.3 Annotation Path](#AnnotationPath) + - [14.4.1.4 Model Element Path](#ModelElementPath) + - [14.4.1.5 Navigation Property Path](#NavigationPropertyPath) + - [14.4.1.6 Property Path](#PropertyPath) + - [14.4.1.7 Value Path](#ValuePath) + - [14.4.2 Comparison and Logical Operators](#ComparisonandLogicalOperators) + - [14.4.3 Arithmetic Operators](#ArithmeticOperators) + - [14.4.4 Apply Client-Side Functions](#ApplyClientSideFunctions) + - [14.4.4.1 Canonical Functions](#CanonicalFunctions) + - [14.4.4.2 Function `odata.fillUriTemplate`](#FunctionodatafillUriTemplate) + - [14.4.4.3 Function `odata.matchesPattern`](#FunctionodatamatchesPattern) + - [14.4.4.4 Function `odata.uriEncode`](#FunctionodatauriEncode) + - [14.4.5 Cast](#Cast) + - [14.4.6 Collection](#Collection) + - [14.4.7 If-Then-Else](#IfThenElse) + - [14.4.8 Is-Of](#IsOf) + - [14.4.9 Labeled Element](#LabeledElement) + - [14.4.10 Labeled Element Reference](#LabeledElementReference) + - [14.4.11 Null](#Null) + - [14.4.12 Record](#Record) + - [14.4.13 URL Reference](#URLReference) +- [15 Identifier and Path Values](#IdentifierandPathValues) + - [15.1 Namespace](#Namespace) + - [15.2 Simple Identifier](#SimpleIdentifier) + - [15.3 Qualified Name](#QualifiedName) + - [15.4 Target Path](#TargetPath) +- [16 CSDL Examples](#CSDLExamples) + - [16.1 Products and Categories Example](#ProductsandCategoriesExample) + - [16.2 Annotations for Products and Categories Example](#AnnotationsforProductsandCategoriesExample) +- [17 Conformance](#Conformance) +- [A References](#References) + - [A.1 Normative References](#NormativeReferences) + - [A.2 Informative References](#InformativeReferences) +- [B Table of XML Elements and Attributes](#TableofXMLElementsandAttributes) +- [C Acknowledgments](#Acknowledgments) + - [C.1 Special Thanks](#SpecialThanks) + - [C.2 Participants](#Participants) +- [D Revision History](#RevisionHistory) +- [E Notices ](#Notices) ::: ------- # 1 Introduction - +OData services are described in terms of an [Entity +Model](#EntityModel). The Common Schema Definition Language (CSDL) +defines a representation of the entity model exposed by an OData service +using the JavaScript Object Notation (JSON), see [RFC8259](#rfc8259). -## 1.1 Changes from earlier Versions +This format is based on the OpenUI5 OData V4 Metadata JSON Format, see +[OpenUI5](#_OpenUI5), with some extensions and +modifications made necessary to fully cover OData CSDL Version 4.01. - - +## 1.1 Changes from Earlier Versions ## 1.2 Glossary ### 1.2.1 Definitions of terms - -TODO: find out why we need a $dummy$ formula to get `monospace` look as we want it. - ### 1.2.2 Acronyms and abbreviations ### 1.2.3 Document conventions -Keywords defined by this specification use `this monospaced font`. +Keywords defined by this specification use `this monospaced font`. Some sections of this specification are illustrated with non-normative examples. @@ -137,6 +276,14 @@ Non-normative examples use this paragraph style. All examples in this document are non-normative and informative only. Examples labeled with ⚠ contain advanced concepts or make use of keywords that are defined only later in the text, they can be skipped at first reading. +Representation-specific text is indented and marked with vertical lines. + +::: rep +### Representation-Specific Headline + +Normative representation-specific text +::: + All other text is normative unless otherwise labeled. ::: example @@ -159,169 +306,5608 @@ pandoc -f gfm+tex_math_dollars+fenced_divs This uses pandoc 3.1.2 from https://github.com/jgm/pandoc/releases/tag/3.1.2. ::: -------- + -# 2 Section Heading -text. + +# 2 XML Representation -## 2.1 Level 2 Heading -text. +OData CSDL XML is a full representation of the OData Common Schema +Definition Language in the Extensible Markup Language (XML) 1.1 (Second +Edition) [XML-1.1](#XML-11) with further building blocks from the +W3C XML Schema Definition Language (XSD) 1.1 as described in +[XML-Schema-1](#XML-Schema1) and +[XML-Schema-2](#XML-Schema2). -### 2.1.1 Level 3 Heading -text. +It is an alternative to the CSDL JSON representation defined in +[OData-CSDLJSON](#ODataCSDLJSON) and neither adds nor +removes features. -#### 2.1.1.1 Level 4 Heading -text. +## 2.1 Requesting the XML Representation -##### 2.1.1.1.1 Level 5 Heading -This is the deepest level, because six # gets transformed into a Reference tag. +The OData CSDL XML representation can be requested using the `$format` +query option in the request URL with the media type `application/xml`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `xml` which MUST NOT be followed by media type parameters. +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/xml`, optionally followed by +media type parameters. -## 2.2 Next Heading -text. +If specified, `$format` overrides any value specified in the `Accept` +header. -------- +The response MUST contain the `Content-Type` header with a value of +`application/xml`, optionally followed by media type parameters. -# 3 Conformance - +This specification does not define additional parameters for the media +type `application/xml`. -`(Note: The [OASIS TC Process](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsConfClause) requires that a specification approved by the TC at the Committee Specification Public Review Draft, Committee Specification or OASIS Standard level must include a separate section, listing a set of numbered conformance clauses, to which any implementation of the specification must adhere in order to claim conformance to the specification (or any optional portion thereof). This is done by listing the conformance clauses here.` -`For the definition of "conformance clause," see [OASIS Defined Terms](https://www.oasis-open.org/policies-guidelines/oasis-defined-terms-2018-05-22/#dConformanceClause).` +## 2.2 XML Namespaces -`See "Guidelines to Writing Conformance Clauses": -https://docs.oasis-open.org/templates/TCHandbook/ConformanceGuidelines.html.` +In addition to the default XML namespace, the elements and attributes +used to describe the entity model of an OData service are defined in one +of the following namespaces. -`Remove this note before submitting for publication.)` +### 2.2.1 Namespace EDMX +Elements and attributes associated with the top-level wrapper that +contains the CSDL used to define the entity model for an OData Service +are qualified with the Entity Data Model for Data Services Packaging +namespace: +- `http://docs.oasis-open.org/odata/ns/edmx` -------- +Prior versions of OData used the following namespace for EDMX: +- EDMX version 1.0: +`http://schemas.microsoft.com/ado/2007/06/edmx` -# Appendix A. References +They are non-normative for this specification. - +In this specification the namespace prefix `edmx` is used to represent +the Entity Data Model for Data Services Packaging namespace, however the +prefix name is not prescriptive. -This appendix contains the normative and informative references that are used in this document. +### 2.2.2 Namespace EDM -While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity. +Elements and attributes that define the entity model exposed by the +OData Service are qualified with the Entity Data Model namespace: +- `http://docs.oasis-open.org/odata/ns/edm` -## A.1 Normative References +Prior versions of CSDL used the following namespaces for EDM: -The following documents are referenced in such a way that some or all of their content constitutes requirements of this document. +- CSDL version 1.0: `http://schemas.microsoft.com/ado/2006/04/edm` +- CSDL version 1.1: `http://schemas.microsoft.com/ado/2007/05/edm` +- CSDL version 1.2: `http://schemas.microsoft.com/ado/2008/01/edm` +- CSDL version 2.0: `http://schemas.microsoft.com/ado/2008/09/edm` +- CSDL version 3.0: `http://schemas.microsoft.com/ado/2009/11/edm` -`(Reference sources: -For references to IETF RFCs, use the approved citation formats at: -https://docs.oasis-open.org/templates/ietf-rfc-list/ietf-rfc-list.html. -For references to W3C Recommendations, use the approved citation formats at: -https://docs.oasis-open.org/templates/w3c-recommendations-list/w3c-recommendations-list.html. -Remove this note before submitting for publication.)` +They are non-normative for this specification. -###### [OData-v4.02] -* _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html +In this specification the namespace prefix `edm` is used to represent +the Entity Data Model namespace, however the prefix name is not +prescriptive. -##### [RFC2119] -_Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997_ -http://www.rfc-editor.org/info/rfc2119. +## 2.3 XML Schema Definitions -###### [RFC8174] -_Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017_ -http://www.rfc-editor.org/info/rfc8174. +This specification contains normative XML schemas for the EDMX and EDM +namespaces; see [OData-EDMX](#ODataEDMX) and +[OData-EDM](#ODataEDM) -## A.2 Informative References +These XML schemas only define the shape of a well-formed CSDL XML +document and are not descriptive enough to define what a correct CSDL +XML document MUST be in every imaginable use case. This specification +document defines additional rules that correct CSDL XML documents MUST +fulfill. In case of doubt on what makes a CSDL XML document correct the +rules defined in this specification document take precedence. -###### [RFC3552] -_Rescorla, E. and B. Korver, "Guidelines for Writing RFC Text on Security Considerations", BCP 72, RFC 3552, DOI 10.17487/RFC3552, July 2003_ -https://www.rfc-editor.org/info/rfc3552. +## 2.4 XML Document Order -------- +Client libraries MUST retain the document order of XML elements for CSDL +XML documents because for some elements the order of child elements is +significant. This includes, but is not limited to, [members of +enumeration types](#EnumerationTypeMember) and items within a +[collection expression](#Collection). -# Appendix B. Safety, Security and Privacy Considerations +OData does not impose any ordering constraints on XML attributes within +XML elements. - +# 3 Entity Model -`(Note: OASIS strongly recommends that Technical Committees consider issues that might affect safety, security, privacy, and/or data protection in implementations of their specification and document them for implementers and adopters. For some purposes, you may find it required, e.g. if you apply for IANA registration.` +An OData service exposes a single entity model. This model may be +distributed over several [schemas](#Schema), and these schemas may be +distributed over several documents. -`While it may not be immediately obvious how your specification might make systems vulnerable to attack, most specifications, because they involve communications between systems, message formats, or system settings, open potential channels for exploit. For example, IETF [[RFC3552](#rfc3552)] lists “eavesdropping, replay, message insertion, deletion, modification, and man-in-the-middle” as well as potential denial of service attacks as threats that must be considered and, if appropriate, addressed in IETF RFCs.` +A service is defined by a single CSDL document which can be accessed by +sending a `GET` request to `/$metadata`. This document is +called the metadata document. It MAY [reference](#Reference) other CSDL +documents. -`In addition to considering and describing foreseeable risks, this section should include guidance on how implementers and adopters can protect against these risks.` +The metadata document contains a single [entity +container](#EntityContainer) that defines the resources exposed by this +service. This entity container MAY [extend](#ExtendinganEntityContainer) +an entity container defined in a [referenced document](#Reference). -`We encourage editors and TC members concerned with this subject to read _Guidelines for Writing RFC Text on Security Considerations_, IETF [[RFC3552](#rfc3552)], for more information.` +The *model* of the service consists of all CSDL constructs used in its +entity containers. -`Remove this note before submitting for publication.)` +The *scope* of a CSDL document is the document itself and all schemas +[included](#IncludedSchema) from directly [referenced +documents](#Reference). All entity types, complex types and other named +model elements *in scope* (that is, defined in the document itself or a +schema of a directly referenced document) can be accessed from a +referencing document by their qualified names. This includes the +[built-in primitive](#PrimitiveTypes) and [abstract +types](#BuiltInAbstractTypes). -------- +Referencing another document may alter the model defined by the +referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, +then an [entity set](#EntitySet) of the service defined by the +referencing document may return entities of the derived type. This is +identical to the behavior if the derived type had been defined directly +in the referencing document. -# Appendix C. Acknowledgments +Note: referencing documents is not recursive. Only named model elements +defined in directly referenced documents can be used within the schema. +However, those elements may in turn include or reference model elements +defined in schemas referenced by their defining schema. - +## 3.1 Nominal Types -`Note: A Work Product approved by the TC must include a list of people who participated in the development of the Work Product. This is generally done by collecting the list of names in this appendix. This list shall be initially compiled by the Chair, and any Member of the TC may add or remove their names from the list by request. Remove this note before submitting for publication.` +A nominal type has a name that MUST be a [simple +identifier](#SimpleIdentifier). Nominal types are referenced using their +[qualified name](#QualifiedName). The qualified type name MUST be unique +within a model as it facilitates references to the element from other +parts of the model. -## C.1 Special Thanks +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. - +## 3.2 Structured Types -Substantial contributions to this document from the following individuals are gratefully acknowledged: +Structured types are composed of other model elements. Structured types +are common in entity models as the means of representing entities and +structured properties in an OData service. [Entity types](#EntityType) +and [complex types](#ComplexType) are both structured types. -Participant Name, Affiliation or "Individual Member" +Structured Types are composed of zero or more [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty). -## C.2 Participants +[Open entity types](#OpenEntityType) and [open complex +types](#OpenComplexType) allow properties to be added dynamically to +instances of the open type. - +## 3.3 Primitive Types -The following individuals have participated in the creation of this specification and are gratefully acknowledged: +Structured types are composed of other structured types and primitive +types. OData defines the following primitive types: -**OpenC2 TC Members:** +Type|Meaning +----|------- +`Edm.Binary` |Binary data +`Edm.Boolean` |Binary-valued logic +`Edm.Byte` |Unsigned 8-bit integer +`Edm.Date` |Date without a time-zone offset +`Edm.DateTimeOffset` |Date and time with a time-zone offset, no leap seconds +`Edm.Decimal` |Numeric values with decimal representation +`Edm.Double` |IEEE 754 binary64 floating-point number (15-17 decimal digits) +`Edm.Duration` |Signed duration in days, hours, minutes, and (sub)seconds +`Edm.Guid` |16-byte (128-bit) unique identifier +`Edm.Int16` |Signed 16-bit integer +`Edm.Int32` |Signed 32-bit integer +`Edm.Int64` |Signed 64-bit integer +`Edm.SByte` |Signed 8-bit integer +`Edm.Single` |IEEE 754 binary32 floating-point number (6-9 decimal digits) +`Edm.Stream` |Binary data stream +`Edm.String` |Sequence of characters +`Edm.TimeOfDay` |Clock time 00:00-23:59:59.999999999999 +`Edm.Geography` |Abstract base type for all Geography types +`Edm.GeographyPoint` |A point in a round-earth coordinate system +`Edm.GeographyLineString` |Line string in a round-earth coordinate system +`Edm.GeographyPolygon` |Polygon in a round-earth coordinate system +`Edm.GeographyMultiPoint` |Collection of points in a round-earth coordinate system +`Edm.GeographyMultiLineString` |Collection of line strings in a round-earth coordinate system +`Edm.GeographyMultiPolygon` |Collection of polygons in a round-earth coordinate system +`Edm.GeographyCollection` |Collection of arbitrary Geography values +`Edm.Geometry` |Abstract base type for all Geometry types +`Edm.GeometryPoint` |Point in a flat-earth coordinate system +`Edm.GeometryLineString` |Line string in a flat-earth coordinate system +`Edm.GeometryPolygon` |Polygon in a flat-earth coordinate system +`Edm.GeometryMultiPoint` |Collection of points in a flat-earth coordinate system +`Edm.GeometryMultiLineString` |Collection of line strings in a flat-earth coordinate system +`Edm.GeometryMultiPolygon` |Collection of polygons in a flat-earth coordinate system +`Edm.GeometryCollection` |Collection of arbitrary Geometry values -| First Name | Last Name | Company | -| :--- | :--- | :--- | -Philippe | Alman | Something Networks -Alex | Amirnovman | Company B -Kris | Anderman | Mini Micro -Darren | Anstman | Big Networks +`Edm.Date` and `Edm.DateTimeOffset` follow +[XML-Schema-2](#XML-Schema2) and use the proleptic Gregorian +calendar, allowing the year `0000` (equivalent to 1 BCE) and negative +years (year `-0001` being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying +persistency layer, e.g. SQL only supports years `0001` to `9999`. + +`Edm.Decimal` with a [`Scale`](#Scale) value of `floating`, +`Edm.Double`, and `Edm.Single` allow the special numeric values `-INF`, +`INF`, and `NaN`. + +`Edm.Stream` is a primitive type that can be used as a property of an +[entity type](#EntityType) or [complex type](#ComplexType), the +underlying type for a [type definition](#TypeDefinition), or the binding +parameter or return type of an [action](#Action) or +[function](#Function). `Edm.Stream`, or a type definition whose +underlying type is `Edm.Stream`, cannot be used in collections or for +non-binding parameters to functions or actions. + +Some of these types allow [facets](#TypeFacets), defined in section +"[Type Facets](#TypeFacets)". + +See rule `primitiveLiteral` in [OData-ABNF](#ODataABNF) for the +representation of primitive type values in URLs and +[OData-JSON](#ODataJSON) for the representation in requests and +responses. + +## 3.4 Built-In Abstract Types + +The following built-in abstract types can be used within a model: +- `Edm.PrimitiveType` +- `Edm.ComplexType` +- `Edm.EntityType` +- `Edm.Untyped` + +Conceptually, these are the abstract base types for primitive types +(including type definitions and enumeration types), complex types, +entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except: +- `Edm.EntityType` + - cannot be used as the type of a singleton in an entity container + because it doesn't define a structure, which defeats the purpose + of a singleton. + - cannot be used as the type of an entity set because all entities + in an entity set must have the same key fields to uniquely + identify them within the set. + - cannot be the base type of an entity type or complex type. +- `Edm.ComplexType` + - cannot be the base type of an entity type or complex type. +- `Edm.PrimitiveType` + - cannot be used as the type of a key property of an entity type + or as the underlying type of an enumeration type. + - cannot be used as the underlying type of a type definition in a + CSDL document with a version of `4.0`. + - can be used as the underlying type of a type definition in a + CSDL document with a version of `4.01` or greater. +- `Edm.Untyped` + - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + - cannot be used as the type of a key property of an entity type. + - cannot be the base type of an entity type or complex type. + - cannot be used as the underlying type of a type definition or + enumeration type. +- `Collection(Edm.PrimitiveType)` + - cannot be used as the type of a property or term. + - cannot be used as the type of a parameter or the return type of + an action or function. +- `Collection(Edm.Untyped)` + - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + +## 3.5 Built-In Types for defining Vocabulary Terms + +[Vocabulary terms](#VocabularyandAnnotation) can, in addition, use +- `Edm.AnnotationPath` +- `Edm.PropertyPath` +- `Edm.NavigationPropertyPath` +- `Edm.AnyPropertyPath` (`Edm.PropertyPath` or `Edm.NavigationPropertyPath`) +- `Edm.ModelElementPath` (any model element, including +`Edm.AnnotationPath`, `Edm.NavigationPropertyPath`, and +`Edm.PropertyPath`) + +as the type of a primitive term, or the type of a property of a complex +type (recursively) that is exclusively used as the type of a term. See +section "[Path Expressions](#PathExpressions)" for details. + +## 3.6 Annotations + +Many parts of the model can be decorated with additional information +using [annotations](#Annotation). Annotations are identified by their +term name and an optional qualifier that allows applying the same term +multiple times to the same model element. + +A model element MUST NOT specify more than one annotation for a given +combination of term and qualifier. ------- -# Appendix D. Revision History +# 4 CSDL XML Document - + + + + +::: {.varxml .rep} +### Element `edmx:Edmx` + +The `edmx:Edmx` element is the root element of a CSDL XML document. It +MUST contain the `Version` attribute and it MUST contain exactly one +`edmx:DataServices` element. + +It MAY contain [`edmx:Reference`](#Reference) elements to reference +other CSDL documents. + +### Attribute `Version` + +The `Version` attribute specifies the OData protocol version of the +service. For OData 4.0 responses the value of this attribute MUST be +`4.0.` For OData 4.01 responses the value of this attribute MUST be +`4.01.` Services MUST return an OData 4.0 response if the request was +made with an `OData-MaxVersion `header with a value of `4.0`. + +### Element `edmx:DataServices` + +The `edmx:DataServices` element MUST contain one or more +[`edm:Schema`](#Schema) elements which define the schemas exposed by the +OData service. +::: + +::: {.varxml .example} +Example 2: +```xml + + + ... + + +``` +::: + +## 4.1 Reference + +A reference to an external CSDL document allows to bring part of the +referenced document's content into the scope of the referencing +document. + +A reference MUST specify a URI that uniquely identifies the referenced +document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be +absolute or relative URI; relative URLs are relative to the URL of the +document containing the reference, or relative to a base URL specified +in a format-specific way. + +A reference MAY be annotated. + +The +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation, defined in [OData-VocCore](#ODataVocCore), MAY be used to +indicate a particular version of the referenced document. If the +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation is present, the `$schemaversion` system query option, defined +[OData-Protocol](#ODataProtocol), SHOULD be used when retrieving the +referenced schema document. -| Revision | Date | Editor | Changes Made | -| :--- | :--- | :--- | :--- | -| specname-v1.0-wd01 | yyyy-mm-dd | Editor Name | Initial working draft | + + +::: {.varxml .rep} +### Element `edmx:Reference` + +The `edmx:Reference` element specifies external CSDL documents +referenced by the referencing document. The child elements +[`edmx:Include`](#IncludedSchema) and +[`edmx:IncludeAnnotations`](#IncludedAnnotations) specify which parts of +the referenced document are available for use in the referencing +document. + +The `edmx:Reference` element MUST contain the `Uri` attribute, and it +MUST contain at least one [`edmx:Include`](#IncludedSchema) or +[`edmx:IncludeAnnotations`](#IncludedAnnotations) child element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Uri` + +The value of `Uri` is an absolute or relative URI; relative URIs are +relative to the `xml:base` attribute, see +[XML-Base](#XML-Base). +::: + +::: {.varxml .example} +Example 3: references to other CSDL documents +```xml + + + + ... + + + ... + + + ... + + ... + +``` +::: + +## 4.2 Included Schema + +A reference MAY include zero or more schemas from the referenced +document. + +The included schemas are identified via their [namespace](#Namespace). +The same namespace MUST NOT be included more than once, even if it is +declared in more than one referenced document. + +When including a schema, a [simple identifier](#SimpleIdentifier) value +MAY be specified as an alias for the schema that is used in qualified +names instead of the namespace. For example, an alias of `display` might +be assigned to the namespace `org.example.vocabularies.display`. An +alias-qualified name is resolved to a fully qualified name by examining +aliases for included schemas and schemas defined within the document. + + +::: {.varxml .rep} +If an included schema specifies an alias, the alias MAY be used instead +of the namespace within qualified names to identify model elements of +the included schema. An alias only provides a more convenient notation, +allowing a short string to be substituted for a long namespace. Every +model element that can be identified via an alias-qualified name can +alternatively be identified via its full namespace-qualified name. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +An alias is only valid within the document in which it is declared; a +referencing document may define its own aliases for included schemas. + + + +::: {.varxml .rep} +### Element `edmx:Include` + +The `edmx:Include` element specifies a schema to include from the +referenced CSDL document. It MUST provide the `Namespace` attribute and +it MAY provide the `Alias` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Namespace` + +The value of `Namespace` is the namespace of a schema defined in the +referenced CSDL document. + +### Attribute `Alias` + +The value of `Alias` is a [simple identifier](#SimpleIdentifier) that +can be used in qualified names instead of the namespace. +::: + +::: {.varxml .example} +Example 4: references to entity models containing definitions of +vocabulary terms +```xml + + + + + + + + + + + + + + ... + +``` +::: + +## 4.3 Included Annotations + +In addition to including whole schemas with all model constructs defined +within that schema, annotations can be included with more flexibility. + +Annotations are selectively included by specifying the +[namespace](#Namespace) of the annotations' term. Consumers can opt not +to inspect the referenced document if none of the term namespaces is of +interest for the consumer. + +In addition, the [qualifier](#Qualifier) of annotations to be included +MAY be specified. For instance, a service author might want to supply a +different set of annotations for various device form factors. If a +qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of +the target namespace, if present) SHOULD be included. If no qualifier is +specified, all annotations within the referenced document from the +specified term namespace (taking into account the target namespace, if +present) SHOULD be included. + +The qualifier also provides consumers insight about what qualifiers are +present in the referenced document. If the consumer is not interested in +that particular qualifier, the consumer can opt not to inspect the +referenced document. + +In addition, the namespace of the annotations' [target](#Target) MAY be +specified. If a target namespace is specified, only those annotations +which apply a term form the specified term namespace to a model element +of the target namespace (with the specified qualifier, if present) +SHOULD be included. If no target namespace is specified, all annotations +within the referenced document from the specified term namespace (taking +into account the qualifier, if present) SHOULD be included. + +The target namespace also provides consumers insight about what +namespaces are present in the referenced document. If the consumer is +not interested in that particular target namespace, the consumer can opt +not to inspect the referenced document. + + + +::: {.varxml .rep} +### Element `edmx:IncludeAnnotations` + +The `edmx:IncludeAnnotations` element specifies the annotations to +include from the referenced CSDL document. If no +`edmx:IncludeAnnotations` element is specified, a client MAY ignore all +annotations in the referenced document that are not explicitly used in +an [`edm:Path`](#ValuePath) expression of the referencing document. + +The `edmx:IncludeAnnotations` element MUST provide the `TermNamespace` +attribute, and it MAY provide the `Qualifier` and `TargetNamespace` +attribute. + +### Attribute `TermNamespace` + +The value of `TermNamespace` is a namespace. + +### Attribute `Qualifier` + +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). + +### Attribute `TargetNamespace` + +The value of `TargetNamespace` is a namespace. +::: + +::: {.varxml .example} +Example 5: reference documents that contain annotations +```xml + + + + + + + + + ... + +``` +::: + +::: example +The following annotations from `http://odata.org/ann/b` are included: +- Annotations that use a +term from the `org.example.validation` namespace, and +- Annotations that use a +term from the `org.example.display` namespace and specify a `Tablet` +qualifier and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Sales` namespace and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Person` namespace and specify a `Tablet` qualifier. +::: ------- -# Appendix E. Example Appendix with subsections +# 5 Schema + +One or more schemas describe the entity model exposed by an OData +service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms. + +A schema is identified by a [namespace](#Namespace). Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally +unique. A schema cannot span more than one document. + +The schema's namespace is combined with the name of elements in the +schema to create unique [qualified names](#QualifiedName), so +identifiers that are used to name types MUST be unique within a +namespace to prevent ambiguity. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +The namespace MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. -## E.1 Subsection title -### E.1.1 Sub-subsection +::: {.varxml .rep} +### Element `edm:Schema` + +The `edm:Schema` element defines a +schema. It MUST contain the `Namespace` attribute and it MAY +contain the `Alias` attribute. + +It MAY contain elements [`edm:Action`](#Action), +[`edm:Annotations`](#AnnotationswithExternalTargeting), +[`edm:Annotation`](#Annotation), [`edm:ComplexType`](#ComplexType), +[`edm:EntityContainer`](#EntityContainer), +[`edm:EntityType`](#EntityType), [`edm:EnumType`](#EnumerationType), +[`edm:Function`](#Function), [`edm:Term`](#Term), or +[`edm:TypeDefinition`](#TypeDefinition). + +### Attribute `Namespace` + +The value of `Namespace` is the namespace of the schema +::: + +## 5.1 Alias + +A schema MAY specify an alias which MUST be a [simple +identifier](#SimpleIdentifier). + + +If a schema specifies an alias, the alias MAY be used instead of the +namespace within qualified names to identify model elements of that +schema. An alias only provides a more convenient notation, allowing a +short string to be substituted for a long namespace. Every model element +that can be identified via an alias-qualified name can alternatively be +identified via its full namespace-qualified name. + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the +containing document and are not restricted to the schema that defines +them. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + + + +::: {.varxml .rep} +### Attribute `Alias` + +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example 6: schema `org.example` with an alias and a description for the +schema +```xml + + + ... + +``` +::: + +## 5.2 Annotations with External Targeting + + + +::: {.varxml .rep} +### Element `edm:Annotations` + +The `edm:Annotations` element is used to apply a group of annotations to +a single model element. It MUST contain the `Target` attribute and it +MAY contain the `Qualifier` attribute. + +It MUST contain at least one [`edm:Annotation`](#Annotation) element. + +### Attribute `Target` + +The value of `Target` is a path expression identifying the [annotation +target](#Target). It MUST resolve to a model element in scope. + +### Attribute `Qualifier` + +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example 7: annotations should only be applied to tablet devices +```xml + + + ... + +``` +::: ------- -# Appendix F. Notices +# 6 Entity Type - +Entity types are [nominal](#NominalTypes) [structured +types](#StructuredTypes) with a key that consists of one or more +references to [structural properties](#StructuralProperty). An entity +type is the template for an entity: any uniquely identifiable record +such as a customer or order. -Copyright © OASIS Open 2023. All Rights Reserved. +The entity type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +An entity type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to another entity type or collection of entity types. + +All properties MUST have a unique name within an entity type. Properties +MUST NOT have the same name as the declaring entity type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + + + +::: {.varxml .rep} +### Element `edm:EntityType` + +The `edm:EntityType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedEntityType), +[`Abstract`](#AbstractEntityType), [`OpenType`](#OpenEntityType), and +[`HasStream`](#MediaEntityType) attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the entity type. + +It MAY contain one [`edm:Key`](#Key) element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the entity type's name. +::: + +::: {.varxml .example} +Example 8: a simple entity type +```xml + + + + + + + + + +``` +::: + +## 6.1 Derived Entity Type + +An entity type can inherit from another entity type by specifying it as +its base type. + +An entity type inherits the [key](#Key) as well as structural and +navigation properties of its base type. + +An entity type MUST NOT introduce an inheritance cycle by specifying a +base type. + + + +::: {.varxml .rep} +### Attribute `BaseType` + +The value of `BaseType` is the qualified name of the base type. +::: + +::: {.varxml .example} +Example 9: a derived entity type based on the previous example +```xml + + + + +``` +::: + +::: example +Note: the derived type has the same name as one of the properties of its +base type. +::: -All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full [Policy](https://www.oasis-open.org/policies-guidelines/ipr/) may be found at the OASIS website. +## 6.2 Abstract Entity Type -This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. +An entity type MAY indicate that it is abstract and cannot have +instances. -The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. +For OData 4.0 responses a non-abstract entity type MUST define a +[key](#Key) or derive from a [base type](#DerivedEntityType) with a +defined key. -This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +An abstract entity type MUST NOT inherit from a non-abstract entity +type. -As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata). -[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.] +::: {.varxml .rep} +### Attribute `Abstract` -[OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.] +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## 6.3 Open Entity Type + +An entity type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +An entity type derived from an open entity type MUST indicate that it is +also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData-Protocol](#ODataProtocol). + + +::: {.varxml .rep} +### Attribute `OpenType` + +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## 6.4 Media Entity Type + +An entity type that does not specify a base type MAY indicate that it is +a media entity type. *Media entities* are entities that represent a +media stream, such as a photo. Use a media entity if the out-of-band +stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal +entity with one or more properties of type `Edm.Stream` if the +structured data of the entity is the main topic of interest and the +stream data is just additional information attached to the structured +data. For more information on media entities see +[OData-Protocol](#ODataProtocol). + +An entity type derived from a media entity type MUST indicate that it is +also a media entity type. + +Media entity types MAY specify a list of acceptable media types using an +annotation with term +[`Core.AcceptableMediaTypes`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#AcceptableMediaTypes), +see [OData-VocCore](#ODataVocCore). + + +::: {.varxml .rep} +### Attribute `HasStream` + +The value of `HasStream` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## 6.5 Key + +An entity is uniquely identified within an entity set by its key. A key +MAY be specified if the entity type does not specify a [base +type](#DerivedEntityType) that already has a key declared. + +In order to be specified as the type of an [entity set](#EntitySet) or a +collection-valued [containment navigation +property](#ContainmentNavigationProperty), the entity type MUST either +specify a key or inherit its key from its [base +type](#DerivedEntityType). + +In OData 4.01 responses entity types used for [singletons](#Singleton) +or single-valued [navigation properties](#NavigationProperty) do not +require a key. In OData 4.0 responses entity types used for +[singletons](#Singleton) or single-valued [navigation +properties](#NavigationProperty) MUST have a key defined. + +An entity type (whether or not it is marked as abstract) MAY define a +key only if it doesn't inherit one. + +An entity type's key refers to the set of properties whose values +uniquely identify an instance of the entity type within an entity set. +The key MUST consist of at least one property. + +Key properties MUST NOT be nullable and MUST be typed with an +[enumeration type](#EnumerationType), one of the following [primitive +types](#PrimitiveTypes), or a [type definition](#TypeDefinition) based +on one of these primitive types: + +- `Edm.Boolean` +- `Edm.Byte` +- `Edm.Date` +- `Edm.DateTimeOffset` +- `Edm.Decimal` +- `Edm.Duration` +- `Edm.Guid` +- `Edm.Int16` +- `Edm.Int32` +- `Edm.Int64` +- `Edm.SByte` +- `Edm.String` +- `Edm.TimeOfDay` + +Key property values MAY be language-dependent, but their values MUST be +unique across all languages and the entity ids (defined in +[OData-Protocol](#ODataProtocol)) MUST be language independent. + +A key property MUST be a non-nullable primitive property of the entity +type itself, including non-nullable primitive properties of non-nullable +single-valued complex properties, recursively. + +In OData 4.01 the key properties of a directly related entity type MAY +also be part of the key if the navigation property is single-valued and +not nullable. This includes navigation properties of non-nullable +single-valued complex properties (recursively) of the entity type. If a +key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key. + +If the key property is a property of a complex property (recursively) or +of a directly related entity type, the key MUST specify an alias for +that property that MUST be a [simple identifier](#SimpleIdentifier) and +MUST be unique within the set of aliases, structural and navigation +properties of the declaring entity type and any of its base types. + +An alias MUST NOT be defined if the key property is a primitive property +of the entity type itself. + +For key properties that are a property of a complex or navigation +property, the alias MUST be used in the key predicate of URLs instead of +the path to the property because the required percent-encoding of the +forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be +used in the query part of URLs, where paths to properties don't require +special encoding and are a standard constituent of expressions anyway. + + + + + +::: {.varxml .rep} +### Element `edm:Key` + +The `edm:Key` element MUST contain at least one `edm:PropertyRef` +element. + +### Element `edm:PropertyRef` + +The `edm:PropertyRef` element MUST contain the `Name` attribute and MAY +contain the `Alias` attribute. + +### Attribute `Name` + +The value of `Name` is a path expression leading to a primitive +property. The names of the properties in the path are joined together by +forward slashes. + +### Attribute `Alias` + +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example 10: entity type with a simple key +```xml + + + + + + + +``` +::: + +::: {.varxml .example} +Example 11: entity type with a simple key referencing a property of a +[complex type](#ComplexType) +```xml + + + + + + + + + + + + +``` +::: + +::: {.varxml .example} +Example 12: entity type with a composite key +```xml + + + + + + + + +``` +::: + +::: example +Example 13 (based on [example 11](#complexkey)): requests to an entity set `Categories` +of type `Category` must use the alias +``` +GET http://host/service/Categories(EntityInfoID=1) +``` +::: + +::: example +Example 14 (based on [example 11](#complexkey)): in a query part the value assigned to +the name attribute must be used +``` +GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100 +``` +::: -[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.] +------- + +# 7 Structural Property + +A structural property is a property of a structured type that has one of +the following types: +- [Primitive type](#PrimitiveTypes) +- [Complex type](#ComplexType) +- [Enumeration type](#EnumerationType) +- A collection of one of the above + +A structural property MUST specify a unique name as well as a +[type](#Type). + +The property's name MUST be a [simple identifier](#SimpleIdentifier). It +is used when referencing, serializing or deserializing the property. It +MUST be unique within the set of structural and navigation properties of +the declaring [structured type](#StructuredTypes), and MUST NOT match +the name of any navigation property in any of its base types. If a +structural property with the same name is defined in any of this type's +base types, then the property's type MUST be a type derived from the +type specified for the property of the base type and constrains this +property to be of the specified subtype for instances of this structured +type. The name MUST NOT match the name of any structural or navigation +property of any of this type's base types for OData 4.0 responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + + + +::: {.varxml .rep} +### Element `edm:Property` + +The `edm:Property` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the facet attributes +[`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), +[`SRID`](#SRID), and [`DefaultValue`](#DefaultValue). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the property's name. +::: + +::: {.varxml .example} +Example 15: complex type with two properties +```xml + + + + +``` +::: + +## 7.1 Type + +The property's type MUST be a [primitive type](#PrimitiveTypes), +[complex type](#ComplexType), or [enumeration type](#EnumerationType) in +scope, or a collection of one of these types. + +A collection-valued property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in +[OData-VocCore](#ODataVocCore), to specify that it supports a +stable ordering. + +A collection-valued property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports inserting items into a specific ordinal position. + + + +::: {.varxml .rep} +### Attribute `Type` + +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. +::: + +::: {.varxml .example} +Example 16: property `Units` that can have zero or more strings as its +value +```xml + +``` +::: + +## 7.2 Type Facets + +Facets modify or constrain the acceptable values of a property. + +For single-valued properties the facets apply to the value of the +property. For collection-valued properties the facets apply to the items +in the collection. + +### 7.2.1 Nullable + +A Boolean value specifying whether the property can have the value +`null`. + + +::: {.varxml .rep} +### Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +If no value is specified for a single-valued property, the `Nullable` +attribute defaults to `true`. + +In OData 4.01 responses a collection-valued property MUST specify a +value for the `Nullable` attribute. + +If no value is specified for a collection-valued property, the client +cannot assume any default value. Clients SHOULD be prepared for this +situation even in OData 4.01 responses. +::: + +### 7.2.2 MaxLength + +A positive integer value specifying the maximum length of a binary, +stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length +(number of code points for Unicode). + +If no maximum length is specified, clients SHOULD expect arbitrary +length. + + +::: {.varxml .rep} +### Attribute `MaxLength` + +The value of `MaxLength` is a positive integer or the symbolic value +`max` as a shorthand for the maximum length supported for the type by +the service. + +Note: the symbolic value `max` is only allowed in OData 4.0 responses; +it is deprecated in OData 4.01. While clients MUST be prepared for this +symbolic value, OData 4.01 and greater services MUST NOT return the +symbolic value `max` and MAY instead specify the concrete maximum length +supported for the type by the service or omit the attribute entirely. +::: + +### 7.2.3 Precision + +For a decimal value: the maximum number of significant decimal digits of +the property's value; it MUST be a positive integer. + +For a temporal value (datetime-with-timezone-offset, duration, or +time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve. + +Note: service authors SHOULD be aware that some clients are unable to +support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential +for data loss when round-tripping values of greater precision. Updating +via `PATCH` and exclusively specifying modified properties will reduce +the risk for unintended data loss. + +Note: duration properties supporting a granularity less than seconds +(e.g. minutes, hours, days) can be annotated with term +[`Measures.DurationGranularity`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Measures.V1.md#DurationGranularity), +see [OData-VocMeasures](#ODataVocMeasures). + + + +::: {.varxml .rep} +### Attribute `Precision` + +The value of `Precision` is a number. + +If not specified for a decimal property, the decimal property has +arbitrary precision. + +If not specified for a temporal property, the temporal property has a +precision of zero. +::: + +::: {.varxml .example} +Example 17: [`Precision`](#Precision) facet applied to the +`DateTimeOffset` type +```xml + +``` +::: + +### 7.2.4 Scale + +A non-negative integer value specifying the maximum number of digits +allowed to the right of the decimal point, or one of the symbolic values +`floating` or `variable`. + +The value `floating` means that the decimal property represents a +decimal floating-point number whose number of significant digits is the +value of the [`Precision`](#Precision) facet. OData 4.0 responses MUST +NOT specify the value `floating`. + +The value `variable` means that the number of digits to the right of the +decimal point can vary from zero to the value of the +[`Precision`](#Precision) facet. + +An integer value means that the number of digits to the right of the +decimal point may vary from zero to the value of the `Scale` facet, and +the number of digits to the left of the decimal point may vary from one +to the value of the `Precision` facet minus the value of the `Scale` +facet. If `Precision` is equal to `Scale`, a single zero MUST precede +the decimal point. + +The value of `Scale` MUST be less than or equal to the value of +[`Precision`](#Precision). + +Note: if the underlying data store allows negative scale, services may +use a [`Precision`](#Precision) with the absolute value of the negative +scale added to the actual number of significant decimal digits, and +client-provided values may have to be rounded before being stored. + + + + + + +::: {.varxml .rep} +### Attribute `Scale` + +The value of `Scale` is a number or one of the symbolic values +`floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +If not specified, the `Scale` facet defaults to zero. +::: + +::: {.varxml .example} +Example 18: [`Precision`](#Precision)`=3` and `Scale=2`. +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 +```xml + +``` +::: + +::: {.varxml .example} +Example 19: `Precision=2` equals `Scale`. +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 +```xml + +``` +::: + +::: {.varxml .example} +Example 20: `Precision=3` and a variable `Scale`. +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. +```xml + +``` +::: + +::: {.varxml .example} +Example 21: `Precision=7` and a floating `Scale`. +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. +```xml + +``` +::: + +### 7.2.5 Unicode + +For a string property the `Unicode` facet indicates whether the property +might contain and accept string values with Unicode characters (code +points) beyond the ASCII character set. The value `false` indicates that +the property will only contain and accept string values with characters +limited to the ASCII character set. + +If no value is specified, the `Unicode` facet defaults to `true`. + + +::: {.varxml .rep} +### Attribute `Unicode` + +The value of `Unicode` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `true`. +::: + +### 7.2.6 SRID + +For a geometry or geography property the `SRID` facet identifies which +spatial reference system is applied to values of the property on type +instances. + +The value of the `SRID` facet MUST be a non-negative integer or the +special value `variable`. If no value is specified, the facet defaults +to `0` for `Geometry` types or `4326` for `Geography` types. + +The valid values of the `SRID` facet and their meanings are as defined +by the European Petroleum Survey Group [EPSG](#_EPSG). + + +::: {.varxml .rep} +### Attribute `SRID` + +The value of `SRID` is a number or the symbolic value `variable`. +::: + +### 7.2.7 Default Value + +A primitive or enumeration property MAY define a default value that is +used if the property is not explicitly represented in an annotation or +the body of a request or response. + +If no value is specified, the client SHOULD NOT assume a default value. + + +::: {.varxml .rep} +### Attribute `DefaultValue` + +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData-ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. +::: + +------- + +# 8 Navigation Property + +A navigation property allows navigation to related entities. It MUST +specify a unique name as well as a type. + +The navigation property's name MUST be a [simple +identifier](#SimpleIdentifier). It is used when referencing, serializing +or deserializing the navigation property. It MUST be unique within the +set of structural and navigation properties of the declaring [structured +type](#StructuredTypes), and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the +same name is defined in any of this type's base types, then the +navigation property's type MUST be a type derived from the type +specified for the navigation property of the base type, and constrains +this navigation property to be of the specified subtype for instances of +this structured type. The name MUST NOT match the name of any structural +or navigation property of any of this type's base types for OData 4.0 +responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + + + +::: {.varxml .rep} +### Element `edm:NavigationProperty` + +The `edm:NavigationProperty` element MUST contain the `Name` and `Type` +attributes, and it MAY contain the attributes +[`Nullable`](#NullableNavigationProperty), +[`Partner`](#PartnerNavigationProperty), and +[`ContainsTarget`](#ContainmentNavigationProperty). + +It MAY contain child elements +[`edm:ReferentialConstraint`](#ReferentialConstraint) and at most one +child element [`edm:OnDelete`](#OnDeleteAction). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the navigation property's name. +::: + +::: {.varxml .example} +Example 22: the Product entity type has a navigation property to a +Category, which has a navigation link back to one or more products +```xml + + ... + + + + + + ... + + +``` +::: + +## 8.1 Navigation Property Type + +The navigation property's type MUST be an [entity type](#EntityType) in +scope, the [abstract type](#BuiltInAbstractTypes) `Edm.EntityType`, or a +collection of one of these types. + +If the type is a collection, an arbitrary number of entities can be +related. Otherwise there is at most one related entity. + +The related entities MUST be of the specified entity type or one of its +subtypes. + +For a collection-valued containment navigation property the specified +entity type MUST have a [key](#Key) defined. + +A collection-valued navigation property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports a stable ordering. + +A collection-valued navigation property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports inserting items into a specific ordinal position. + + +::: {.varxml .rep} +### Attribute `Type` + +For single-valued navigation properties the value of `Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `Type` is the +character sequence `Collection(` followed by the qualified name of the +navigation property's item type, followed by a closing parenthesis `)`. +::: + +## 8.2 Nullable Navigation Property + +A Boolean value specifying whether the declaring type MAY have no +related entity. If false, instances of the declaring structured type +MUST always have a related entity. + +Nullable MUST NOT be specified for a collection-valued navigation +property, a collection is allowed to have zero items. + + +::: {.varxml .rep} +### Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. +::: + +## 8.3 Partner Navigation Property + +A navigation property of an [entity type](#EntityType) MAY specify a +partner navigation property. Navigation properties of complex types MUST +NOT specify a partner. + +If specified, the partner navigation property is identified by a path +relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that +type or a derived type. The path MAY traverse complex types, including +derived complex types, but MUST NOT traverse any navigation properties. +The type of the partner navigation property MUST be the declaring entity +type of the current navigation property or one of its parent entity +types. + +If the partner navigation property is single-valued, it MUST lead back +to the source entity from all related entities. If the partner +navigation property is collection-valued, the source entity MUST be part +of that collection. + +If no partner navigation property is specified, no assumptions can be +made as to whether one of the navigation properties on the target type +will lead back to the source entity. + +If a partner navigation property is specified, this partner navigation +property MUST either specify the current navigation property as its +partner to define a bi-directional relationship or it MUST NOT specify a +partner navigation property. The latter can occur if the partner +navigation property is defined on a complex type, or if the current +navigation property is defined on a type derived from the type of the +partner navigation property. + + +::: {.varxml .rep} +### Attribute `Partner` + +The value of `Partner` is the path to the of the partner navigation +property. +::: + +## 8.4 Containment Navigation Property + +A navigation property MAY indicate that instances of its declaring +structured type contain the targets of the navigation property, in which +case the navigation property is called a *containment navigation +property*. + +Containment navigation properties define an implicit entity set for each +instance of its declaring structured type. This implicit entity set is +identified by the read URL of the navigation property for that +structured type instance. + +Instances of the structured type that declares the navigation property, +either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The +canonical URL for contained entities is the canonical URL of the +containing instance, followed by the path segment of the navigation +property and the key of the contained entity, see +[OData-URL](#ODataURL). + +Entity types used in collection-valued containment navigation properties +MUST have a [key](#Key) defined. + +For items of an ordered collection of complex types (those annotated +with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term defined in [OData-VocCore](#ODataVocCore) the canonical URL +of the item is the canonical URL of the collection appended with a +segment containing the zero-based ordinal of the item. Items within in +an unordered collection of complex types do not have a canonical URL. +Services that support unordered collections of complex types declaring a +containment navigation property, either directly or indirectly via a +property of complex type, MUST specify the URL for the navigation link +within a payload representing that item, according to format-specific +rules. + +OData 4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued +property. + +An entity cannot be referenced by more than one containment +relationship, and cannot both belong to an entity set declared within +the entity container and be referenced by a containment relationship. + +Containment navigation properties MUST NOT be specified as the last path +segment in the path of a [navigation property +binding](#NavigationPropertyBinding). + +When a containment navigation property navigates between entity types in +the same inheritance hierarchy, the containment is called *recursive*. + +Containment navigation properties MAY specify a partner navigation +property. If the containment is recursive, the relationship defines a +tree, thus the partner navigation property MUST be +[nullable](#NullableNavigationProperty) (for the root of the tree) and +single-valued (for the parent of a non-root entity). If the containment +is not recursive, the partner navigation property MUST NOT be nullable. + +An entity type inheritance chain MUST NOT contain more than one +navigation property with a partner navigation property that is a +containment navigation property. + +Note: without a partner navigation property, there is no reliable way +for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity +can also be reached via a non-containment navigation path. + + +::: {.varxml .rep} +### Attribute `ContainsTarget` + +The value of `ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## 8.5 Referential Constraint + +A single-valued navigation property MAY define one or more referential +constraints. A referential constraint asserts that the *dependent +property* (the property defined on the structured type declaring the +navigation property) MUST have the same value as the *principal +property* (the referenced property declared on the entity type that is +the target of the navigation). + +The type of the dependent property MUST match the type of the principal +property, or both types MUST be complex types. + +If the principle property references an entity, then the dependent +property must reference the same entity. + +If the principle property's value is a complex type instance, then the +dependent property's value must be a complex type instance with the same +properties, each with the same values. + +If the navigation property on which the referential constraint is +defined is nullable, or the principal property is nullable, then the +dependent property MUST also be nullable. If both the navigation +property and the principal property are not nullable, then the dependent +property MUST NOT be nullable. + + + +::: {.varxml .rep} +### Element `edm:ReferentialConstraint` + +The `edm:ReferentialConstraint` element MUST contain the attributes +`Property` and `ReferencedProperty`. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Property` + +The `Property` attribute specifies the property that takes part in the +referential constraint on the dependent structured type. Its value MUST +be a path expression resolving to a property of the dependent structured +type itself or to a property of a complex property (recursively) of the +dependent structured type. The names of the properties in the path are +joined together by forward slashes. The path is relative to the +dependent structured type declaring the navigation property. + +### Attribute `ReferencedProperty` + +The `ReferencedProperty` attribute specifies the corresponding property +of the principal entity type. Its value MUST be a path expression +resolving to a property of the principal entity type itself or to a +property of a complex property (recursively) of the principal entity +type that MUST have the same type as the property of the dependent +entity type. The path is relative to the entity type that is the target +of the navigation property. +::: + +::: {.varxml .example} +Example 23: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. +```xml + + ... + + + + + + + + + + + + + + + + + ... + +``` +::: + +## 8.6 On-Delete Action + +A navigation property MAY define an on-delete action that describes the +action the service will take on related entities when the entity on +which the navigation property is defined is deleted. + +The action can have one of the following values: + +- `Cascade`, meaning the related entities will be deleted if the + source entity is deleted, +- `None`, meaning a `DELETE` request on a source entity with related + entities will fail, +- `SetNull`, meaning all properties of related entities that are tied + to properties of the source entity via a referential constraint and + that do not participate in other referential constraints will be set + to null, +- `SetDefault`, meaning all properties of related entities that are + tied to properties of the source entity via a referential constraint + and that do not participate in other referential constraints will be + set to their default value. + +If no on-delete action is specified, the action taken by the service is +not predictable by the client and could vary per entity. + + + +::: {.varxml .rep} +### Element `edm:OnDelete` + +The `edm:OnDelete` element MUST contain the `Action` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Action` + +The value of `Action` is one of the values `Cascade`, `None`, `SetNull`, +or `SetDefault`. +::: + +::: {.varxml .example} +Example 24: deletion of a category implies deletion of the related +products in that category +```xml + + ... + + + + + + +``` +::: + +------- + +# 9 Complex Type + +Complex types are keyless [nominal](#NominalTypes) [structured +types](#StructuredTypes). The lack of a key means that instances of +complex types cannot be referenced, created, updated or deleted +independently of an entity type. Complex types allow entity models to +group properties into common structures. + +The complex type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +A complex type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to an entity type or a collection of entity types. + +All properties MUST have a unique name within a complex type. Properties +MUST NOT have the same name as the declaring complex type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + + + +::: {.varxml .rep} +### Element `edm:ComplexType` + +The `edm:ComplexType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedComplexType), +[`Abstract`](#AbstractComplexType), and [`OpenType`](#OpenComplexType) +attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the complex type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the complex type's name. +::: + +::: {.varxml .example} +Example 25: a complex type used by two entity types +```xml + + + + + + + + ... + + + + + + ... + + +``` +::: + +## 9.1 Derived Complex Type + +A complex type can inherit from another complex type by specifying it as +its base type. + +A complex type inherits the structural and navigation properties of its +base type. + +A complex type MUST NOT introduce an inheritance cycle by specifying a +base type. + +The rules for annotations of derived complex types are described in +[section 14.2](#Annotation). + + +::: {.varxml .rep} +### Attribute `BaseType` + +The value of `BaseType` is the qualified name of the base type. +::: + +## 9.2 Abstract Complex Type + +A complex type MAY indicate that it is abstract and cannot have +instances. + + +::: {.varxml .rep} +### Attribute `Abstract` + +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## 9.3 Open Complex Type + +A complex type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +A complex type derived from an open complex type MUST indicate that it +is also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + + +::: {.varxml .rep} +### Attribute `OpenType` + +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +------- + +# 10 Enumeration Type + +Enumeration types are [nominal](#NominalTypes) types that represent a +non-empty series of related values. Enumeration types expose these +related values as members of the enumeration. + +The enumeration type's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Although enumeration types have an underlying numeric value, the +preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the `AllowedValues` annotation defined in +[OData-VocCore](#ODataVocCore). + +Enumeration types marked as flags allow values that consist of more than +one enumeration member at a time. + + + +::: {.varxml .rep} +### Element `edm:EnumType` + +The `edm:EnumType` element MUST contain the Name attribute, and it MAY +contain the [`UnderlyingType`](#UnderlyingIntegerType) and +[`IsFlags`](#FlagsEnumerationType) attributes. + +It MUST contain one or more [`edm:Member`](#EnumerationTypeMember) +elements defining the members of the enumeration type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the enumeration type's name. +::: + +::: {.varxml .example} +Example 26: a simple flags-enabled enumeration +```xml + + + + + + +``` +::: + +## 10.1 Underlying Integer Type + +An enumeration type MAY specify one of `Edm.Byte`, `Edm.SByte`, +`Edm.Int16`, `Edm.Int32`, or `Edm.Int64` as its underlying type. + +If not explicitly specified, `Edm.Int32` is used as the underlying type. + + +::: {.varxml .rep} +### Attribute `UnderlyingType` + +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +## 10.2 Flags Enumeration Type + +An enumeration type MAY indicate that the enumeration type allows +multiple members to be selected simultaneously. + +If not explicitly specified, only one enumeration type member MAY be +selected simultaneously. + + + +::: {.varxml .rep} +### Attribute `IsFlags` + +The value of `IsFlags` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +::: {.varxml .example} +Example 27: pattern values can be combined, and some combined values +have explicit names +```xml + + + + + + + + + + + + + + +``` +::: + +## 10.3 Enumeration Type Member + +Enumeration type values consist of discrete members. + +Each member is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within the +enumeration type. Names are case-sensitive, but service authors SHOULD +NOT choose names that differ only in case. + +Each member MUST specify an associated numeric value that MUST be a +valid value for the underlying type of the enumeration type. + +Enumeration types can have multiple members with the same value. Members +with the same numeric value compare as equal, and members with the same +numeric value can be used interchangeably. + +Enumeration members are sorted by their numeric value. + +For flag enumeration types the combined numeric value of simultaneously +selected members is the bitwise OR of the discrete numeric member +values. + + + +::: {.varxml .rep} +### Element `edm:Member` + +The `edm:Member` element MUST contain the `Name` attribute and it MAY +contain the `Value` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the enumeration member's name. + +### Attribute `Value` + +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`false`, either all members MUST specify an integer value for the +`Value` attribute, or all members MUST NOT specify a value for the +`Value` attribute. If no values are specified, the members are assigned +consecutive integer values in the order of their appearance, starting +with zero for the first member. Client libraries MUST preserve elements +in document order. + +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`true`, a non-negative integer value MUST be specified for the `Value` +attribute. A combined value is equivalent to the bitwise OR of the +discrete values. +::: + +::: {.varxml .example} +Example 28: `FirstClass` has a value of `0`, `TwoDay` a value of 1, and +`Overnight` a value of 2. +```xml + + + + + + + + + + + +``` +::: + +------- + +# 11 Type Definition + +A type definition defines a specialization of one of the [primitive +types](#PrimitiveTypes) or of the built-in abstract type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes). + +The type definition's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Type definitions can be used wherever a primitive type is used (other +than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions +defined using the same underlying type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden. + + + +::: {.varxml .rep} +### Element `edm:TypeDefinition` + +The `edm:TypeDefinition` element MUST contain the `Name` and +[`UnderlyingType`](#UnderlyingPrimitiveType) attributes. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the type definition's name. +::: + +::: {.varxml .example} +Example 29: +```xml + + + + + + + + + + + + +``` +::: + +## 11.1 Underlying Primitive Type + +The underlying type of a type definition MUST be a primitive type that +MUST NOT be another type definition. + + + +::: {.varxml .rep} +### Attribute `UnderlyingType` + +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), or +[`SRID`](#SRID). + +Additional facets appropriate for the underlying type MAY be specified +when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified. + +For a type definition with underlying type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes) no facets are applicable, +neither in the definition itself nor when the type definition is used, +and these should be ignored by the client. + +Where type definitions are used, the type definition is returned in +place of the primitive type wherever the type is specified in a +response. + +------- + +# 12 Action and Function + +## 12.1 Action + +Actions are service-defined operations that MAY have observable side +effects and MAY return a single instance or a collection of instances of +any type. + +The action's name is a [simple identifier](#SimpleIdentifier) that MUST +be unique within its schema. + +Actions cannot be composed with additional path segments. + +An action MAY specify a [return type](#ReturnType) that MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +An action MAY define [parameters](#Parameter) used during the execution +of the action. + +## 12.2 Action Overloads + +[Bound](#BoundorUnboundActionorFunctionOverloads) actions support +overloading (multiple actions having the same name within the same +schema) by binding parameter type. The combination of action name and +the binding parameter type MUST be unique within a schema. + +[Unbound](#BoundorUnboundActionorFunctionOverloads) actions do not support +overloads. The names of all unbound actions MUST be unique within a +schema. + +An unbound action MAY have the same name as a bound action. + + +::: {.varxml .rep} +### Element `edm:Action` + +The `edm:Action` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverloads) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MAY contain at most one [`edm:ReturnType`](#ReturnType) element and +MAY contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the action's name. +::: + +## 12.3 Function + +Functions are service-defined operations that MUST NOT have observable +side effects and MUST return a single instance or a collection of +instances of any type. + +The function's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +Functions MAY be [composable](#ComposableFunction). + +The function MUST specify a [return type](#ReturnType) which MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +A function MAY define [parameters](#Parameter) used during the execution +of the function. + +## 12.4 Function Overloads + +[Bound](#BoundorUnboundActionorFunctionOverloads) functions support +overloading (multiple functions having the same name within the same +schema) subject to the following rules: +- The combination of function name, +binding parameter type, and unordered set of non-binding parameter names +MUST be unique within a schema. +- The combination of function name, +binding parameter type, and ordered set of parameter types MUST be +unique within a schema. +- All bound functions with the same +function name and binding parameter type within a schema MUST specify +the same return type. + +[Unbound](#BoundorUnboundActionorFunctionOverloads) functions support +overloading subject to the following rules: +- The combination of function name and +unordered set of parameter names MUST be unique within a schema. +- The combination of function name and +ordered set of parameter types MUST be unique within a schema. +- All unbound functions with the same +function name within a schema MUST specify the same return type. + +An unbound function MAY have the same name as a bound function. + +Note that [type definitions](#TypeDefinition) can be used to +disambiguate overloads for both bound and unbound functions, even if +they specify the same underlying type. + + +::: {.varxml .rep} +### Element `edm:Function` + +The `edm:Function` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverloads) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MUST contain one [`edm:ReturnType`](#ReturnType) element, and it MAY +contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the action's name. +::: + +## 12.5 Bound or Unbound Action or Function Overloads + +An action or function overload MAY indicate that it is bound. If not +explicitly indicated, it is unbound. + +Bound actions or functions are invoked on resources matching the type of +the binding parameter. The binding parameter can be of any type, and it +MAY be [nullable](#Nullable). + +Unbound actions are invoked from the entity container through an [action +import](#ActionImport). + +Unbound functions are invoked as static functions within a filter or +orderby expression, or from the entity container through a [function +import](#FunctionImport). + + +::: {.varxml .rep} +### Attribute `IsBound` + +The value of `IsBound` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +## 12.6 Entity Set Path + +Bound actions and functions that return an entity or a collection of +entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter +value. + +The entity set path consists of a series of segments joined together +with forward slashes. + +The first segment of the entity set path MUST be the name of the binding +parameter. The remaining segments of the entity set path MUST represent +navigation segments or type casts. + +A navigation segment names the [simple identifier](#SimpleIdentifier) of +the [navigation property](#NavigationProperty) to be traversed. A +type-cast segment names the [qualified name](#QualifiedName) of the +entity type that should be returned from the type cast. + + +::: {.varxml .rep} +### Attribute `EntitySetPath` + +The value of `EntitySetPath` is the entity set path. +::: + +## 12.7 Composable Function + +A function MAY indicate that it is composable. If not explicitly +indicated, it is not composable. + +A composable function can be invoked with additional path segments or +key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for +the type returned by the composable function. + + +::: {.varxml .rep} +### Attribute `IsComposable` + +The value of `IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## 12.8 Return Type + +The return type of an action or function overload MAY be any type in +scope, or a collection of any type in scope. + +The facets [`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID) can be +used as appropriate to specify value restrictions of the return type, as +well as the [`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For a single-valued return type the facets apply to the returned value. +For a collection-valued return type the facets apply to the items in the +returned collection. + + +::: {.varxml .rep} +### Element `edm:ReturnType` + +The `edm:ReturnType` element MUST contain the `Type` attribute, and it +MAY contain the attributes `Nullable`, [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Type` + +For single-valued return types the value of `Type` is the qualified name +of the return type. + +For collection-valued return types the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the return item +type, followed by a closing parenthesis `)`. + +### Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +If the return type is a collection of entity types, the `Nullable` +attribute has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + +## 12.9 Parameter + +An action or function overload MAY specify parameters. + +A bound action or function overload MUST specify at least one parameter; +the first parameter is its binding parameter. The order of parameters +MUST NOT change unless the schema version changes. + +Each parameter MUST have a name that is a [simple +identifier](#SimpleIdentifier). The parameter name MUST be unique within +the action or function overload. + +The parameter MUST specify a type. It MAY be any type in scope, or a +collection of any type in scope. + +The facets [`MaxLength`](#MaxLength), [`Precision`](#Precision), +[`Scale`](#Scale), or [`SRID`](#SRID) can be used as appropriate to +specify value restrictions of the parameter, as well as the +[`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For single-valued parameters the facets apply to the parameter value. If +the parameter value is a collection, the facets apply to the items in +the collection. + + + +::: {.varxml .rep} +### Element `edm:Parameter` + +The `edm:Parameter` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the attributes `Nullable`, +[`MaxLength`](#MaxLength), [`Unicode`](#Unicode), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the parameter's name. + +### Attribute `Type` + +For single-valued parameters the value of `Type` is the qualified name +of the parameter. + +For collection-valued parameters the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the parameter's +type, followed by a closing parenthesis `)`. + +### Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +The value `true` means that the parameter accepts a `null` value. +::: + +::: {.varxml .example} +Example 30: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `edm:Parameter` element. +```xml + + + + +``` +::: + +------- + +# 13 Entity Container + +Each metadata document used to describe an OData service MUST define +exactly one entity container. + +The entity container's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Entity containers define the entity sets, singletons, function and +action imports exposed by the service. + +Entity set, singleton, action import, and function import names MUST be +unique within an entity container. + +An [*entity set*](#EntitySet) allows access to entity type instances. +Simple entity models frequently have one entity set per entity type. + + +::: {.varxml .example} +Example 31: one entity set per entity type +```xml + + +``` +::: + +Other entity models may expose multiple entity sets per type. + + +::: {.varxml .example} +Example 32: three entity sets referring to the two entity types +```xml + + + + + + + +``` +::: + +There are separate entity sets for standard customers and preferred +customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have [navigation +property bindings](#NavigationPropertyBinding) to the orders entity set, +but the orders entity set does not have a navigation property binding +for the Customer navigation property, since it could lead to either set +of customers. + +An entity set can expose instances of the specified entity type as well +as any entity type inherited from the specified entity type. + +A [*singleton*](#Singleton) allows addressing a single entity directly +from the entity container without having to know its key, and without +requiring an entity set. + +A [*function import*](#FunctionImport) or an [*action +import*](#ActionImport) is used to expose a function or action defined +in an entity model as a top level resource. + + + +::: {.varxml .rep} +### Element `edm:EntityContainer` + +The `edm:EntityContainer` MUST contain one or more +[`edm:EntitySet`](#EntitySet), [`edm:Singleton`](#Singleton), +[`edm:ActionImport`](#ActionImport), or +[`edm:FunctionImport`](#FunctionImport) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the entity container's name. +::: + +::: {.varxml .example} +Example 33: An entity container aggregates entity sets, singletons, +action imports, and function imports. +```xml + + + + + + + + + + + + + + + +``` +::: + +## 13.1 Extending an Entity Container + +An entity container MAY specify that it extends another entity container +in scope. All children of the "base" entity container are added to the +"extending" entity container. + +If the "extending" entity container defines an entity set with the same +name as defined in any of its "base" containers, then the entity set's +type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the "base" container. The same +holds for singletons. Action imports and function imports cannot be +redefined, nor can the "extending" container define a child with the +same name as a child of a different kind in a "base" container. + +Note: services should not introduce cycles by extending entity +containers. Clients should be prepared to process cycles introduced by +extending entity containers. + + + +::: {.varxml .rep} +### Attribute `Extends` + +The value of `Extends` is the qualified name of the entity container to +be extended. +::: + +::: {.varxml .example} +Example 34: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` +```xml + + ... + +``` +::: + +## 13.2 Entity Set + +Entity sets are top-level collection-valued resources. + +An entity set is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An entity set MUST specify a type that MUST be an entity type in scope. + +An entity set MUST contain only instances of its specified entity type +or its subtypes. The entity type MAY be [abstract](#AbstractEntityType) +but MUST have a [key](#Key) defined. + +An entity set MAY indicate whether it is included in the service +document. If not explicitly indicated, it is included. + +Entity sets that cannot be queried without specifying additional query +options SHOULD NOT be included in the service document. + + +::: {.varxml .rep} +### Element `edm:EntitySet` + +The `edm:EntitySet` element MUST contain the attributes `Name` and +`EntityType`, and it MAY contain the `IncludeInServiceDocument` +attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the entity set's name. + +### Attribute `EntityType` + +The value of `EntityType` is the qualified name of an entity type in +scope. + +### Attribute `IncludeInServiceDocument` + +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `true`. +::: + +## 13.3 Singleton + +Singletons are top-level single-valued resources. + +A singleton is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A singleton MUST specify a type that MUST be an entity type in scope. + +A singleton MUST reference an instance its entity type. + + +::: {.varxml .rep} +### Element `edm:Singleton` + +The `edm:Singleton` element MUST include the attributes `Name` and +`Type`, and it MAY contain the `Nullable` attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the singleton's name. + +### Attribute `Type` + +The value of `Type` is whose value is the [qualified +name](#QualifiedName) of an entity type in scope. + +### Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +If no value is specified, the `Nullable` attribute defaults to `false`. + +In OData 4.0 responses this attribute MUST NOT be specified. +::: + +## 13.4 Navigation Property Binding + +If the entity type of an entity set or singleton declares navigation +properties, a navigation property binding allows describing which entity +set or singleton will contain the related entities. + +An [entity set](#EntitySet) or a [singleton](#Singleton) SHOULD specify +a navigation property binding for each [navigation +property](#NavigationProperty) of its entity type, including navigation +properties defined on complex typed properties or derived types. + +If omitted, clients MUST assume that the target entity set or singleton +can vary per related entity. + +### 13.4.1 Navigation Property Path Binding + +A navigation property binding MUST specify a path to a navigation +property of the entity set's or singleton's declared entity type, or a +navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation +property is defined on a subtype, the path MUST contain the [qualified +name](#QualifiedName) of the subtype, followed by a forward slash, +followed by the navigation property name. If the navigation property is +defined on a complex type used in the definition of the entity set's +entity type, the path MUST contain a forward-slash separated list of +complex property names and qualified type names that describe the path +leading to the navigation property. + +The path can traverse one or more containment navigation properties, but +the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment. + +If the path traverses collection-valued complex properties or +collection-valued containment navigation properties, the binding applies +to all items of these collections. + +If the path contains a recursive sub-path (i.e. a path leading back to +the same structured type, the binding applies recursively to any +positive number of cycles through that sub-path. + +OData 4.01 services MAY have a type-cast segment as the last path +segment, allowing to bind instances of different sub-types to different +targets. + +The same navigation property path MUST NOT be specified in more than one +navigation property binding; navigation property bindings are only used +when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths +that differ only in a type-cast segment, allowing to bind instances of +different sub-types to different targets. If paths differ only in +type-cast segments, the most specific path applies. + +### 13.4.2 Binding Target + +A navigation property binding MUST specify a target via a [simple +identifier](#SimpleIdentifier) or [target path](#TargetPath). It +specifies the entity set, singleton, or containment navigation property +that contains the related entities. + +If the target is a [simple identifier](#SimpleIdentifier), it MUST +resolve to an entity set or singleton defined in the same entity +container. + +If the target is a [target path](#TargetPath), it MUST resolve to an +entity set, singleton, or direct or indirect containment navigation +property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties +before ending in a containment navigation property, and there MUST NOT +be any non-containment navigation properties prior to the final segment. + + + + + +::: {.varxml .rep} +### Element `edm:NavigationPropertyBinding` + +The `edm:NavigationPropertyBinding` element MUST contain the attributes +`Path` and `Target`. + +### Attribute `Path` + +The value of `Path` is a path expression. + +### Attribute `Target` + +The value of `Target` is a [target path](#TargetPath). +::: + +::: {.varxml .example} +Example 35: for an entity set in the same container as the enclosing +entity set `Categories` +```xml + + + +``` +::: + +::: {.varxml .example} +Example 36: for an entity set in any container in scope +```xml + + + +``` +::: + +::: {.varxml .example} +Example 37: binding `Supplier` on `Products` contained within +`Categories – binding applies to all suppliers of all products of all categories` +```xml + + + +``` +::: + +## 13.5 Action Import + +Action imports sets are top-level resources that are never included in +the service document. + +An action import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An action import MUST specify the name of an unbound action in scope. + +If the imported action returns an entity or a collection of entities, a +[simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + + +::: {.varxml .rep} +### Element `edm:ActionImport` + +The `edm:ActionImport` element MUST contain the attributes `Name` and +`Action`, and it MAY contain the `EntitySet` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the action import's name. + +### Attribute `Action` + +The value of `Action` is the qualified name of an unbound action. + +### Attribute `EntitySet` + +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. +::: + +## 13.6 Function Import + +Function imports sets are top-level resources. + +A function import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A function import MUST specify the name of an unbound function in scope. +All [unbound overloads](#BoundorUnboundActionorFunctionOverloads) of the +imported function can be invoked from the entity container. + +If the imported function returns an entity or a collection of entities, +a [simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +A function import for a parameterless function MAY indicate whether it +is included in the service document. If not explicitly indicated, it is +not included. + + +::: {.varxml .rep} +### Element `edm:FunctionImport` + +The `edm:FunctionImport` element MUST contain the attributes `Name` and +`Function`, and it MAY contain the attributes `EntitySet` and +`IncludeInServiceDocument`. + +### Attribute `Name` + +The value of `Name` is the function import's name. + +### Attribute `Function` + +The value of `Function` is the qualified name of an unbound function. + +### Attribute `EntitySet` + +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. + +### Attribute `IncludeInServiceDocument` + +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `false`. +::: + +------- + +# 14 Vocabulary and Annotation + +Vocabularies and annotations provide the ability to annotate metadata as +well as instance data, and define a powerful extensibility point for +OData. An [*annotation*](#Annotation) applies a [*term*](#Term) to a +model element and defines how to calculate a value for the applied term. + +*Metadata annotations* are terms applied to model elements. Behaviors or +constraints described by a metadata annotation must be consistent with +the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity +type, property, function, action, or parameter. For example, a metadata +annotation may define ranges of valid values for a particular property. +Metadata annotations are applied in CSDL documents describing or +referencing an entity model. + +*Instance annotations* are terms applied to a particular instance within +an OData payload, such as described in [OData-JSON](#ODataJSON). An +instance annotation can be used to define additional information +associated with a particular result, entity, property, or error. For +example, whether a property is read-only for a particular instance. +Where the same annotation is defined at both the metadata and instance +level, the instance-level annotation overrides the annotation specified +at the metadata level. Annotations that apply across instances should be +specified as metadata annotations. + +A *vocabulary* is a schema containing a set of terms where each +[term](#Term) is a named metadata extension. Anyone can define a +vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary +[OData-VocCore](#ODataVocCore). + +A [term](#Term) can be used to: +- Extend model elements and type instances +with additional information. +- Map instances of annotated structured +types to an interface defined by the term type; i.e. annotations allow +viewing instances of a structured type as instances of a differently +structured type specified by the applied term. + +A service SHOULD NOT require a client to interpret annotations. Clients +SHOULD ignore invalid or unknown terms and silently treat unexpected or +invalid values (including invalid type, invalid literal expression, +invalid targets, etc.) as an unknown value for the term. Unknown or +invalid annotations should never result in an error, as long as the +payload remains well-formed. + + +::: {.varxml .example} +Example 38: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` +```xml + + + + + + + + ... + + + + + + + + Products( + ID + ) + + + + + +``` +::: + +## 14.1 Term + +A term allows annotating a model element or OData resource +representation with additional data. + +The term's name is a [simple identifier](#SimpleIdentifier) that MUST be +unique within its schema. + +The term's type MUST be a type in scope, or a collection of a type in +scope. + + +::: {.varxml .rep} +### Element `edm:Term` + +The `edm:Term` element MUST contain the attributes `Name` and `Type`. It +MAY contain the attributes `BaseTerm` and `AppliesTo`. + +It MAY specify values for the [`Nullable`](#Nullable), +[ ]{.apple-converted-space}[`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), or [`SRID`](#SRID) facet +attributes, as well as the [`Unicode`](#Unicode) facet attribute for +4.01 and greater payloads. These facets and their implications are +described in section 7.2. + +A `edm:Term` element whose `Type` attribute specifies a primitive or +enumeration type MAY define a value for the `DefaultValue` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the term's name. + +### Attribute `Type` + +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. + +### Attribute `DefaultValue` + +The value of this attribute determines the value of the term when +applied in an [`edm:Annotation`](#Annotation) without providing an +expression. + +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData-ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. + +If no value is specified, the `DefaultValue` attribute defaults to +`null`. +::: + +### 14.1.1 Specialized Term + +A term MAY specialize another term in scope by specifying it as its base +term. + +When applying a specialized term, the base term MUST also be applied +with the same qualifier, and so on until a term without a base term is +reached. + + +::: {.varxml .rep} +### Attribute `BaseTerm` + +The value of `BaseTerm` is the qualified name of the base term. +::: + +### 14.1.2 Applicability + +The applicability of a term MAY be restricted to a list of model +elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be +extended in future versions of the vocabulary. As the intended usage may +evolve over time, clients SHOULD be prepared for any term to be applied +to any model element and SHOULD be prepared to handle unknown values +within the list of model constructs. Applicability is expressed using +the following symbolic values: + +Symbolic Value|Model Element +--------------|------------- +`Action` |Action +`ActionImport` |Action Import +`Annotation` |Annotation +`Apply` |Application of a client-side function in an annotation +`Cast` |Type Cast annotation expression +`Collection` |Entity Set or collection-valued Property or Navigation Property +`ComplexType` |Complex Type +`EntityContainer` |Entity Container +`EntitySet` |Entity Set +`EntityType` |Entity Type +`EnumType` |Enumeration Type +`Function` |Function +`FunctionImport` |Function Import +`If` |Conditional annotation expression +`Include` |Reference to an Included Schema +`IsOf` |Type Check annotation expression +`LabeledElement` |Labeled Element expression +`Member` |Enumeration Member +`NavigationProperty` |Navigation Property +`Null` |Null annotation expression +`OnDelete` |On-Delete Action of a navigation property +`Parameter` |Action of Function Parameter +`Property` |Property of a structured type +`PropertyValue` |Property value of a Record annotation expression +`Record` |Record annotation expression +`Reference` |Reference to another CSDL document +`ReferentialConstraint` |Referential Constraint of a navigation property +`ReturnType` |Return Type of an Action or Function +`Schema` |Schema +`Singleton` |Singleton +`Term` |Term +`TypeDefinition` |Type Definition +`UrlRef` |UrlRef annotation expression + + + +::: {.varxml .rep} +### Attribute `AppliesTo` + +The value of `AppliesTo` is a whitespace-separated list of symbolic +values from the table above that identify model elements the term is +intended to be applied to. +::: + +::: {.varxml .example} +Example 39: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData-VocCore](#ODataVocCore)) +```xml + + + + Properties and terms annotated with this term MUST contain a valid URL + + + + +``` +::: + +## 14.2 Annotation + +An annotation applies a [term](#Term) to a model element and defines how +to calculate a value for the term application. Both term and model +element MUST be in scope. Section 14.1.2 specifies which model elements +MAY be annotated with a term. + +The value of an annotation is specified as an *annotation expression*, +which is either a [constant expression](#ConstantExpression) +representing a constant value, or a [dynamic +expression](#DynamicExpression). The most common construct for assigning +an annotation value is a [path expression](#ValuePath) that refers to a +property of the same or a related structured type. + + + +::: {.varxml .rep} +### Element `edm:Annotation` + +The `edm:Annotation` element MUST contain the attribute `Term`, and it +MAY contain the attribute [`Qualifier`](#Qualifier). + +The value of the annotation MAY be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +If no expression is specified for a term with a primitive type, the +annotation evaluates to the [default value](#DefaultValue) of the term +definition. If no expression is specified for a term with a complex +type, the annotation evaluates to a complex instance with default values +for its properties. If no expression is specified for a +collection-valued term, the annotation evaluates to an empty collection. + +An `edm:Annotation` element can be used as a child of the model element +it annotates, or as the child of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element that +targets the model element to be annotated. + +An `edm:Annotation` element MAY contain [`edm:Annotation`](#Annotation) +elements that annotate the annotation. + +### Attribute `Term` + +The value of `Term` is the qualified name of a [term](#Term) in scope. +::: + +::: {.varxml .example} +Example 40: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value +```xml + + + + + + + + + +``` +::: + +If an entity type or complex type is annotated with a term that itself +has a structured type, an instance of the annotated type may be viewed +as an "instance" of the term, and the qualified term name may be used as +a [term-cast segment](#TermCast) in path expressions. + +Structured types "inherit" annotations from their direct or indirect +base types. If both the type and one of its base types is annotated with +the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or +collection-valued annotation values are not merged. Similarly, +properties of a structured type inherit annotations from identically +named properties of a base type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a "Label" +annotation for a UI can propagate from a type definition to all +properties using that type definition and may be overridden at each +property with a more specific label, whereas an annotation marking a +type definition as containing a phone number will propagate to all using +properties but may not be overridden. + +### 14.2.1 Qualifier + +A term can be applied multiple times to the same model element by +providing a qualifier to distinguish the annotations. The qualifier is a +[simple identifier](#SimpleIdentifier). + +The combination of target model element, term, and qualifier uniquely +identifies an annotation. + + +::: {.varxml .rep} +### Attribute `Qualifier` + +Annotation elements that are children of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element MUST NOT +provide a value for the qualifier attribute if the parent +[`edm:Annotations`](#AnnotationswithExternalTargeting) element provides +a value for the qualifier attribute. +::: + +::: {.varxml .example} +Example 41: annotation should only be applied to tablet devices +```xml + +``` +::: + +### 14.2.2 Target + +The target of an annotation is the model element the term is applied to. + +The target of an annotation MAY be specified indirectly by "nesting" the +annotation within the model element. Whether and how this is possible is +described per model element in this specification. + +The target of an annotation MAY also be specified directly; this allows +defining an annotation in a different schema than the targeted model +element. + +This external targeting is only possible for model elements that are +uniquely identified within their parent, and all their ancestor elements +are uniquely identified within their parent: + +- [Action](#Action) (single or all overloads) +- [Action Import](#ActionImport) +- [Complex Type](#ComplexType) +- [Entity Container](#EntityContainer) +- [Entity Set](#EntitySet) +- [Entity Type](#EntityType) +- [Enumeration Type](#EnumerationType) +- [Enumeration Type Member](#EnumerationTypeMember) +- [Function](#Function) (single or all overloads) +- [Function Import](#FunctionImport) +- [Navigation Property](#NavigationProperty) (via type, entity set, or + singleton) +- [Parameter](#Parameter) of an action or function (single overloads + or all overloads defining the + parameter) +- [Property](#StructuralProperty) (via type, entity set, or singleton) +- [Return Type](#ReturnType) of an action or function (single or all + overloads) +- [Singleton](#Singleton) +- [Type Definition](#TypeDefinition) + +These are the direct children of a schema with a unique name (i.e. +except actions and functions whose overloads to not possess a natural +identifier), and all direct children of an entity container. + +External targeting is possible for actions, functions, their parameters, +and their return type, either in a way that applies to all overloads of +the action or function or all parameters of that name across all +overloads, or in a way that identifies a single overload. + +External targeting is also possible for properties and navigation +properties of singletons or entities in a particular entity set. These +annotations override annotations on the properties or navigation +properties targeted via the declaring structured type. + +The allowed path expressions are: +- [qualified name](#QualifiedName) +of schema child +- [qualified +name](#QualifiedName) of schema child followed by a forward slash and +name of child element +- [qualified +name](#QualifiedName) of structured type followed by zero or more +property, navigation property, or type-cast segments, each segment +starting with a forward slash +- [qualified name](#QualifiedName) +of an entity container followed by a segment containing a singleton or +entity set name and zero or more property, navigation property, or +type-cast segments +- [qualified +name](#QualifiedName) of an action followed by parentheses containing +the [qualified name](#QualifiedName) of the binding parameter *type* of +a bound action overload to identify that bound overload, or by empty +parentheses to identify the unbound overload +- [qualified name](#QualifiedName) of a +function followed by parentheses containing the comma-separated list of +[qualified names](#QualifiedName) of the parameter *types* of a bound +or unbound function overload in the order of their definition in the +function overload +- [qualified +name](#QualifiedName) of an action or function, optionally followed by +parentheses as described in the two previous bullet points to identify a +single overload, followed by a forward slash and either a parameter name +or `$ReturnType` +- [qualified +name](#QualifiedName) of an entity container followed by a segment +containing an action or function import name, optionally followed by a +forward slash and either a parameter name or `$ReturnType` + +- One of the preceding, followed by a forward slash, an at (`@`), the + [qualified name](#QualifiedName) of a term, and optionally a hash + (`#`) and the qualifier of an + annotation + +All [qualified names](#QualifiedName) used in a target path MUST be in +scope. + +::: example +Example 42: Target expressions +``` +MySchema.MyEntityType +MySchema.MyEntityType/MyProperty +MySchema.MyEntityType/MyNavigationProperty +MySchema.MyComplexType +MySchema.MyComplexType/MyProperty +MySchema.MyComplexType/MyNavigationProperty +MySchema.MyEnumType +MySchema.MyEnumType/MyMember +MySchema.MyTypeDefinition +MySchema.MyTerm +MySchema.MyEntityContainer +MySchema.MyEntityContainer/MyEntitySet +MySchema.MyEntityContainer/MySingleton +MySchema.MyEntityContainer/MyActionImport +MySchema.MyEntityContainer/MyFunctionImport +MySchema.MyAction +MySchema.MyAction(MySchema.MyBindingType) +MySchema.MyAction() +MySchema.MyFunction +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType) +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType) +MySchema.MyFunction/MyParameter +MySchema.MyEntityContainer/MyEntitySet/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty +``` +::: + +## 14.3 Constant Expression + +Constant expressions allow assigning a constant value to an applied +term. + +### 14.3.1 Binary + + + +::: {.varxml .rep} +### Expression `edm:Binary` + +The `edm:Binary` expression evaluates to a primitive binary value. A +binary expression MUST be assigned a value conforming to the rule +`binaryValue` in [OData-ABNF](#ODataABNF). + +The binary expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 43: base64url-encoded binary value (OData) +```xml + + + + T0RhdGE + +``` +::: + +### 14.3.2 Boolean + + + +::: {.varxml .rep} +### Expression `edm:Bool` + +The `edm:Bool` expression evaluates to a primitive Boolean value. A +Boolean expression MUST be assigned a Boolean value. + +The Boolean expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 44: +```xml + + + + true + +``` +::: + +### 14.3.3 Date + + + +::: {.varxml .rep} +### Expression `edm:Date` + +The `edm:Date` expression evaluates to a primitive date value. A date +expression MUST be assigned a value of type `xs:date`, see +[XML-Schema-2](#XML-Schema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData-ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. + +The date expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example 45: +```xml + + + + 2000-01-01 + +``` +::: + +### 14.3.4 DateTimeOffset + + + +::: {.varxml .rep} +### Expression `edm:DateTimeOffset` + +The `edm:DateTimeOffset` expression evaluates to a primitive +datetimestamp value with a time-zone offset. A datetimestamp expression +MUST be assigned a value of type `xs:dateTimeStamp`, see +[XML-Schema-2](#XML-Schema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData-ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). + +The datetimestamp expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 46: +```xml + + + + 2000-01-01T16:00:00.000-09:00 + +``` +::: + +### 14.3.5 Decimal + + + + +::: {.varxml .rep} +### Expression `edm:Decimal` + +The `edm:Decimal` expression evaluates to a primitive decimal value. A +decimal expression MUST be assigned a value conforming to the rule +`decimalValue` in [OData-ABNF](#ODataABNF). + +The decimal expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .rep} +Example 47: attribute notation +```xml + +``` +::: + +::: {.varxml .example} +Example 48: element notation +```xml + + 3.14 + +``` +::: + +### 14.3.6 Duration + + + +::: {.varxml .rep} +### Expression `edm:Duration` + +The `edm:Duration` expression evaluates to a primitive duration value. A +duration expression MUST be assigned a value of type +`xs:dayTimeDuration`, see [XML-Schema-2](#XML-Schema2), +[section 3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). + +The duration expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 49: +```xml + + + + P11DT23H59M59.999999999999S + +``` +::: + +### 14.3.7 Enumeration Member + + + + +::: {.varxml .rep} +### Expression `edm:EnumMember` + +The `edm:EnumMember` expression references a +[member](#EnumerationTypeMember) of an [enumeration +type](#EnumerationType). An enumeration member expression MUST be +assigned a value that consists of the qualified name of the enumeration +type, followed by a forward slash and the name of the enumeration +member. If the enumeration type specifies an `IsFlags` attribute with +value `true`, the expression MAY also be assigned a whitespace-separated +list of values. Each of these values MUST resolve to the name of a +member of the enumeration type of the specified term. + +The enumeration member expression MAY be provided using element notation +or attribute notation. +::: + +::: {.varxml .example} +Example 50: single value +```xml + + + + org.example.Pattern/Red + +``` +::: + +::: {.varxml .example} +Example 51: combined value for `IsFlags` enumeration type +```xml + + + + org.example.Pattern/Red org.example.Pattern/Striped + +``` +::: + +### 14.3.8 Floating-Point Number + + + +::: {.varxml .rep} +### Expression `edm:Float` + +The `edm:Float` expression evaluates to a primitive floating point (or +double) value. A float expression MUST be assigned a value conforming to +the rule `doubleValue` in [OData-ABNF](#ODataABNF). + +The float expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example 52: +```xml + + + + 3.14 + +``` +::: + +### 14.3.9 Guid + + + +::: {.varxml .rep} +### Expression `edm:Guid` + +The `edm:Guid` expression evaluates to a primitive guid value. A guid +expression MUST be assigned a value conforming to the rule `guidValue` +in [OData-ABNF](#ODataABNF). + +The guid expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example 53: +```xml + + + + 21EC2020-3AEA-1069-A2DD-08002B30309D + +``` +::: + +### 14.3.10 Integer + + + + +::: {.varxml .rep} +### Expression `edm:Int` + +The `edm:Int` expression evaluates to a primitive integer value. An +integer MUST be assigned a value conforming to the rule `int64Value` in +[OData-ABNF](#ODataABNF). + +The integer expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 54: attribute notation +```xml + +``` +::: + +::: {.varxml .example} +Example 55: element notation +```xml + + 42 + +``` +::: + +### 14.3.11 String + + + +::: {.varxml .rep} +### Expression `edm:String` + +The `edm:String` expression evaluates to a primitive string value. A +string expression MUST be assigned a value of the type `xs:string`, see +[XML-Schema-2](#XML-Schema2), [section +3.3.1](http://www.w3.org/TR/xmlschema11-2/#string). + +The string expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 56: +```xml + + + + Product Catalog + +``` +::: + +### 14.3.12 Time of Day + + + +::: {.varxml .rep} +### Expression `edm:TimeOfDay` + +The `edm:TimeOfDay` expression evaluates to a primitive time value. A +time-of-day expression MUST be assigned a value conforming to the rule +`timeOfDayValue` in [OData-ABNF](#ODataABNF). + +The time-of-day expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 57: +```xml + + + + 21:45:00 + +``` +::: + +## 14.4 Dynamic Expression + +Dynamic expressions allow assigning a calculated value to an applied +term. + +### 14.4.1 Path Expressions + +Path expressions allow assigning a value to an applied term or term +component. There are two kinds of path expressions: +- A *model path* is used within +[Annotation Path](#AnnotationPath), [Model Element Path](#ModelElementPath), +[Navigation Property Path](#NavigationPropertyPath), and [Property +Path](#PropertyPath) expressions to traverse the model of a service and +resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) `Edm.AnnotationPath`, +`Edm.NavigationPropertyPath`, `Edm.PropertyPath`, and their base types +`Edm.AnyPropertyPath` and `Edm.ModelElementPath`. +- An *instance path* is used within a +[Value Path](#ValuePath) expression to traverse a graph of type +instances and resolves to the value identified by the path. It allows +assigning values to terms or term properties of built-in types other +than the `Edm.*Path` types, or of any model-defined type. + +#### 14.4.1.1 Path Syntax + +Model paths and instance paths share a common syntax which is derived +from the path expression syntax of URLs, see [OData-URL](#ODataURL). + +A path MUST be composed of zero or more path segments joined together by +forward slashes (`/`). + +Paths starting with a forward slash (`/`) are absolute paths, and the +first path segment MUST be the qualified name of a model element, e.g. +an entity container. The remaining path after the second forward slash +is interpreted relative to that model element. + +::: example +Example 58: absolute path to an entity set +``` +/My.Schema.MyEntityContainer/MyEntitySet +``` +::: + +Paths not starting with a forward slash are interpreted relative to the +annotation target, following the rules specified in section "[Path +Evaluation](#PathEvaluation)". + +::: example +Example 59: relative path to a property +``` +Address/City +``` +::: + +If a path segment is a [qualified name](#QualifiedName), it represents a +*type cast*, and the segment MUST be the name of a type +in scope. If the type or instance identified by the preceding path part +cannot be cast to the specified type, the path expression evaluates to +the null value. + +::: example +Example 60: type-cast segment +``` +.../self.Manager/... +``` +::: + +If a path segment starts with an at (`@`) character, it represents a +*term cast*. The at (`@`) character MUST be followed by +a [qualified name](#QualifiedName) that MAY be followed by a hash (`#`) +character and a [simple identifier](#SimpleIdentifier). The [qualified +name](#QualifiedName) preceding the hash character MUST resolve to a +term that is in scope, the [simple identifier](#SimpleIdentifier) +following the hash sign is interpreted as a [qualifier](#Qualifier) for +the term. If the model element or instance identified by the preceding +path part has not been annotated with that term (and if present, with +that qualifier), the term cast evaluates to the null value. Four special +terms are implicitly "annotated" for media entities and stream +properties: + +- `odata.mediaEditLink` +- `odata.mediaReadLink` +- `odata.mediaContentType` +- `odata.mediaEtag` + +::: example +Example 61: term-cast segments +``` +.../@Capabilities.SortRestrictions/... +``` +::: + +If a path segment is a [simple identifier](#SimpleIdentifier), it MUST +be the name of a child model element of the model element identified by +the preceding path part, or a structural or navigation property of the +instance identified by the preceding path part. A sequence of navigation +segments can traverse multiple CSDL documents. The document containing +the path expression only needs to reference the next traversed document +to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document. + +A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path. + +::: example +Example 62: property segments in model path +``` +.../Orders/Items/Product/... +``` +::: + +An instance path MUST NOT contain more than one segment representing a +collection-valued construct, e.g. an entity set or a collection-valued +navigation property that is not followed by a key predicate, or a +collection-valued structural property that is not followed by an index +segment. The result of the expression is the collection of instances +resulting from applying any remaining path segments that operate on a +single-valued expression to each instance in the collection-valued +segment. + +An instance path MAY terminate in a `$count` segment if the previous +segment is collection-valued, in which case the path evaluates to the +number of items in the collection identified by the preceding segment. + +::: example +Example 63: property segments in instance path +``` +.../Addresses/Street +``` + +``` +.../Addresses/$count +``` +::: + +A model path MAY contain path segments starting with a navigation +property, then followed by an at (`@`) character, then followed by the +[qualified name](#QualifiedName) of a term in scope, and optionally +followed by a hash (`#`) character and a [simple +identifier](#SimpleIdentifier) which is interpreted as a +[qualifier](#Qualifier) for the term. If the navigation property has not +been annotated with that term (and if present, with that qualifier), the +path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity +type specified by the navigation property are addressed via a [term-cast +segment](#TermCast). + +::: example +Example 64: model path addressing an annotation on a navigation property +``` +.../Items@Capabilities.InsertRestrictions/Insertable +``` +::: + +An instance path MAY contain path segments starting with an entity set +or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see +[OData-URL](#ODataURL). The key values are either primitive literals or +instance paths. If the key value is a relative instance path, it is +interpreted according to the same rule below as the instance path it is +part of, *not* relative to the instance identified by the preceding path +part. + +::: example +Example 65: instance path with entity set and key predicate +``` +/self.container/SettingsCollection('FeatureXxx')/IsAvailable +``` + +``` +/self.container/Products(ID=ProductID)/Name +``` +::: + +An instance path MAY contain an index segment immediately following a +path segment representing an ordered collection-valued structural +property. The index is zero-based and MUST be an integer literal. +Negative integers count from the end of the collection, with -1 +representing the last item in the collection. Remaining path segments +are evaluated relative to the identified item of the collection. + +::: example +Example 66: instance path with collection-valued structural property and +index segment +``` +Addresses/1 +``` + +``` +Addresses/-1/Street +``` +::: + +#### 14.4.1.2 Path Evaluation + +Annotations MAY be embedded within their target, or specified +separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as +*targeting* in the remainder of this section. + +For annotations embedded within or targeting an entity container, the +path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a +segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules +for paths targeting the corresponding child element. + +For annotations embedded within or targeting an entity set or a +singleton, the path is evaluated starting at the entity set or +singleton, i.e. an empty path resolves to the entity set or singleton, +and non-empty paths MUST follow the rules for annotations targeting the +declared entity type of the entity set or singleton. + +For annotations embedded within or targeting an entity type or complex +type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be +a structural or navigation property of the type, a [type +cast](#TypeCast), or a [term cast](#TermCast). + +For annotations embedded within a structural or navigation property of +an entity type or complex type, the path is evaluated starting at the +directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other +properties of the same type. An empty path resolves to the enclosing +type, and non-empty paths MUST follow the rules for annotations +targeting the directly enclosing type. + +For annotations targeting a structural or navigation property of an +entity type or complex type, the path is evaluated starting at the +*outermost* entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the +first segment of a non-empty path MUST be a structural or navigation +property of the outermost type, a [type cast](#TypeCast), or a [term +cast](#TermCast). + +For annotations embedded within or targeting an action, action import, +function, function import, parameter, or return type, the first segment +of the path MUST be a parameter name or `$ReturnType`. + +#### 14.4.1.3 Annotation Path + +The annotation path expression provides a value for terms or term +properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.AnnotationPath or Edm.ModelElementPath`. Its argument is a [model +path](#PathExpressions) with the following restriction: +- A non-null path MUST resolve to an annotation. + +A term or term property of type `Edm.AnnotationPath` can be annotated +with term `Validation.AllowedTerms` (see +[OData-VocValidation](#ODataVocValidation)) if its intended value is an +annotation path that ends in a term cast with one of the listed terms. + +The value of the annotation path expression is the path itself, not the +value of the annotation identified by the path. This is useful for terms +that reuse or refer to other terms. + + + +::: {.varxml .rep} +### Expression `edm:AnnotationPath` + +The `edm:AnnotationPath` expression MAY be provided using element +notation or attribute notation. +::: + +::: {.varxml .example} +Example 67: +```xml + + + + + Supplier/@Communication.Contact + Customer/@Communication.Contact + + +``` +::: + +#### 14.4.1.4 Model Element Path + +The model element path expression provides a value for terms or term +properties that specify the [built-in +type](#BuiltInTypesfordefiningVocabularyTerms)` Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions). + +The value of the model element path expression is the path itself, not +the instance(s) identified by the path. + + + +::: {.varxml .rep} +### Expression `edm:ModelElementPath` + +The `edm:ModelElementPath` expression MAY be provided using element +notation or attribute notation. +::: + +::: {.varxml .example} +Example 68: +```xml + + + + /org.example.someAction + +``` +::: + +#### 14.4.1.5 Navigation Property Path + +The navigation property path expression provides a value for terms or +term properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. +Its argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is an entity type, or a collection of entity types, +e.g. a navigation property. + +The value of the navigation property path expression is the path itself, +not the entitiy or collection of entities identified by the path. + + + +::: {.varxml .rep} +### Expression `edm:NavigationPropertyPath` + +The `edm:NavigationPropertyPath` expression MAY be provided using +element notation or attribute notation. +::: + +::: {.varxml .example} +Example 69: +```xml + + + + + + + Supplier + Category + + + + +``` +::: + +#### 14.4.1.6 Property Path + +The property path expression provides a value for terms or term +properties that specify one of the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is a primitive or complex type, an enumeration type, +a type definition, or a collection of one of these types. + +The value of the property path expression is the path itself, not the +value of the structural property or the value of the term cast +identified by the path. + + + +::: {.varxml .rep} +### Expression `edm:PropertyPath` + +The `edm:PropertyPath` MAY be provided using either element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 70: +```xml + + + + + + + CreatedAt + ChangedAt + + + + +``` +::: + +#### 14.4.1.7 Value Path + +The value path expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation +properties of structured types, and structural properties of structured +types. Its argument is an [instance path](#PathExpressions). + +The value of the path expression is the instance or collection of +instances identified by the path. + + + +::: {.varxml .rep} +### Expression `edm:Path` + +The `edm:Path` expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example 71: +```xml + + + + @vCard.Address#work/FullName + +``` +::: + +### 14.4.2 Comparison and Logical Operators + +Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and +they MAY be used anywhere instead of a Boolean expression. + +Operator|Description +--------|----------- +**Logical Operators**| +`And` |Logical and +`Or` |Logical or +`Not` |Logical negation +**Comparison Operators**| +`Eq` |Equal +`Ne` |Not equal +`Gt` |Greater than +`Ge` |Greater than or equal +`Lt` |Less than +`Le` |Less than or equal +`Has` |Has enumeration flag(s) set +`In` |Is in collection + +The `And` and `Or` operators require two operand expressions that +evaluate to Boolean values. The `Not` operator requires a single operand +expression that evaluates to a Boolean value. For details on null +handling for comparison operators see [OData-URL](#ODataURL). + +The other comparison operators require two operand expressions that +evaluate to comparable values. + + + +::: {.varxml .rep} +### Expressions `edm:And` and `edm:Or` + +The `And` and `Or` logical expressions are represented as elements +`edm:And` and `edm:Or` that MUST contain two annotation expressions. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Expression `edm:Not` + +Negation expressions are represented as an element `edm:Not` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Expressions `edm:Eq`, `edm:Ne`, `edm:Gt`, `edm:Ge`, `edm:Lt`, `edm:Le`, `edm:Has`, and `edm:In` + +All comparison expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example 72: +```xml + + IsMale + IsMarried + + + IsMale + IsMarried + + + IsMale + + + + IsMale + + + + IsMale + + + Price + 20 + + + Price + 10 + + + Price + 20 + + + Price + 100 + + + Fabric + org.example.Pattern/Red + + + Size + + XS + S + + +``` +::: + +### 14.4.3 Arithmetic Operators + +Annotations MAY use the following arithmetic expressions which evaluate +to a numeric value. These expressions MAY be combined, and they MAY be +used anywhere instead of a numeric expression of the appropriate type. +The semantics and evaluation rules for each arithmetic expression is +identical to the corresponding arithmetic operator defined in +[OData-URL](#ODataURL). + +Operator|Description +--------|----------- +`Add` |Addition +`Sub` |Subtraction +`Neg` |Negation +`Mul` |Multiplication +`Div` |Division (with integer result for integer operands) +`DivBy` |Division (with fractional result also for integer operands) +`Mod` |Modulo + +The `Neg` operator requires a single operand expression that evaluates +to a numeric value. The other arithmetic operators require two operand +expressions that evaluate to numeric values. + + + +::: {.varxml .rep} +### Expression `edm:Neg` + +Negation expressions are represented as an element `edm:Neg` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Expressions `edm:Add`, `edm:Sub`, `edm:Mul`, `edm:Div`, `edm:DivBy`, and `edm:Mod` + +These arithmetic expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example 73: +```xml + + StartDate + Duration + + + Revenue + Cost + + + Height + + + NetPrice + TaxRate + +
    + Quantity + QuantityPerParcel +
    + + Quantity + QuantityPerParcel + + + Quantity + QuantityPerParcel + +``` +::: + +### 14.4.4 Apply Client-Side Functions + +The apply expression enables a value to be obtained by applying a +client-side function. The apply expression MAY have operand expressions. +The operand expressions are used as parameters to the client-side +function. + + +::: {.varxml .rep} +### Expression `edm:Apply` + +The `edm:Apply` element MUST contain the `Function` attribute and MAY +contain annotation expressions as operands for the applied function. + +It MAY contain more [`edm:Annotation`](#Annotation) elements. + +### Attribute `Function` + +The value of `Function` is the [qualified name](#QualifiedName) of the +client-side function to apply. +::: + +OData defines the following functions. Services MAY support additional +functions that MUST be qualified with a namespace other than `odata`. +Function names qualified with `odata` are reserved for this +specification and its future versions. + +#### 14.4.4.1 Canonical Functions + +All canonical functions defined in [OData-URL](#ODataURL) can be used as +client-side functions, qualified with the namespace `odata`. The +semantics of these client-side functions is identical to their +counterpart function defined in [OData-URL](#ODataURL). + +For example, the `odata.concat` client-side function takes two or more +expressions as arguments. Each argument MUST evaluate to a primitive or +enumeration type. It returns a value of type `Edm.String` that is the +concatenation of the literal representations of the results of the +argument expressions. Values of primitive types other than `Edm.String` +are represented according to the appropriate alternative in the +`primitiveValue` rule of [OData-ABNF](#ODataABNF), i.e. `Edm.Binary` as +`binaryValue`, `Edm.Boolean` as `booleanValue` etc. + + +::: {.varxml .example} +Example 74: +```xml + + + Product: + ProductName + ( + Available/Quantity + + Available/Unit + available) + + +``` +::: + +`ProductName` is of type `String`, `Quantity` in complex type +`Available` is of type `Decimal`, and `Unit` in `Available` is of type +enumeration, so the result of the `Path` expression is represented as +the member name of the enumeration value. + +#### 14.4.4.2 Function `odata.fillUriTemplate` + +The `odata.fillUriTemplate` client-side function takes two or more +expressions as arguments and returns a value of type `Edm.String.` + +The first argument MUST be of type `Edm.String` and specifies a URI +template according to [RFC6570](#rfc6570), the other arguments MUST be +[labeled element expressions](#LabeledElement). Each [labeled element +expression](#LabeledElement) specifies the template parameter name as +its name and evaluates to the template parameter value. + +[RFC6570](#rfc6570) defines three kinds of template parameters: simple +values, lists of values, and key-value maps. + +Simple values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a single primitive value. +The literal representation of this value according to +[OData-ABNF](#ODataABNF) is used to fill the corresponding template +parameter. + +Lists of values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of primitive +values. + +Key-value maps are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of complex +types with two properties that are used in lexicographic order. The +first property is used as key, the second property as value. + + +::: {.varxml .example} +Example 75: assuming there are no special characters in values of the +Name property of the Actor entity +```xml + + http://host/someAPI/Actors/{actorName}/CV + + +``` +::: + +#### 14.4.4.3 Function `odata.matchesPattern` + +The `odata.matchesPattern` client-side function takes two string +expressions as arguments and returns a Boolean value. + +The function returns true if the second expression evaluates to an +[ECMAScript](#_ECMAScript) (JavaScript) regular expression and +the result of the first argument expression matches that regular +expression, using syntax and semantics of +[ECMAScript](#_ECMAScript) regular expressions. + + +::: {.varxml .example} +Example 76: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` +```xml + + FirstName + ^[^b-d]+$ + +``` +::: + +#### 14.4.4.4 Function `odata.uriEncode` + +The `odata.uriEncode `client-side function takes one argument of +primitive type and returns the URL-encoded OData literal that can be +used as a key value in OData URLs or in the query part of OData URLs. + +Note: string literals are surrounded by single quotes as required by the +paren-style key syntax. + + +::: {.varxml .example} +Example 77: +```xml + + http://host/service/Genres({genreName}) + + + NameOfMovieGenre + + + +``` +::: + +### 14.4.5 Cast + +The cast expression casts the value obtained from its single child +expression to the specified type. The cast expression follows the same +rules as the `cast` canonical function defined in +[OData-URL](#ODataURL). + + + +::: {.varxml .rep} +### Expression `edm:Cast` + +The `edm:Cast` element MUST contain the `Type` attribute and MUST +contain exactly one expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Type` + +The value of `Type` is a qualified type name in scope, or the character +sequence `Collection(` followed by the qualified name of a type in +scope, followed by a closing parenthesis `)`. + +If the specified type is a primitive type or a collection of a primitive +type, the facet attributes [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet attributes are not specified, their values +are considered unspecified. +::: + +::: {.varxml .example} +Example 78: +```xml + + + Average + + +``` +::: + +### 14.4.6 Collection + +The collection expression enables a value to be obtained from zero or +more item expressions. The value calculated by the collection expression +is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type +compatible. + + + +::: {.varxml .rep} +### Expression `edm:Collection` + +The `edm:Collection` element contains zero or more child expressions. +::: + +::: {.varxml .example} +Example 79: +```xml + + + Product + Supplier + Customer + + +``` +::: + +### 14.4.7 If-Then-Else + +The if-then-else expression enables a value to be obtained by evaluating +a *condition expression*. It MUST contain exactly three child +expressions. There is one exception to this rule: if and only if the +if-then-else expression is an item of a collection expression, the third +child expression MAY be omitted, reducing it to an if-then expression. +This can be used to conditionally add an element to a collection. + +The first child expression is the condition and MUST evaluate to a +Boolean result, e.g. the [comparison and logical +operators](#ComparisonandLogicalOperators) can be used. + +The second and third child expressions are evaluated conditionally. The +result MUST be type compatible with the type expected by the surrounding +expression. + +If the first expression evaluates to `true`, the second expression MUST +be evaluated and its value MUST be returned as the result of the +if-then-else expression. If the first expression evaluates to `false` +and a third child element is present, it MUST be evaluated and its value +MUST be returned as the result of the if-then-else expression. If no +third expression is present, nothing is added to the surrounding +collection. + + + +::: {.varxml .rep} +### Expression `edm:If` + +The `edm:If` element MUST contain two or three child expressions that +MUST use element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example 80: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale`, whose value then determines +the value of the `edm:If` expression (or so it was long ago) +```xml + + + IsFemale + Female + Male + + +``` +::: + +### 14.4.8 Is-Of + +The `is-of` expression checks whether the value obtained from its single +child expression is compatible with the specified type. It returns +`true` if the child expression returns a type that is compatible with +the specified type, and `false` otherwise. + + + +::: {.varxml .rep} +### Expression `edm:UrlRef` + +The `edm:UrlRef` expression MAY be provided using element notation or +attribute notation. + +Relative URLs are relative to the `xml:base` attribute, see +[XML-Base](#XML-Base). + +In element notation it MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example 81: +```xml + + + Customer + + +``` +::: + +### 14.4.9 Labeled Element + +The labeled element expression assigns a name to its single child +expression. The value of the child expression can then be reused +elsewhere with a [labeled element reference +expression](#LabeledElementReference). + +A labeled element expression MUST contain exactly one child expression. +The value of the child expression is also the value of the labeled +element expression. + +A labeled element expression MUST provide a [simple +identifier](#SimpleIdentifier) value as its name that MUST be unique +within the schema containing the expression. + + + +::: {.varxml .rep} +### Expression `edm:LabeledElement` + +The `edm:LabeledElement` element MUST contain the Name attribute. + +It MUST contain a child expression written either in attribute notation +or element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Name` + +The value of `Name` is the labeled element's name. +::: + +::: {.varxml .example} +Example 82: +```xml + + + + + + + FirstName + + +``` +::: + +### 14.4.10 Labeled Element Reference + +The labeled element reference expression MUST specify the [qualified +name](#QualifiedName) of a [labeled element expression](#LabeledElement) +in scope and returns the value of the identified labeled element +expression as its value. + + + +::: {.varxml .rep} +### Expression `edm:LabeledElementReference` + +The `edm:LabeledElementReference` element MUST contain the qualified name +of a labeled element expression in its body. +::: + +::: {.varxml .example} +Example 83: +```xml + + Model.CustomerFirstName + +``` +::: + +### 14.4.11 Null + +The null expression indicates the absence of a value. The null +expression MAY be annotated. + + + + + +::: {.varxml .rep} +### Expression `edm:Null` + +The `edm:Null` element MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example 84: +```xml + + + +``` +::: + +::: {.varxml .example} +Example 85: +```xml + + + + + +``` +::: + +### 14.4.12 Record + +The record expression enables a new entity type or complex type instance +to be constructed. + +A record expression MAY specify the structured type of its result, which +MUST be an entity type or complex type in scope. If not explicitly +specified, the type is derived from the expression's context. + +A record expression contains zero or more property value expressions. +For each single-valued structural or navigation property of the record +expression's type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if +the record expression is the value of an annotation for a term that has +a [base term](#SpecializedTerm) whose type is structured and directly or +indirectly inherits from the type of its base term. In this case, +property values that already have been specified in the annotation for +the base term or its base term etc. need not be specified again. + +For collection-valued properties the absence of a property value +expression is equivalent to specifying an empty collection as its value. + + + +::: {.varxml .rep} +### Expression `edm:Record` + +The `edm:Record` element MAY contain the `Type` attribute and MAY +contain `edm:PropertyValue` elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Type` + +The value of `Type` is the qualified name of a structured type in scope. + +### Element `edm:PropertyValue` + +The `edm:PropertyValue` element MUST contain the `Property` attribute, +and it MUST contain exactly one expression that MAY be provided using +either element notation or attribute notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### Attribute `Property` + +The value of `Property` is the name of a property of the type of the +enclosing `edm:Record` expression. +::: + +::: {.varxml .example} +Example 86: this annotation "morphs" the entity type from [example 8](#entitytype) into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service +```xml + + + + + + + + + + + + http://host/anotherservice/CostCenters('{ccid}') + + + + + + +``` +::: + +### 14.4.13 URL Reference + +The URL reference expression enables a value to be obtained by sending a +`GET` request. + +The URL reference expression MUST contain exactly one expression of type +`Edm.String`. Its value is treated as a URL that MAY be relative or +absolute; relative URLs are relative to the URL of the document +containing the URL reference expression, or relative to a base URL +specified in a format-specific way. + +The response body of the `GET` request MUST be returned as the result of +the URL reference expression. The result of the URL reference +expression MUST be type compatible with the type expected by the +surrounding expression. + + + +::: {.varxml .rep} +### Expression `edm:UrlRef` + +The `edm:UrlRef` expression MAY be provided using element notation or +attribute notation. + +Relative URLs are relative to the `xml:base` attribute, see +[XML-Base](#XML-Base). + +In element notation it MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example 87: +```xml + + + + http://host/service/Suppliers({suppID}) + + + SupplierId + + + + + + + + http://host/wiki/HowToUse + + + +``` +::: + +------- + +# 15 Identifier and Path Values + +## 15.1 Namespace + +A namespace is a dot-separated sequence of [simple +identifier](#SimpleIdentifier)s with a maximum length of 511 Unicode +characters (code points). + +## 15.2 Simple Identifier + +A simple identifier is a Unicode character sequence with the following +restrictions: + +- It consists of at least one and at most 128 Unicode characters (code + points). +- The first character MUST be the underscore character (U+005F) or any + character in the Unicode category "Letter (L)" or "Letter number + (Nl)". +- The remaining characters MUST be the underscore character (U+005F) + or any character in the Unicode category "Letter (L)", "Letter + number (Nl)", "Decimal number (Nd)", "Non-spacing mark (Mn)", + "Combining spacing mark (Mc)", "Connector punctuation (Pc)", and + "Other, format (Cf)". + +Non-normatively speaking it starts with a letter or underscore, followed +by at most 127 letters, underscores or digits. + +## 15.3 Qualified Name + +For model elements that are direct children of a schema: the namespace +or alias of the schema that defines the model element, followed by a dot +and the name of the model element, see rule `qualifiedTypeName` in +[OData‑ABNF](#ODataABNF). + +For built-in [primitive types](#PrimitiveTypes): the name of the type, +prefixed with `Edm` followed by a dot. + +## 15.4 Target Path + +Target paths are used to refer to other model elements. + +The allowed path expressions are: +- The [qualified +name](#QualifiedName) of an entity container, followed by a forward +slash and the name of a container child element +- The target +path of a container child followed by a forward slash and one or more +forward-slash separated property, navigation property, or type-cast +segments + +::: example +Example 88: Target expressions +``` +MySchema.MyEntityContainer/MyEntitySet +MySchema.MyEntityContainer/MySingleton +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp +``` +::: + +------- + +# 16 CSDL Examples + + +Following are two basic examples of valid EDM models as represented in +CSDL. These examples demonstrate many of the topics covered above. + +## 16.1 Products and Categories Example + + +::: {.varxml .example} +Example 89: +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Concurrency + + + + + + + + + + + + + +``` +::: + + +## 16.2 Annotations for Products and Categories Example + + +::: {.varxml .example} +Example 90: +```xml + + + + + + + + + + + + + + + + + + Name + in + Address/CountryName + + + + + + + MasterData + + + + + + +``` +::: + +------- + +# 17 Conformance + +Conforming services MUST follow all rules of this specification document +for the types, sets, functions, actions, containers and annotations they +expose. + +In addition, conforming services MUST NOT return 4.01 CSDL constructs +for requests made with `OData-MaxVersion:4.0`. + +Specifically, they + +1. MUST NOT include properties in derived types that overwrite a +property defined in the base type + +2. MUST NOT include `Edm.Untyped` + +3. MUST NOT use [path syntax](#PathSyntax) added with 4.01 + +4. MUST NOT use `Edm.ModelElementPath` and `Edm.AnyPropertyPath` + +5. MUST NOT specify [referential constraints](#ReferentialConstraint) +to complex types and navigation properties + +6. MUST NOT include a non-abstract entity type with no inherited or +defined [entity key](#Key) + +7. MUST NOT include the +[`Core.DefaultNamespace`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#DefaultNamespace) +annotation on [included schemas](#IncludedSchema) + +8. MUST NOT return the Unicode facet for terms, parameters, and return +types + +9. MUST NOT include collections of `Edm.ComplexType` or `Edm.Untyped` + +10. MUST NOT specify a key as a property of a related entity + + +11. SHOULD NOT include new/unknown values for the +[`AppliesTo`](#Applicability) attribute + +12. MAY include new CSDL annotations + +In addition, OData 4.01 services: + +13. SHOULD NOT have identifiers within a uniqueness scope (e.g. a +schema, a structural type, or an entity container) that differ only by +case + +Conforming clients MUST be prepared to consume a model that uses any or +all constructs defined in this specification, including custom +annotations, and MUST ignore constructs not defined in this version of +the specification. + +------- + +# Appendix A. References + + + +This appendix contains the normative and informative references that are used in this document. + +While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity. + +## A.1 Normative References + +The following documents are referenced in such a way that some or all of their content constitutes requirements of this document. + +###### [OData-v4.02] +- _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: + - _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html + - _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + +###### [ECMAScript] +_ECMAScript 2016 Language Specification, 7th Edition_. June 2016. Standard ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm. + +###### [EPSG] +_European Petroleum Survey Group (EPSG)_. http://www.epsg.org/. + +###### [OData-ABNF] +_OData ABNF Construction Rules Version 4.01_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-CSDL-Schema] +_OData CSDL JSON Schema_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-CSDL-JSON] +_OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-CSDL-XML] +_OData Common Schema Definition Language (CSDL) XML Representation Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-EDM] +_OData EDM XML Schema_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-EDMX] +_OData EDM XML Schema_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-JSON] +_OData JSON Format Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-Protocol] +_OData Version 4.01 Part 1: Protocol_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-URL] +_OData Version 4.01 Part 2: URL Conventions_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocCore] +_OData Vocabularies Version 4.0: Core Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocMeasures] +_OData Vocabularies Version 4.0: Measures Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocValidation] +_OData Vocabularies Version 4.0: Validation Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [RFC2119] +_Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997_. +https://www.rfc-editor.org/info/rfc2119. + +###### [RFC6570] +_Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template”, RFC 6570, March 2012_. +http://tools.ietf.org/html/rfc6570. + +###### [RFC7493] +_Bray, T., Ed., "The I-JSON Message Format", RFC7493, March 2015_. +https://tools.ietf.org/html/rfc7493. + +###### [RFC8174] +_Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017_. +http://www.rfc-editor.org/info/rfc8174. + +###### [RFC8259] +_Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, December 2017_. +http://tools.ietf.org/html/rfc8259. + +###### [XML-1.1] +_Extensible Markup Language (XML) 1.1 (Second Edition)_. F. Yergeau, E. Maler, J. Cowan, T. Bray, C. M. Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August 2006. +http://www.w3.org/TR/2006/REC-xml11-20060816. Latest version available at http://www.w3.org/TR/xml11/. + +###### [XML-Base] +_XML Base (Second Edition)_. J. Marsh, R. Tobin, Editors, W3C Recommendation, 28 January 2009. +http://www.w3.org/TR/2009/REC-xmlbase-20090128/. Latest version available at http://www.w3.org/TR/xmlbase/. +###### [XML-Schema-1] +_W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures_. D. Beech, M. Maloney, C. M. Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, Editors, W3C Recommendation, 5 April 2012. +http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-1/. + +###### [XML-Schema-2] +_W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes_. D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April 2012. +http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-2/. + +## A.2 Informative References + +###### [OpenUI5] +_OpenUI5 Version 1.40.10 - OData V4 Metadata JSON Format_. +https://openui5.hana.ondemand.com/1.40.10/#docs/guide/87aac894a40640f89920d7b2a414499b.html. + +------- + +# Appendix B. Table of XML Elements and Attributes + +::: toc +- [Element `edmx:Edmx`](#ElementedmxEdmx1) + - [Attribute `Version`](#AttributeVersion1.1) +- [Element `edmx:DataServices`](#ElementedmxDataServices2) +- [Element `edmx:Reference`](#ElementedmxReference3) + - [Attribute `Uri`](#AttributeUri3.1) +- [Element `edmx:Include`](#ElementedmxInclude4) + - [Attribute `Namespace`](#AttributeNamespace4.1) + - [Attribute `Alias`](#AttributeAlias4.2) +- [Element `edmx:IncludeAnnotations`](#ElementedmxIncludeAnnotations5) + - [Attribute `TermNamespace`](#AttributeTermNamespace5.1) + - [Attribute `Qualifier`](#AttributeQualifier5.2) + - [Attribute `TargetNamespace`](#AttributeTargetNamespace5.3) +- [Element `edm:Schema`](#ElementedmSchema6) + - [Attribute `Namespace`](#AttributeNamespace6.1) + - [Attribute `Alias`](#AttributeAlias6.2) +- [Element `edm:Annotations`](#ElementedmAnnotations7) + - [Attribute `Target`](#AttributeTarget7.1) + - [Attribute `Qualifier`](#AttributeQualifier7.2) +- [Element `edm:EntityType`](#ElementedmEntityType8) + - [Attribute `Name`](#AttributeName8.1) + - [Attribute `BaseType`](#AttributeBaseType8.2) + - [Attribute `Abstract`](#AttributeAbstract8.3) + - [Attribute `OpenType`](#AttributeOpenType8.4) + - [Attribute `HasStream`](#AttributeHasStream8.5) +- [Element `edm:Key`](#ElementedmKey9) +- [Element `edm:PropertyRef`](#ElementedmPropertyRef10) + - [Attribute `Name`](#AttributeName10.1) + - [Attribute `Alias`](#AttributeAlias10.2) +- [Element `edm:Property`](#ElementedmProperty11) + - [Attribute `Name`](#AttributeName11.1) + - [Attribute `Type`](#AttributeType11.2) + - [Attribute `Nullable`](#AttributeNullable11.3) + - [Attribute `MaxLength`](#AttributeMaxLength11.4) + - [Attribute `Precision`](#AttributePrecision11.5) + - [Attribute `Scale`](#AttributeScale11.6) + - [Attribute `Unicode`](#AttributeUnicode11.7) + - [Attribute `SRID`](#AttributeSRID11.8) + - [Attribute `DefaultValue`](#AttributeDefaultValue11.9) +- [Element `edm:NavigationProperty`](#ElementedmNavigationProperty12) + - [Attribute `Name`](#AttributeName12.1) + - [Attribute `Type`](#AttributeType12.2) + - [Attribute `Nullable`](#AttributeNullable12.3) + - [Attribute `Partner`](#AttributePartner12.4) + - [Attribute `ContainsTarget`](#AttributeContainsTarget12.5) +- [Element `edm:ReferentialConstraint`](#ElementedmReferentialConstraint13) + - [Attribute `Property`](#AttributeProperty13.1) + - [Attribute `ReferencedProperty`](#AttributeReferencedProperty13.2) +- [Element `edm:OnDelete`](#ElementedmOnDelete14) + - [Attribute `Action`](#AttributeAction14.1) +- [Element `edm:ComplexType`](#ElementedmComplexType15) + - [Attribute `Name`](#AttributeName15.1) + - [Attribute `BaseType`](#AttributeBaseType15.2) + - [Attribute `Abstract`](#AttributeAbstract15.3) + - [Attribute `OpenType`](#AttributeOpenType15.4) +- [Element `edm:EnumType`](#ElementedmEnumType16) + - [Attribute `Name`](#AttributeName16.1) + - [Attribute `UnderlyingType`](#AttributeUnderlyingType16.2) + - [Attribute `IsFlags`](#AttributeIsFlags16.3) +- [Element `edm:Member`](#ElementedmMember17) + - [Attribute `Name`](#AttributeName17.1) + - [Attribute `Value`](#AttributeValue17.2) +- [Element `edm:TypeDefinition`](#ElementedmTypeDefinition18) + - [Attribute `Name`](#AttributeName18.1) + - [Attribute `UnderlyingType`](#AttributeUnderlyingType18.2) +- [Element `edm:Action`](#ElementedmAction19) + - [Attribute `Name`](#AttributeName19.1) +- [Element `edm:Function`](#ElementedmFunction20) + - [Attribute `Name`](#AttributeName20.1) + - [Attribute `IsBound`](#AttributeIsBound20.2) + - [Attribute `EntitySetPath`](#AttributeEntitySetPath20.3) + - [Attribute `IsComposable`](#AttributeIsComposable20.4) +- [Element `edm:ReturnType`](#ElementedmReturnType21) + - [Attribute `Type`](#AttributeType21.1) + - [Attribute `Nullable`](#AttributeNullable21.2) +- [Element `edm:Parameter`](#ElementedmParameter22) + - [Attribute `Name`](#AttributeName22.1) + - [Attribute `Type`](#AttributeType22.2) + - [Attribute `Nullable`](#AttributeNullable22.3) +- [Element `edm:EntityContainer`](#ElementedmEntityContainer23) + - [Attribute `Name`](#AttributeName23.1) + - [Attribute `Extends`](#AttributeExtends23.2) +- [Element `edm:EntitySet`](#ElementedmEntitySet24) + - [Attribute `Name`](#AttributeName24.1) + - [Attribute `EntityType`](#AttributeEntityType24.2) + - [Attribute `IncludeInServiceDocument`](#AttributeIncludeInServiceDocument24.3) +- [Element `edm:Singleton`](#ElementedmSingleton25) + - [Attribute `Name`](#AttributeName25.1) + - [Attribute `Type`](#AttributeType25.2) + - [Attribute `Nullable`](#AttributeNullable25.3) +- [Element `edm:NavigationPropertyBinding`](#ElementedmNavigationPropertyBinding26) + - [Attribute `Path`](#AttributePath26.1) + - [Attribute `Target`](#AttributeTarget26.2) +- [Element `edm:ActionImport`](#ElementedmActionImport27) + - [Attribute `Name`](#AttributeName27.1) + - [Attribute `Action`](#AttributeAction27.2) + - [Attribute `EntitySet`](#AttributeEntitySet27.3) +- [Element `edm:FunctionImport`](#ElementedmFunctionImport28) + - [Attribute `Name`](#AttributeName28.1) + - [Attribute `Function`](#AttributeFunction28.2) + - [Attribute `EntitySet`](#AttributeEntitySet28.3) + - [Attribute `IncludeInServiceDocument`](#AttributeIncludeInServiceDocument28.4) +- [Element `edm:Term`](#ElementedmTerm29) + - [Attribute `Name`](#AttributeName29.1) + - [Attribute `Type`](#AttributeType29.2) + - [Attribute `DefaultValue`](#AttributeDefaultValue29.3) + - [Attribute `BaseTerm`](#AttributeBaseTerm29.4) + - [Attribute `AppliesTo`](#AttributeAppliesTo29.5) +- [Element `edm:Annotation`](#ElementedmAnnotation30) + - [Attribute `Term`](#AttributeTerm30.1) + - [Attribute `Qualifier`](#AttributeQualifier30.2) +- [Expression `edm:Binary`](#ExpressionedmBinary31) +- [Expression `edm:Bool`](#ExpressionedmBool32) +- [Expression `edm:Date`](#ExpressionedmDate33) +- [Expression `edm:DateTimeOffset`](#ExpressionedmDateTimeOffset34) +- [Expression `edm:Decimal`](#ExpressionedmDecimal35) +- [Expression `edm:Duration`](#ExpressionedmDuration36) +- [Expression `edm:EnumMember`](#ExpressionedmEnumMember37) +- [Expression `edm:Float`](#ExpressionedmFloat38) +- [Expression `edm:Guid`](#ExpressionedmGuid39) +- [Expression `edm:Int`](#ExpressionedmInt40) +- [Expression `edm:String`](#ExpressionedmString41) +- [Expression `edm:TimeOfDay`](#ExpressionedmTimeOfDay42) +- [Expression `edm:AnnotationPath`](#ExpressionedmAnnotationPath43) +- [Expression `edm:ModelElementPath`](#ExpressionedmModelElementPath44) +- [Expression `edm:NavigationPropertyPath`](#ExpressionedmNavigationPropertyPath45) +- [Expression `edm:PropertyPath`](#ExpressionedmPropertyPath46) +- [Expression `edm:Path`](#ExpressionedmPath47) +- [Expressions `edm:And`](#ExpressionsedmAnd48) + - [`edm:Or`](#edmOr48.1) +- [Expression `edm:Not`](#ExpressionedmNot49) +- [Expressions `edm:Eq`](#ExpressionsedmEq50) + - [`edm:Ne`](#edmNe50.1) + - [`edm:Gt`](#edmGt50.2) + - [`edm:Ge`](#edmGe50.3) + - [`edm:Lt`](#edmLt50.4) + - [`edm:Le`](#edmLe50.5) + - [`edm:Has`](#edmHas50.6) + - [`edm:In`](#edmIn50.7) +- [Expression `edm:Neg`](#ExpressionedmNeg51) +- [Expressions `edm:Add`](#ExpressionsedmAdd52) + - [`edm:Sub`](#edmSub52.1) + - [`edm:Mul`](#edmMul52.2) + - [`edm:Div`](#edmDiv52.3) + - [`edm:DivBy`](#edmDivBy52.4) + - [`edm:Mod`](#edmMod52.5) +- [Expression `edm:Apply`](#ExpressionedmApply53) + - [Attribute `Function`](#AttributeFunction53.1) +- [Expression `edm:Cast`](#ExpressionedmCast54) + - [Attribute `Type`](#AttributeType54.1) +- [Expression `edm:Collection`](#ExpressionedmCollection55) +- [Expression `edm:If`](#ExpressionedmIf56) +- [Expression `edm:UrlRef`](#ExpressionedmUrlRef57) +- [Expression `edm:LabeledElement`](#ExpressionedmLabeledElement58) + - [Attribute `Name`](#AttributeName58.1) +- [Expression `edm:LabeledElementReference`](#ExpressionedmLabeledElementReference59) +- [Expression `edm:Null`](#ExpressionedmNull60) +- [Expression `edm:Record`](#ExpressionedmRecord61) + - [Attribute `Type`](#AttributeType61.1) +- [Element `edm:PropertyValue`](#ElementedmPropertyValue62) + - [Attribute `Property`](#AttributeProperty62.1) +- [Expression `edm:UrlRef`](#ExpressionedmUrlRef63) +::: + +------- + +# Appendix C. Acknowledgments + +## C.1 Special Thanks + +The work of the OpenUI5 team on the OData V4 Metadata JSON Format, see +[OpenUI5](#_OpenUI5), is gratefully acknowledged, +especially the contributions of +- Thomas Chadzelek (SAP SE) +- Jens Ittel (SAP SE) +- Patric Ksinsik (SAP SE) + +The contributions of the OASIS OData Technical Committee members, +enumerated in [ODataProtocol](#ODataProtocol), are gratefully +acknowledged. + +## C.2 Participants + + + +The following individuals have participated in the creation of this specification and are gratefully acknowledged: + +**OpenC2 TC Members:** + +| First Name | Last Name | Company | +| :--- | :--- | :--- | +Philippe | Alman | Something Networks +Alex | Amirnovman | Company B +Kris | Anderman | Mini Micro +Darren | Anstman | Big Networks + +------- + +# Appendix D. Revision History + + + +| Revision | Date | Editor | Changes Made | +| :--- | :--- | :--- | :--- | +Committee Specification Draft 01|2023-07-14|Michael Pizzo
    Ralf Handl
    Heiko Theißen| + -The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance. +# Appendix E. Notices + + + +Copyright © OASIS Open 2023. All Rights Reserved.-------------- +Michael Pizzo All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full [Policy](https://www.oasis-open.org/policies-guidelines/ipr/) may be found at the OASIS website. +Ralf Handl +This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. + +This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.-------------- +Michael Pizzo As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata). +Ralf Handl +[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.]-------------- +Michael Pizzo [OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.] +Ralf Handl +[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.] + +The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance. + + + + + + + + + + + + + + + + + + + +-------------- +Michael Pizzo +Ralf Handl + + + +-------------- +Michael Pizzo +Ralf Handl +-------------- +Michael Pizzo +Ralf Handl diff --git a/docs/odata-csdl-xml/odata-csdl-xml.pdf b/docs/odata-csdl-xml/odata-csdl-xml.pdf index f5f71daa8..67e9579ce 100644 Binary files a/docs/odata-csdl-xml/odata-csdl-xml.pdf and b/docs/odata-csdl-xml/odata-csdl-xml.pdf differ diff --git a/docs/odata-csdl-xml/styles/odata.css b/docs/odata-csdl-xml/styles/odata.css index 7144dbd23..6a591fb26 100644 --- a/docs/odata-csdl-xml/styles/odata.css +++ b/docs/odata-csdl-xml/styles/odata.css @@ -2,19 +2,25 @@ a:target { background-color: yellow; } +a[href^="#_"], a[href^="#OData"], -a[href^="#rfc"] { +a[href^="#rfc"], +a[href^="#XML-"] { font-weight: bold; } +a[href^="#_"]::before, a[href^="#OData"]::before, -a[href^="#rfc"]::before { +a[href^="#rfc"]::before, +a[href^="#XML-"]::before { content: "["; font-weight: bold; } +a[href^="#_"]::after, a[href^="#OData"]::after, -a[href^="#rfc"]::after { +a[href^="#rfc"]::after, +a[href^="#XML-"]::after { content: "]"; font-weight: bold; } @@ -33,6 +39,11 @@ a[href^="#rfc"]::after { font-style: italic; } +.rep { + border-left: solid windowtext 1pt; + padding-left: 8pt; +} + table { width: auto; } @@ -122,7 +133,8 @@ h2 code, h3 code, h4 code, h5 code, -h6 code { +h6 code, +td>code { font-family: MJXZERO, MJXTEX-T; font-size: 1em; line-height: 0; @@ -133,7 +145,8 @@ h6 code { font-style: initial; } -.example pre { +.example pre, +.rep { margin-left: 40px; } diff --git a/docs/odata-data-aggregation-ext/odata-data-aggregation-ext.pdf b/docs/odata-data-aggregation-ext/odata-data-aggregation-ext.pdf index a7da57cfe..8a543542a 100644 Binary files a/docs/odata-data-aggregation-ext/odata-data-aggregation-ext.pdf and b/docs/odata-data-aggregation-ext/odata-data-aggregation-ext.pdf differ diff --git a/docs/odata-data-aggregation-ext/styles/odata.css b/docs/odata-data-aggregation-ext/styles/odata.css index 7144dbd23..6a591fb26 100644 --- a/docs/odata-data-aggregation-ext/styles/odata.css +++ b/docs/odata-data-aggregation-ext/styles/odata.css @@ -2,19 +2,25 @@ a:target { background-color: yellow; } +a[href^="#_"], a[href^="#OData"], -a[href^="#rfc"] { +a[href^="#rfc"], +a[href^="#XML-"] { font-weight: bold; } +a[href^="#_"]::before, a[href^="#OData"]::before, -a[href^="#rfc"]::before { +a[href^="#rfc"]::before, +a[href^="#XML-"]::before { content: "["; font-weight: bold; } +a[href^="#_"]::after, a[href^="#OData"]::after, -a[href^="#rfc"]::after { +a[href^="#rfc"]::after, +a[href^="#XML-"]::after { content: "]"; font-weight: bold; } @@ -33,6 +39,11 @@ a[href^="#rfc"]::after { font-style: italic; } +.rep { + border-left: solid windowtext 1pt; + padding-left: 8pt; +} + table { width: auto; } @@ -122,7 +133,8 @@ h2 code, h3 code, h4 code, h5 code, -h6 code { +h6 code, +td>code { font-family: MJXZERO, MJXTEX-T; font-size: 1em; line-height: 0; @@ -133,7 +145,8 @@ h6 code { font-style: initial; } -.example pre { +.example pre, +.rep { margin-left: 40px; } diff --git a/docs/odata-json-format/odata-json-format.html b/docs/odata-json-format/odata-json-format.html index 0cee7db42..52ab66412 100644 --- a/docs/odata-json-format/odata-json-format.html +++ b/docs/odata-json-format/odata-json-format.html @@ -269,7 +269,7 @@

    Table of Contents

  • A References
  • B Safety, Security and Privacy Considerations
  • C Acknowledgments @@ -2001,7 +2001,7 @@
    [RFC8174]
    https://www.rfc-editor.org/info/rfc8174.

    [RFC8259]

    Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, December 2017 http://tools.ietf.org/html/rfc8259.

    -

    A.2 Informative References

    +

    A.2 Informative References

    [ECMAScript]

    ECMAScript 2023 Language Specification, 14th Edition, June 2023. Standard ECMA-262. https://www.ecma-international.org/publications-and-standards/standards/ecma-262/.

    [GeoJSON-2008]
    diff --git a/docs/odata-json-format/odata-json-format.md b/docs/odata-json-format/odata-json-format.md index 1c38fba0b..64aa7e950 100644 --- a/docs/odata-json-format/odata-json-format.md +++ b/docs/odata-json-format/odata-json-format.md @@ -177,7 +177,7 @@ For complete copyright information please see the full Notices section in an App - [23 Conformance](#Conformance) - [A References](#References) - [A.1 Normative References](#NormativeReferences) - - [A.2 Informative References ](#InformativeReferences) + - [A.2 Informative References](#InformativeReferences) - [B Safety, Security and Privacy Considerations](#SafetySecurityandPrivacyConsiderations) - [C Acknowledgments](#Acknowledgments) - [C.1 Special Thanks](#SpecialThanks) @@ -3752,8 +3752,7 @@ https://www.rfc-editor.org/info/rfc8174. _Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, December 2017_ http://tools.ietf.org/html/rfc8259. -## A.2 Informative References - +## A.2 Informative References ###### [ECMAScript] _ECMAScript 2023 Language Specification, 14th Edition_, June 2023. Standard ECMA-262. https://www.ecma-international.org/publications-and-standards/standards/ecma-262/. diff --git a/docs/odata-json-format/odata-json-format.pdf b/docs/odata-json-format/odata-json-format.pdf index dc4ce89c4..d453e7224 100644 Binary files a/docs/odata-json-format/odata-json-format.pdf and b/docs/odata-json-format/odata-json-format.pdf differ diff --git a/docs/odata-json-format/styles/odata.css b/docs/odata-json-format/styles/odata.css index 7144dbd23..6a591fb26 100644 --- a/docs/odata-json-format/styles/odata.css +++ b/docs/odata-json-format/styles/odata.css @@ -2,19 +2,25 @@ a:target { background-color: yellow; } +a[href^="#_"], a[href^="#OData"], -a[href^="#rfc"] { +a[href^="#rfc"], +a[href^="#XML-"] { font-weight: bold; } +a[href^="#_"]::before, a[href^="#OData"]::before, -a[href^="#rfc"]::before { +a[href^="#rfc"]::before, +a[href^="#XML-"]::before { content: "["; font-weight: bold; } +a[href^="#_"]::after, a[href^="#OData"]::after, -a[href^="#rfc"]::after { +a[href^="#rfc"]::after, +a[href^="#XML-"]::after { content: "]"; font-weight: bold; } @@ -33,6 +39,11 @@ a[href^="#rfc"]::after { font-style: italic; } +.rep { + border-left: solid windowtext 1pt; + padding-left: 8pt; +} + table { width: auto; } @@ -122,7 +133,8 @@ h2 code, h3 code, h4 code, h5 code, -h6 code { +h6 code, +td>code { font-family: MJXZERO, MJXTEX-T; font-size: 1em; line-height: 0; @@ -133,7 +145,8 @@ h6 code { font-style: initial; } -.example pre { +.example pre, +.rep { margin-left: 40px; } diff --git a/docs/odata-protocol/odata-protocol.pdf b/docs/odata-protocol/odata-protocol.pdf index 92cbc1049..4cb9921bf 100644 Binary files a/docs/odata-protocol/odata-protocol.pdf and b/docs/odata-protocol/odata-protocol.pdf differ diff --git a/docs/odata-protocol/styles/odata.css b/docs/odata-protocol/styles/odata.css index 7144dbd23..6a591fb26 100644 --- a/docs/odata-protocol/styles/odata.css +++ b/docs/odata-protocol/styles/odata.css @@ -2,19 +2,25 @@ a:target { background-color: yellow; } +a[href^="#_"], a[href^="#OData"], -a[href^="#rfc"] { +a[href^="#rfc"], +a[href^="#XML-"] { font-weight: bold; } +a[href^="#_"]::before, a[href^="#OData"]::before, -a[href^="#rfc"]::before { +a[href^="#rfc"]::before, +a[href^="#XML-"]::before { content: "["; font-weight: bold; } +a[href^="#_"]::after, a[href^="#OData"]::after, -a[href^="#rfc"]::after { +a[href^="#rfc"]::after, +a[href^="#XML-"]::after { content: "]"; font-weight: bold; } @@ -33,6 +39,11 @@ a[href^="#rfc"]::after { font-style: italic; } +.rep { + border-left: solid windowtext 1pt; + padding-left: 8pt; +} + table { width: auto; } @@ -122,7 +133,8 @@ h2 code, h3 code, h4 code, h5 code, -h6 code { +h6 code, +td>code { font-family: MJXZERO, MJXTEX-T; font-size: 1em; line-height: 0; @@ -133,7 +145,8 @@ h6 code { font-style: initial; } -.example pre { +.example pre, +.rep { margin-left: 40px; } diff --git a/docs/odata-url-conventions/odata-url-conventions.pdf b/docs/odata-url-conventions/odata-url-conventions.pdf index c2107953f..b422674d6 100644 Binary files a/docs/odata-url-conventions/odata-url-conventions.pdf and b/docs/odata-url-conventions/odata-url-conventions.pdf differ diff --git a/docs/odata-url-conventions/styles/odata.css b/docs/odata-url-conventions/styles/odata.css index 7144dbd23..6a591fb26 100644 --- a/docs/odata-url-conventions/styles/odata.css +++ b/docs/odata-url-conventions/styles/odata.css @@ -2,19 +2,25 @@ a:target { background-color: yellow; } +a[href^="#_"], a[href^="#OData"], -a[href^="#rfc"] { +a[href^="#rfc"], +a[href^="#XML-"] { font-weight: bold; } +a[href^="#_"]::before, a[href^="#OData"]::before, -a[href^="#rfc"]::before { +a[href^="#rfc"]::before, +a[href^="#XML-"]::before { content: "["; font-weight: bold; } +a[href^="#_"]::after, a[href^="#OData"]::after, -a[href^="#rfc"]::after { +a[href^="#rfc"]::after, +a[href^="#XML-"]::after { content: "]"; font-weight: bold; } @@ -33,6 +39,11 @@ a[href^="#rfc"]::after { font-style: italic; } +.rep { + border-left: solid windowtext 1pt; + padding-left: 8pt; +} + table { width: auto; } @@ -122,7 +133,8 @@ h2 code, h3 code, h4 code, h5 code, -h6 code { +h6 code, +td>code { font-family: MJXZERO, MJXTEX-T; font-size: 1em; line-height: 0; @@ -133,7 +145,8 @@ h6 code { font-style: initial; } -.example pre { +.example pre, +.rep { margin-left: 40px; } diff --git a/lib/README.md b/lib/README.md index fc96a9e76..5d4f41908 100644 --- a/lib/README.md +++ b/lib/README.md @@ -24,6 +24,7 @@ The [`number.js`](number.js) module generates a single Markdown document by prep - Resolve references - Replace placeholders like `$$$pagetitle$$$` with values from a [`meta.yaml`](../odata-data-aggregation-ext/meta.yaml) file - Join multiple lines that end with a single space into one line +- Sections of the file between `: varXXX` and `:` or between `::: {.varXXX` ...}` and `:::` belong to a variant. One source file can contain several variants. The single Markdown document is output into a writable stream: @@ -32,6 +33,13 @@ import * as Number from './lib/number.js'; new Number("odata-data-aggregation-ext").build(«writable stream»); ``` +or, if variant `XXX` shall be produced: + +```js +import * as Number from './lib/number.js'; +new Number("odata-data-aggregation-ext", "XXX").build(«writable stream»); +``` + The [`pandoc.js`](pandoc.js) module converts this single Markdown document to HTML with [MathJax](https://www.mathjax.org/). It expects [pandoc 3.1.2](https://github.com/jgm/pandoc/releases/tag/3.1.2) to be set up, for example in a GitHub Action with the step ```yaml diff --git a/lib/build-pdf.js b/lib/build-pdf.js index ffc01aa7d..a3a0b6abd 100644 --- a/lib/build-pdf.js +++ b/lib/build-pdf.js @@ -1,26 +1,14 @@ +const iterator = require("./iterator"); const pdf = require("./pdf.js"); -const fs = require("fs"); -fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function ( - doc -) { - if (doc.isDirectory() && doc.name.startsWith("odata-")) { - const htmlFile = `${__dirname}/../docs/${doc.name}/${doc.name}.html`; - const pdfFile = `${__dirname}/../docs/${doc.name}/${doc.name}.pdf`; - - const htmlStat = fs.statSync(htmlFile, { throwIfNoEntry: false }); - const pdfStat = fs.statSync(pdfFile, { throwIfNoEntry: false }); - - if (pdfStat === undefined || htmlStat?.mtime > pdfStat?.mtime) { - pdf(doc.name) - .then(() => { - console.log("✓ " + doc.name); - }) - .catch((error) => { - console.log("❌ " + doc.name); - console.error(error); - process.exitCode = 1; - }); - } - } +iterator(function (srcname, name, variant, meta) { + pdf(name, variant, meta) + .then((refreshed) => { + console.log(refreshed ? "✓" : "=", srcname, variant); + }) + .catch((error) => { + console.log("❌", srcname, variant); + console.error(error); + process.exitCode = 1; + }); }); diff --git a/lib/build.js b/lib/build.js index 4f6a1afe3..d2e61812b 100644 --- a/lib/build.js +++ b/lib/build.js @@ -1,49 +1,40 @@ +const iterator = require("./iterator"); const fs = require("fs"); const Number = require("./number"); const pandoc = require("./pandoc"); const { PassThrough } = require("stream"); -fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function ( - doc -) { - if (doc.isDirectory() && doc.name.startsWith("odata-")) { - fs.cpSync( - __dirname + "/../styles", - __dirname + "/../docs/" + doc.name + "/styles", - { recursive: true } - ); - var md = fs.createWriteStream( - __dirname + "/../docs/" + doc.name + "/" + doc.name + ".md" - ); - var html = pandoc({ - "--metadata-file": __dirname + "/../" + doc.name + "/meta.yaml", +iterator(function (srcname, name, variant, meta) { + fs.cpSync(`${__dirname}/../styles`, `${__dirname}/../docs/${name}/styles`, { + recursive: true, + }); + var md = fs.createWriteStream(`${__dirname}/../docs/${name}/${name}.md`); + var html = pandoc({ + "--metadata-file": `${__dirname}/../${srcname}/${variant}.yaml`, + }); + html.stdout.pipe( + fs.createWriteStream(`${__dirname}/../docs/${name}/${name}.html`) + ); + md.write(Buffer.of(0xef, 0xbb, 0xbf)); + new Number(srcname, variant, meta) + .build( + new PassThrough() + .on("data", function (chunk) { + md.write(chunk); + html.stdin.write(chunk); + }) + .on("end", function () { + md.end(); + html.stdin.end(); + }) + ) + .then(() => { + console.log("✓", srcname, variant); + }) + .catch((err) => { + console.log("❌", srcname, variant); + console.error(err.join("\n")); + console.error(); + process.exitCode = 1; }); - html.stdout.pipe( - fs.createWriteStream( - __dirname + "/../docs/" + doc.name + "/" + doc.name + ".html" - ) - ); - md.write(Buffer.of(0xef, 0xbb, 0xbf)); - new Number(doc.name) - .build( - new PassThrough() - .on("data", function (chunk) { - md.write(chunk); - html.stdin.write(chunk); - }) - .on("end", function () { - md.end(); - html.stdin.end(); - }) - ) - .then(() => { - console.log("✓ " + doc.name); - }) - .catch((err) => { - console.log("❌ " + doc.name); - console.error(err.join("\n")); - console.error(); - process.exitCode = 1; - }); - } }); diff --git a/lib/clean.mjs b/lib/clean.mjs index 4b29524b9..b97e2956e 100644 --- a/lib/clean.mjs +++ b/lib/clean.mjs @@ -55,6 +55,7 @@ const clean = old ) .replace(/([^<]*)<\/span>/g, "$1") .replace(/([^<]*)<\/span>/g, "$1") + .replace(/([^<]*)<\/span>/g, "$1") // TODO: clean up more tags // clean up code formatting @@ -100,11 +101,21 @@ const clean = old .replace(/\[(OData[^<]*)\]<\/b>/g, "$1") .replace(/\[(RFC[^<]*)\]<\/b>/g, "$1") .replace(/#ABNF/g, "#ODataABNF") + .replace(/#BMABNF/g, "#ODataABNF") + .replace(/#BMJSON/g, "#ODataJSON") + .replace(/#BMProtocol/g, "#ODataProtocol") + .replace(/#BMRFC6570/g, "#rfc6570") + .replace(/#BMURL/g, "#ODataURL") + .replace(/#BMVocCore/g, "#ODataVocCore") + .replace(/#BMVocMeasures/g, "#ODataVocMeasures") + .replace(/#BMVocValidation/g, "#ODataVocValidation") + .replace(/#CSDLxml/g, "#ODataCSDL") .replace(/#ODataCSDLJSONRef/g, "#ODataCSDL") .replace(/#ODataCSDLXMLRef/g, "#ODataCSDL") .replace(/#ODataJSONRef/g, "#ODataJSON") .replace(/#ODataURLRef/g, "#ODataURL") .replace(/#RFC/gi, "#rfc") + .replace(/#RFC_JSON/gi, "#rfc8259") .replace(/#VocCapabilities/g, "#ODataVocCap") .replace(/#VocCore/g, "#ODataVocCore") .replaceAll('href="#sec_', 'href="#'); @@ -121,12 +132,33 @@ const raw = fs.readFileSync(`${basename}-raw.md`, "utf8"); const final = raw // bullet points - .replace(/\n\[· \]\{style="font-family:Symbol(;font-style:normal)?"\}/g, "- ") - .replace(/\n\[\[· \]\{style="font-family:Symbol"\}\]\{\.Datatype\}/g, "- ") + .replace( + /\n\[· \]\{style="(font-size:[\d\.]+pt;)?font-family:\n?Symbol(;color:black)?(;font-style:normal)?"\}/g, + "- " + ) + .replace( + /\n\[\[·[ \n]\]\{style="(font-size:[\d\.]+pt;)?font-family:Symbol(;\n?color:(black|windowtext))?"\}\]\{[^}]*\}/g, + "- " + ) // code blocks .replace( /\n::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom:\nsolid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in;\nbackground:#D9D9D9;margin-left:[^;]+;margin-right:.3in"}\n([\s\S]*?)\n:::\n/g, - "```\n$1\n```\n" + (match, p1) => + "```\n" + + p1 + .replace(/`\n\n`/g, "\n") + .replace(/^`/, "") + .replace(/`$/, "") + + "\n```\n" + ) + // CSDL representation-specific stuff + .replace( + /^::: \{style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt;\nmargin-left:21.55pt;margin-right:0in"\}\n/gm, + "::: csdlHeadline\n" + ) + .replace( + /^::: \{style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt;\nmargin-left:21.55pt;margin-right:21.55pt"\}\n/gm, + "::: csdl\n" ) // examples: twice for consecutive examples without empty lines between them .replace( @@ -136,7 +168,10 @@ const final = raw .replace( /\n ?Example \d+:([\s\S]*?)\n\n/g, "\n::: example\nExample ##ex:$1\n:::\n\n" - ); + ) + // minor tweaks + .replace(/\[([^\]]+)\]\{#_Toc[^}]+\}/g, "$1"); + fs.writeFileSync(`${basename}.md`, final, { encoding: "utf8" }); function pandoc(args, cwd) { diff --git a/lib/iterator.js b/lib/iterator.js new file mode 100644 index 000000000..101ddfe7d --- /dev/null +++ b/lib/iterator.js @@ -0,0 +1,26 @@ +const fs = require("fs"); +const yaml = require("js-yaml"); + +module.exports = function (callback) { + fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function ( + doc + ) { + if (doc.isDirectory() && doc.name.startsWith("odata-")) { + fs.readdirSync(`${__dirname}/../${doc.name}`) + .filter((fn) => fn.endsWith(".yaml")) + .forEach(function (metaname) { + var meta = yaml.load( + fs.readFileSync(`${__dirname}/../${doc.name}/${metaname}`) + ); + var name = + metaname === "meta.yaml" || !meta.dirname ? doc.name : meta.dirname; + callback( + doc.name, + name, + metaname.substring(0, metaname.length - 5), + meta + ); + }); + } + }); +}; diff --git a/lib/number.js b/lib/number.js index 596ff0a37..d3240b93b 100644 --- a/lib/number.js +++ b/lib/number.js @@ -5,14 +5,18 @@ const yaml = require("js-yaml"); const { compareSectionNumbers } = require("./utilities"); class Number { - constructor(dir) { + constructor(dir, variant, meta) { this.dir = dir; + this.variant = variant; this.chapters = fs .readdirSync(dir) .filter((fn) => fn.endsWith(".md")) .sort(compareSectionNumbers); - // console.log(this.chapters); - this.meta = yaml.load(fs.readFileSync(dir + "/meta.yaml")); + this.meta = + meta || + yaml.load( + fs.readFileSync(dir + "/" + (this.variant || "meta") + ".yaml") + ); } secno(type) { @@ -21,9 +25,32 @@ class Number { : String(this.counter[type]); } + skip(line) { + if (this.fence) { + if (line.trimEnd() === this.fence) { + var skip = this.skipping || this.fence.length < 3; + this.fence = undefined; + this.skipping = false; + return skip; + } + return this.skipping; + } + var m = line.match(/^(:+)\s+(?:\{\.)?var(\S+)/); + if (m) { + this.fence = m[1]; + if (this.variant && this.variant !== m[2]) { + return (this.skipping = true); + } + return this.fence.length < 3; + } + return this.skipping; + } + phase1(file) { return new Promise( function (resolve, reject) { + this.fence = undefined; + this.skipping = undefined; createInterface({ input: fs.createReadStream(this.dir + "/" + file), crlfDelay: Infinity, @@ -31,12 +58,21 @@ class Number { .on( "line", function (line) { + if (this.skip(line)) return; for (var m, regex = //g; (m = regex.exec(line)); ) this.refs[m[1]] = true; m = line.match(/ ##([A-Za-z]+)(_([A-Za-z]+))?/); if (m && line[m.index + m[0].length] !== "]") { + if ( + !m[1].startsWith("sub") && + m[1].endsWith("isec") && + !this.toc[m[1]] + ) + this.toc[m[1]] = { sub: [] }; if (m[1].endsWith("sec")) { - m = line.match(/ ##([a-z]+)\s+(.+)$/); + m = line.match( + / ##([A-Za-z]+)(?:_[A-Za-z]+)?\s+(.+)$/ + ); m[3] = m[2].replace(/[^A-Za-z]/g, ""); } this.counter[m[1]] = (this.counter[m[1]] || 0) + 1; @@ -48,6 +84,10 @@ class Number { this.secno((supc = supc.substring(3))) + "." + this.number[this.match]; + if (m[1].endsWith("isec")) { + m[3] += this.number[this.match]; + this.number[this.match] = "i" + this.number[this.match]; + } if (m[1].endsWith("sec")) { var s = this.number[this.match]; this.toc[s] = { @@ -56,17 +96,19 @@ class Number { href: m[3], sub: [], }; - this.toc[s.substring(0, s.lastIndexOf("."))]?.sub.push( - this.toc[s] - ); + var p = s.substring(0, s.lastIndexOf(".")); + if (p === "" && m[1].endsWith("isec")) p = m[1]; + this.toc[p]?.sub.push(this.toc[s]); } if (m[2]) { this.refs[m[3]] = this.number[this.match]; this.number[this.match] = `${this.number[this.match]}${ - m[1] === "asec" ? "." : "" - }`; + }">${ + this.number[this.match].startsWith("i") + ? "" + : this.number[this.match] + }${m[1] === "asec" ? "." : ""}`; } this.match++; } @@ -80,6 +122,8 @@ class Number { phase2(file, out) { return new Promise( function (resolve, reject) { + this.fence = undefined; + this.skipping = undefined; var lineno = 0; createInterface({ input: fs.createReadStream(this.dir + "/" + file), @@ -89,45 +133,53 @@ class Number { "line", function (line) { lineno++; - line = line.replace( - /\$\$\$(.*?)\$\$\$/g, - function (m, p) { - return this.meta[p] || m; - }.bind(this) - ); - for (var m, regex = /\]\(#(.*?)\)/g; (m = regex.exec(line)); ) - if (!this.refs[m[1]]) - this.errors.push( - `${this.dir}/${file}(${lineno}): Undefined link #${m[1]}` - ); - m = line.match(/ ##([A-Za-z]+)(_([A-Za-z]+))?/); - if (m && line[m.index + m[0].length] !== "]") { - var prefix = line.substring(0, m.index) + " "; - var suffix = line.substring(m.index + m[0].length); - if (m[1].endsWith("sec")) - line = ( - prefix + - this.number[this.match].replace(/<\/a>$/, suffix + "") - ).replace(/(Appendix )()/, "$2$1"); - else line = prefix + this.number[this.match] + suffix; - this.match++; - } - out.write( - line.replace( - /##([A-Za-z]+)\]/g, + if (this.skip(line)) return; + var m1 = line.match(/^\$\$\$(.*?isec)\$\$\$$/); + if (m1) this.tableofcontents(this.toc[m1[1]]?.sub || [], out, ""); + else { + line = line.replace( + /\$\$\$(.*?)\$\$\$/g, function (m, p) { - var r = this.refs[p]; - if (r) return `${r}](#${p})`; - else { - this.errors.push( - `${this.dir}/${file}(${lineno}): Undefined link ##${p}` - ); - return `~~${p}~~]`; - } + return this.meta[p] || m; }.bind(this) - ) - ); - if (!/\S\s$/.test(line)) out.write("\n"); + ); + for (var m, regex = /\]\(#(.*?)\)/g; (m = regex.exec(line)); ) + if (!this.refs[m[1]]) + this.errors.push( + `${this.dir}/${file}(${lineno}): Undefined link #${m[1]}` + ); + m = line.match(/ ##([A-Za-z]+)(_([A-Za-z]+))?/); + var outline = line; + if (m && line[m.index + m[0].length] !== "]") { + var prefix = line.substring(0, m.index) + " "; + var suffix = line.substring(m.index + m[0].length); + if (m[1].endsWith("sec")) + outline = ( + prefix + + this.number[this.match].replace(/<\/a>$/, suffix + "") + ) + .replace(/(Appendix )()/, "$2$1") + .replace(/(,? )(<\/a>)$/, "$2$1"); + else outline = prefix + this.number[this.match] + suffix; + this.match++; + } + out.write( + outline.replace( + /##([A-Za-z]+)\]/g, + function (m, p) { + var r = this.refs[p]; + if (r) return `${r}](#${p})`; + else { + this.errors.push( + `${this.dir}/${file}(${lineno}): Undefined link ##${p}` + ); + return `~~${p}~~]`; + } + }.bind(this) + ) + ); + if (!/\S\s$/.test(line)) out.write("\n"); + } }.bind(this) ) .on("close", resolve); @@ -137,7 +189,11 @@ class Number { tableofcontents(t, out, indent) { for (var s of t) { - out.write(`${indent}- [${s.number} ${s.name}](#${s.href})\n`); + out.write( + `${indent}- [${s.number.startsWith("i") ? "" : s.number + " "}${ + s.name.replace(/,? $/, "") + }](#${s.href})\n` + ); this.tableofcontents(s.sub, out, indent + " "); } } diff --git a/lib/pdf.js b/lib/pdf.js index bb893c5eb..6c75ecd48 100644 --- a/lib/pdf.js +++ b/lib/pdf.js @@ -1,37 +1,43 @@ const puppeteer = require("puppeteer"); const fs = require("fs"); const url = require("url"); -const yaml = require("js-yaml"); -module.exports = async function (name) { - const meta = yaml.load( - fs.readFileSync(__dirname + "/../" + name + "/meta.yaml") - ); +module.exports = async function (name, _variant, meta, force) { + if (!force) { + const htmlFile = `${__dirname}/../docs/${name}/${name}.html`; + const pdfFile = `${__dirname}/../docs/${name}/${name}.pdf`; + const htmlStat = fs.statSync(htmlFile, { throwIfNoEntry: false }); + const pdfStat = fs.statSync(pdfFile, { throwIfNoEntry: false }); + if (pdfStat === undefined || htmlStat?.mtime > pdfStat?.mtime) force = true; + } - const browser = await puppeteer.launch({ - headless: "new", - }); - const page = await browser.newPage(); - const htmlUrl = url.pathToFileURL( - `${__dirname}/../docs/${name}/${name}.html` - ).href; - await page.goto(htmlUrl, { - waitUntil: "networkidle2", - }); - await page.pdf({ - path: `${__dirname}/../docs/${name}/${name}.pdf`, - format: "letter", - printBackground: true, - displayHeaderFooter: true, - headerTemplate: - '
    Standards Track Work Product
    ', - footerTemplate: `
    + if (force) { + const browser = await puppeteer.launch({ + headless: "new", + }); + const page = await browser.newPage(); + const htmlUrl = url.pathToFileURL( + `${__dirname}/../docs/${name}/${name}.html` + ).href; + await page.goto(htmlUrl, { + waitUntil: "networkidle2", + }); + await page.pdf({ + path: `${__dirname}/../docs/${name}/${name}.pdf`, + format: "letter", + printBackground: true, + displayHeaderFooter: true, + headerTemplate: + '
    Standards Track Work Product
    ', + footerTemplate: `
    ${meta.filename} Copyright ${meta.copyright}. All Rights Reserved. ${meta.pubdate} - Page of
    `, - margin: { top: 50, bottom: 60 }, - }); + margin: { top: 50, bottom: 60 }, + }); - await browser.close(); + await browser.close(); + return true; + } }; diff --git a/lib/server.js b/lib/server.js index 207ca19ff..616e2ed14 100644 --- a/lib/server.js +++ b/lib/server.js @@ -4,7 +4,7 @@ const pandoc = require("./pandoc"); const http = require("http"); const { execSync } = require("child_process"); const path = require("path"); -const fs = require("fs"); +const iterator = require("./iterator"); const livereload = require("livereload"); const liveReloadServer = livereload.createServer({ extraExts: ["md"] }); @@ -14,42 +14,42 @@ const connectLivereload = require("connect-livereload"); var app = express() .use(connectLivereload()) - .use(express.static(__dirname + "/../docs")) - .get("/", function (req, res, next) { - const docs = fs - .readdirSync(__dirname + "/..", { withFileTypes: true }) - .filter((doc) => doc.isDirectory() && doc.name.startsWith("odata-")) - .map((doc) => `
  • ${doc.name}
  • `); + .use("/styles", express.static(`${__dirname}/../styles`)) + .get("/", function (_req, res, _next) { + var docs = []; + iterator(function (srcname, name, variant) { + docs.push(`
  • ${name}
  • `); + }); res.send(`

    Documents

      ${docs.join("")}
    `); }) - .get("/*", function (req, res, next) { - if (req.path.endsWith("/")) { - try { - var branch = execSync("git branch --show-current", { - cwd: __dirname, - }).toString(); - if (branch) req.query["-T"] = branch; - } catch (e) {} - var dir = req.params[0].substring(0, req.params[0].length - 1); - try { - var number = new Number(__dirname + "/../" + dir); - res.type("html"); - var proc = pandoc({ - "--metadata-file": __dirname + "/../" + dir + "/meta.yaml", - ...req.query, - }); - proc.stdout.pipe(res); - number.build(proc.stdin).catch((err) => { - console.error(); - console.error(err.join("\n")); - }); - } catch (err) { - next(); - } - } else { - var url = new URL("s://" + req.originalUrl); - url.pathname += "/"; - res.redirect(url.href.substring(4)); + .get("/:doc", function (req, res, next) { + try { + var branch = execSync("git branch --show-current", { + cwd: __dirname, + }).toString(); + if (branch) req.query["-T"] = branch; + } catch (e) {} + try { + var number = new Number( + __dirname + "/../" + req.params.doc, + req.query.variant + ); + var meta = `${__dirname}/../${req.params.doc}/${ + req.query.variant || "meta" + }.yaml`; + delete req.query.variant; + res.type("html"); + var proc = pandoc({ + "--metadata-file": meta, + ...req.query, + }); + proc.stdout.pipe(res); + number.build(proc.stdin).catch((err) => { + console.error(); + console.error(err.join("\n")); + }); + } catch (err) { + next(); } }); diff --git a/odata-csdl-json/1 TODO.md b/odata-csdl-json/1 TODO.md deleted file mode 100644 index 44c5bdfba..000000000 --- a/odata-csdl-json/1 TODO.md +++ /dev/null @@ -1,224 +0,0 @@ -------- - -# ##sec Introduction - - - -## ##subsec Changes from earlier Versions - - - - -## ##subsec Glossary - -### ##subsubsec Definitions of terms - - -TODO: find out why we need a $dummy$ formula to get `monospace` look as we want it. - -### ##subsubsec Acronyms and abbreviations - - - -### ##subsubsec Document conventions - -Keywords defined by this specification use `this monospaced font`. - -Some sections of this specification are illustrated with non-normative examples. - -::: example -Example ##ex: text describing an example uses this paragraph style -``` -Non-normative examples use this paragraph style. -``` -::: - -All examples in this document are non-normative and informative only. Examples labeled with ⚠ contain advanced concepts or make use of keywords that are defined only later in the text, they can be skipped at first reading. - -All other text is normative unless otherwise labeled. - -::: example -Here is a customized command line which will generate HTML from this markdown file (named `$$$filename$$$.md`). Line breaks are added for readability only: - -``` -pandoc -f gfm+tex_math_dollars+fenced_divs - -t html - -o $$$filename$$$.html - -c styles/markdown-styles-v1.7.3b.css - -c styles/odata.css - -s - --mathjax - --eol=lf - --wrap=none - --metadata pagetitle="$$$pagetitle$$$" - $$$filename$$$.md -``` - -This uses pandoc 3.1.2 from https://github.com/jgm/pandoc/releases/tag/3.1.2. -::: - -------- - -# 2 Section Heading -text. - -## 2.1 Level 2 Heading -text. - -### 2.1.1 Level 3 Heading -text. - -#### 2.1.1.1 Level 4 Heading -text. - -##### 2.1.1.1.1 Level 5 Heading -This is the deepest level, because six # gets transformed into a Reference tag. - - -## 2.2 Next Heading -text. - -------- - -# 3 Conformance - - -`(Note: The [OASIS TC Process](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsConfClause) requires that a specification approved by the TC at the Committee Specification Public Review Draft, Committee Specification or OASIS Standard level must include a separate section, listing a set of numbered conformance clauses, to which any implementation of the specification must adhere in order to claim conformance to the specification (or any optional portion thereof). This is done by listing the conformance clauses here.` -`For the definition of "conformance clause," see [OASIS Defined Terms](https://www.oasis-open.org/policies-guidelines/oasis-defined-terms-2018-05-22/#dConformanceClause).` - -`See "Guidelines to Writing Conformance Clauses": -https://docs.oasis-open.org/templates/TCHandbook/ConformanceGuidelines.html.` - -`Remove this note before submitting for publication.)` - - -------- - -# Appendix A. References - - - -This appendix contains the normative and informative references that are used in this document. - -While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity. - -## A.1 Normative References - -The following documents are referenced in such a way that some or all of their content constitutes requirements of this document. - -`(Reference sources: -For references to IETF RFCs, use the approved citation formats at: -https://docs.oasis-open.org/templates/ietf-rfc-list/ietf-rfc-list.html. -For references to W3C Recommendations, use the approved citation formats at: -https://docs.oasis-open.org/templates/w3c-recommendations-list/w3c-recommendations-list.html. -Remove this note before submitting for publication.)` - -###### [OData-v4.02] -* _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html - -##### [RFC2119] -_Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997_ -http://www.rfc-editor.org/info/rfc2119. - -###### [RFC8174] -_Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017_ -http://www.rfc-editor.org/info/rfc8174. - -## A.2 Informative References - -###### [RFC3552] -_Rescorla, E. and B. Korver, "Guidelines for Writing RFC Text on Security Considerations", BCP 72, RFC 3552, DOI 10.17487/RFC3552, July 2003_ -https://www.rfc-editor.org/info/rfc3552. - -------- - -# Appendix B. Safety, Security and Privacy Considerations - - - -`(Note: OASIS strongly recommends that Technical Committees consider issues that might affect safety, security, privacy, and/or data protection in implementations of their specification and document them for implementers and adopters. For some purposes, you may find it required, e.g. if you apply for IANA registration.` - -`While it may not be immediately obvious how your specification might make systems vulnerable to attack, most specifications, because they involve communications between systems, message formats, or system settings, open potential channels for exploit. For example, IETF [[RFC3552](#rfc3552)] lists “eavesdropping, replay, message insertion, deletion, modification, and man-in-the-middle” as well as potential denial of service attacks as threats that must be considered and, if appropriate, addressed in IETF RFCs.` - -`In addition to considering and describing foreseeable risks, this section should include guidance on how implementers and adopters can protect against these risks.` - -`We encourage editors and TC members concerned with this subject to read _Guidelines for Writing RFC Text on Security Considerations_, IETF [[RFC3552](#rfc3552)], for more information.` - -`Remove this note before submitting for publication.)` - -------- - -# Appendix C. Acknowledgments - - - -`Note: A Work Product approved by the TC must include a list of people who participated in the development of the Work Product. This is generally done by collecting the list of names in this appendix. This list shall be initially compiled by the Chair, and any Member of the TC may add or remove their names from the list by request. Remove this note before submitting for publication.` - -## C.1 Special Thanks - - - -Substantial contributions to this document from the following individuals are gratefully acknowledged: - -Participant Name, Affiliation or "Individual Member" - -## C.2 Participants - - - -The following individuals have participated in the creation of this specification and are gratefully acknowledged: - -**OpenC2 TC Members:** - -| First Name | Last Name | Company | -| :--- | :--- | :--- | -Philippe | Alman | Something Networks -Alex | Amirnovman | Company B -Kris | Anderman | Mini Micro -Darren | Anstman | Big Networks - -------- - -# Appendix D. Revision History - - - -| Revision | Date | Editor | Changes Made | -| :--- | :--- | :--- | :--- | -| specname-v1.0-wd01 | yyyy-mm-dd | Editor Name | Initial working draft | - -------- - -# Appendix E. Example Appendix with subsections - -## E.1 Subsection title - -### E.1.1 Sub-subsection - -------- - -# Appendix F. Notices - - - -Copyright © OASIS Open 2023. All Rights Reserved. - -All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full [Policy](https://www.oasis-open.org/policies-guidelines/ipr/) may be found at the OASIS website. - -This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. - -The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. - -This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata). - -[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.] - -[OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.] - -[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.] - -The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance. diff --git a/odata-csdl-xml/0 frontmatter.md b/odata-csdl-xml/0 frontmatter.md deleted file mode 100644 index e6f64062d..000000000 --- a/odata-csdl-xml/0 frontmatter.md +++ /dev/null @@ -1,90 +0,0 @@ - -![OASIS Logo](https://docs.oasis-open.org/templates/OASISLogo-v3.0.png) - -------- - -# OData Common Schema Definition Language (CSDL) XML Representation Version 4.02 - -## Committee Specification Draft 01 - -## 14 July 2023 - -  - -#### This stage: -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/$$$stage$$$/$$$filename$$$.md (Authoritative) \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/$$$stage$$$/$$$filename$$$.html \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/$$$stage$$$/$$$filename$$$.pdf - -#### Previous stage: -N/A - -#### Latest stage: -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.md (Authoritative) \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.html \ -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.pdf - -#### Technical Committee: -[OASIS Open Data Protocol (OData) TC](https://www.oasis-open.org/committees/odata/) - -#### Chairs: - -Ralf Handl (ralf.handl@sap.com), [SAP SE](http://www.sap.com/) \ -Michael Pizzo (mikep@microsoft.com), [Microsoft](http://www.microsoft.com/) - -#### Editors: - -Ralf Handl (ralf.handl@sap.com), [SAP SE](http://www.sap.com/) \ -Michael Pizzo (mikep@microsoft.com), [Microsoft](http://www.microsoft.com/) \ -Heiko Theißen (heiko.theissen@sap.com), [SAP SE](http://www.sap.com/) - -#### Additional artifacts: -This prose specification is one component of a Work Product that also includes: -* XML schemas: (list file names or directory name) -* Other parts (list titles and/or file names) -* `(Note: Any normative computer language definitions that are part of the Work Product, such as XML instances, schemas and Java(TM) code, including fragments of such, must be (a) well formed and valid, (b) provided in separate plain text files, (c) referenced from the Work Product; and (d) where any definition in these separate files disagrees with the definition found in the specification, the definition in the separate file prevails. Remove this note before submitting for publication.)` - -#### Related work: -This specification replaces or supersedes: -* _OData Common Schema Definition Language (CSDL) XML Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. OASIS Standard. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html. - -This specification is related to: -* _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html - -#### Abstract: -OData services are described by an Entity Model (EDM). The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service using, XML, JSON, and other formats. This document (OData CSDL XML Representation) specifically defines the XML representation of CSDL. - -#### Status: -This document was last revised or approved by the OASIS Open Data Protocol (OData) TC on the above date. The level of approval is also listed above. Check the "Latest stage" location noted above for possible later revisions of this document. Any other numbered Versions and other technical work produced by the Technical Committee (TC) are listed at https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=odata#technical. - -TC members should send comments on this specification to the TC's email list. Others should send comments to the TC's public comment list, after subscribing to it by following the instructions at the "[Send A Comment](https://www.oasis-open.org/committees/comments/index.php?wg_abbrev=odata)" button on the TC's web page at https://www.oasis-open.org/committees/odata/. - -This specification is provided under the [RF on RAND Terms Mode](https://www.oasis-open.org/policies-guidelines/ipr/#RF-on-RAND-Mode) of the [OASIS IPR Policy](https://www.oasis-open.org/policies-guidelines/ipr/), the mode chosen when the Technical Committee was established. For information on whether any patents have been disclosed that may be essential to implementing this specification, and any offers of patent licensing terms, please refer to the Intellectual Property Rights section of the TC's web page (https://www.oasis-open.org/committees/odata/ipr.php). - -Note that any machine-readable content ([Computer Language Definitions](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsCompLang)) declared Normative for this Work Product is provided in separate plain text files. In the event of a discrepancy between any such plain text file and display content in the Work Product's prose narrative document(s), the content in the separate plain text file prevails. - -#### Key words: -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [[RFC2119](#rfc2119)] and [[RFC8174](#rfc8174)] when, and only when, they appear in all capitals, as shown here. - -#### Citation format: -When referencing this specification the following citation format should be used: - -**[OData-CSDL-XML-v4.02]** - -_OData Common Schema Definition Language (CSDL) XML Representation Version 4.02_. -Edited by Ralf Handl, Michael Pizzo, and Heiko Theißen. 14 July 2023. OASIS Committee Specification Draft 01. -https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/$$$stage$$$/$$$filename$$$.html. -Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.02/odata-csdl-xml-v4.02.html. - -#### Notices -Copyright © OASIS Open 2023. All Rights Reserved. - -Distributed under the terms of the OASIS [IPR Policy](https://www.oasis-open.org/policies-guidelines/ipr/). - -The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. - -For complete copyright information please see the full Notices section in an Appendix below. - -------- diff --git a/odata-csdl-xml/1 TODO.md b/odata-csdl-xml/1 TODO.md deleted file mode 100644 index 44c5bdfba..000000000 --- a/odata-csdl-xml/1 TODO.md +++ /dev/null @@ -1,224 +0,0 @@ -------- - -# ##sec Introduction - - - -## ##subsec Changes from earlier Versions - - - - -## ##subsec Glossary - -### ##subsubsec Definitions of terms - - -TODO: find out why we need a $dummy$ formula to get `monospace` look as we want it. - -### ##subsubsec Acronyms and abbreviations - - - -### ##subsubsec Document conventions - -Keywords defined by this specification use `this monospaced font`. - -Some sections of this specification are illustrated with non-normative examples. - -::: example -Example ##ex: text describing an example uses this paragraph style -``` -Non-normative examples use this paragraph style. -``` -::: - -All examples in this document are non-normative and informative only. Examples labeled with ⚠ contain advanced concepts or make use of keywords that are defined only later in the text, they can be skipped at first reading. - -All other text is normative unless otherwise labeled. - -::: example -Here is a customized command line which will generate HTML from this markdown file (named `$$$filename$$$.md`). Line breaks are added for readability only: - -``` -pandoc -f gfm+tex_math_dollars+fenced_divs - -t html - -o $$$filename$$$.html - -c styles/markdown-styles-v1.7.3b.css - -c styles/odata.css - -s - --mathjax - --eol=lf - --wrap=none - --metadata pagetitle="$$$pagetitle$$$" - $$$filename$$$.md -``` - -This uses pandoc 3.1.2 from https://github.com/jgm/pandoc/releases/tag/3.1.2. -::: - -------- - -# 2 Section Heading -text. - -## 2.1 Level 2 Heading -text. - -### 2.1.1 Level 3 Heading -text. - -#### 2.1.1.1 Level 4 Heading -text. - -##### 2.1.1.1.1 Level 5 Heading -This is the deepest level, because six # gets transformed into a Reference tag. - - -## 2.2 Next Heading -text. - -------- - -# 3 Conformance - - -`(Note: The [OASIS TC Process](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsConfClause) requires that a specification approved by the TC at the Committee Specification Public Review Draft, Committee Specification or OASIS Standard level must include a separate section, listing a set of numbered conformance clauses, to which any implementation of the specification must adhere in order to claim conformance to the specification (or any optional portion thereof). This is done by listing the conformance clauses here.` -`For the definition of "conformance clause," see [OASIS Defined Terms](https://www.oasis-open.org/policies-guidelines/oasis-defined-terms-2018-05-22/#dConformanceClause).` - -`See "Guidelines to Writing Conformance Clauses": -https://docs.oasis-open.org/templates/TCHandbook/ConformanceGuidelines.html.` - -`Remove this note before submitting for publication.)` - - -------- - -# Appendix A. References - - - -This appendix contains the normative and informative references that are used in this document. - -While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity. - -## A.1 Normative References - -The following documents are referenced in such a way that some or all of their content constitutes requirements of this document. - -`(Reference sources: -For references to IETF RFCs, use the approved citation formats at: -https://docs.oasis-open.org/templates/ietf-rfc-list/ietf-rfc-list.html. -For references to W3C Recommendations, use the approved citation formats at: -https://docs.oasis-open.org/templates/w3c-recommendations-list/w3c-recommendations-list.html. -Remove this note before submitting for publication.)` - -###### [OData-v4.02] -* _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html - -##### [RFC2119] -_Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997_ -http://www.rfc-editor.org/info/rfc2119. - -###### [RFC8174] -_Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017_ -http://www.rfc-editor.org/info/rfc8174. - -## A.2 Informative References - -###### [RFC3552] -_Rescorla, E. and B. Korver, "Guidelines for Writing RFC Text on Security Considerations", BCP 72, RFC 3552, DOI 10.17487/RFC3552, July 2003_ -https://www.rfc-editor.org/info/rfc3552. - -------- - -# Appendix B. Safety, Security and Privacy Considerations - - - -`(Note: OASIS strongly recommends that Technical Committees consider issues that might affect safety, security, privacy, and/or data protection in implementations of their specification and document them for implementers and adopters. For some purposes, you may find it required, e.g. if you apply for IANA registration.` - -`While it may not be immediately obvious how your specification might make systems vulnerable to attack, most specifications, because they involve communications between systems, message formats, or system settings, open potential channels for exploit. For example, IETF [[RFC3552](#rfc3552)] lists “eavesdropping, replay, message insertion, deletion, modification, and man-in-the-middle” as well as potential denial of service attacks as threats that must be considered and, if appropriate, addressed in IETF RFCs.` - -`In addition to considering and describing foreseeable risks, this section should include guidance on how implementers and adopters can protect against these risks.` - -`We encourage editors and TC members concerned with this subject to read _Guidelines for Writing RFC Text on Security Considerations_, IETF [[RFC3552](#rfc3552)], for more information.` - -`Remove this note before submitting for publication.)` - -------- - -# Appendix C. Acknowledgments - - - -`Note: A Work Product approved by the TC must include a list of people who participated in the development of the Work Product. This is generally done by collecting the list of names in this appendix. This list shall be initially compiled by the Chair, and any Member of the TC may add or remove their names from the list by request. Remove this note before submitting for publication.` - -## C.1 Special Thanks - - - -Substantial contributions to this document from the following individuals are gratefully acknowledged: - -Participant Name, Affiliation or "Individual Member" - -## C.2 Participants - - - -The following individuals have participated in the creation of this specification and are gratefully acknowledged: - -**OpenC2 TC Members:** - -| First Name | Last Name | Company | -| :--- | :--- | :--- | -Philippe | Alman | Something Networks -Alex | Amirnovman | Company B -Kris | Anderman | Mini Micro -Darren | Anstman | Big Networks - -------- - -# Appendix D. Revision History - - - -| Revision | Date | Editor | Changes Made | -| :--- | :--- | :--- | :--- | -| specname-v1.0-wd01 | yyyy-mm-dd | Editor Name | Initial working draft | - -------- - -# Appendix E. Example Appendix with subsections - -## E.1 Subsection title - -### E.1.1 Sub-subsection - -------- - -# Appendix F. Notices - - - -Copyright © OASIS Open 2023. All Rights Reserved. - -All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full [Policy](https://www.oasis-open.org/policies-guidelines/ipr/) may be found at the OASIS website. - -This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. - -The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. - -This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata). - -[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.] - -[OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.] - -[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.] - -The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance. diff --git a/odata-csdl-json/0 frontmatter.md b/odata-csdl/0 frontmatter.md similarity index 76% rename from odata-csdl-json/0 frontmatter.md rename to odata-csdl/0 frontmatter.md index 8a4c1f0ba..3d786c7e4 100644 --- a/odata-csdl-json/0 frontmatter.md +++ b/odata-csdl/0 frontmatter.md @@ -3,13 +3,13 @@ ------- -# OData Common Schema Definition Language (CSDL) JSON Representation Version 4.02 +# $$$pagetitle$$$ -## Committee Specification Draft 01 +## $$$subtitle$$$ -## 14 July 2023 +## $$$pubdate$$$ -  +$\hbox{}$ #### This stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.02/$$$stage$$$/$$$filename$$$.md (Authoritative) \ @@ -38,20 +38,27 @@ Ralf Handl (ralf.handl@sap.com), [SAP SE](http://www.sap.com/) \ Michael Pizzo (mikep@microsoft.com), [Microsoft](http://www.microsoft.com/) \ Heiko Theißen (heiko.theissen@sap.com), [SAP SE](http://www.sap.com/) -#### Additional artifacts: +#### Additional artifacts: This prose specification is one component of a Work Product that also includes: -* XML schemas: (list file names or directory name) -* Other parts (list titles and/or file names) -* `(Note: Any normative computer language definitions that are part of the Work Product, such as XML instances, schemas and Java(TM) code, including fragments of such, must be (a) well formed and valid, (b) provided in separate plain text files, (c) referenced from the Work Product; and (d) where any definition in these separate files disagrees with the definition found in the specification, the definition in the separate file prevails. Remove this note before submitting for publication.)` +* XML schemas: _OData EDMX XML Schema and OData EDM XML Schema_. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/schemas/ -#### Related work: +#### Related work: This specification replaces or supersedes: * _OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. OASIS Standard. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html. This specification is related to: * _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: - * _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html - * _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + * _OData Version 4.02 Part 1: Protocol_. Latest stage: https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html + * _OData Version 4.02 Part 2: URL Conventions_. Latest stage: https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + * _ABNF components: OData ABNF Construction Rules Version 4.01 and OData ABNF Test Cases_. https://docs.oasis-open.org/odata/odata/v4.01/os/abnf/ +* _OData Vocabularies Version 4.0_. Edited by Michael Pizzo, Ralf Handl, and Ram Jeyaraman. Latest stage: https://docs.oasis-open.org/odata/odata-vocabularies/v4.0/odata-vocabularies-v4.0.html +: varxml +* _OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html +: +: varjson +* _OData Common Schema Definition Language (CSDL) XML Representation Version 4.01_. Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html +: +* _OData JSON Format Version 4.01_. Edited by Ralf Handl, Mike Pizzo, and Mark Biamonte. Latest stage: https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html #### Abstract: OData services are described by an Entity Model (EDM). The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service, using XML, JSON, and other formats. This document (OData CSDL JSON Representation) specifically defines the JSON representation of CSDL. @@ -66,7 +73,7 @@ This specification is provided under the [RF on RAND Terms Mode](https://www.oas Note that any machine-readable content ([Computer Language Definitions](https://www.oasis-open.org/policies-guidelines/tc-process-2017-05-26/#wpComponentsCompLang)) declared Normative for this Work Product is provided in separate plain text files. In the event of a discrepancy between any such plain text file and display content in the Work Product's prose narrative document(s), the content in the separate plain text file prevails. #### Key words: -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [[RFC2119](#rfc2119)] and [[RFC8174](#rfc8174)] when, and only when, they appear in all capitals, as shown here. +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119](#rfc2119) and [RFC8174](#rfc8174) when, and only when, they appear in all capitals, as shown here. #### Citation format: When referencing this specification the following citation format should be used: diff --git a/odata-csdl/1 Introduction.md b/odata-csdl/1 Introduction.md new file mode 100644 index 000000000..f135c2948 --- /dev/null +++ b/odata-csdl/1 Introduction.md @@ -0,0 +1,541 @@ +------- + +# ##sec Introduction + +OData services are described in terms of an [Entity +Model](#EntityModel). The Common Schema Definition Language (CSDL) +defines a representation of the entity model exposed by an OData service +using the JavaScript Object Notation (JSON), see [RFC8259](#rfc8259). + +This format is based on the OpenUI5 OData V4 Metadata JSON Format, see +[OpenUI5](#_OpenUI5), with some extensions and +modifications made necessary to fully cover OData CSDL Version 4.01. + +## ##subsec Changes from Earlier Versions + +## ##subsec Glossary + +### ##subsubsec Definitions of terms + +### ##subsubsec Acronyms and abbreviations + + + +### ##subsubsec Document conventions + +Keywords defined by this specification use `this monospaced font`. + +Some sections of this specification are illustrated with non-normative examples. + +::: example +Example ##ex: text describing an example uses this paragraph style +``` +Non-normative examples use this paragraph style. +``` +::: + +All examples in this document are non-normative and informative only. Examples labeled with ⚠ contain advanced concepts or make use of keywords that are defined only later in the text, they can be skipped at first reading. + +Representation-specific text is indented and marked with vertical lines. + +::: rep +### Representation-Specific Headline + +Normative representation-specific text +::: + +All other text is normative unless otherwise labeled. + +::: example +Here is a customized command line which will generate HTML from this markdown file (named `$$$filename$$$.md`). Line breaks are added for readability only: + +``` +pandoc -f gfm+tex_math_dollars+fenced_divs + -t html + -o $$$filename$$$.html + -c styles/markdown-styles-v1.7.3b.css + -c styles/odata.css + -s + --mathjax + --eol=lf + --wrap=none + --metadata pagetitle="$$$pagetitle$$$" + $$$filename$$$.md +``` + +This uses pandoc 3.1.2 from https://github.com/jgm/pandoc/releases/tag/3.1.2. +::: + + +: varjson +# ##sec JSON Representation + +OData CSDL JSON is a full representation of the OData Common Schema +Definition Language in the JavaScript Object Notation (JSON) defined in +[RFC8259](#rfc8259). It additionally follows the rules +for "Internet JSON" (I-JSON) defined in +[RFC7493](#rfc7493) for e.g. objects, numbers, date +values, and duration values. + +It is an alternative to the CSDL XML representation defined in +[OData-CSDLXML](#ODataCSDL) and neither adds nor removes +features. + +## ##subsec Requesting the JSON Representation + +The OData CSDL JSON representation can be requested using the `$format` +query option in the request URL with the media type `application/json`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `json` which MUST NOT be followed by media type parameters. + +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/json`, optionally followed by +media type parameters. + +If specified, `$format` overrides any value specified in the `Accept` +header. + +The response MUST contain the `Content-Type` header with a value of +`application/json`, optionally followed by media type parameters. + +Possible media type parameters are: +- [`IEEE754Compatible`](#ControllingtheRepresentationofNumbers) +- [`metadata`](#ControllingtheAmountofControlInformation) + +The names and values of these parameters are case-insensitive. + +### ##subsubsec Controlling the Representation of Numbers + +The `IEEE754Compatible=true` parameter indicates that the service MUST +serialize `Edm.Int64` and `Edm.Decimal` numbers as strings. This is in +conformance with [RFC7493](#rfc7493). If not specified, or specified as +`IEEE754Compatible=false`, all numbers MUST be serialized as JSON +numbers. + +This enables support for JavaScript numbers that are defined to be +64-bit binary format IEEE 754 values [ECMAScript](#_ECMAScript) +(see [section +4.3.1.9](http://www.ecma-international.org/ecma-262/5.1/#sec-4.3.19)) +resulting in integers losing precision past 15 digits, and decimals +losing precision due to the conversion from base 10 to base 2. + +Responses that format `Edm.Int64` and `Edm.Decimal` values as strings +MUST specify this parameter in the media type returned in the +`Content-Type` header. + +### ##subsubsec Controlling the Amount of Control Information + +The representation of constant annotation values in CSDL JSON documents +closely follows the representation of data defined in +[OData-JSON](#ODataJSON). + +A client application can use the `metadata` format parameter in the +`Accept` header when requesting a CSDL JSON document to influence how +much control information will be included in the response. + +Other `Accept` header parameters are orthogonal to the `metadata` +parameter and are therefore not mentioned in this section. + +#### ##subsubsubsec `metadata=minimal` + +The `metadata=minimal` format parameter indicates that the service +SHOULD remove computable control information from the payload wherever +possible. + +This means that the `@type` control information is only included if the +type of the containing object or targeted property cannot be +heuristically determined, e.g. for +- Terms or term properties with an abstract declared type, +- Terms or term properties with a declared type that has derived +types, or +- Dynamic properties of open types. + +See [OData-JSON](#ODataJSON) for the exact rules. + +#### ##subsubsubsec `metadata=full` + +The `metadata=full` format parameter indicates that the service MUST +include all control information explicitly in the payload. + +This means that the `@type` control information is included in +annotation values except for primitive values whose type can be +heuristically determined from the representation of the value, see +[OData-JSON](#ODataJSON) for the exact rules. + +#### ##subsubsubsec `metadata=none` + +The `metadata=none` format parameter indicates that the service SHOULD +omit all control information. + +## ##subsec Design Considerations + +CSDL JSON documents are designed for easy and efficient lookup of model +constructs by their name without having to know or guess what kind of +model element it is. Thus, all primary model elements (entity types, +complex types, type definitions, enumeration types, terms, actions, +functions, and the entity container) are direct members of their schema, +using the schema-unique name as the member name. Similarly, child +elements of primary model elements (properties, navigation properties, +enumeration type members, entity sets, singletons, action imports, and +function imports) are direct members of the objects describing their +parent model element, using their locally unique name as the member +name. + +To avoid name collisions, all fixed member names are prefixed with a +dollar (`$`) sign and otherwise have the same name and capitalization as +their counterparts in the CSDL XML representation +[OData-CSDLXML](#ODataCSDL) (with one exception: the +counterpart of the `EntitySet` element's `EntityType` member is +[`$Type`](#EntitySet), to harmonize it with all other type references). + +Additional fixed members introduced by this specification and without +counterpart in [OData-CSDLXML](#ODataCSDL) are also +prefixed with a dollar (`$`) sign and use upper-camel-case names. One of +these is `$Kind` which represents the kind of model element. Its value +is the upper-camel-case local name of the XML element representing this +kind of model element in [OData-CSDLXML](#ODataCSDL), +e.g. `EntityType` or `NavigationProperty`. + +While the XML representation of CSDL allows referencing model elements +with alias-qualified names as well as with namespace-qualified names, +this JSON representation requires the use of alias-qualified names if an +alias is specified for an included or document-defined schema. Aliases +are usually shorter than namespaces, so this reduces text size of the +JSON document. Text size matters even if the actual HTTP messages are +sent in compressed form because the decompressed form needs to be +reconstructed, and clients not using a streaming JSON parser have to +materialize the full JSON document before parsing. + +To further reduce size the member `$Kind` is optional for [structural +properties](#StructuralProperty) as these are more common than +[navigation properties](#NavigationProperty), and the member +[`$Type`](#Type) is optional for string properties, parameters, and +return types, as this type is more common than other primitive types. + +In general, all members that have a default value SHOULD be omitted if +they have the default value. + +## ##subsec JSON Schema Definition + +The structure of CSDL JSON documents can be verified with the JSON +Schema [OData-CSDL-Schema](#ODataCSDL) provided as an +additional artifact of this prose specification. This schema only +defines the shape of a well-formed CSDL JSON document but is not +descriptive enough to define what a correct CSDL JSON document MUST be +in every imaginable use case. This specification document defines +additional rules that correct CSDL JSON documents MUST fulfill. In case +of doubt on what makes a CSDL JSON document correct the rules defined in +this specification document take precedence. +: + + +: varxml +# ##sec XML Representation + +OData CSDL XML is a full representation of the OData Common Schema +Definition Language in the Extensible Markup Language (XML) 1.1 (Second +Edition) [XML-1.1](#XML-11) with further building blocks from the +W3C XML Schema Definition Language (XSD) 1.1 as described in +[XML-Schema-1](#XML-Schema1) and +[XML-Schema-2](#XML-Schema2). + +It is an alternative to the CSDL JSON representation defined in +[OData-CSDLJSON](#ODataCSDLJSON) and neither adds nor +removes features. + +## ##subsec Requesting the XML Representation + +The OData CSDL XML representation can be requested using the `$format` +query option in the request URL with the media type `application/xml`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `xml` which MUST NOT be followed by media type parameters. + +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/xml`, optionally followed by +media type parameters. + +If specified, `$format` overrides any value specified in the `Accept` +header. + +The response MUST contain the `Content-Type` header with a value of +`application/xml`, optionally followed by media type parameters. + +This specification does not define additional parameters for the media +type `application/xml`. + +## ##subsec XML Namespaces + +In addition to the default XML namespace, the elements and attributes +used to describe the entity model of an OData service are defined in one +of the following namespaces. + +### ##subsubsec Namespace EDMX + +Elements and attributes associated with the top-level wrapper that +contains the CSDL used to define the entity model for an OData Service +are qualified with the Entity Data Model for Data Services Packaging +namespace: +- `http://docs.oasis-open.org/odata/ns/edmx` + +Prior versions of OData used the following namespace for EDMX: +- EDMX version 1.0: +`http://schemas.microsoft.com/ado/2007/06/edmx` + +They are non-normative for this specification. + +In this specification the namespace prefix `edmx` is used to represent +the Entity Data Model for Data Services Packaging namespace, however the +prefix name is not prescriptive. + +### ##subsubsec Namespace EDM + +Elements and attributes that define the entity model exposed by the +OData Service are qualified with the Entity Data Model namespace: +- `http://docs.oasis-open.org/odata/ns/edm` + +Prior versions of CSDL used the following namespaces for EDM: + +- CSDL version 1.0: `http://schemas.microsoft.com/ado/2006/04/edm` +- CSDL version 1.1: `http://schemas.microsoft.com/ado/2007/05/edm` +- CSDL version 1.2: `http://schemas.microsoft.com/ado/2008/01/edm` +- CSDL version 2.0: `http://schemas.microsoft.com/ado/2008/09/edm` +- CSDL version 3.0: `http://schemas.microsoft.com/ado/2009/11/edm` + +They are non-normative for this specification. + +In this specification the namespace prefix `edm` is used to represent +the Entity Data Model namespace, however the prefix name is not +prescriptive. + +## ##subsec XML Schema Definitions + +This specification contains normative XML schemas for the EDMX and EDM +namespaces; see [OData-EDMX](#ODataEDMX) and +[OData-EDM](#ODataEDM) + +These XML schemas only define the shape of a well-formed CSDL XML +document and are not descriptive enough to define what a correct CSDL +XML document MUST be in every imaginable use case. This specification +document defines additional rules that correct CSDL XML documents MUST +fulfill. In case of doubt on what makes a CSDL XML document correct the +rules defined in this specification document take precedence. + +## ##subsec XML Document Order + +Client libraries MUST retain the document order of XML elements for CSDL +XML documents because for some elements the order of child elements is +significant. This includes, but is not limited to, [members of +enumeration types](#EnumerationTypeMember) and items within a +[collection expression](#Collection). + +OData does not impose any ordering constraints on XML attributes within +XML elements. +: + +# ##sec Entity Model + +An OData service exposes a single entity model. This model may be +distributed over several [schemas](#Schema), and these schemas may be +distributed over several documents. + +A service is defined by a single CSDL document which can be accessed by +sending a `GET` request to `/$metadata`. This document is +called the metadata document. It MAY [reference](#Reference) other CSDL +documents. + +The metadata document contains a single [entity +container](#EntityContainer) that defines the resources exposed by this +service. This entity container MAY [extend](#ExtendinganEntityContainer) +an entity container defined in a [referenced document](#Reference). + +The *model* of the service consists of all CSDL constructs used in its +entity containers. + +The *scope* of a CSDL document is the document itself and all schemas +[included](#IncludedSchema) from directly [referenced +documents](#Reference). All entity types, complex types and other named +model elements *in scope* (that is, defined in the document itself or a +schema of a directly referenced document) can be accessed from a +referencing document by their qualified names. This includes the +[built-in primitive](#PrimitiveTypes) and [abstract +types](#BuiltInAbstractTypes). + +Referencing another document may alter the model defined by the +referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, +then an [entity set](#EntitySet) of the service defined by the +referencing document may return entities of the derived type. This is +identical to the behavior if the derived type had been defined directly +in the referencing document. + +Note: referencing documents is not recursive. Only named model elements +defined in directly referenced documents can be used within the schema. +However, those elements may in turn include or reference model elements +defined in schemas referenced by their defining schema. + +## ##subsec Nominal Types + +A nominal type has a name that MUST be a [simple +identifier](#SimpleIdentifier). Nominal types are referenced using their +[qualified name](#QualifiedName). The qualified type name MUST be unique +within a model as it facilitates references to the element from other +parts of the model. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +## ##subsec Structured Types + +Structured types are composed of other model elements. Structured types +are common in entity models as the means of representing entities and +structured properties in an OData service. [Entity types](#EntityType) +and [complex types](#ComplexType) are both structured types. + +Structured Types are composed of zero or more [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty). + +[Open entity types](#OpenEntityType) and [open complex +types](#OpenComplexType) allow properties to be added dynamically to +instances of the open type. + +## ##subsec Primitive Types + +Structured types are composed of other structured types and primitive +types. OData defines the following primitive types: + +Type|Meaning +----|------- +`Edm.Binary` |Binary data +`Edm.Boolean` |Binary-valued logic +`Edm.Byte` |Unsigned 8-bit integer +`Edm.Date` |Date without a time-zone offset +`Edm.DateTimeOffset` |Date and time with a time-zone offset, no leap seconds +`Edm.Decimal` |Numeric values with decimal representation +`Edm.Double` |IEEE 754 binary64 floating-point number (15-17 decimal digits) +`Edm.Duration` |Signed duration in days, hours, minutes, and (sub)seconds +`Edm.Guid` |16-byte (128-bit) unique identifier +`Edm.Int16` |Signed 16-bit integer +`Edm.Int32` |Signed 32-bit integer +`Edm.Int64` |Signed 64-bit integer +`Edm.SByte` |Signed 8-bit integer +`Edm.Single` |IEEE 754 binary32 floating-point number (6-9 decimal digits) +`Edm.Stream` |Binary data stream +`Edm.String` |Sequence of characters +`Edm.TimeOfDay` |Clock time 00:00-23:59:59.999999999999 +`Edm.Geography` |Abstract base type for all Geography types +`Edm.GeographyPoint` |A point in a round-earth coordinate system +`Edm.GeographyLineString` |Line string in a round-earth coordinate system +`Edm.GeographyPolygon` |Polygon in a round-earth coordinate system +`Edm.GeographyMultiPoint` |Collection of points in a round-earth coordinate system +`Edm.GeographyMultiLineString` |Collection of line strings in a round-earth coordinate system +`Edm.GeographyMultiPolygon` |Collection of polygons in a round-earth coordinate system +`Edm.GeographyCollection` |Collection of arbitrary Geography values +`Edm.Geometry` |Abstract base type for all Geometry types +`Edm.GeometryPoint` |Point in a flat-earth coordinate system +`Edm.GeometryLineString` |Line string in a flat-earth coordinate system +`Edm.GeometryPolygon` |Polygon in a flat-earth coordinate system +`Edm.GeometryMultiPoint` |Collection of points in a flat-earth coordinate system +`Edm.GeometryMultiLineString` |Collection of line strings in a flat-earth coordinate system +`Edm.GeometryMultiPolygon` |Collection of polygons in a flat-earth coordinate system +`Edm.GeometryCollection` |Collection of arbitrary Geometry values + +`Edm.Date` and `Edm.DateTimeOffset` follow +[XML-Schema-2](#XML-Schema2) and use the proleptic Gregorian +calendar, allowing the year `0000` (equivalent to 1 BCE) and negative +years (year `-0001` being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying +persistency layer, e.g. SQL only supports years `0001` to `9999`. + +`Edm.Decimal` with a [`Scale`](#Scale) value of `floating`, +`Edm.Double`, and `Edm.Single` allow the special numeric values `-INF`, +`INF`, and `NaN`. + +`Edm.Stream` is a primitive type that can be used as a property of an +[entity type](#EntityType) or [complex type](#ComplexType), the +underlying type for a [type definition](#TypeDefinition), or the binding +parameter or return type of an [action](#Action) or +[function](#Function). `Edm.Stream`, or a type definition whose +underlying type is `Edm.Stream`, cannot be used in collections or for +non-binding parameters to functions or actions. + +Some of these types allow [facets](#TypeFacets), defined in section +"[Type Facets](#TypeFacets)". + +See rule `primitiveLiteral` in [OData-ABNF](#ODataABNF) for the +representation of primitive type values in URLs and +[OData-JSON](#ODataJSON) for the representation in requests and +responses. + +## ##subsec Built-In Abstract Types + +The following built-in abstract types can be used within a model: +- `Edm.PrimitiveType` +- `Edm.ComplexType` +- `Edm.EntityType` +- `Edm.Untyped` + +Conceptually, these are the abstract base types for primitive types +(including type definitions and enumeration types), complex types, +entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except: +- `Edm.EntityType` + - cannot be used as the type of a singleton in an entity container + because it doesn't define a structure, which defeats the purpose + of a singleton. + - cannot be used as the type of an entity set because all entities + in an entity set must have the same key fields to uniquely + identify them within the set. + - cannot be the base type of an entity type or complex type. +- `Edm.ComplexType` + - cannot be the base type of an entity type or complex type. +- `Edm.PrimitiveType` + - cannot be used as the type of a key property of an entity type + or as the underlying type of an enumeration type. + - cannot be used as the underlying type of a type definition in a + CSDL document with a version of `4.0`. + - can be used as the underlying type of a type definition in a + CSDL document with a version of `4.01` or greater. +- `Edm.Untyped` + - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + - cannot be used as the type of a key property of an entity type. + - cannot be the base type of an entity type or complex type. + - cannot be used as the underlying type of a type definition or + enumeration type. +- `Collection(Edm.PrimitiveType)` + - cannot be used as the type of a property or term. + - cannot be used as the type of a parameter or the return type of + an action or function. +- `Collection(Edm.Untyped)` + - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + +## ##subsec Built-In Types for defining Vocabulary Terms + +[Vocabulary terms](#VocabularyandAnnotation) can, in addition, use +- `Edm.AnnotationPath` +- `Edm.PropertyPath` +- `Edm.NavigationPropertyPath` +- `Edm.AnyPropertyPath` (`Edm.PropertyPath` or `Edm.NavigationPropertyPath`) +- `Edm.ModelElementPath` (any model element, including +`Edm.AnnotationPath`, `Edm.NavigationPropertyPath`, and +`Edm.PropertyPath`) + +as the type of a primitive term, or the type of a property of a complex +type (recursively) that is exclusively used as the type of a term. See +section "[Path Expressions](#PathExpressions)" for details. + +## ##subsec Annotations + +Many parts of the model can be decorated with additional information +using [annotations](#Annotation). Annotations are identified by their +term name and an optional qualifier that allows applying the same term +multiple times to the same model element. + +A model element MUST NOT specify more than one annotation for a given +combination of term and qualifier. diff --git a/odata-csdl/12 Action and Function.md b/odata-csdl/12 Action and Function.md new file mode 100644 index 000000000..638df7979 --- /dev/null +++ b/odata-csdl/12 Action and Function.md @@ -0,0 +1,466 @@ +------- + +# ##sec Action and Function + +## ##subsec Action + +Actions are service-defined operations that MAY have observable side +effects and MAY return a single instance or a collection of instances of +any type. + +The action's name is a [simple identifier](#SimpleIdentifier) that MUST +be unique within its schema. + +Actions cannot be composed with additional path segments. + +An action MAY specify a [return type](#ReturnType) that MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +An action MAY define [parameters](#Parameter) used during the execution +of the action. + +## ##subsec Action Overloads + +[Bound](#BoundorUnboundActionorFunctionOverloads) actions support +overloading (multiple actions having the same name within the same +schema) by binding parameter type. The combination of action name and +the binding parameter type MUST be unique within a schema. + +[Unbound](#BoundorUnboundActionorFunctionOverloads) actions do not support +overloads. The names of all unbound actions MUST be unique within a +schema. + +An unbound action MAY have the same name as a bound action. + +::: {.varjson .rep} +### ##isec Action Overload Object + +An action is represented as a member of the schema object whose name is +the unqualified name of the action and whose value is an array. The +array contains one object per action overload. + +The action overload object MUST contain the member `$Kind` with a string +value of `Action`. + +It MAY contain the members +[`$IsBound`](#BoundorUnboundActionorFunctionOverloads), +[`$EntitySetPath`](#EntitySetPath), [`$Parameter`](#Parameter), and +[`$ReturnType`](#ReturnType), and it MAY contain +[annotations](#Annotation). +::: + +::: {.varxml .rep} +### ##isec Element `edm:Action` + +The `edm:Action` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverloads) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MAY contain at most one [`edm:ReturnType`](#ReturnType) element and +MAY contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the action's name. +::: + +## ##subsec Function + +Functions are service-defined operations that MUST NOT have observable +side effects and MUST return a single instance or a collection of +instances of any type. + +The function's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +Functions MAY be [composable](#ComposableFunction). + +The function MUST specify a [return type](#ReturnType) which MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +A function MAY define [parameters](#Parameter) used during the execution +of the function. + +## ##subsec Function Overloads + +[Bound](#BoundorUnboundActionorFunctionOverloads) functions support +overloading (multiple functions having the same name within the same +schema) subject to the following rules: +- The combination of function name, +binding parameter type, and unordered set of non-binding parameter names +MUST be unique within a schema. +- The combination of function name, +binding parameter type, and ordered set of parameter types MUST be +unique within a schema. +- All bound functions with the same +function name and binding parameter type within a schema MUST specify +the same return type. + +[Unbound](#BoundorUnboundActionorFunctionOverloads) functions support +overloading subject to the following rules: +- The combination of function name and +unordered set of parameter names MUST be unique within a schema. +- The combination of function name and +ordered set of parameter types MUST be unique within a schema. +- All unbound functions with the same +function name within a schema MUST specify the same return type. + +An unbound function MAY have the same name as a bound function. + +Note that [type definitions](#TypeDefinition) can be used to +disambiguate overloads for both bound and unbound functions, even if +they specify the same underlying type. + +::: {.varjson .rep} +### ##isec Function Overload Object + +A function is represented as a member of the schema object whose name is +the unqualified name of the function and whose value is an array. The +array contains one object per function overload. + +The function overload object MUST contain the member `$Kind` with a +string value of `Function`. + +It MUST contain the member [`$ReturnType`](#ReturnType), and it MAY +contain the members [`$IsBound`](#BoundorUnboundActionorFunctionOverloads), +[`$EntitySetPath`](#EntitySetPath), and [`$Parameter`](#Parameter), +and it MAY contain [annotations](#Annotation). +::: + +::: {.varxml .rep} +### ##isec Element `edm:Function` + +The `edm:Function` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverloads) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MUST contain one [`edm:ReturnType`](#ReturnType) element, and it MAY +contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the action's name. +::: + +## ##subsec Bound or Unbound Action or Function Overloads + +An action or function overload MAY indicate that it is bound. If not +explicitly indicated, it is unbound. + +Bound actions or functions are invoked on resources matching the type of +the binding parameter. The binding parameter can be of any type, and it +MAY be [nullable](#Nullable). + +Unbound actions are invoked from the entity container through an [action +import](#ActionImport). + +Unbound functions are invoked as static functions within a filter or +orderby expression, or from the entity container through a [function +import](#FunctionImport). + +::: {.varjson .rep} +### ##subisec `$IsBound` + +The value of `$IsBound` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `IsBound` + +The value of `IsBound` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +## ##subsec Entity Set Path + +Bound actions and functions that return an entity or a collection of +entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter +value. + +The entity set path consists of a series of segments joined together +with forward slashes. + +The first segment of the entity set path MUST be the name of the binding +parameter. The remaining segments of the entity set path MUST represent +navigation segments or type casts. + +A navigation segment names the [simple identifier](#SimpleIdentifier) of +the [navigation property](#NavigationProperty) to be traversed. A +type-cast segment names the [qualified name](#QualifiedName) of the +entity type that should be returned from the type cast. + +::: {.varjson .rep} +### ##subisec `$EntitySetPath` + +The value of `$EntitySetPath` is a string containing the entity set +path. +::: + +::: {.varxml .rep} +### ##subisec Attribute `EntitySetPath` + +The value of `EntitySetPath` is the entity set path. +::: + +## ##subsec Composable Function + +A function MAY indicate that it is composable. If not explicitly +indicated, it is not composable. + +A composable function can be invoked with additional path segments or +key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for +the type returned by the composable function. + +::: {.varjson .rep} +### ##subisec `$IsComposable` + +The value of `$IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `IsComposable` + +The value of `IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Return Type + +The return type of an action or function overload MAY be any type in +scope, or a collection of any type in scope. + +The facets [`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID) can be +used as appropriate to specify value restrictions of the return type, as +well as the [`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For a single-valued return type the facets apply to the returned value. +For a collection-valued return type the facets apply to the items in the +returned collection. + +::: {.varjson .rep} +### ##subisec `$ReturnType` + +The value of `$ReturnType` is an object. It MAY contain the members +`$Type`, `$Collection`, `$Nullable`, [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID). + +It also MAY contain [annotations](#Annotation). + +### ##subisec `$Type` +and ##subisec `$Collection` + +For single-valued return types the value of `$Type` is the qualified +name of the returned type. + +For collection-valued return types the value of `$Type` is the qualified +name of the returned item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. + +### ##subisec `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +If the return type is a collection of entity types, the `$Nullable` +member has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + +::: {.varxml .rep} +### ##isec Element `edm:ReturnType` + +The `edm:ReturnType` element MUST contain the `Type` attribute, and it +MAY contain the attributes `Nullable`, [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Type` + +For single-valued return types the value of `Type` is the qualified name +of the return type. + +For collection-valued return types the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the return item +type, followed by a closing parenthesis `)`. + +### ##subisec Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +If the return type is a collection of entity types, the `Nullable` +attribute has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + +## ##subsec Parameter + +An action or function overload MAY specify parameters. + +A bound action or function overload MUST specify at least one parameter; +the first parameter is its binding parameter. The order of parameters +MUST NOT change unless the schema version changes. + +Each parameter MUST have a name that is a [simple +identifier](#SimpleIdentifier). The parameter name MUST be unique within +the action or function overload. + +The parameter MUST specify a type. It MAY be any type in scope, or a +collection of any type in scope. + +The facets [`MaxLength`](#MaxLength), [`Precision`](#Precision), +[`Scale`](#Scale), or [`SRID`](#SRID) can be used as appropriate to +specify value restrictions of the parameter, as well as the +[`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For single-valued parameters the facets apply to the parameter value. If +the parameter value is a collection, the facets apply to the items in +the collection. + +::: {.varjson .rep} +### ##subisec `$Parameter` + +The value of `$Parameter` is an array. The array contains one object per +parameter. + +### ##isec Parameter Object + +A parameter object MUST contain the member `$Name`, and it MAY contain +the members `$Type`, `$Collection`, `$Nullable`, +[`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID). + +Parameter objects MAY also contain [annotations](#Annotation). + +### ##subisec `$Name` + +The value of `$Name` is a string containing the parameter name. + +### ##subisec `$Type` +and ##subisec `$Collection` + +For single-valued parameters the value of `$Type` is the qualified name +of the accepted type. + +For collection-valued parameters the value of `$Type` is the qualified +name of the accepted item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. + +### ##subisec `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued parameters the value `true` means that the parameter +accepts a `null` value. + +For collection-valued parameters the parameter value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + +::: {.varjson .example} +Example ##ex: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `$Parameter` member. +```json +"TopSellingProducts": [ + { + "$Kind": "Function", + "$Parameter": [ + { + "$Name": "Year", + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 4, + "$Scale": 0 + } + ], + "$ReturnType": { + "$Collection": true, + "$Type": "self.Product" + } + } +] +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:Parameter` + +The `edm:Parameter` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the attributes `Nullable`, +[`MaxLength`](#MaxLength), [`Unicode`](#Unicode), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the parameter's name. + +### ##subisec Attribute `Type` + +For single-valued parameters the value of `Type` is the qualified name +of the parameter. + +For collection-valued parameters the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the parameter's +type, followed by a closing parenthesis `)`. + +### ##subisec Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +The value `true` means that the parameter accepts a `null` value. +::: + +::: {.varxml .example} +Example ##ex: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `edm:Parameter` element. +```xml + + + + +``` +::: diff --git a/odata-csdl/13 Entity Container.md b/odata-csdl/13 Entity Container.md new file mode 100644 index 000000000..3732b0698 --- /dev/null +++ b/odata-csdl/13 Entity Container.md @@ -0,0 +1,710 @@ +------- + +# ##sec Entity Container + +Each metadata document used to describe an OData service MUST define +exactly one entity container. + +The entity container's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Entity containers define the entity sets, singletons, function and +action imports exposed by the service. + +Entity set, singleton, action import, and function import names MUST be +unique within an entity container. + +An [*entity set*](#EntitySet) allows access to entity type instances. +Simple entity models frequently have one entity set per entity type. + +::: {.varjson .example} +Example ##ex: one entity set per entity type +```json +"Products": { + "$Collection": true, + "$Type": "self.Product" +}, +"Categories": { + "$Collection": true, + "$Type": "self.Category" +} +``` +::: + +::: {.varxml .example} +Example ##ex: one entity set per entity type +```xml + + +``` +::: + +Other entity models may expose multiple entity sets per type. + +::: {.varjson .example} +Example ##ex: three entity sets referring to the two entity types +```json +"StandardCustomers": { + "$Collection": true, + "$Type": "self.Customer", + "$NavigationPropertyBinding": { + "Orders": "Orders" + } +}, +"PreferredCustomers": { + "$Collection": true, + "$Type": "self.Customer", + "$NavigationPropertyBinding": { + "Orders": "Orders" + } +}, +"Orders": { + "$Collection": true, + "$Type": "self.Order" +} +``` +::: + +::: {.varxml .example} +Example ##ex: three entity sets referring to the two entity types +```xml + + + + + + + +``` +::: + +There are separate entity sets for standard customers and preferred +customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have [navigation +property bindings](#NavigationPropertyBinding) to the orders entity set, +but the orders entity set does not have a navigation property binding +for the Customer navigation property, since it could lead to either set +of customers. + +An entity set can expose instances of the specified entity type as well +as any entity type inherited from the specified entity type. + +A [*singleton*](#Singleton) allows addressing a single entity directly +from the entity container without having to know its key, and without +requiring an entity set. + +A [*function import*](#FunctionImport) or an [*action +import*](#ActionImport) is used to expose a function or action defined +in an entity model as a top level resource. + +::: {.varjson .rep} +### ##isec Entity Container Object + +An entity container is represented as a member of the schema object +whose name is the unqualified name of the entity container and whose +value is an object. + +The entity container object MUST contain the member `$Kind` with a +string value of `EntityContainer`. + +The entity container object MAY contain the member +[`$Extends`](#ExtendinganEntityContainer), members representing [entity +sets](#EntitySet), [singletons](#Singleton), [action +imports](#ActionImport), and [function imports](#FunctionImport), as +well as [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: An entity container aggregates entity sets, singletons, +action imports, and function imports. +```json +"DemoService": { + "$Kind": "EntityContainer", + "Products": { + "$Collection": true, + "$Type": "self.Product", + "$NavigationPropertyBinding": { + "Category": "Categories", + "Supplier": "Suppliers" + }, + "@UI.DisplayName": "Product Catalog" + }, + "Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "Products" + } + }, + "Suppliers": { + "$Collection": true, + "$Type": "self.Supplier", + "$NavigationPropertyBinding": { + "Products": "Products" + }, + "@UI.DisplayName": "Supplier Directory" + }, + "MainSupplier": { + "$Type": "self.Supplier" + }, + "LeaveRequestApproval": { + "$Action": "self.Approval" + }, + "ProductsByRating": { + "$EntitySet": "Products", + "$Function": "self.ProductsByRating" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:EntityContainer` + +The `edm:EntityContainer` MUST contain one or more +[`edm:EntitySet`](#EntitySet), [`edm:Singleton`](#Singleton), +[`edm:ActionImport`](#ActionImport), or +[`edm:FunctionImport`](#FunctionImport) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the entity container's name. +::: + +::: {.varxml .example} +Example ##ex: An entity container aggregates entity sets, singletons, +action imports, and function imports. +```xml + + + + + + + + + + + + + + + +``` +::: + +## ##subsec Extending an Entity Container + +An entity container MAY specify that it extends another entity container +in scope. All children of the "base" entity container are added to the +"extending" entity container. + +If the "extending" entity container defines an entity set with the same +name as defined in any of its "base" containers, then the entity set's +type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the "base" container. The same +holds for singletons. Action imports and function imports cannot be +redefined, nor can the "extending" container define a child with the +same name as a child of a different kind in a "base" container. + +Note: services should not introduce cycles by extending entity +containers. Clients should be prepared to process cycles introduced by +extending entity containers. + +::: {.varjson .rep} +### ##subisec `$Extends` + +The value of `$Extends` is the qualified name of the entity container to +be extended. +::: + +::: {.varjson .example} +Example ##ex: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` +```json +"Extending": { + "$Kind": "EntityContainer", + "$Extends": "Some.Other.Schema.Base", + ... +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `Extends` + +The value of `Extends` is the qualified name of the entity container to +be extended. +::: + +::: {.varxml .example} +Example ##ex: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` +```xml + + ... + +``` +::: + +## ##subsec Entity Set + +Entity sets are top-level collection-valued resources. + +An entity set is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An entity set MUST specify a type that MUST be an entity type in scope. + +An entity set MUST contain only instances of its specified entity type +or its subtypes. The entity type MAY be [abstract](#AbstractEntityType) +but MUST have a [key](#Key) defined. + +An entity set MAY indicate whether it is included in the service +document. If not explicitly indicated, it is included. + +Entity sets that cannot be queried without specifying additional query +options SHOULD NOT be included in the service document. + +::: {.varjson .rep} +### ##isec Entity Set Object + +An entity set is represented as a member of the entity container object +whose name is the name of the entity set and whose value is an object. + +The entity set object MUST contain the members `$Collection` and +`$Type`. + +It MAY contain the members `$IncludeInServiceDocument` and +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). + +### ##subisec `$Collection` + +The value of `$Collection` is the Booelan value `true`. + +### ##subisec `$Type` + +The value of `$Type` is the qualified name of an entity type. + +### ##subisec `$IncludeInServiceDocument` + +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `true`. +::: + +::: {.varxml .rep} +### ##isec Element `edm:EntitySet` + +The `edm:EntitySet` element MUST contain the attributes `Name` and +`EntityType`, and it MAY contain the `IncludeInServiceDocument` +attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the entity set's name. + +### ##subisec Attribute `EntityType` + +The value of `EntityType` is the qualified name of an entity type in +scope. + +### ##subisec Attribute `IncludeInServiceDocument` + +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `true`. +::: + +## ##subsec Singleton + +Singletons are top-level single-valued resources. + +A singleton is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A singleton MUST specify a type that MUST be an entity type in scope. + +A singleton MUST reference an instance its entity type. + +::: {.varjson .rep} +### ##isec Singleton Object + +A singleton is represented as a member of the entity container object +whose name is the name of the singleton and whose value is an object. + +The singleton object MUST contain the member `$Type` and it MAY contain +the member `$Nullable`. + +It MAY contain the member +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). + +### ##subisec `$Type` + +The value of `$Type` is the qualified name of an entity type. + +### ##subisec `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`.In OData 4.0 responses this +member MUST NOT be specified. +::: + +::: {.varxml .rep} +### ##isec Element `edm:Singleton` + +The `edm:Singleton` element MUST include the attributes `Name` and +`Type`, and it MAY contain the `Nullable` attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the singleton's name. + +### ##subisec Attribute `Type` + +The value of `Type` is whose value is the [qualified +name](#QualifiedName) of an entity type in scope. + +### ##subisec Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +If no value is specified, the `Nullable` attribute defaults to `false`. + +In OData 4.0 responses this attribute MUST NOT be specified. +::: + +## ##subsec Navigation Property Binding + +If the entity type of an entity set or singleton declares navigation +properties, a navigation property binding allows describing which entity +set or singleton will contain the related entities. + +An [entity set](#EntitySet) or a [singleton](#Singleton) SHOULD specify +a navigation property binding for each [navigation +property](#NavigationProperty) of its entity type, including navigation +properties defined on complex typed properties or derived types. + +If omitted, clients MUST assume that the target entity set or singleton +can vary per related entity. + +### ##subsubsec Navigation Property Path Binding + +A navigation property binding MUST specify a path to a navigation +property of the entity set's or singleton's declared entity type, or a +navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation +property is defined on a subtype, the path MUST contain the [qualified +name](#QualifiedName) of the subtype, followed by a forward slash, +followed by the navigation property name. If the navigation property is +defined on a complex type used in the definition of the entity set's +entity type, the path MUST contain a forward-slash separated list of +complex property names and qualified type names that describe the path +leading to the navigation property. + +The path can traverse one or more containment navigation properties, but +the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment. + +If the path traverses collection-valued complex properties or +collection-valued containment navigation properties, the binding applies +to all items of these collections. + +If the path contains a recursive sub-path (i.e. a path leading back to +the same structured type, the binding applies recursively to any +positive number of cycles through that sub-path. + +OData 4.01 services MAY have a type-cast segment as the last path +segment, allowing to bind instances of different sub-types to different +targets. + +The same navigation property path MUST NOT be specified in more than one +navigation property binding; navigation property bindings are only used +when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths +that differ only in a type-cast segment, allowing to bind instances of +different sub-types to different targets. If paths differ only in +type-cast segments, the most specific path applies. + +### ##subsubsec Binding Target + +A navigation property binding MUST specify a target via a [simple +identifier](#SimpleIdentifier) or [target path](#TargetPath). It +specifies the entity set, singleton, or containment navigation property +that contains the related entities. + +If the target is a [simple identifier](#SimpleIdentifier), it MUST +resolve to an entity set or singleton defined in the same entity +container. + +If the target is a [target path](#TargetPath), it MUST resolve to an +entity set, singleton, or direct or indirect containment navigation +property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties +before ending in a containment navigation property, and there MUST NOT +be any non-containment navigation properties prior to the final segment. + +::: {.varjson .rep} +### ##subisec `$NavigationPropertyBinding` + +The value of `$NavigationPropertyBinding` is an object. It consists of +members whose name is the navigation property binding path and whose +value is a string containing the navigation property binding target. If +the target is in the same entity container, the target MUST NOT be +prefixed with the qualified entity container name. +::: + +::: {.varjson .example} +Example ##ex: for an entity set in the same container as the enclosing +entity set `Categories` +```json +"Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "SomeSet" + } +} +``` +::: + +::: {.varjson .example} +Example ##ex: for an entity set in any container in scope +```json +"Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "SomeModel.SomeContainer/SomeSet" + } +} +``` +::: + +::: {.varjson .example} +Example ##ex: binding `Supplier` on `Products` contained within +`Categories` – binding applies to all suppliers of all products of all categories +```json +"Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products/Supplier": "Suppliers" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:NavigationPropertyBinding` + +The `edm:NavigationPropertyBinding` element MUST contain the attributes +`Path` and `Target`. + +### ##subisec Attribute `Path` + +The value of `Path` is a path expression. + +### ##subisec Attribute `Target` + +The value of `Target` is a [target path](#TargetPath). +::: + +::: {.varxml .example} +Example ##ex: for an entity set in the same container as the enclosing +entity set `Categories` +```xml + + + +``` +::: + +::: {.varxml .example} +Example ##ex: for an entity set in any container in scope +```xml + + + +``` +::: + +::: {.varxml .example} +Example ##ex: binding `Supplier` on `Products` contained within +`Categories – binding applies to all suppliers of all products of all categories` +```xml + + + +``` +::: + +## ##subsec Action Import + +Action imports sets are top-level resources that are never included in +the service document. + +An action import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An action import MUST specify the name of an unbound action in scope. + +If the imported action returns an entity or a collection of entities, a +[simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +::: {.varjson .rep} +### ##isec Action Import Object + +An action import is represented as a member of the entity container +object whose name is the name of the action import and whose value is an +object. + +The action import object MUST contain the member `$Action`. + +It MAY contain the member `$EntitySet`. + +It MAY also contain [annotations](#Annotation). + +### ##subisec `$Action` + +The value of `$Action` is a string containing the qualified name of an +unbound action. + +### ##subisec `$EntitySet` + +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. +::: + +::: {.varxml .rep} +### ##isec Element `edm:ActionImport` + +The `edm:ActionImport` element MUST contain the attributes `Name` and +`Action`, and it MAY contain the `EntitySet` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the action import's name. + +### ##subisec Attribute `Action` + +The value of `Action` is the qualified name of an unbound action. + +### ##subisec Attribute `EntitySet` + +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. +::: + +## ##subsec Function Import + +Function imports sets are top-level resources. + +A function import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A function import MUST specify the name of an unbound function in scope. +All [unbound overloads](#BoundorUnboundActionorFunctionOverloads) of the +imported function can be invoked from the entity container. + +If the imported function returns an entity or a collection of entities, +a [simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +A function import for a parameterless function MAY indicate whether it +is included in the service document. If not explicitly indicated, it is +not included. + +::: {.varjson .rep} +### ##isec Function Import Object + +A function import is represented as a member of the entity container +object whose name is the name of the function import and whose value is +an object. + +The function import object MUST contain the member `$Function`. + +It MAY contain the members `$EntitySet` and `$IncludeInServiceDocument`. + +It MAY also contain [annotations](#Annotation). + +### ##subisec `$Function` + +The value of `$Function` is a string containing the qualified name of an +unbound function. + +### ##subisec `$EntitySet` + +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. + +### ##subisec `$IncludeInServiceDocument` + +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##isec Element `edm:FunctionImport` + +The `edm:FunctionImport` element MUST contain the attributes `Name` and +`Function`, and it MAY contain the attributes `EntitySet` and +`IncludeInServiceDocument`. + +### ##subisec Attribute `Name` + +The value of `Name` is the function import's name. + +### ##subisec Attribute `Function` + +The value of `Function` is the qualified name of an unbound function. + +### ##subisec Attribute `EntitySet` + +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. + +### ##subisec Attribute `IncludeInServiceDocument` + +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `false`. +::: diff --git a/odata-csdl/14 Vocabulary and Annotation.md b/odata-csdl/14 Vocabulary and Annotation.md new file mode 100644 index 000000000..831772cea --- /dev/null +++ b/odata-csdl/14 Vocabulary and Annotation.md @@ -0,0 +1,2970 @@ +------- + +# ##sec Vocabulary and Annotation + +Vocabularies and annotations provide the ability to annotate metadata as +well as instance data, and define a powerful extensibility point for +OData. An [*annotation*](#Annotation) applies a [*term*](#Term) to a +model element and defines how to calculate a value for the applied term. + +*Metadata annotations* are terms applied to model elements. Behaviors or +constraints described by a metadata annotation must be consistent with +the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity +type, property, function, action, or parameter. For example, a metadata +annotation may define ranges of valid values for a particular property. +Metadata annotations are applied in CSDL documents describing or +referencing an entity model. + +*Instance annotations* are terms applied to a particular instance within +an OData payload, such as described in [OData-JSON](#ODataJSON). An +instance annotation can be used to define additional information +associated with a particular result, entity, property, or error. For +example, whether a property is read-only for a particular instance. +Where the same annotation is defined at both the metadata and instance +level, the instance-level annotation overrides the annotation specified +at the metadata level. Annotations that apply across instances should be +specified as metadata annotations. + +A *vocabulary* is a schema containing a set of terms where each +[term](#Term) is a named metadata extension. Anyone can define a +vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary +[OData-VocCore](#ODataVocCore). + +A [term](#Term) can be used to: +- Extend model elements and type instances +with additional information. +- Map instances of annotated structured +types to an interface defined by the term type; i.e. annotations allow +viewing instances of a structured type as instances of a differently +structured type specified by the applied term. + +A service SHOULD NOT require a client to interpret annotations. Clients +SHOULD ignore invalid or unknown terms and silently treat unexpected or +invalid values (including invalid type, invalid literal expression, +invalid targets, etc.) as an unknown value for the term. Unknown or +invalid annotations should never result in an error, as long as the +payload remains well-formed. + +::: {.varjson .example} +Example ##ex: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` +```json +"Product": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": { + "$Type": "Edm.Int32" + }, + "Name": { + "$Nullable": true + }, + "Description": { + "$Nullable": true + }, + "@UI.DisplayName": { + "$Path": "Name" + }, + "@SearchVocabulary.SearchResult": { + "Title": { + "$Path": "Name" + }, + "Abstract": { + "$Path": "Description" + }, + "Url": { + "$Apply": [ + "Products(", + { + "$Path": "ID" + }, + ")" + ], + "$Function": "odata.concat" + } + } +} +``` +::: + +::: {.varxml .example} +Example ##ex: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` +```xml + + + + + + + + ... + + + + + + + + Products( + ID + ) + + + + + +``` +::: + +## ##subsec Term + +A term allows annotating a model element or OData resource +representation with additional data. + +The term's name is a [simple identifier](#SimpleIdentifier) that MUST be +unique within its schema. + +The term's type MUST be a type in scope, or a collection of a type in +scope. + +::: {.varjson .rep} +### ##isec Term Object + +A term is represented as a member of the schema object whose name is the +unqualified name of the term and whose value is an object. + +The term object MUST contain the member `$Kind` with a string value of +`Term`. + +It MAY contain the members `$Type`, `$Collection`, +[`$AppliesTo`](#Applicability), [`$Nullable`](#Nullable), +[`$MaxLength`](#MaxLength), [`$Precision`](#Precision), +[`$Scale`](#Scale), [`$SRID`](#SRID), and `$DefaultValue`, as well as +[`$Unicode`](#Unicode) for 4.01 and greater payloads. + +It MAY contain [annotations](#Annotation). + +### ##subisec `$Type` +and ##subisec `$Collection` + +For single-valued terms the value of `$Type` is the qualified name of +the term's type. + +For collection-valued terms the value of `$Type` is the qualified name +of the term's item type, and the member `$Collection` MUST be present +with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. + +### ##subisec `$DefaultValue` + +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the term, see +[OData-JSON](#ODataJSON). + +Note: the `$DefaultValue` member is purely for documentation and +isomorphy to [OData-CSDLXML](#ODataCSDL). Annotations in +CSDL JSON documents MUST always specify an explicit value. +::: + +::: {.varxml .rep} +### ##isec Element `edm:Term` + +The `edm:Term` element MUST contain the attributes `Name` and `Type`. It +MAY contain the attributes `BaseTerm` and `AppliesTo`. + +It MAY specify values for the [`Nullable`](#Nullable), +[ ]{.apple-converted-space}[`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), or [`SRID`](#SRID) facet +attributes, as well as the [`Unicode`](#Unicode) facet attribute for +4.01 and greater payloads. These facets and their implications are +described in section 7.2. + +A `edm:Term` element whose `Type` attribute specifies a primitive or +enumeration type MAY define a value for the `DefaultValue` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the term's name. + +### ##subisec Attribute `Type` + +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. + +### ##subisec Attribute `DefaultValue` + +The value of this attribute determines the value of the term when +applied in an [`edm:Annotation`](#Annotation) without providing an +expression. + +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData-ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. + +If no value is specified, the `DefaultValue` attribute defaults to +`null`. +::: + +### ##subsubsec Specialized Term + +A term MAY specialize another term in scope by specifying it as its base +term. + +When applying a specialized term, the base term MUST also be applied +with the same qualifier, and so on until a term without a base term is +reached. + +::: {.varjson .rep} +### ##subisec `$BaseTerm` + +The value of `$BaseTerm` is the qualified name of the base term. +::: + +::: {.varxml .rep} +### ##subisec Attribute `BaseTerm` + +The value of `BaseTerm` is the qualified name of the base term. +::: + +### ##subsubsec Applicability + +The applicability of a term MAY be restricted to a list of model +elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be +extended in future versions of the vocabulary. As the intended usage may +evolve over time, clients SHOULD be prepared for any term to be applied +to any model element and SHOULD be prepared to handle unknown values +within the list of model constructs. Applicability is expressed using +the following symbolic values: + +Symbolic Value|Model Element +--------------|------------- +`Action` |Action +`ActionImport` |Action Import +`Annotation` |Annotation +`Apply` |Application of a client-side function in an annotation +`Cast` |Type Cast annotation expression +`Collection` |Entity Set or collection-valued Property or Navigation Property +`ComplexType` |Complex Type +`EntityContainer` |Entity Container +`EntitySet` |Entity Set +`EntityType` |Entity Type +`EnumType` |Enumeration Type +`Function` |Function +`FunctionImport` |Function Import +`If` |Conditional annotation expression +`Include` |Reference to an Included Schema +`IsOf` |Type Check annotation expression +`LabeledElement` |Labeled Element expression +`Member` |Enumeration Member +`NavigationProperty` |Navigation Property +`Null` |Null annotation expression +`OnDelete` |On-Delete Action of a navigation property +`Parameter` |Action of Function Parameter +`Property` |Property of a structured type +`PropertyValue` |Property value of a Record annotation expression +`Record` |Record annotation expression +`Reference` |Reference to another CSDL document +`ReferentialConstraint` |Referential Constraint of a navigation property +`ReturnType` |Return Type of an Action or Function +`Schema` |Schema +`Singleton` |Singleton +`Term` |Term +`TypeDefinition` |Type Definition +`UrlRef` |UrlRef annotation expression + +::: {.varjson .rep} +### ##subisec `$AppliesTo` + +The value of `$AppliesTo` is an array whose items are strings containing +symbolic values from the table above that identify model elements the +term is intended to be applied to. +::: + +::: {.varjson .example} +Example ##ex: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData-VocCore](#ODataVocCore)) +```json +"IsURL": { + "$Kind": "Term", + "$Type": "Core.Tag", + "$DefaultValue": true, + "$AppliesTo": [ + "Property" + ], + "@Core.Description": "Properties and terms annotated with this term +MUST contain a valid URL", + "@Core.RequiresType": "Edm.String" +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `AppliesTo` + +The value of `AppliesTo` is a whitespace-separated list of symbolic +values from the table above that identify model elements the term is +intended to be applied to. +::: + +::: {.varxml .example} +Example ##ex: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData-VocCore](#ODataVocCore)) +```xml + + + + Properties and terms annotated with this term MUST contain a valid URL + + + + +``` +::: + +## ##subsec Annotation + +An annotation applies a [term](#Term) to a model element and defines how +to calculate a value for the term application. Both term and model +element MUST be in scope. Section 14.1.2 specifies which model elements +MAY be annotated with a term. + +The value of an annotation is specified as an *annotation expression*, +which is either a [constant expression](#ConstantExpression) +representing a constant value, or a [dynamic +expression](#DynamicExpression). The most common construct for assigning +an annotation value is a [path expression](#ValuePath) that refers to a +property of the same or a related structured type. + +::: {.varjson .rep} +### ##isec Annotation Member + +An annotation is represented as a member whose name consists of an at +(`@`) character, followed by the qualified name of a term, optionally +followed by a hash (`#`) and a [qualifier](#Qualifier). + +The value of the annotation MUST be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +The annotation can be a member of the object representing the model +element it annotates, or a second-level member of the +[`$Annotations`](#AnnotationswithExternalTargeting) member of a schema +object. + +An annotation can itself be annotated. Annotations on annotations are +represented as a member whose name consists of the annotation name +(including the optional qualifier), followed by an at (`@`) character, +followed by the qualified name of a term, optionally followed by a hash +(`#`) and a [qualifier](#Qualifier). +::: + +::: {.varjson .example} +Example ##ex: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value +```json +"AmountInReportingCurrency": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Scale": 0, + "@Measures.ISOCurrency": "USD", + "@Measures.ISOCurrency@Core.Description": "The parent company's currency" +}, +"AmountInTransactionCurrency": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Scale": 0, + "@Measures.ISOCurrency": { + "$Path": "Currency" + } +}, +"Currency": { + "$Nullable": true, + "$MaxLength": 3 +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:Annotation` + +The `edm:Annotation` element MUST contain the attribute `Term`, and it +MAY contain the attribute [`Qualifier`](#Qualifier). + +The value of the annotation MAY be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +If no expression is specified for a term with a primitive type, the +annotation evaluates to the [default value](#DefaultValue) of the term +definition. If no expression is specified for a term with a complex +type, the annotation evaluates to a complex instance with default values +for its properties. If no expression is specified for a +collection-valued term, the annotation evaluates to an empty collection. + +An `edm:Annotation` element can be used as a child of the model element +it annotates, or as the child of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element that +targets the model element to be annotated. + +An `edm:Annotation` element MAY contain [`edm:Annotation`](#Annotation) +elements that annotate the annotation. + +### ##subisec Attribute `Term` + +The value of `Term` is the qualified name of a [term](#Term) in scope. +::: + +::: {.varxml .example} +Example ##ex: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value +```xml + + + + + + + + + +``` +::: + +If an entity type or complex type is annotated with a term that itself +has a structured type, an instance of the annotated type may be viewed +as an "instance" of the term, and the qualified term name may be used as +a [term-cast segment](#TermCast) in path expressions. + +Structured types "inherit" annotations from their direct or indirect +base types. If both the type and one of its base types is annotated with +the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or +collection-valued annotation values are not merged. Similarly, +properties of a structured type inherit annotations from identically +named properties of a base type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a "Label" +annotation for a UI can propagate from a type definition to all +properties using that type definition and may be overridden at each +property with a more specific label, whereas an annotation marking a +type definition as containing a phone number will propagate to all using +properties but may not be overridden. + +### ##subsubsec Qualifier + +A term can be applied multiple times to the same model element by +providing a qualifier to distinguish the annotations. The qualifier is a +[simple identifier](#SimpleIdentifier). + +The combination of target model element, term, and qualifier uniquely +identifies an annotation. + +::: {.varjson .example} +Example ##ex: annotation should only be applied to tablet devices +```json +"@UI.DisplayName#Tablet": { + "$Path": "FirstName" +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `Qualifier` + +Annotation elements that are children of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element MUST NOT +provide a value for the qualifier attribute if the parent +[`edm:Annotations`](#AnnotationswithExternalTargeting) element provides +a value for the qualifier attribute. +::: + +::: {.varxml .example} +Example ##ex: annotation should only be applied to tablet devices +```xml + +``` +::: + +### ##subsubsec Target + +The target of an annotation is the model element the term is applied to. + +The target of an annotation MAY be specified indirectly by "nesting" the +annotation within the model element. Whether and how this is possible is +described per model element in this specification. + +The target of an annotation MAY also be specified directly; this allows +defining an annotation in a different schema than the targeted model +element. + +This external targeting is only possible for model elements that are +uniquely identified within their parent, and all their ancestor elements +are uniquely identified within their parent: + +- [Action](#Action) (single or all overloads) +- [Action Import](#ActionImport) +- [Complex Type](#ComplexType) +- [Entity Container](#EntityContainer) +- [Entity Set](#EntitySet) +- [Entity Type](#EntityType) +- [Enumeration Type](#EnumerationType) +- [Enumeration Type Member](#EnumerationTypeMember) +- [Function](#Function) (single or all overloads) +- [Function Import](#FunctionImport) +- [Navigation Property](#NavigationProperty) (via type, entity set, or + singleton) +- [Parameter](#Parameter) of an action or function (single overloads + or all overloads defining the + parameter) +- [Property](#StructuralProperty) (via type, entity set, or singleton) +- [Return Type](#ReturnType) of an action or function (single or all + overloads) +- [Singleton](#Singleton) +- [Type Definition](#TypeDefinition) + +These are the direct children of a schema with a unique name (i.e. +except actions and functions whose overloads to not possess a natural +identifier), and all direct children of an entity container. + +External targeting is possible for actions, functions, their parameters, +and their return type, either in a way that applies to all overloads of +the action or function or all parameters of that name across all +overloads, or in a way that identifies a single overload. + +External targeting is also possible for properties and navigation +properties of singletons or entities in a particular entity set. These +annotations override annotations on the properties or navigation +properties targeted via the declaring structured type. + +The allowed path expressions are: +- [qualified name](#QualifiedName) +of schema child +- [qualified +name](#QualifiedName) of schema child followed by a forward slash and +name of child element +- [qualified +name](#QualifiedName) of structured type followed by zero or more +property, navigation property, or type-cast segments, each segment +starting with a forward slash +- [qualified name](#QualifiedName) +of an entity container followed by a segment containing a singleton or +entity set name and zero or more property, navigation property, or +type-cast segments +- [qualified +name](#QualifiedName) of an action followed by parentheses containing +the [qualified name](#QualifiedName) of the binding parameter *type* of +a bound action overload to identify that bound overload, or by empty +parentheses to identify the unbound overload +- [qualified name](#QualifiedName) of a +function followed by parentheses containing the comma-separated list of +[qualified names](#QualifiedName) of the parameter *types* of a bound +or unbound function overload in the order of their definition in the +function overload +- [qualified +name](#QualifiedName) of an action or function, optionally followed by +parentheses as described in the two previous bullet points to identify a +single overload, followed by a forward slash and either a parameter name +or `$ReturnType` +- [qualified +name](#QualifiedName) of an entity container followed by a segment +containing an action or function import name, optionally followed by a +forward slash and either a parameter name or `$ReturnType` + +- One of the preceding, followed by a forward slash, an at (`@`), the + [qualified name](#QualifiedName) of a term, and optionally a hash + (`#`) and the qualifier of an + annotation + +All [qualified names](#QualifiedName) used in a target path MUST be in +scope. + +::: example +Example ##ex: Target expressions +``` +MySchema.MyEntityType +MySchema.MyEntityType/MyProperty +MySchema.MyEntityType/MyNavigationProperty +MySchema.MyComplexType +MySchema.MyComplexType/MyProperty +MySchema.MyComplexType/MyNavigationProperty +MySchema.MyEnumType +MySchema.MyEnumType/MyMember +MySchema.MyTypeDefinition +MySchema.MyTerm +MySchema.MyEntityContainer +MySchema.MyEntityContainer/MyEntitySet +MySchema.MyEntityContainer/MySingleton +MySchema.MyEntityContainer/MyActionImport +MySchema.MyEntityContainer/MyFunctionImport +MySchema.MyAction +MySchema.MyAction(MySchema.MyBindingType) +MySchema.MyAction() +MySchema.MyFunction +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType) +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType) +MySchema.MyFunction/MyParameter +MySchema.MyEntityContainer/MyEntitySet/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty +``` +::: + +## ##subsec Constant Expression + +Constant expressions allow assigning a constant value to an applied +term. + +### ##subsubsec Binary + +::: {.varjson .rep} +Binary expressions are represented as a string containing the +base64url-encoded binary value. +::: + +::: {.varjson .example} +Example ##ex: base64url-encoded binary value (OData) +```json +"@UI.Thumbnail": "T0RhdGE" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Binary` + +The `edm:Binary` expression evaluates to a primitive binary value. A +binary expression MUST be assigned a value conforming to the rule +`binaryValue` in [OData-ABNF](#ODataABNF). + +The binary expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: base64url-encoded binary value (OData) +```xml + + + + T0RhdGE + +``` +::: + +### ##subsubsec Boolean + +::: {.varjson .rep} +Boolean expressions are represented as the literals `true` or `false`. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.ReadOnly": true +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Bool` + +The `edm:Bool` expression evaluates to a primitive Boolean value. A +Boolean expression MUST be assigned a Boolean value. + +The Boolean expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + true + +``` +::: + +### ##subsubsec Date + +::: {.varjson .rep} +Date expressions are represented as a string containing the date value. +The value MUST conform to type `xs:date`, see +[XML-Schema-2](#XML-Schema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData-ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@vCard.birthDay": "2000-01-01" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Date` + +The `edm:Date` expression evaluates to a primitive date value. A date +expression MUST be assigned a value of type `xs:date`, see +[XML-Schema-2](#XML-Schema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData-ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. + +The date expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + 2000-01-01 + +``` +::: + +### ##subsubsec DateTimeOffset + +::: {.varjson .rep} +Datetimestamp expressions are represented as a string containing the +timestamp value. The value MUST conform to type `xs:dateTimeStamp`, see +[XML-Schema-2](#XML-Schema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData-ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.LastUpdated": "2000-01-01T16:00:00.000Z" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:DateTimeOffset` + +The `edm:DateTimeOffset` expression evaluates to a primitive +datetimestamp value with a time-zone offset. A datetimestamp expression +MUST be assigned a value of type `xs:dateTimeStamp`, see +[XML-Schema-2](#XML-Schema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData-ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). + +The datetimestamp expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + 2000-01-01T16:00:00.000-09:00 + +``` +::: + +### ##subsubsec Decimal + +::: {.varjson .rep} +Decimal expressions are represented as either a number or a string. The +special values `INF`, `-INF`, or `NaN` are represented as strings. +Numeric values are represented as numbers or strings depending on the +media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumbers). +::: + +::: {.varjson .example} +Example ##ex: default representation as a number +```json +"@UI.Width": 3.14 +``` +::: + +::: {.varjson .example} +Example ##ex: "safe" representation as a string +```json +"@UI.Width": "3.14" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Decimal` + +The `edm:Decimal` expression evaluates to a primitive decimal value. A +decimal expression MUST be assigned a value conforming to the rule +`decimalValue` in [OData-ABNF](#ODataABNF). + +The decimal expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .rep} +Example ##ex: attribute notation +```xml + +``` +::: + +::: {.varxml .example} +Example ##ex: element notation +```xml + + 3.14 + +``` +::: + +### ##subsubsec Duration + +::: {.varjson .rep} +Duration expressions are represented as a string containing the duration +value. The value MUST conform to type `xs:dayTimeDuration`, see +[XML-Schema-2](#XML-Schema2), [section +3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). +::: + +::: {.varjson .example} +Example ##ex: +```json +"@task.duration": "P7D" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Duration` + +The `edm:Duration` expression evaluates to a primitive duration value. A +duration expression MUST be assigned a value of type +`xs:dayTimeDuration`, see [XML-Schema-2](#XML-Schema2), +[section 3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). + +The duration expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + P11DT23H59M59.999999999999S + +``` +::: + +### ##subsubsec Enumeration Member + +::: {.varjson .rep} +Enumeration member expressions are represented as a string containing +the numeric or symbolic enumeration value. +::: + +::: {.varjson .example} +Example ##ex: single value `Red` with numeric value and symbolic value +```json +"@self.HasPattern": "1" +``` + +```json +"@self.HasPattern": "Red" +``` +::: + +::: {.varjson .example} +Example ##ex: combined value `Red,Striped` with numeric value 1 + 16 and +symbolic value +```json +"@self.HasPattern": "17" +``` + +```json +"@self.HasPattern": "Red,Striped" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:EnumMember` + +The `edm:EnumMember` expression references a +[member](#EnumerationTypeMember) of an [enumeration +type](#EnumerationType). An enumeration member expression MUST be +assigned a value that consists of the qualified name of the enumeration +type, followed by a forward slash and the name of the enumeration +member. If the enumeration type specifies an `IsFlags` attribute with +value `true`, the expression MAY also be assigned a whitespace-separated +list of values. Each of these values MUST resolve to the name of a +member of the enumeration type of the specified term. + +The enumeration member expression MAY be provided using element notation +or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: single value +```xml + + + + org.example.Pattern/Red + +``` +::: + +::: {.varxml .example} +Example ##ex: combined value for `IsFlags` enumeration type +```xml + + + + org.example.Pattern/Red org.example.Pattern/Striped + +``` +::: + +### ##subsubsec Floating-Point Number + +::: {.varjson .rep} +Floating-point expressions are represented as a number or as a string +containing one of the special values `INF`, `-INF`, or `NaN`. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.FloatWidth": 3.14 +``` + +```json +"@UI.FloatWidth": "INF" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Float` + +The `edm:Float` expression evaluates to a primitive floating point (or +double) value. A float expression MUST be assigned a value conforming to +the rule `doubleValue` in [OData-ABNF](#ODataABNF). + +The float expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + 3.14 + +``` +::: + +### ##subsubsec Guid + +::: {.varjson .rep} +Guid expressions are represented as a string containing the uuid value. +The value MUST conform to the rule `guidValue` in +[OData-ABNF](#ODataABNF). +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.Id": "21EC2020-3AEA-1069-A2DD-08002B30309D" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Guid` + +The `edm:Guid` expression evaluates to a primitive guid value. A guid +expression MUST be assigned a value conforming to the rule `guidValue` +in [OData-ABNF](#ODataABNF). + +The guid expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + 21EC2020-3AEA-1069-A2DD-08002B30309D + +``` +::: + +### ##subsubsec Integer + +::: {.varjson .rep} +Integer expressions are represented as either a number or a string, +depending on the media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumbers). +::: + +::: {.varjson .example} +Example ##ex: default representation as a number +```json +"@An.Int": 42 +``` +::: + +::: {.varjson .example} +Example ##ex: "safe" representation as a string +```json +"@A.Very.Long.Int": "9007199254740992" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Int` + +The `edm:Int` expression evaluates to a primitive integer value. An +integer MUST be assigned a value conforming to the rule `int64Value` in +[OData-ABNF](#ODataABNF). + +The integer expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: attribute notation +```xml + +``` +::: + +::: {.varxml .example} +Example ##ex: element notation +```xml + + 42 + +``` +::: + +### ##subsubsec String + +::: {.varjson .rep} +String expressions are represented as a JSON string. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.DisplayName": "Product Catalog" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:String` + +The `edm:String` expression evaluates to a primitive string value. A +string expression MUST be assigned a value of the type `xs:string`, see +[XML-Schema-2](#XML-Schema2), [section +3.3.1](http://www.w3.org/TR/xmlschema11-2/#string). + +The string expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + Product Catalog + +``` +::: + +### ##subsubsec Time of Day + +::: {.varjson .rep} +Time-of-day expressions are represented as a string containing the +time-of-day value. The value MUST conform to the rule `timeOfDayValue` +in [OData-ABNF](#ODataABNF). +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.EndTime": "21:45:00" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:TimeOfDay` + +The `edm:TimeOfDay` expression evaluates to a primitive time value. A +time-of-day expression MUST be assigned a value conforming to the rule +`timeOfDayValue` in [OData-ABNF](#ODataABNF). + +The time-of-day expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + 21:45:00 + +``` +::: + +## ##subsec Dynamic Expression + +Dynamic expressions allow assigning a calculated value to an applied +term. + +### ##subsubsec Path Expressions + +Path expressions allow assigning a value to an applied term or term +component. There are two kinds of path expressions: +- A *model path* is used within +[Annotation Path](#AnnotationPath), [Model Element Path](#ModelElementPath), +[Navigation Property Path](#NavigationPropertyPath), and [Property +Path](#PropertyPath) expressions to traverse the model of a service and +resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) `Edm.AnnotationPath`, +`Edm.NavigationPropertyPath`, `Edm.PropertyPath`, and their base types +`Edm.AnyPropertyPath` and `Edm.ModelElementPath`. +- An *instance path* is used within a +[Value Path](#ValuePath) expression to traverse a graph of type +instances and resolves to the value identified by the path. It allows +assigning values to terms or term properties of built-in types other +than the `Edm.*Path` types, or of any model-defined type. + +#### ##subsubsubsec Path Syntax + +Model paths and instance paths share a common syntax which is derived +from the path expression syntax of URLs, see [OData-URL](#ODataURL). + +A path MUST be composed of zero or more path segments joined together by +forward slashes (`/`). + +Paths starting with a forward slash (`/`) are absolute paths, and the +first path segment MUST be the qualified name of a model element, e.g. +an entity container. The remaining path after the second forward slash +is interpreted relative to that model element. + +::: example +Example ##ex: absolute path to an entity set +``` +/My.Schema.MyEntityContainer/MyEntitySet +``` +::: + +Paths not starting with a forward slash are interpreted relative to the +annotation target, following the rules specified in section "[Path +Evaluation](#PathEvaluation)". + +::: example +Example ##ex: relative path to a property +``` +Address/City +``` +::: + +If a path segment is a [qualified name](#QualifiedName), it represents a +*type cast*, and the segment MUST be the name of a type +in scope. If the type or instance identified by the preceding path part +cannot be cast to the specified type, the path expression evaluates to +the null value. + +::: example +Example ##ex: type-cast segment +``` +.../self.Manager/... +``` +::: + +If a path segment starts with an at (`@`) character, it represents a +*term cast*. The at (`@`) character MUST be followed by +a [qualified name](#QualifiedName) that MAY be followed by a hash (`#`) +character and a [simple identifier](#SimpleIdentifier). The [qualified +name](#QualifiedName) preceding the hash character MUST resolve to a +term that is in scope, the [simple identifier](#SimpleIdentifier) +following the hash sign is interpreted as a [qualifier](#Qualifier) for +the term. If the model element or instance identified by the preceding +path part has not been annotated with that term (and if present, with +that qualifier), the term cast evaluates to the null value. Four special +terms are implicitly "annotated" for media entities and stream +properties: + +- `odata.mediaEditLink` +- `odata.mediaReadLink` +- `odata.mediaContentType` +- `odata.mediaEtag` + +::: example +Example ##ex: term-cast segments +``` +.../@Capabilities.SortRestrictions/... +``` +::: + +If a path segment is a [simple identifier](#SimpleIdentifier), it MUST +be the name of a child model element of the model element identified by +the preceding path part, or a structural or navigation property of the +instance identified by the preceding path part. A sequence of navigation +segments can traverse multiple CSDL documents. The document containing +the path expression only needs to reference the next traversed document +to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document. + +A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path. + +::: example +Example ##ex: property segments in model path +``` +.../Orders/Items/Product/... +``` +::: + +An instance path MUST NOT contain more than one segment representing a +collection-valued construct, e.g. an entity set or a collection-valued +navigation property that is not followed by a key predicate, or a +collection-valued structural property that is not followed by an index +segment. The result of the expression is the collection of instances +resulting from applying any remaining path segments that operate on a +single-valued expression to each instance in the collection-valued +segment. + +An instance path MAY terminate in a `$count` segment if the previous +segment is collection-valued, in which case the path evaluates to the +number of items in the collection identified by the preceding segment. + +::: example +Example ##ex: property segments in instance path +``` +.../Addresses/Street +``` + +``` +.../Addresses/$count +``` +::: + +A model path MAY contain path segments starting with a navigation +property, then followed by an at (`@`) character, then followed by the +[qualified name](#QualifiedName) of a term in scope, and optionally +followed by a hash (`#`) character and a [simple +identifier](#SimpleIdentifier) which is interpreted as a +[qualifier](#Qualifier) for the term. If the navigation property has not +been annotated with that term (and if present, with that qualifier), the +path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity +type specified by the navigation property are addressed via a [term-cast +segment](#TermCast). + +::: example +Example ##ex: model path addressing an annotation on a navigation property +``` +.../Items@Capabilities.InsertRestrictions/Insertable +``` +::: + +An instance path MAY contain path segments starting with an entity set +or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see +[OData-URL](#ODataURL). The key values are either primitive literals or +instance paths. If the key value is a relative instance path, it is +interpreted according to the same rule below as the instance path it is +part of, *not* relative to the instance identified by the preceding path +part. + +::: example +Example ##ex: instance path with entity set and key predicate +``` +/self.container/SettingsCollection('FeatureXxx')/IsAvailable +``` + +``` +/self.container/Products(ID=ProductID)/Name +``` +::: + +An instance path MAY contain an index segment immediately following a +path segment representing an ordered collection-valued structural +property. The index is zero-based and MUST be an integer literal. +Negative integers count from the end of the collection, with -1 +representing the last item in the collection. Remaining path segments +are evaluated relative to the identified item of the collection. + +::: example +Example ##ex: instance path with collection-valued structural property and +index segment +``` +Addresses/1 +``` + +``` +Addresses/-1/Street +``` +::: + +#### ##subsubsubsec Path Evaluation + +Annotations MAY be embedded within their target, or specified +separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as +*targeting* in the remainder of this section. + +For annotations embedded within or targeting an entity container, the +path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a +segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules +for paths targeting the corresponding child element. + +For annotations embedded within or targeting an entity set or a +singleton, the path is evaluated starting at the entity set or +singleton, i.e. an empty path resolves to the entity set or singleton, +and non-empty paths MUST follow the rules for annotations targeting the +declared entity type of the entity set or singleton. + +For annotations embedded within or targeting an entity type or complex +type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be +a structural or navigation property of the type, a [type +cast](#TypeCast), or a [term cast](#TermCast). + +For annotations embedded within a structural or navigation property of +an entity type or complex type, the path is evaluated starting at the +directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other +properties of the same type. An empty path resolves to the enclosing +type, and non-empty paths MUST follow the rules for annotations +targeting the directly enclosing type. + +For annotations targeting a structural or navigation property of an +entity type or complex type, the path is evaluated starting at the +*outermost* entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the +first segment of a non-empty path MUST be a structural or navigation +property of the outermost type, a [type cast](#TypeCast), or a [term +cast](#TermCast). + +For annotations embedded within or targeting an action, action import, +function, function import, parameter, or return type, the first segment +of the path MUST be a parameter name or `$ReturnType`. + +#### ##subsubsubsec Annotation Path + +The annotation path expression provides a value for terms or term +properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.AnnotationPath or Edm.ModelElementPath`. Its argument is a [model +path](#PathExpressions) with the following restriction: +- A non-null path MUST resolve to an annotation. + +A term or term property of type `Edm.AnnotationPath` can be annotated +with term `Validation.AllowedTerms` (see +[OData-VocValidation](#ODataVocValidation)) if its intended value is an +annotation path that ends in a term cast with one of the listed terms. + +The value of the annotation path expression is the path itself, not the +value of the annotation identified by the path. This is useful for terms +that reuse or refer to other terms. + +::: {.varjson .rep} +Annotation path expressions are represented as a string containing a +path. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.ReferenceFacet": "Product/Supplier/@UI.LineItem", +"@UI.CollectionFacet#Contacts": [ + "Supplier/@Communication.Contact", + "Customer/@Communication.Contact" +] +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:AnnotationPath` + +The `edm:AnnotationPath` expression MAY be provided using element +notation or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + Supplier/@Communication.Contact + Customer/@Communication.Contact + + +``` +::: + +#### ##subsubsubsec Model Element Path + +The model element path expression provides a value for terms or term +properties that specify the [built-in +type](#BuiltInTypesfordefiningVocabularyTerms)` Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions). + +The value of the model element path expression is the path itself, not +the instance(s) identified by the path. + +::: {.varjson .rep} +Model element path expressions are represented as a string containing a +path. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@org.example.MyFavoriteModelElement": "/self.someAction" +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:ModelElementPath` + +The `edm:ModelElementPath` expression MAY be provided using element +notation or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + /org.example.someAction + +``` +::: + +#### ##subsubsubsec Navigation Property Path + +The navigation property path expression provides a value for terms or +term properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. +Its argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is an entity type, or a collection of entity types, +e.g. a navigation property. + +The value of the navigation property path expression is the path itself, +not the entitiy or collection of entities identified by the path. + +::: {.varjson .rep} +Navigation property path expressions are represented as a string +containing a path. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.HyperLink": "Supplier", + +"@Capabilities.UpdateRestrictions": { + "NonUpdatableNavigationProperties": [ + "Supplier", + "Category" + ] +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:NavigationPropertyPath` + +The `edm:NavigationPropertyPath` expression MAY be provided using +element notation or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + + + Supplier + Category + + + + +``` +::: + +#### ##subsubsubsec Property Path + +The property path expression provides a value for terms or term +properties that specify one of the [built-in +types](#BuiltInTypesfordefiningVocabularyTerms) +`Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is a primitive or complex type, an enumeration type, +a type definition, or a collection of one of these types. + +The value of the property path expression is the path itself, not the +value of the structural property or the value of the term cast +identified by the path. + +::: {.varjson .rep} +Property path expressions are represented as a string containing a path. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.RefreshOnChangeOf": "ChangedAt", + +"@Capabilities.UpdateRestrictions": { + "NonUpdatableProperties": [ + "CreatedAt", + "ChangedAt" + ] +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:PropertyPath` + +The `edm:PropertyPath` MAY be provided using either element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + + + CreatedAt + ChangedAt + + + + +``` +::: + +#### ##subsubsubsec Value Path + +The value path expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation +properties of structured types, and structural properties of structured +types. Its argument is an [instance path](#PathExpressions). + +The value of the path expression is the instance or collection of +instances identified by the path. + +::: {.varjson .rep} +### ##subisec `$Path` + +Path expressions are represented as an object with a single member +`$Path` whose value is a string containing a path. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.DisplayName": { + "$Path": "FirstName" +}, + +"@UI.DisplayName#second": { + "$Path": "@vCard.Address#work/FullName" +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Path` + +The `edm:Path` expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + @vCard.Address#work/FullName + +``` +::: + +### ##subsubsec Comparison and Logical Operators + +Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and +they MAY be used anywhere instead of a Boolean expression. + +Operator|Description +--------|----------- +**Logical Operators**| +`And` |Logical and +`Or` |Logical or +`Not` |Logical negation +**Comparison Operators**| +`Eq` |Equal +`Ne` |Not equal +`Gt` |Greater than +`Ge` |Greater than or equal +`Lt` |Less than +`Le` |Less than or equal +`Has` |Has enumeration flag(s) set +`In` |Is in collection + +The `And` and `Or` operators require two operand expressions that +evaluate to Boolean values. The `Not` operator requires a single operand +expression that evaluates to a Boolean value. For details on null +handling for comparison operators see [OData-URL](#ODataURL). + +The other comparison operators require two operand expressions that +evaluate to comparable values. + +::: {.varjson .rep} +### ##subisec `$And` +and ##subisec `$Or` + +The `And` and `Or` logical expressions are represented as an object with +a single member whose value is an array with two annotation expressions. +The member name is one of `$And`, or `$Or`. + +It MAY contain [annotations](#Annotation). + +### ##subisec `$Not` + +Negation expressions are represented as an object with a single member +`$Not` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). + +### ##subisec `$Eq`, + ##subisec `$Ne`, + ##subisec `$Gt`, + ##subisec `$Ge`, + ##subisec `$Lt`, + ##subisec `$Le`, + ##subisec `$Has`, +and ##subisec `$In` + +All comparison expressions are represented as an object with a single +member whose value is an array with two annotation expressions. The +member name is one of `$Eq`, `$Ne`, `$Gt`, `$Ge`, `$Lt`, `$Le`, `$Has`, +or `$In`. + +They MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: +```json +{ + "$And": [ + { + "$Path": "IsMale" + }, + { + "$Path": "IsMarried" + } + ] +}, +{ + "$Or": [ + { + "$Path": "IsMale" + }, + { + "$Path": "IsMarried" + } + ] +}, +{ + "$Not": { + "$Path": "IsMale" + } +}, +{ + "$Eq": [ + null, + { + "$Path": "IsMale" + } + ] +}, +{ + "$Ne": [ + null, + { + "$Path": "IsMale" + } + ] +}, +{ + "$Gt": [ + { + "$Path": "Price" + }, + 20 + ] +}, +{ + "$Ge": [ + { + "$Path": "Price" + }, + 10 + ] +}, +{ + "$Lt": [ + { + "$Path": "Price" + }, + 20 + ] +}, +{ + "$Le": [ + { + "$Path": "Price" + }, + 100 + ] +}, +{ + "$Has": [ + { + "$Path": "Fabric" + }, + "Red" + ] +}, +{ + "$In": [ + { + "$Path": "Size" + }, + [ + "XS", + "S" + ] + ] +} +``` +::: + +::: {.varxml .rep} +### ##isec Expressions `edm:And` +and ##subisec `edm:Or` + +The `And` and `Or` logical expressions are represented as elements +`edm:And` and `edm:Or` that MUST contain two annotation expressions. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##isec Expression `edm:Not` + +Negation expressions are represented as an element `edm:Not` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##isec Expressions `edm:Eq`, + ##subisec `edm:Ne`, + ##subisec `edm:Gt`, + ##subisec `edm:Ge`, + ##subisec `edm:Lt`, + ##subisec `edm:Le`, + ##subisec `edm:Has`, +and ##subisec `edm:In` + +All comparison expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + IsMale + IsMarried + + + IsMale + IsMarried + + + IsMale + + + + IsMale + + + + IsMale + + + Price + 20 + + + Price + 10 + + + Price + 20 + + + Price + 100 + + + Fabric + org.example.Pattern/Red + + + Size + + XS + S + + +``` +::: + +### ##subsubsec Arithmetic Operators + +Annotations MAY use the following arithmetic expressions which evaluate +to a numeric value. These expressions MAY be combined, and they MAY be +used anywhere instead of a numeric expression of the appropriate type. +The semantics and evaluation rules for each arithmetic expression is +identical to the corresponding arithmetic operator defined in +[OData-URL](#ODataURL). + +Operator|Description +--------|----------- +`Add` |Addition +`Sub` |Subtraction +`Neg` |Negation +`Mul` |Multiplication +`Div` |Division (with integer result for integer operands) +`DivBy` |Division (with fractional result also for integer operands) +`Mod` |Modulo + +The `Neg` operator requires a single operand expression that evaluates +to a numeric value. The other arithmetic operators require two operand +expressions that evaluate to numeric values. + +::: {.varjson .rep} +### ##subisec `$Neg` + +Negation expressions are represented as an object with a single member +`$Neg` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). + +### ##subisec `$Add`, + ##subisec `$Sub`, + ##subisec `$Mul`, + ##subisec `$Div`, + ##subisec `$DivBy`, +and ##subisec `$Mod` + +These arithmetic expressions are represented as an object with as single +member whose value is an array with two annotation expressions. The +member name is one of `$Add`, `$Sub`, `$Neg`, `$Mul`, `$Div`, `$DivBy`, +or `$Mod`. + +They MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: +```json +{ + "$Add": [ + { + "$Path": "StartDate" + }, + { + "$Path": "Duration" + } + ] +}, +{ + "$Sub": [ + { + "$Path": "Revenue" + }, + { + "$Path": "Cost" + } + ] +}, +{ + "$Neg": { + "$Path": "Height" + } +}, +{ + "$Mul": [ + { + "$Path": "NetPrice" + }, + { + "$Path": "TaxRate" + } + ] +}, +{ + "$Div": [ + { + "$Path": "Quantity" + }, + { + "$Path": "QuantityPerParcel" + } + ] +}, +{ + "$DivBy": [ + { + "$Path": "Quantity" + }, + { + "$Path": "QuantityPerParcel" + } + ] +}, +{ + "$Mod": [ + { + "$Path": "Quantity" + }, + { + "$Path": "QuantityPerParcel" + } + ] +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Neg` + +Negation expressions are represented as an element `edm:Neg` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##isec Expressions `edm:Add`, + ##subisec `edm:Sub`, + ##subisec `edm:Mul`, + ##subisec `edm:Div`, + ##subisec `edm:DivBy`, +and ##subisec `edm:Mod` + +These arithmetic expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + StartDate + Duration + + + Revenue + Cost + + + Height + + + NetPrice + TaxRate + +
    + Quantity + QuantityPerParcel +
    + + Quantity + QuantityPerParcel + + + Quantity + QuantityPerParcel + +``` +::: + +### ##subsubsec Apply Client-Side Functions + +The apply expression enables a value to be obtained by applying a +client-side function. The apply expression MAY have operand expressions. +The operand expressions are used as parameters to the client-side +function. + +::: {.varjson .rep} +### ##subisec `$Apply` + +Apply expressions are represented as an object with a member `$Apply` +whose value is an array of annotation expressions, and a member +`$Function` whose value is a string containing the [qualified +name](#QualifiedName) of the client-side function to be applied. + +It MAY contain [annotations](#Annotation). +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Apply` + +The `edm:Apply` element MUST contain the `Function` attribute and MAY +contain annotation expressions as operands for the applied function. + +It MAY contain more [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Function` + +The value of `Function` is the [qualified name](#QualifiedName) of the +client-side function to apply. +::: + +OData defines the following functions. Services MAY support additional +functions that MUST be qualified with a namespace other than `odata`. +Function names qualified with `odata` are reserved for this +specification and its future versions. + +#### ##subsubsubsec Canonical Functions + +All canonical functions defined in [OData-URL](#ODataURL) can be used as +client-side functions, qualified with the namespace `odata`. The +semantics of these client-side functions is identical to their +counterpart function defined in [OData-URL](#ODataURL). + +For example, the `odata.concat` client-side function takes two or more +expressions as arguments. Each argument MUST evaluate to a primitive or +enumeration type. It returns a value of type `Edm.String` that is the +concatenation of the literal representations of the results of the +argument expressions. Values of primitive types other than `Edm.String` +are represented according to the appropriate alternative in the +`primitiveValue` rule of [OData-ABNF](#ODataABNF), i.e. `Edm.Binary` as +`binaryValue`, `Edm.Boolean` as `booleanValue` etc. + +::: {.varjson .example} +Example ##ex: +```json +"@UI.DisplayName": { + "$Apply": [ + "Product: ", + { + "$Path": "ProductName" + }, + " (", + { + "$Path": "Available/Quantity" + }, + " ", + { + "$Path": "Available/Unit" + }, + " available)" + ], + "$Function": "odata.concat" +} +``` +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + Product: + ProductName + ( + Available/Quantity + + Available/Unit + available) + + +``` +::: + +`ProductName` is of type `String`, `Quantity` in complex type +`Available` is of type `Decimal`, and `Unit` in `Available` is of type +enumeration, so the result of the `Path` expression is represented as +the member name of the enumeration value. + +#### ##subsubsubsec Function `odata.fillUriTemplate` + +The `odata.fillUriTemplate` client-side function takes two or more +expressions as arguments and returns a value of type `Edm.String.` + +The first argument MUST be of type `Edm.String` and specifies a URI +template according to [RFC6570](#rfc6570), the other arguments MUST be +[labeled element expressions](#LabeledElement). Each [labeled element +expression](#LabeledElement) specifies the template parameter name as +its name and evaluates to the template parameter value. + +[RFC6570](#rfc6570) defines three kinds of template parameters: simple +values, lists of values, and key-value maps. + +Simple values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a single primitive value. +The literal representation of this value according to +[OData-ABNF](#ODataABNF) is used to fill the corresponding template +parameter. + +Lists of values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of primitive +values. + +Key-value maps are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of complex +types with two properties that are used in lexicographic order. The +first property is used as key, the second property as value. + +::: {.varjson .example} +Example ##ex: assuming there are no special characters in values of the +Name property of the Actor entity +```json +{ + "$Apply": [ + "http://host/someAPI/Actors/{actorName}/CV", + { + "$LabeledElement": { + "$Path": "Actor/Name" + }, + "$Name": "self.actorName" + } + ], + "$Function": "odata.fillUriTemplate" +} +``` +::: + +::: {.varxml .example} +Example ##ex: assuming there are no special characters in values of the +Name property of the Actor entity +```xml + + http://host/someAPI/Actors/{actorName}/CV + + +``` +::: + +#### ##subsubsubsec Function `odata.matchesPattern` + +The `odata.matchesPattern` client-side function takes two string +expressions as arguments and returns a Boolean value. + +The function returns true if the second expression evaluates to an +[ECMAScript](#_ECMAScript) (JavaScript) regular expression and +the result of the first argument expression matches that regular +expression, using syntax and semantics of +[ECMAScript](#_ECMAScript) regular expressions. + +::: {.varjson .example} +Example ##ex: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` +```json +{ + "$Apply": [ + { + "$Path": "FirstName" + }, + "^[^b-d]+$" + ], + "$Function": "odata.matchesPattern" +} +``` +::: + +::: {.varxml .example} +Example ##ex: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` +```xml + + FirstName + ^[^b-d]+$ + +``` +::: + +#### ##subsubsubsec Function `odata.uriEncode` + +The `odata.uriEncode `client-side function takes one argument of +primitive type and returns the URL-encoded OData literal that can be +used as a key value in OData URLs or in the query part of OData URLs. + +Note: string literals are surrounded by single quotes as required by the +paren-style key syntax. + +::: {.varjson .example} +Example ##ex: +```json +{ + "$Apply": [ + "http://host/service/Genres({genreName})", + { + "$LabeledElement": { + "$Apply": [ + { + "$Path": "NameOfMovieGenre" + } + ], + "$Function": "odata.uriEncode" + }, + "$Name": "self.genreName" + } + ], + "$Function": "odata.fillUriTemplate" +} +``` +::: + +::: {.varxml .example} +Example ##ex: +```xml + + http://host/service/Genres({genreName}) + + + NameOfMovieGenre + + + +``` +::: + +### ##subsubsec Cast + +The cast expression casts the value obtained from its single child +expression to the specified type. The cast expression follows the same +rules as the `cast` canonical function defined in +[OData-URL](#ODataURL). + +::: {.varjson .rep} +### ##subisec `$Cast` + +Cast expressions are represented as an object with a member `$Cast` +whose value is an annotation expression, a member `$Type` whose value is +a string containing the qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.Threshold": { + "$Cast": { + "$Path": "Average" + }, + "$Type": "Edm.Decimal" +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Cast` + +The `edm:Cast` element MUST contain the `Type` attribute and MUST +contain exactly one expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Type` + +The value of `Type` is a qualified type name in scope, or the character +sequence `Collection(` followed by the qualified name of a type in +scope, followed by a closing parenthesis `)`. + +If the specified type is a primitive type or a collection of a primitive +type, the facet attributes [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet attributes are not specified, their values +are considered unspecified. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + Average + + +``` +::: + +### ##subsubsec Collection + +The collection expression enables a value to be obtained from zero or +more item expressions. The value calculated by the collection expression +is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type +compatible. + +::: {.varjson .rep} +Collection expressions are represented as arrays with one array item per +item expression within the collection expression. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@seo.SeoTerms": [ + "Product", + "Supplier", + "Customer" +] +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Collection` + +The `edm:Collection` element contains zero or more child expressions. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + Product + Supplier + Customer + + +``` +::: + +### ##subsubsec If-Then-Else + +The if-then-else expression enables a value to be obtained by evaluating +a *condition expression*. It MUST contain exactly three child +expressions. There is one exception to this rule: if and only if the +if-then-else expression is an item of a collection expression, the third +child expression MAY be omitted, reducing it to an if-then expression. +This can be used to conditionally add an element to a collection. + +The first child expression is the condition and MUST evaluate to a +Boolean result, e.g. the [comparison and logical +operators](#ComparisonandLogicalOperators) can be used. + +The second and third child expressions are evaluated conditionally. The +result MUST be type compatible with the type expected by the surrounding +expression. + +If the first expression evaluates to `true`, the second expression MUST +be evaluated and its value MUST be returned as the result of the +if-then-else expression. If the first expression evaluates to `false` +and a third child element is present, it MUST be evaluated and its value +MUST be returned as the result of the if-then-else expression. If no +third expression is present, nothing is added to the surrounding +collection. + +::: {.varjson .rep} +### ##subisec `$If` + +Conditional expressions are represented as an object with a member `$If` +whose value is an array of two or three annotation expressions. + +It MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale`, whose value then determines +the value of the `$If` expression (or so it was long ago) +```json +"@person.Gender": { + "$If": [ + { + "$Path": "IsFemale" + }, + "Female", + "Male" + ] +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:If` + +The `edm:If` element MUST contain two or three child expressions that +MUST use element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example ##ex: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale`, whose value then determines +the value of the `edm:If` expression (or so it was long ago) +```xml + + + IsFemale + Female + Male + + +``` +::: + +### ##subsubsec Is-Of + +The `is-of` expression checks whether the value obtained from its single +child expression is compatible with the specified type. It returns +`true` if the child expression returns a type that is compatible with +the specified type, and `false` otherwise. + +::: {.varjson .rep} +### ##subisec `$IsOf` + +Is-of expressions are represented as an object with a member `$IsOf` +whose value is an annotation expression, a member `$Type` whose value is +a string containing an qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@Self.IsPreferredCustomer": { + "$IsOf": { + "$Path": "Customer" + }, + "$Type": "self.PreferredCustomer" +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:UrlRef` + +The `edm:UrlRef` expression MAY be provided using element notation or +attribute notation. + +Relative URLs are relative to the `xml:base` attribute, see +[XML-Base](#XML-Base). + +In element notation it MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + Customer + + +``` +::: + +### ##subsubsec Labeled Element + +The labeled element expression assigns a name to its single child +expression. The value of the child expression can then be reused +elsewhere with a [labeled element reference +expression](#LabeledElementReference). + +A labeled element expression MUST contain exactly one child expression. +The value of the child expression is also the value of the labeled +element expression. + +A labeled element expression MUST provide a [simple +identifier](#SimpleIdentifier) value as its name that MUST be unique +within the schema containing the expression. + +::: {.varjson .rep} +### ##subisec `$LabeledElement` + +Labeled element expressions are represented as an object with a member +`$LabeledElement` whose value is an annotation expression, and a member +`$Name` whose value is a string containing the labeled element's name. + +It MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.DisplayName": { + "$LabeledElement": { + "$Path": "FirstName" + }, + "$Name": "CustomerFirstName" +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:LabeledElement` + +The `edm:LabeledElement` element MUST contain the Name attribute. + +It MUST contain a child expression written either in attribute notation +or element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the labeled element's name. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + + + FirstName + + +``` +::: + +### ##subsubsec Labeled Element Reference + +The labeled element reference expression MUST specify the [qualified +name](#QualifiedName) of a [labeled element expression](#LabeledElement) +in scope and returns the value of the identified labeled element +expression as its value. + +::: {.varjson .rep} +### ##subisec `$LabeledElementReference` + +Labeled element reference expressions are represented as an object with +a member `$LabeledElementReference` whose value is a string containing +an qualified name. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.DisplayName": { + "$LabeledElementReference": "self.CustomerFirstName" +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:LabeledElementReference` + +The `edm:LabeledElementReference` element MUST contain the qualified name +of a labeled element expression in its body. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + Model.CustomerFirstName + +``` +::: + +### ##subsubsec Null + +The null expression indicates the absence of a value. The null +expression MAY be annotated. + +::: {.varjson .rep} +Null expressions that do not contain annotations are represented as the +literal `null`. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.DisplayName": null, +``` +::: + +::: {.varjson .rep} +### ##subisec `$Null` + +Null expression containing [annotations](#Annotations) are represented +as an object with a member `$Null` whose value is the literal `null`. +::: + +::: {.varjson .example} +Example ##ex: +```json +"@UI.Address": { + "$Null": null, + "@self.Reason": "Private" +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Null` + +The `edm:Null` element MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + +``` +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + +``` +::: + +### ##subsubsec Record + +The record expression enables a new entity type or complex type instance +to be constructed. + +A record expression MAY specify the structured type of its result, which +MUST be an entity type or complex type in scope. If not explicitly +specified, the type is derived from the expression's context. + +A record expression contains zero or more property value expressions. +For each single-valued structural or navigation property of the record +expression's type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if +the record expression is the value of an annotation for a term that has +a [base term](#SpecializedTerm) whose type is structured and directly or +indirectly inherits from the type of its base term. In this case, +property values that already have been specified in the annotation for +the base term or its base term etc. need not be specified again. + +For collection-valued properties the absence of a property value +expression is equivalent to specifying an empty collection as its value. + +::: {.varjson .rep} +Record expressions are represented as objects with one member per +property value expression. The member name is the property name, and the +member value is the property value expression. + +The type of a record expression is represented as the `@type` control +information, see [OData-JSON](#ODataJSON). + +It MAY contain [annotations](#Annotation) for itself and its members. +Annotations for record members are prefixed with the member name. +::: + +::: {.varjson .example} +Example ##ex: this annotation "morphs" the entity type from [example ##entitytype] into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service +```json +"@person.Employee": { + "@type": "https://example.org/vocabs/person#org.example.person.Manager", + "@Core.Description": "Annotation on record", + "GivenName": { + "$Path": "FirstName" + }, + "GivenName@Core.Description": "Annotation on record member", + "Surname": { + "$Path": "LastName" + }, + "DirectSupervisor": { + "$Path": "Manager" + }, + "CostCenter": { + "$UrlRef": { + "$Apply": [ + "http://host/anotherservice/CostCenters('{ccid}')", + { + "$LabeledElement": { + "$Path": "CostCenterID" + }, + "$Name": "ccid" + } + ], + "$Function": "odata.fillUriTemplate" + } + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:Record` + +The `edm:Record` element MAY contain the `Type` attribute and MAY +contain `edm:PropertyValue` elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Type` + +The value of `Type` is the qualified name of a structured type in scope. + +### ##isec Element `edm:PropertyValue` + +The `edm:PropertyValue` element MUST contain the `Property` attribute, +and it MUST contain exactly one expression that MAY be provided using +either element notation or attribute notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Property` + +The value of `Property` is the name of a property of the type of the +enclosing `edm:Record` expression. +::: + +::: {.varxml .example} +Example ##ex: this annotation "morphs" the entity type from [example ##entitytype] into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service +```xml + + + + + + + + + + + + http://host/anotherservice/CostCenters('{ccid}') + + + + + + +``` +::: + +### ##subsubsec URL Reference + +The URL reference expression enables a value to be obtained by sending a +`GET` request. + +The URL reference expression MUST contain exactly one expression of type +`Edm.String`. Its value is treated as a URL that MAY be relative or +absolute; relative URLs are relative to the URL of the document +containing the URL reference expression, or relative to a base URL +specified in a format-specific way. + +The response body of the `GET` request MUST be returned as the result of +the URL reference expression. The result of the URL reference +expression MUST be type compatible with the type expected by the +surrounding expression. + +::: {.varjson .rep} +### ##subisec `$UrlRef` + +URL reference expressions are represented as an object with a single +member `$UrlRef` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: +```json +"@org.example.person.Supplier": { + "$UrlRef": { + "$Apply": [ + "http://host/service/Suppliers({suppID})", + { + "$LabeledElement": { + "$Apply": [ + { + "$Path": "SupplierId" + } + ], + "$Function": "odata.uriEncode" + }, + "$Name": "suppID" + } + ], + "$Function": "odata.fillUriTemplate" + } +}, + +"@Core.LongDescription#element": { + "$UrlRef": "http://host/wiki/HowToUse" +} +``` +::: + +::: {.varxml .rep} +### ##isec Expression `edm:UrlRef` + +The `edm:UrlRef` expression MAY be provided using element notation or +attribute notation. + +Relative URLs are relative to the `xml:base` attribute, see +[XML-Base](#XML-Base). + +In element notation it MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + http://host/service/Suppliers({suppID}) + + + SupplierId + + + + + + + + http://host/wiki/HowToUse + + + +``` +::: diff --git a/odata-csdl/15 Identifier and Path Values.md b/odata-csdl/15 Identifier and Path Values.md new file mode 100644 index 000000000..243dc8dd1 --- /dev/null +++ b/odata-csdl/15 Identifier and Path Values.md @@ -0,0 +1,571 @@ +------- + +# ##sec Identifier and Path Values + +## ##subsec Namespace + +A namespace is a dot-separated sequence of [simple +identifier](#SimpleIdentifier)s with a maximum length of 511 Unicode +characters (code points). + +## ##subsec Simple Identifier + +A simple identifier is a Unicode character sequence with the following +restrictions: + +- It consists of at least one and at most 128 Unicode characters (code + points). +- The first character MUST be the underscore character (U+005F) or any + character in the Unicode category "Letter (L)" or "Letter number + (Nl)". +- The remaining characters MUST be the underscore character (U+005F) + or any character in the Unicode category "Letter (L)", "Letter + number (Nl)", "Decimal number (Nd)", "Non-spacing mark (Mn)", + "Combining spacing mark (Mc)", "Connector punctuation (Pc)", and + "Other, format (Cf)". + +Non-normatively speaking it starts with a letter or underscore, followed +by at most 127 letters, underscores or digits. + +## ##subsec Qualified Name + +For model elements that are direct children of a schema: the namespace +or alias of the schema that defines the model element, followed by a dot +and the name of the model element, see rule `qualifiedTypeName` in +[OData‑ABNF](#ODataABNF). + +For built-in [primitive types](#PrimitiveTypes): the name of the type, +prefixed with `Edm` followed by a dot. + +## ##subsec Target Path + +Target paths are used to refer to other model elements. + +The allowed path expressions are: +- The [qualified +name](#QualifiedName) of an entity container, followed by a forward +slash and the name of a container child element +- The target +path of a container child followed by a forward slash and one or more +forward-slash separated property, navigation property, or type-cast +segments + +::: example +Example ##ex: Target expressions +``` +MySchema.MyEntityContainer/MyEntitySet +MySchema.MyEntityContainer/MySingleton +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp +``` +::: + +------- + +# ##sec CSDL Examples + +: varjson +Following are two basic examples of valid EDM models as represented in +CSDL JSON. These examples demonstrate many of the topics covered above. +: + +: varxml +Following are two basic examples of valid EDM models as represented in +CSDL. These examples demonstrate many of the topics covered above. +: + +## ##subsec Products and Categories Example + +::: {.varjson .example} +Example ##ex: +```json +{ + "$Version": "4.0", + "$EntityContainer": "ODataDemo.DemoService", + "$Reference": { + "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": { + "$Include": [ + { + "$Namespace": "Org.OData.Core.V1", + "$Alias": "Core", + "@Core.DefaultNamespace": true + } + ] + }, + "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.json": { + "$Include": [ + { + "$Namespace": "Org.OData.Measures.V1", + "$Alias": "Measures" + } + ] + } + }, + "ODataDemo": { + "$Alias": "self", + "@Core.DefaultNamespace": true, + "Product": { + "$Kind": "EntityType", + "$HasStream": true, + "$Key": [ + "ID" + ], + "ID": {}, + "Description": { + "$Nullable": true, + "@Core.IsLanguageDependent": true + }, + "ReleaseDate": { + "$Nullable": true, + "$Type": "Edm.Date" + }, + "DiscontinuedDate": { + "$Nullable": true, + "$Type": "Edm.Date" + }, + "Rating": { + "$Nullable": true, + "$Type": "Edm.Int32" + }, + "Price": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "@Measures.ISOCurrency": { + "$Path": "Currency" + } + }, + "Currency": { + "$Nullable": true, + "$MaxLength": 3 + }, + "Category": { + "$Kind": "NavigationProperty", + "$Type": "self.Category", + "$Partner": "Products" + }, + "Supplier": { + "$Kind": "NavigationProperty", + "$Nullable": true, + "$Type": "self.Supplier", + "$Partner": "Products" + } + }, + "Category": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": { + "$Type": "Edm.Int32" + }, + "Name": { + "@Core.IsLanguageDependent": true + }, + "Products": { + "$Kind": "NavigationProperty", + "$Partner": "Category", + "$Collection": true, + "$Type": "self.Product", + "$OnDelete": "Cascade" + } + }, + "Supplier": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": {}, + "Name": { + "$Nullable": true + }, + "Address": { + "$Type": "self.Address" + }, + "Concurrency": { + "$Type": "Edm.Int32" + }, + "Products": { + "$Kind": "NavigationProperty", + "$Partner": "Supplier", + "$Collection": true, + "$Type": "self.Product" + } + }, + "Country": { + "$Kind": "EntityType", + "$Key": [ + "Code" + ], + "Code": { + "$MaxLength": 2 + }, + "Name": { + "$Nullable": true + } + }, + "Address": { + "$Kind": "ComplexType", + "Street": { + "$Nullable": true + }, + "City": { + "$Nullable": true + }, + "State": { + "$Nullable": true + }, + "ZipCode": { + "$Nullable": true + }, + "CountryName": { + "$Nullable": true + }, + "Country": { + "$Kind": "NavigationProperty", + "$Nullable": true, + "$Type": "self.Country", + "$ReferentialConstraint": { + "CountryName": "Name" + } + } + }, + "ProductsByRating": [ + { + "$Kind": "Function", + "$Parameter": [ + { + "$Name": "Rating", + "$Nullable": true, + "$Type": "Edm.Int32" + } + ], + "$ReturnType": { + "$Collection": true, + "$Type": "self.Product" + } + } + ], + "DemoService": { + "$Kind": "EntityContainer", + "Products": { + "$Collection": true, + "$Type": "self.Product", + "$NavigationPropertyBinding": { + "Category": "Categories" + } + }, + "Categories": { + "$Collection": true, + "$Type": "self.Category", + "$NavigationPropertyBinding": { + "Products": "Products" + }, + "@Core.Description": "Product Categories" + }, + "Suppliers": { + "$Collection": true, + "$Type": "self.Supplier", + "$NavigationPropertyBinding": { + "Products": "Products", + "Address/Country": "Countries" + }, + "@Core.OptimisticConcurrency": [ + "Concurrency" + ] + }, + "Countries": { + "$Collection": true, + "$Type": "self.Country" + }, + "MainSupplier": { + "$Type": "self.Supplier", + "$NavigationPropertyBinding": { + "Products": "Products" + }, + "@Core.Description": "Primary Supplier" + }, + "ProductsByRating": { + "$EntitySet": "Products", + "$Function": "self.ProductsByRating" + } + } + } +} +``` +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Concurrency + + + + + + + + + + + + + +``` +::: + + +## ##subsec Annotations for Products and Categories Example + +::: {.varjson .example} +Example ##ex: +```json +{ + "$Version": "4.01", + "$Reference": { + "http://host/service/$metadata": { + "$Include": [ + { + "$Namespace": "ODataDemo", + "$Alias": "target" + } + ] + }, + "http://somewhere/Vocabulary/V1": { + "$Include": [ + { + "$Namespace": "Some.Vocabulary.V1", + "$Alias": "Vocabulary1" + } + ] + } + }, + "External.Annotations": { + "$Annotations": { + "target.Supplier": { + "@Vocabulary1.EMail": null, + "@Vocabulary1.AccountID": { + "$Path": "ID" + }, + "@Vocabulary1.Title": "Supplier Info", + "@Vocabulary1.DisplayName": { + "$Apply": [ + { + "$Path": "Name" + }, + " in ", + { + "$Path": "Address/CountryName" + } + ], + "$Function": "odata.concat" + } + }, + "target.Product": { + "@Vocabulary1.Tags": [ + "MasterData" + ] + } + } + } +} +``` +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + + + + + + + + + + + + + + Name + in + Address/CountryName + + + + + + + MasterData + + + + + + +``` +::: + +------- + +# ##sec Conformance + +Conforming services MUST follow all rules of this specification document +for the types, sets, functions, actions, containers and annotations they +expose. + +In addition, conforming services MUST NOT return 4.01 CSDL constructs +for requests made with `OData-MaxVersion:4.0`. + +Specifically, they + +1. MUST NOT include properties in derived types that overwrite a +property defined in the base type + +2. MUST NOT include `Edm.Untyped` + +3. MUST NOT use [path syntax](#PathSyntax) added with 4.01 + +4. MUST NOT use `Edm.ModelElementPath` and `Edm.AnyPropertyPath` + +5. MUST NOT specify [referential constraints](#ReferentialConstraint) +to complex types and navigation properties + +6. MUST NOT include a non-abstract entity type with no inherited or +defined [entity key](#Key) + +7. MUST NOT include the +[`Core.DefaultNamespace`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#DefaultNamespace) +annotation on [included schemas](#IncludedSchema) + +8. MUST NOT return the Unicode facet for terms, parameters, and return +types + +9. MUST NOT include collections of `Edm.ComplexType` or `Edm.Untyped` + +10. MUST NOT specify a key as a property of a related entity + +: varjson +11. SHOULD NOT include new/unknown values for +[`$AppliesTo`](#Applicability) +: + +: varxml +11. SHOULD NOT include new/unknown values for the +[`AppliesTo`](#Applicability) attribute +: + +12. MAY include new CSDL annotations + +In addition, OData 4.01 services: + +13. SHOULD NOT have identifiers within a uniqueness scope (e.g. a +schema, a structural type, or an entity container) that differ only by +case + +Conforming clients MUST be prepared to consume a model that uses any or +all constructs defined in this specification, including custom +annotations, and MUST ignore constructs not defined in this version of +the specification. diff --git a/odata-csdl/4 CSDL Document.md b/odata-csdl/4 CSDL Document.md new file mode 100644 index 000000000..fdf4d3cec --- /dev/null +++ b/odata-csdl/4 CSDL Document.md @@ -0,0 +1,478 @@ +------- + +: varjson +# ##sec CSDL JSON Document +: +: varxml +# ##sec CSDL XML Document +: + + +::: {.varjson .rep} +### ##isec Document Object + +A CSDL JSON document consists of a single JSON object. This document object MUST contain the member `$Version`. + +The document object MAY contain the member [`$Reference`](#Reference) to reference other CSDL documents. + +It also MAY contain members for schemas. + +If the CSDL JSON document is the metadata document of an OData service, the document object MUST contain the member `$EntityContainer`. + +### ##subisec `$Version` + +The value of `$Version` is a string containing either `4.0` or `4.01`. + +### ##subisec `$EntityContainer` + +The value of `$EntityContainer` is value is the namespace-qualified name of the entity container of that service. This is the only place where a model element MUST be referenced with its namespace-qualified name and use of the alias-qualified name is not allowed. +::: + +::: {.varjson .example} +Example ##ex: +```json +{ + "$Version": "4.01", + "$EntityContainer": "org.example.DemoService", + ... +} +``` +::: + + +::: {.varxml .rep} +### ##isec Element `edmx:Edmx` + +The `edmx:Edmx` element is the root element of a CSDL XML document. It +MUST contain the `Version` attribute and it MUST contain exactly one +`edmx:DataServices` element. + +It MAY contain [`edmx:Reference`](#Reference) elements to reference +other CSDL documents. + +### ##subisec Attribute `Version` + +The `Version` attribute specifies the OData protocol version of the +service. For OData 4.0 responses the value of this attribute MUST be +`4.0.` For OData 4.01 responses the value of this attribute MUST be +`4.01.` Services MUST return an OData 4.0 response if the request was +made with an `OData-MaxVersion `header with a value of `4.0`. + +### ##isec Element `edmx:DataServices` + +The `edmx:DataServices` element MUST contain one or more +[`edm:Schema`](#Schema) elements which define the schemas exposed by the +OData service. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + ... + + +``` +::: + +## ##subsec Reference + +A reference to an external CSDL document allows to bring part of the +referenced document's content into the scope of the referencing +document. + +A reference MUST specify a URI that uniquely identifies the referenced +document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be +absolute or relative URI; relative URLs are relative to the URL of the +document containing the reference, or relative to a base URL specified +in a format-specific way. + +A reference MAY be annotated. + +The +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation, defined in [OData-VocCore](#ODataVocCore), MAY be used to +indicate a particular version of the referenced document. If the +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation is present, the `$schemaversion` system query option, defined +[OData-Protocol](#ODataProtocol), SHOULD be used when retrieving the +referenced schema document. + +::: {.varjson .rep} +### ##subisec `$Reference` + +The value of `$Reference` is an object that contains one member per +referenced CSDL document. The name of the pair is a URI for the +referenced document. The URI MAY be relative to the document containing +the `$Reference`. The value of each member is a reference object. + +### ##isec Reference Object + +The reference object MAY contain the members +[`$Include`](#IncludedSchema) and +[`$IncludeAnnotations`](#IncludedAnnotations) as well as +[annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: references to other CSDL documents +```json +{ + ... + "$Reference": { + "http://vocabs.odata.org/capabilities/v1": { + ... + }, + "http://vocabs.odata.org/core/v1": { + ... + }, + "http://example.org/display/v1": { + ... + } + }, + ... +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edmx:Reference` + +The `edmx:Reference` element specifies external CSDL documents +referenced by the referencing document. The child elements +[`edmx:Include`](#IncludedSchema) and +[`edmx:IncludeAnnotations`](#IncludedAnnotations) specify which parts of +the referenced document are available for use in the referencing +document. + +The `edmx:Reference` element MUST contain the `Uri` attribute, and it +MUST contain at least one [`edmx:Include`](#IncludedSchema) or +[`edmx:IncludeAnnotations`](#IncludedAnnotations) child element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Uri` + +The value of `Uri` is an absolute or relative URI; relative URIs are +relative to the `xml:base` attribute, see +[XML-Base](#XML-Base). +::: + +::: {.varxml .example} +Example ##ex: references to other CSDL documents +```xml + + + + ... + + + ... + + + ... + + ... + +``` +::: + +## ##subsec Included Schema + +A reference MAY include zero or more schemas from the referenced +document. + +The included schemas are identified via their [namespace](#Namespace). +The same namespace MUST NOT be included more than once, even if it is +declared in more than one referenced document. + +When including a schema, a [simple identifier](#SimpleIdentifier) value +MAY be specified as an alias for the schema that is used in qualified +names instead of the namespace. For example, an alias of `display` might +be assigned to the namespace `org.example.vocabularies.display`. An +alias-qualified name is resolved to a fully qualified name by examining +aliases for included schemas and schemas defined within the document. + +::: {.varjson .rep} +If an included schema specifies an alias, the alias MUST be used in +qualified names throughout the document to identify model elements of +the included schema. A mixed use of namespace-qualified names and +alias-qualified names is not allowed. +::: + +::: {.varxml .rep} +If an included schema specifies an alias, the alias MAY be used instead +of the namespace within qualified names to identify model elements of +the included schema. An alias only provides a more convenient notation, +allowing a short string to be substituted for a long namespace. Every +model element that can be identified via an alias-qualified name can +alternatively be identified via its full namespace-qualified name. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +An alias is only valid within the document in which it is declared; a +referencing document may define its own aliases for included schemas. + +::: {.varjson .rep} +### ##subisec `$Include` + +The value of `$Include` is an array. Array items are objects that MUST +contain the member `$Namespace` and MAY contain the member `$Alias`. + +The item objects MAY contain [annotations](#Annotation). + +### ##subisec `$Namespace` + +The value of `$Namespace` is a string containing the namespace of the +included schema. + +### ##subisec `$Alias` + +The value of `$Alias` is a string containing the alias for the included +schema. +::: + +::: {.varjson .example} +Example ##ex: references to entity models containing definitions of +vocabulary terms +```json +{ + ... + "$Reference": { + "http://vocabs.odata.org/capabilities/v1": { + "$Include": [ + { + "$Namespace": "Org.OData.Capabilities.V1", + "$Alias": "Capabilities" + } + ] + }, + "http://vocabs.odata.org/core/v1": { + "$Include": [ + { + "$Namespace": "Org.OData.Core.V1", + "$Alias": "Core", + "@Core.DefaultNamespace": true + } + ] + }, + "http://example.org/display/v1": { + "$Include": [ + { + "$Namespace": "org.example.display", + "$Alias": "UI" + } + ] + } + }, + ... +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edmx:Include` + +The `edmx:Include` element specifies a schema to include from the +referenced CSDL document. It MUST provide the `Namespace` attribute and +it MAY provide the `Alias` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Namespace` + +The value of `Namespace` is the namespace of a schema defined in the +referenced CSDL document. + +### ##subisec Attribute `Alias` + +The value of `Alias` is a [simple identifier](#SimpleIdentifier) that +can be used in qualified names instead of the namespace. +::: + +::: {.varxml .example} +Example ##ex: references to entity models containing definitions of +vocabulary terms +```xml + + + + + + + + + + + + + + ... + +``` +::: + +## ##subsec Included Annotations + +In addition to including whole schemas with all model constructs defined +within that schema, annotations can be included with more flexibility. + +Annotations are selectively included by specifying the +[namespace](#Namespace) of the annotations' term. Consumers can opt not +to inspect the referenced document if none of the term namespaces is of +interest for the consumer. + +In addition, the [qualifier](#Qualifier) of annotations to be included +MAY be specified. For instance, a service author might want to supply a +different set of annotations for various device form factors. If a +qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of +the target namespace, if present) SHOULD be included. If no qualifier is +specified, all annotations within the referenced document from the +specified term namespace (taking into account the target namespace, if +present) SHOULD be included. + +The qualifier also provides consumers insight about what qualifiers are +present in the referenced document. If the consumer is not interested in +that particular qualifier, the consumer can opt not to inspect the +referenced document. + +In addition, the namespace of the annotations' [target](#Target) MAY be +specified. If a target namespace is specified, only those annotations +which apply a term form the specified term namespace to a model element +of the target namespace (with the specified qualifier, if present) +SHOULD be included. If no target namespace is specified, all annotations +within the referenced document from the specified term namespace (taking +into account the qualifier, if present) SHOULD be included. + +The target namespace also provides consumers insight about what +namespaces are present in the referenced document. If the consumer is +not interested in that particular target namespace, the consumer can opt +not to inspect the referenced document. + +::: {.varjson .rep} +### ##subisec `$IncludeAnnotations` + +The value of `$IncludeAnnotations` is an array. Array items are objects +that MUST contain the member `$TermNamespace` and MAY contain the +members `$Qualifier` and `$TargetNamespace`. + +### ##subisec `$TermNamespace` + +The value of `$TermNamespace` is a namespace. + +### ##subisec `$Qualifier` + +The value of `$Qualifier` is a simple identifier. + +### ##subisec `$TargetNamespace` + +The value of `$TargetNamespace` is a namespace. +::: + +::: {.varjson .example} +Example ##ex: reference documents that contain annotations +```json +{ + ... + "$Reference": { + "http://odata.org/ann/b": { + "$IncludeAnnotations": [ + { + "$TermNamespace": "org.example.validation" + }, + { + "$TermNamespace": "org.example.display", + "$Qualifier": "Tablet" + }, + { + "$TermNamespace": "org.example.hcm", + "$TargetNamespace": "com.example.Sales" + }, + { + "$TermNamespace": "org.example.hcm", + "$Qualifier": "Tablet", + "$TargetNamespace": "com.example.Person" + } + ] + } + }, + ... +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edmx:IncludeAnnotations` + +The `edmx:IncludeAnnotations` element specifies the annotations to +include from the referenced CSDL document. If no +`edmx:IncludeAnnotations` element is specified, a client MAY ignore all +annotations in the referenced document that are not explicitly used in +an [`edm:Path`](#ValuePath) expression of the referencing document. + +The `edmx:IncludeAnnotations` element MUST provide the `TermNamespace` +attribute, and it MAY provide the `Qualifier` and `TargetNamespace` +attribute. + +### ##subisec Attribute `TermNamespace` + +The value of `TermNamespace` is a namespace. + +### ##subisec Attribute `Qualifier` + +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). + +### ##subisec Attribute `TargetNamespace` + +The value of `TargetNamespace` is a namespace. +::: + +::: {.varxml .example} +Example ##ex: reference documents that contain annotations +```xml + + + + + + + + + ... + +``` +::: + +::: example +The following annotations from `http://odata.org/ann/b` are included: +- Annotations that use a +term from the `org.example.validation` namespace, and +- Annotations that use a +term from the `org.example.display` namespace and specify a `Tablet` +qualifier and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Sales` namespace and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Person` namespace and specify a `Tablet` qualifier. +::: diff --git a/odata-csdl/5 Schema.md b/odata-csdl/5 Schema.md new file mode 100644 index 000000000..a1f55ec41 --- /dev/null +++ b/odata-csdl/5 Schema.md @@ -0,0 +1,676 @@ +------- + +# ##sec Schema + +One or more schemas describe the entity model exposed by an OData +service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms. + +A schema is identified by a [namespace](#Namespace). Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally +unique. A schema cannot span more than one document. + +The schema's namespace is combined with the name of elements in the +schema to create unique [qualified names](#QualifiedName), so +identifiers that are used to name types MUST be unique within a +namespace to prevent ambiguity. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +The namespace MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {.varjson .rep} +### ##isec Schema Object + +A schema is represented as a member of the document object whose name is +the schema namespace. Its value is an object that MAY contain the +members [`$Alias`](#Alias) and +[`$Annotations`](#AnnotationswithExternalTargeting). + +The schema object MAY contain members representing [entity +types](#EntityType), [complex types](#ComplexType), [enumeration +types](#EnumerationType), [type definitions](#TypeDefinition), +[actions](#Action), [functions](#Function), [terms](#Term), and an +[entity container](#EntityContainer). + +The schema object MAY also contain [annotations](#Annotation) that apply +to the schema itself. +::: + +::: {.varxml .rep} +### ##isec Element `edm:Schema` + +The `edm:Schema` element defines a +schema. It MUST contain the `Namespace` attribute and it MAY +contain the `Alias` attribute. + +It MAY contain elements [`edm:Action`](#Action), +[`edm:Annotations`](#AnnotationswithExternalTargeting), +[`edm:Annotation`](#Annotation), [`edm:ComplexType`](#ComplexType), +[`edm:EntityContainer`](#EntityContainer), +[`edm:EntityType`](#EntityType), [`edm:EnumType`](#EnumerationType), +[`edm:Function`](#Function), [`edm:Term`](#Term), or +[`edm:TypeDefinition`](#TypeDefinition). + +### ##subisec Attribute `Namespace` + +The value of `Namespace` is the namespace of the schema +::: + +## ##subsec Alias + +A schema MAY specify an alias which MUST be a [simple +identifier](#SimpleIdentifier). + +: varjson +If a schema specifies an alias, the alias MUST be used instead of the +namespace within qualified names throughout the document to identify +model elements of that schema. A mixed use of namespace-qualified names +and alias-qualified names is not allowed. +: + +: varxml +If a schema specifies an alias, the alias MAY be used instead of the +namespace within qualified names to identify model elements of that +schema. An alias only provides a more convenient notation, allowing a +short string to be substituted for a long namespace. Every model element +that can be identified via an alias-qualified name can alternatively be +identified via its full namespace-qualified name. +: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the +containing document and are not restricted to the schema that defines +them. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {.varjson .rep} +### ##subisec `$Alias` + +The value of `$Alias` is a string containing the alias for the schema. +::: + +::: {.varjson .example} +Example ##ex: document defining a schema `org.example` with an alias and a +description for the schema +```json +{ + ... + "org.example": { + "$Alias": "self", + "@Core.Description": "Example schema", + ... + }, + ... +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `Alias` + +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example ##ex: schema `org.example` with an alias and a description for the +schema +```xml + + + ... + +``` +::: + +## ##subsec Annotations with External Targeting + +::: {.varjson .rep} +### ##subisec `$Annotations` + +The value of `$Annotations` is an object with one member per [annotation +target](#Target). The member name is a path identifying the [annotation +target](#Target), the member value is an object containing +[annotations](#Annotation) for that target. +::: + +::: {.varjson .example} +Example ##ex: annotations targeting the `Person` type with qualifier +`Tablet` +```json +"org.example": { + "$Alias": "self", + "$Annotations": { + "self.Person": { + "@Core.Description#Tablet": "Dummy", + ... + } + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:Annotations` + +The `edm:Annotations` element is used to apply a group of annotations to +a single model element. It MUST contain the `Target` attribute and it +MAY contain the `Qualifier` attribute. + +It MUST contain at least one [`edm:Annotation`](#Annotation) element. + +### ##subisec Attribute `Target` + +The value of `Target` is a path expression identifying the [annotation +target](#Target). It MUST resolve to a model element in scope. + +### ##subisec Attribute `Qualifier` + +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example ##ex: annotations should only be applied to tablet devices +```xml + + + ... + +``` +::: + +------- + +# ##sec Entity Type + +Entity types are [nominal](#NominalTypes) [structured +types](#StructuredTypes) with a key that consists of one or more +references to [structural properties](#StructuralProperty). An entity +type is the template for an entity: any uniquely identifiable record +such as a customer or order. + +The entity type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +An entity type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to another entity type or collection of entity types. + +All properties MUST have a unique name within an entity type. Properties +MUST NOT have the same name as the declaring entity type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {.varjson .rep} +### ##isec Entity Type Object + +An entity type is represented as a member of the schema object whose +name is the unqualified name of the entity type and whose value is an +object. + +The entity type object MUST contain the member `$Kind` with a string +value of `EntityType`. + +It MAY contain the members [`$BaseType`](#DerivedEntityType), +[`$Abstract`](#AbstractEntityType), [`$OpenType`](#OpenEntityType), +[`$HasStream`](#MediaEntityType), and [`$Key`](#Key). + +It also MAY contain members representing [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty) as well as [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex_entitytype: a simple entity type +```json +"Employee": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": {}, + "FirstName": {}, + "LastName": {}, + "Manager": { + "$Kind": "NavigationProperty", + "$Nullable": true, + "$Type": "self.Manager" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:EntityType` + +The `edm:EntityType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedEntityType), +[`Abstract`](#AbstractEntityType), [`OpenType`](#OpenEntityType), and +[`HasStream`](#MediaEntityType) attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the entity type. + +It MAY contain one [`edm:Key`](#Key) element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the entity type's name. +::: + +::: {.varxml .example} +Example ##ex_entitytype: a simple entity type +```xml + + + + + + + + + +``` +::: + +## ##subsec Derived Entity Type + +An entity type can inherit from another entity type by specifying it as +its base type. + +An entity type inherits the [key](#Key) as well as structural and +navigation properties of its base type. + +An entity type MUST NOT introduce an inheritance cycle by specifying a +base type. + +::: {.varjson .rep} +### ##subisec `$BaseType` + +The value of `$BaseType` is the qualified name of the base type. +::: + +::: {.varjson .example} +Example ##ex: a derived entity type based on the previous example +```json +"Manager": { + "$Kind": "EntityType", + "$BaseType": "self.Employee", + "AnnualBudget": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Scale": 0 + }, + "Employees": { + "$Kind": "NavigationProperty", + "$Collection": true, + "$Type": "self.Employee" + } +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `BaseType` + +The value of `BaseType` is the qualified name of the base type. +::: + +::: {.varxml .example} +Example ##ex: a derived entity type based on the previous example +```xml + + + + +``` +::: + +::: example +Note: the derived type has the same name as one of the properties of its +base type. +::: + +## ##subsec Abstract Entity Type + +An entity type MAY indicate that it is abstract and cannot have +instances. + +For OData 4.0 responses a non-abstract entity type MUST define a +[key](#Key) or derive from a [base type](#DerivedEntityType) with a +defined key. + +An abstract entity type MUST NOT inherit from a non-abstract entity +type. + +::: {.varjson .rep} +### ##subisec `$Abstract` + +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `Abstract` + +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Open Entity Type + +An entity type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +An entity type derived from an open entity type MUST indicate that it is +also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData-Protocol](#ODataProtocol). + +::: {.varjson .rep} +### ##subisec `$OpenType` + +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `OpenType` + +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Media Entity Type + +An entity type that does not specify a base type MAY indicate that it is +a media entity type. *Media entities* are entities that represent a +media stream, such as a photo. Use a media entity if the out-of-band +stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal +entity with one or more properties of type `Edm.Stream` if the +structured data of the entity is the main topic of interest and the +stream data is just additional information attached to the structured +data. For more information on media entities see +[OData-Protocol](#ODataProtocol). + +An entity type derived from a media entity type MUST indicate that it is +also a media entity type. + +Media entity types MAY specify a list of acceptable media types using an +annotation with term +[`Core.AcceptableMediaTypes`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#AcceptableMediaTypes), +see [OData-VocCore](#ODataVocCore). + +::: {.varjson .rep} +### ##subisec `$HasStream` + +The value of `$HasStream `is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `HasStream` + +The value of `HasStream` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Key + +An entity is uniquely identified within an entity set by its key. A key +MAY be specified if the entity type does not specify a [base +type](#DerivedEntityType) that already has a key declared. + +In order to be specified as the type of an [entity set](#EntitySet) or a +collection-valued [containment navigation +property](#ContainmentNavigationProperty), the entity type MUST either +specify a key or inherit its key from its [base +type](#DerivedEntityType). + +In OData 4.01 responses entity types used for [singletons](#Singleton) +or single-valued [navigation properties](#NavigationProperty) do not +require a key. In OData 4.0 responses entity types used for +[singletons](#Singleton) or single-valued [navigation +properties](#NavigationProperty) MUST have a key defined. + +An entity type (whether or not it is marked as abstract) MAY define a +key only if it doesn't inherit one. + +An entity type's key refers to the set of properties whose values +uniquely identify an instance of the entity type within an entity set. +The key MUST consist of at least one property. + +Key properties MUST NOT be nullable and MUST be typed with an +[enumeration type](#EnumerationType), one of the following [primitive +types](#PrimitiveTypes), or a [type definition](#TypeDefinition) based +on one of these primitive types: + +- `Edm.Boolean` +- `Edm.Byte` +- `Edm.Date` +- `Edm.DateTimeOffset` +- `Edm.Decimal` +- `Edm.Duration` +- `Edm.Guid` +- `Edm.Int16` +- `Edm.Int32` +- `Edm.Int64` +- `Edm.SByte` +- `Edm.String` +- `Edm.TimeOfDay` + +Key property values MAY be language-dependent, but their values MUST be +unique across all languages and the entity ids (defined in +[OData-Protocol](#ODataProtocol)) MUST be language independent. + +A key property MUST be a non-nullable primitive property of the entity +type itself, including non-nullable primitive properties of non-nullable +single-valued complex properties, recursively. + +In OData 4.01 the key properties of a directly related entity type MAY +also be part of the key if the navigation property is single-valued and +not nullable. This includes navigation properties of non-nullable +single-valued complex properties (recursively) of the entity type. If a +key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key. + +If the key property is a property of a complex property (recursively) or +of a directly related entity type, the key MUST specify an alias for +that property that MUST be a [simple identifier](#SimpleIdentifier) and +MUST be unique within the set of aliases, structural and navigation +properties of the declaring entity type and any of its base types. + +An alias MUST NOT be defined if the key property is a primitive property +of the entity type itself. + +For key properties that are a property of a complex or navigation +property, the alias MUST be used in the key predicate of URLs instead of +the path to the property because the required percent-encoding of the +forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be +used in the query part of URLs, where paths to properties don't require +special encoding and are a standard constituent of expressions anyway. + +::: {.varjson .rep} +### ##subisec `$Key` + +The value of `$Key` is an array with one item per key property. + +Key properties without a key alias are represented as strings containing +the property name. + +Key properties with a key alias are represented as objects with one +member whose name is the key alias and whose value is a string +containing the path to the property. +::: + +::: {.varjson .example} +Example ##ex: entity type with a simple key +```json +"Category": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": { + "$Type": "Edm.Int32" + }, + "Name": { + "$Nullable": true, + "@Core.IsLanguageDependent": true + } +} +``` +::: + +::: {.varjson .example} +Example ##ex_complexkey: entity type with a simple key referencing a property of a +[complex type](#ComplexType) +```json +"Category": { + "$Kind": "EntityType", + "$Key": [ + { + "EntityInfoID": "Info/ID" + } + ], + "Info": { + "$Type": "self.EntityInfo" + }, + "Name": { + "$Nullable": true + } +}, +"EntityInfo": { + "$Kind": "ComplexType", + "ID": { + "$Type": "Edm.Int32" + }, + "Created": { + "$Type": "Edm.DateTimeOffset", + "$Precision": 0 + } +} +``` +::: + +::: {.varjson .example} +Example ##ex: entity type with a composite key +```json +"OrderLine": { + "$Kind": "EntityType", + "$Key": [ + "OrderID", + "LineNumber" + ], + "OrderID": { + "$Type": "Edm.Int32" + }, + "LineNumber": { + "$Type": "Edm.Int32" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:Key` + +The `edm:Key` element MUST contain at least one `edm:PropertyRef` +element. + +### ##isec Element `edm:PropertyRef` + +The `edm:PropertyRef` element MUST contain the `Name` attribute and MAY +contain the `Alias` attribute. + +### ##subisec Attribute `Name` + +The value of `Name` is a path expression leading to a primitive +property. The names of the properties in the path are joined together by +forward slashes. + +### ##subisec Attribute `Alias` + +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example ##ex: entity type with a simple key +```xml + + + + + + + +``` +::: + +::: {.varxml .example} +Example ##ex_complexkey: entity type with a simple key referencing a property of a +[complex type](#ComplexType) +```xml + + + + + + + + + + + + +``` +::: + +::: {.varxml .example} +Example ##ex: entity type with a composite key +```xml + + + + + + + + +``` +::: + +::: example +Example ##ex (based on [example ##complexkey]): requests to an entity set `Categories` +of type `Category` must use the alias +``` +GET http://host/service/Categories(EntityInfoID=1) +``` +::: + +::: example +Example ##ex (based on [example ##complexkey]): in a query part the value assigned to +the name attribute must be used +``` +GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100 +``` +::: diff --git a/odata-csdl/7 Structural Property.md b/odata-csdl/7 Structural Property.md new file mode 100644 index 000000000..6426d400c --- /dev/null +++ b/odata-csdl/7 Structural Property.md @@ -0,0 +1,1059 @@ +------- + +# ##sec Structural Property + +A structural property is a property of a structured type that has one of +the following types: +- [Primitive type](#PrimitiveTypes) +- [Complex type](#ComplexType) +- [Enumeration type](#EnumerationType) +- A collection of one of the above + +A structural property MUST specify a unique name as well as a +[type](#Type). + +The property's name MUST be a [simple identifier](#SimpleIdentifier). It +is used when referencing, serializing or deserializing the property. It +MUST be unique within the set of structural and navigation properties of +the declaring [structured type](#StructuredTypes), and MUST NOT match +the name of any navigation property in any of its base types. If a +structural property with the same name is defined in any of this type's +base types, then the property's type MUST be a type derived from the +type specified for the property of the base type and constrains this +property to be of the specified subtype for instances of this structured +type. The name MUST NOT match the name of any structural or navigation +property of any of this type's base types for OData 4.0 responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {.varjson .rep} +### ##isec Property Object + +Structural properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The property object MAY contain the member `$Kind` with a string value +of `Property`. This member SHOULD be omitted to reduce document size. + +It MAY contain the member [`$Type`](#Type), [`$Collection`](#Type), +[`$Nullable`](#Nullable), [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +[`$SRID`](#SRID), and [`$DefaultValue`](#DefaultValue). + +It also MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: complex type with two properties `Dimension` and `Length` +```json +"Measurement": { + "$Kind": "ComplexType", + "Dimension": { + "$MaxLength": 50, + "$DefaultValue": "Unspecified" + }, + "Length": { + "$Type": "Edm.Decimal", + "$Precision": 18, + "$Scale": 2 + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:Property` + +The `edm:Property` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the facet attributes +[`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), +[`SRID`](#SRID), and [`DefaultValue`](#DefaultValue). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the property's name. +::: + +::: {.varxml .example} +Example ##ex: complex type with two properties +```xml + + + + +``` +::: + +## ##subsec Type + +The property's type MUST be a [primitive type](#PrimitiveTypes), +[complex type](#ComplexType), or [enumeration type](#EnumerationType) in +scope, or a collection of one of these types. + +A collection-valued property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in +[OData-VocCore](#ODataVocCore), to specify that it supports a +stable ordering. + +A collection-valued property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports inserting items into a specific ordinal position. + +::: {.varjson .rep} +### ##subisec `$Type` +and ##subisec `$Collection` + +For single-valued properties the value of `$Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `$Type` is the qualified +name of the property's item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. This +member SHOULD be omitted for string properties to reduce document size. +::: + +::: {.varjson .example} +Example ##ex: property `Units` that can have zero or more strings as its +value +```json +"Units": { + "$Collection": true +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `Type` + +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. +::: + +::: {.varxml .example} +Example ##ex: property `Units` that can have zero or more strings as its +value +```xml + +``` +::: + +## ##subsec Type Facets + +Facets modify or constrain the acceptable values of a property. + +For single-valued properties the facets apply to the value of the +property. For collection-valued properties the facets apply to the items +in the collection. + +### ##subsubsec Nullable + +A Boolean value specifying whether the property can have the value +`null`. + +::: {.varjson .rep} +### ##subisec `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + +::: {.varxml .rep} +### ##subisec Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +If no value is specified for a single-valued property, the `Nullable` +attribute defaults to `true`. + +In OData 4.01 responses a collection-valued property MUST specify a +value for the `Nullable` attribute. + +If no value is specified for a collection-valued property, the client +cannot assume any default value. Clients SHOULD be prepared for this +situation even in OData 4.01 responses. +::: + +### ##subsubsec MaxLength + +A positive integer value specifying the maximum length of a binary, +stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length +(number of code points for Unicode). + +If no maximum length is specified, clients SHOULD expect arbitrary +length. + +::: {.varjson .rep} +### ##subisec `$MaxLength` + +The value of `$MaxLength` is a positive integer. + +Note: [OData-CSDL-XML](#ODataCSDLXML) defines a symbolic +value `max` that is only allowed in OData 4.0 responses. This symbolic +value is not allowed in CDSL JSON documents at all. Services MAY instead +specify the concrete maximum length supported for the type by the +service or omit the member entirely. +::: + +::: {.varxml .rep} +### ##subisec Attribute `MaxLength` + +The value of `MaxLength` is a positive integer or the symbolic value +`max` as a shorthand for the maximum length supported for the type by +the service. + +Note: the symbolic value `max` is only allowed in OData 4.0 responses; +it is deprecated in OData 4.01. While clients MUST be prepared for this +symbolic value, OData 4.01 and greater services MUST NOT return the +symbolic value `max` and MAY instead specify the concrete maximum length +supported for the type by the service or omit the attribute entirely. +::: + +### ##subsubsec Precision + +For a decimal value: the maximum number of significant decimal digits of +the property's value; it MUST be a positive integer. + +For a temporal value (datetime-with-timezone-offset, duration, or +time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve. + +Note: service authors SHOULD be aware that some clients are unable to +support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential +for data loss when round-tripping values of greater precision. Updating +via `PATCH` and exclusively specifying modified properties will reduce +the risk for unintended data loss. + +Note: duration properties supporting a granularity less than seconds +(e.g. minutes, hours, days) can be annotated with term +[`Measures.DurationGranularity`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Measures.V1.md#DurationGranularity), +see [OData-VocMeasures](#ODataVocMeasures). + +::: {.varjson .rep} +### ##subisec `$Precision` + +The value of `$Precision` is a number. + +Absence of `$Precision` means arbitrary precision. +::: + +::: {.varjson .example} +Example ##ex: `Precision` facet applied to the `DateTimeOffset` type +```json +"SuggestedTimes": { + "$Type": "Edm.DateTimeOffset", + "$Collection": true, + "$Precision": 6 +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `Precision` + +The value of `Precision` is a number. + +If not specified for a decimal property, the decimal property has +arbitrary precision. + +If not specified for a temporal property, the temporal property has a +precision of zero. +::: + +::: {.varxml .example} +Example ##ex: [`Precision`](#Precision) facet applied to the +`DateTimeOffset` type +```xml + +``` +::: + +### ##subsubsec Scale + +A non-negative integer value specifying the maximum number of digits +allowed to the right of the decimal point, or one of the symbolic values +`floating` or `variable`. + +The value `floating` means that the decimal property represents a +decimal floating-point number whose number of significant digits is the +value of the [`Precision`](#Precision) facet. OData 4.0 responses MUST +NOT specify the value `floating`. + +The value `variable` means that the number of digits to the right of the +decimal point can vary from zero to the value of the +[`Precision`](#Precision) facet. + +An integer value means that the number of digits to the right of the +decimal point may vary from zero to the value of the `Scale` facet, and +the number of digits to the left of the decimal point may vary from one +to the value of the `Precision` facet minus the value of the `Scale` +facet. If `Precision` is equal to `Scale`, a single zero MUST precede +the decimal point. + +The value of `Scale` MUST be less than or equal to the value of +[`Precision`](#Precision). + +Note: if the underlying data store allows negative scale, services may +use a [`Precision`](#Precision) with the absolute value of the negative +scale added to the actual number of significant decimal digits, and +client-provided values may have to be rounded before being stored. + +::: {.varjson .rep} +### ##subisec `$Scale` + +The value of `$Scale` is a number or a string with one of the symbolic +values `floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +Absence of `$Scale` means `variable`. +::: + +::: {.varjson .example} +Example ##ex: [`Precision`](#Precision)`=3` and `Scale=2`. +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 +```json +"Amount32": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 3, + "$Scale": 2 +} +``` +::: + +::: {.varjson .example} +Example ##ex: `Precision=2` equals `Scale`. +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 +```json +"Amount22": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 2, + "$Scale": 2 +} +``` +::: + +::: {.varjson .example} +Example ##ex: `Precision=3` and a variable `Scale`. +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. +```json +"Amount3v": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 3 +} +``` +::: + +::: {.varjson .example} +Example ##ex: `Precision=7` and a floating `Scale`. +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. +```json +"Amount7f": { + "$Nullable": true, + "$Type": "Edm.Decimal", + "$Precision": 7, + "$Scale": "floating" +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `Scale` + +The value of `Scale` is a number or one of the symbolic values +`floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +If not specified, the `Scale` facet defaults to zero. +::: + +::: {.varxml .example} +Example ##ex: [`Precision`](#Precision)`=3` and `Scale=2`. +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 +```xml + +``` +::: + +::: {.varxml .example} +Example ##ex: `Precision=2` equals `Scale`. +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 +```xml + +``` +::: + +::: {.varxml .example} +Example ##ex: `Precision=3` and a variable `Scale`. +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. +```xml + +``` +::: + +::: {.varxml .example} +Example ##ex: `Precision=7` and a floating `Scale`. +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. +```xml + +``` +::: + +### ##subsubsec Unicode + +For a string property the `Unicode` facet indicates whether the property +might contain and accept string values with Unicode characters (code +points) beyond the ASCII character set. The value `false` indicates that +the property will only contain and accept string values with characters +limited to the ASCII character set. + +If no value is specified, the `Unicode` facet defaults to `true`. + +::: {.varjson .rep} +### ##subisec `$Unicode` + +The value of `$Unicode` is one of the Boolean literals `true` or +`false`. Absence of the member means `true`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `Unicode` + +The value of `Unicode` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `true`. +::: + +### ##subsubsec SRID + +For a geometry or geography property the `SRID` facet identifies which +spatial reference system is applied to values of the property on type +instances. + +The value of the `SRID` facet MUST be a non-negative integer or the +special value `variable`. If no value is specified, the facet defaults +to `0` for `Geometry` types or `4326` for `Geography` types. + +The valid values of the `SRID` facet and their meanings are as defined +by the European Petroleum Survey Group [EPSG](#_EPSG). + +::: {.varjson .rep} +### ##subisec `$SRID` + +The value of `$SRID` is a string containing a number or the symbolic +value `variable`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `SRID` + +The value of `SRID` is a number or the symbolic value `variable`. +::: + +### ##subsubsec Default Value + +A primitive or enumeration property MAY define a default value that is +used if the property is not explicitly represented in an annotation or +the body of a request or response. + +If no value is specified, the client SHOULD NOT assume a default value. + +::: {.varjson .rep} +### ##subisec `$DefaultValue` + +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the property, see +[OData-JSON](#ODataJSON). For properties of type +`Edm.Decimal` and `Edm.Int64` the representation depends on the media +type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumbers). +::: + +::: {.varxml .rep} +### ##subisec Attribute `DefaultValue` + +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData-ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. +::: + +------- + +# ##sec Navigation Property + +A navigation property allows navigation to related entities. It MUST +specify a unique name as well as a type. + +The navigation property's name MUST be a [simple +identifier](#SimpleIdentifier). It is used when referencing, serializing +or deserializing the navigation property. It MUST be unique within the +set of structural and navigation properties of the declaring [structured +type](#StructuredTypes), and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the +same name is defined in any of this type's base types, then the +navigation property's type MUST be a type derived from the type +specified for the navigation property of the base type, and constrains +this navigation property to be of the specified subtype for instances of +this structured type. The name MUST NOT match the name of any structural +or navigation property of any of this type's base types for OData 4.0 +responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {.varjson .rep} +### ##isec Navigation Property Object + +Navigation properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The navigation property object MUST contain the member `$Kind` with a +string value of `NavigationProperty`. + +It MUST contain the member [`$Type`](#NavigationPropertyType), and it +MAY contain the members [`$Collection`](#NavigationPropertyType), +[`$Nullable`](#NullableNavigationProperty), +[`$Partner`](#PartnerNavigationProperty), +[`$ContainsTarget`](#ContainmentNavigationProperty), +[`$ReferentialConstraint`](#ReferentialConstraint), and +[`$OnDelete`](#OnDeleteAction). + +It also MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: the `Product` entity type has a navigation property to a +`Category`, which has a navigation link back to one or more products +```json +"Product": { + "$Kind": "EntityType", + ... + "Category": { + "$Kind": "NavigationProperty", + "$Type": "self.Category", + "$Partner": "Products", + "$ReferentialConstraint": { + "CategoryID": "ID" + } + }, + "Supplier": { + "$Kind": "NavigationProperty", + "$Type": "self.Supplier" + } +}, +"Category": { + "$Kind": "EntityType", + ... + "Products": { + "$Kind": "NavigationProperty", + "$Collection": true, + "$Type": "self.Product", + "$Partner": "Category", + "$OnDelete": "Cascade", + "$OnDelete@Core.Description": "Delete all related entities" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:NavigationProperty` + +The `edm:NavigationProperty` element MUST contain the `Name` and `Type` +attributes, and it MAY contain the attributes +[`Nullable`](#NullableNavigationProperty), +[`Partner`](#PartnerNavigationProperty), and +[`ContainsTarget`](#ContainmentNavigationProperty). + +It MAY contain child elements +[`edm:ReferentialConstraint`](#ReferentialConstraint) and at most one +child element [`edm:OnDelete`](#OnDeleteAction). + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the navigation property's name. +::: + +::: {.varxml .example} +Example ##ex: the Product entity type has a navigation property to a +Category, which has a navigation link back to one or more products +```xml + + ... + + + + + + ... + + +``` +::: + +## ##subsec Navigation Property Type + +The navigation property's type MUST be an [entity type](#EntityType) in +scope, the [abstract type](#BuiltInAbstractTypes) `Edm.EntityType`, or a +collection of one of these types. + +If the type is a collection, an arbitrary number of entities can be +related. Otherwise there is at most one related entity. + +The related entities MUST be of the specified entity type or one of its +subtypes. + +For a collection-valued containment navigation property the specified +entity type MUST have a [key](#Key) defined. + +A collection-valued navigation property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports a stable ordering. + +A collection-valued navigation property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore), to specify that it +supports inserting items into a specific ordinal position. + +::: {.varjson .rep} +### ##subisec `$Type` +and ##subisec `$Collection` + +For single-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's item type, and the member +`$Collection` MUST be present with the literal value `true`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `Type` + +For single-valued navigation properties the value of `Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `Type` is the +character sequence `Collection(` followed by the qualified name of the +navigation property's item type, followed by a closing parenthesis `)`. +::: + +## ##subsec Nullable Navigation Property + +A Boolean value specifying whether the declaring type MAY have no +related entity. If false, instances of the declaring structured type +MUST always have a related entity. + +Nullable MUST NOT be specified for a collection-valued navigation +property, a collection is allowed to have zero items. + +::: {.varjson .rep} +### ##subisec `$Nullable` + +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `Nullable` + +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. +::: + +## ##subsec Partner Navigation Property + +A navigation property of an [entity type](#EntityType) MAY specify a +partner navigation property. Navigation properties of complex types MUST +NOT specify a partner. + +If specified, the partner navigation property is identified by a path +relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that +type or a derived type. The path MAY traverse complex types, including +derived complex types, but MUST NOT traverse any navigation properties. +The type of the partner navigation property MUST be the declaring entity +type of the current navigation property or one of its parent entity +types. + +If the partner navigation property is single-valued, it MUST lead back +to the source entity from all related entities. If the partner +navigation property is collection-valued, the source entity MUST be part +of that collection. + +If no partner navigation property is specified, no assumptions can be +made as to whether one of the navigation properties on the target type +will lead back to the source entity. + +If a partner navigation property is specified, this partner navigation +property MUST either specify the current navigation property as its +partner to define a bi-directional relationship or it MUST NOT specify a +partner navigation property. The latter can occur if the partner +navigation property is defined on a complex type, or if the current +navigation property is defined on a type derived from the type of the +partner navigation property. + +::: {.varjson .rep} +### ##subisec `$Partner` + +The value of `$Partner` is a string containing the path to the partner +navigation property. +::: + +::: {.varxml .rep} +### ##subisec Attribute `Partner` + +The value of `Partner` is the path to the of the partner navigation +property. +::: + +## ##subsec Containment Navigation Property + +A navigation property MAY indicate that instances of its declaring +structured type contain the targets of the navigation property, in which +case the navigation property is called a *containment navigation +property*. + +Containment navigation properties define an implicit entity set for each +instance of its declaring structured type. This implicit entity set is +identified by the read URL of the navigation property for that +structured type instance. + +Instances of the structured type that declares the navigation property, +either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The +canonical URL for contained entities is the canonical URL of the +containing instance, followed by the path segment of the navigation +property and the key of the contained entity, see +[OData-URL](#ODataURL). + +Entity types used in collection-valued containment navigation properties +MUST have a [key](#Key) defined. + +For items of an ordered collection of complex types (those annotated +with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term defined in [OData-VocCore](#ODataVocCore) the canonical URL +of the item is the canonical URL of the collection appended with a +segment containing the zero-based ordinal of the item. Items within in +an unordered collection of complex types do not have a canonical URL. +Services that support unordered collections of complex types declaring a +containment navigation property, either directly or indirectly via a +property of complex type, MUST specify the URL for the navigation link +within a payload representing that item, according to format-specific +rules. + +OData 4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued +property. + +An entity cannot be referenced by more than one containment +relationship, and cannot both belong to an entity set declared within +the entity container and be referenced by a containment relationship. + +Containment navigation properties MUST NOT be specified as the last path +segment in the path of a [navigation property +binding](#NavigationPropertyBinding). + +When a containment navigation property navigates between entity types in +the same inheritance hierarchy, the containment is called *recursive*. + +Containment navigation properties MAY specify a partner navigation +property. If the containment is recursive, the relationship defines a +tree, thus the partner navigation property MUST be +[nullable](#NullableNavigationProperty) (for the root of the tree) and +single-valued (for the parent of a non-root entity). If the containment +is not recursive, the partner navigation property MUST NOT be nullable. + +An entity type inheritance chain MUST NOT contain more than one +navigation property with a partner navigation property that is a +containment navigation property. + +Note: without a partner navigation property, there is no reliable way +for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity +can also be reached via a non-containment navigation path. + +::: {.varjson .rep} +### ##subisec `$ContainsTarget` + +The value of `$ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `ContainsTarget` + +The value of `ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Referential Constraint + +A single-valued navigation property MAY define one or more referential +constraints. A referential constraint asserts that the *dependent +property* (the property defined on the structured type declaring the +navigation property) MUST have the same value as the *principal +property* (the referenced property declared on the entity type that is +the target of the navigation). + +The type of the dependent property MUST match the type of the principal +property, or both types MUST be complex types. + +If the principle property references an entity, then the dependent +property must reference the same entity. + +If the principle property's value is a complex type instance, then the +dependent property's value must be a complex type instance with the same +properties, each with the same values. + +If the navigation property on which the referential constraint is +defined is nullable, or the principal property is nullable, then the +dependent property MUST also be nullable. If both the navigation +property and the principal property are not nullable, then the dependent +property MUST NOT be nullable. + +::: {.varjson .rep} +### ##subisec `$ReferentialConstraint` + +The value of `$ReferentialConstraint` is an object with one member per +referential constraint. The member name is the path to the dependent +property, this path is relative to the structured type declaring the +navigation property. The member value is a string containing the path to +the principal property, this path is relative to the entity type that is +the target of the navigation property. + +It also MAY contain [annotations](#Annotation). These are prefixed with +the path of the dependent property of the annotated referential +constraint. +::: + +::: {.varjson .example} +Example ##ex: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. +```json +"Product": { + "$Kind": "EntityType", + ... + "CategoryID": {}, + "CategoryKind": {}, + "Category": { + "$Kind": "NavigationProperty", + "$Type": "self.Category", + "$Partner": "Products", + "$ReferentialConstraint": { + "CategoryID": "ID", + "CategoryKind": "Kind", + "CategoryKind@Core.Description": "Referential Constraint to non-key property" + } + } +}, +"Category": { + "$Kind": "EntityType", + "$Key": [ + "ID" + ], + "ID": {}, + "Kind": { + "$Nullable": true + }, + ... +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:ReferentialConstraint` + +The `edm:ReferentialConstraint` element MUST contain the attributes +`Property` and `ReferencedProperty`. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Property` + +The `Property` attribute specifies the property that takes part in the +referential constraint on the dependent structured type. Its value MUST +be a path expression resolving to a property of the dependent structured +type itself or to a property of a complex property (recursively) of the +dependent structured type. The names of the properties in the path are +joined together by forward slashes. The path is relative to the +dependent structured type declaring the navigation property. + +### ##subisec Attribute `ReferencedProperty` + +The `ReferencedProperty` attribute specifies the corresponding property +of the principal entity type. Its value MUST be a path expression +resolving to a property of the principal entity type itself or to a +property of a complex property (recursively) of the principal entity +type that MUST have the same type as the property of the dependent +entity type. The path is relative to the entity type that is the target +of the navigation property. +::: + +::: {.varxml .example} +Example ##ex: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. +```xml + + ... + + + + + + + + + + + + + + + + + ... + +``` +::: + +## ##subsec On-Delete Action + +A navigation property MAY define an on-delete action that describes the +action the service will take on related entities when the entity on +which the navigation property is defined is deleted. + +The action can have one of the following values: + +- `Cascade`, meaning the related entities will be deleted if the + source entity is deleted, +- `None`, meaning a `DELETE` request on a source entity with related + entities will fail, +- `SetNull`, meaning all properties of related entities that are tied + to properties of the source entity via a referential constraint and + that do not participate in other referential constraints will be set + to null, +- `SetDefault`, meaning all properties of related entities that are + tied to properties of the source entity via a referential constraint + and that do not participate in other referential constraints will be + set to their default value. + +If no on-delete action is specified, the action taken by the service is +not predictable by the client and could vary per entity. + +::: {.varjson .rep} +### ##subisec `$OnDelete` + +The value of `$OnDelete` is a string with one of the values `Cascade`, +`None`, `SetNull`, or `SetDefault`. + +[Annotations](#Annotation) for `$OnDelete` are prefixed with +`$OnDelete`. +::: + +::: {.varjson .example} +Example ##ex: deletion of a category implies deletion of the related +products in that category +```json +"Category": { + "$Kind": "EntityType", + ... + "Products": { + "$Kind": "NavigationProperty", + "$Collection": true, + "$Type": "self.Product", + "$Partner": "Category", + "$OnDelete": "Cascade", + "$OnDelete@Core.Description": "Delete all products in this category" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:OnDelete` + +The `edm:OnDelete` element MUST contain the `Action` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Action` + +The value of `Action` is one of the values `Cascade`, `None`, `SetNull`, +or `SetDefault`. +::: + +::: {.varxml .example} +Example ##ex: deletion of a category implies deletion of the related +products in that category +```xml + + ... + + + + + + +``` +::: diff --git a/odata-csdl/9 Complex Type.md b/odata-csdl/9 Complex Type.md new file mode 100644 index 000000000..1500a3969 --- /dev/null +++ b/odata-csdl/9 Complex Type.md @@ -0,0 +1,609 @@ +------- + +# ##sec Complex Type + +Complex types are keyless [nominal](#NominalTypes) [structured +types](#StructuredTypes). The lack of a key means that instances of +complex types cannot be referenced, created, updated or deleted +independently of an entity type. Complex types allow entity models to +group properties into common structures. + +The complex type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +A complex type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to an entity type or a collection of entity types. + +All properties MUST have a unique name within a complex type. Properties +MUST NOT have the same name as the declaring complex type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {.varjson .rep} +### ##isec Complex Type Object + +A complex type is represented as a member of the schema object whose +name is the unqualified name of the complex type and whose value is an +object. + +The complex type object MUST contain the member `$Kind` with a string +value of `ComplexType`. It MAY contain the members +[`$BaseType`](#DerivedComplexType), [`$Abstract`](#AbstractComplexType), +and [`$OpenType`](#OpenComplexType). It also MAY contain members +representing [structural properties](#StructuralProperty) and +[navigation properties](#NavigationProperty) as well as +[annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: a complex type used by two entity types +```json +"Dimensions": { + "$Kind": "ComplexType", + "Height": { + "$Type": "Edm.Decimal", + "$Scale": 0 + }, + "Weight": { + "$Type": "Edm.Decimal", + "$Scale": 0 + }, + "Length": { + "$Type": "Edm.Decimal", + "$Scale": 0 + } +}, +"Product": { + ... + "ProductDimensions": { + "$Nullable": true, + "$Type": "self.Dimensions" + }, + "ShippingDimensions": { + "$Nullable": true, + "$Type": "self.Dimensions" + } +}, +"ShipmentBox": { + ... + "Dimensions": { + "$Nullable": true, + "$Type": "self.Dimensions" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:ComplexType` + +The `edm:ComplexType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedComplexType), +[`Abstract`](#AbstractComplexType), and [`OpenType`](#OpenComplexType) +attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the complex type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the complex type's name. +::: + +::: {.varxml .example} +Example ##ex: a complex type used by two entity types +```xml + + + + + + + + ... + + + + + + ... + + +``` +::: + +## ##subsec Derived Complex Type + +A complex type can inherit from another complex type by specifying it as +its base type. + +A complex type inherits the structural and navigation properties of its +base type. + +A complex type MUST NOT introduce an inheritance cycle by specifying a +base type. + +The rules for annotations of derived complex types are described in +[section ##Annotation]. + +::: {.varjson .rep} +### ##subisec `$BaseType` + +The value of `$BaseType` is the qualified name of the base type. +::: + +::: {.varxml .rep} +### ##subisec Attribute `BaseType` + +The value of `BaseType` is the qualified name of the base type. +::: + +## ##subsec Abstract Complex Type + +A complex type MAY indicate that it is abstract and cannot have +instances. + +::: {.varjson .rep} +### ##subisec `$Abstract` + +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `Abstract` + +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Open Complex Type + +A complex type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +A complex type derived from an open complex type MUST indicate that it +is also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {.varjson .rep} +### ##subisec `$OpenType` + +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varxml .rep} +### ##subisec Attribute `OpenType` + +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +------- + +# ##sec Enumeration Type + +Enumeration types are [nominal](#NominalTypes) types that represent a +non-empty series of related values. Enumeration types expose these +related values as members of the enumeration. + +The enumeration type's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Although enumeration types have an underlying numeric value, the +preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the `AllowedValues` annotation defined in +[OData-VocCore](#ODataVocCore). + +Enumeration types marked as flags allow values that consist of more than +one enumeration member at a time. + +::: {.varjson .rep} +### ##isec Enumeration Type Object + +An enumeration type is represented as a member of the schema object +whose name is the unqualified name of the enumeration type and whose +value is an object. + +The enumeration type object MUST contain the member `$Kind` with a +string value of `EnumType`. + +It MAY contain the members [`$UnderlyingType`](#UnderlyingIntegerType) +and [`$IsFlags`](#FlagsEnumerationType). + +The enumeration type object MUST contain members representing [the +enumeration type members](#EnumerationTypeMember). + +The enumeration type object MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: a simple flags-enabled enumeration +```json +"FileAccess": { + "$Kind": "EnumType", + "$UnderlyingType": "Edm.Int32", + "$IsFlags": true, + "Read": 1, + "Write": 2, + "Create": 4, + "Delete": 8 +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:EnumType` + +The `edm:EnumType` element MUST contain the Name attribute, and it MAY +contain the [`UnderlyingType`](#UnderlyingIntegerType) and +[`IsFlags`](#FlagsEnumerationType) attributes. + +It MUST contain one or more [`edm:Member`](#EnumerationTypeMember) +elements defining the members of the enumeration type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the enumeration type's name. +::: + +::: {.varxml .example} +Example ##ex: a simple flags-enabled enumeration +```xml + + + + + + +``` +::: + +## ##subsec Underlying Integer Type + +An enumeration type MAY specify one of `Edm.Byte`, `Edm.SByte`, +`Edm.Int16`, `Edm.Int32`, or `Edm.Int64` as its underlying type. + +If not explicitly specified, `Edm.Int32` is used as the underlying type. + +::: {.varjson .rep} +### ##subisec `$UnderlyingType` + +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + +::: {.varxml .rep} +### ##subisec Attribute `UnderlyingType` + +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +## ##subsec Flags Enumeration Type + +An enumeration type MAY indicate that the enumeration type allows +multiple members to be selected simultaneously. + +If not explicitly specified, only one enumeration type member MAY be +selected simultaneously. + +::: {.varjson .rep} +### ##subisec `$IsFlags` + +The value of `$IsFlags` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: {.varjson .example} +Example ##ex: pattern values can be combined, and some combined values +have explicit names +```json +"Pattern": { + "$Kind": "EnumType", + "$UnderlyingType": "Edm.Int32", + "$IsFlags": true, + "Plain": 0, + "Red": 1, + "Blue": 2, + "Yellow": 4, + "Solid": 8, + "Striped": 16, + "SolidRed": 9, + "SolidBlue": 10, + "SolidYellow": 12, + "RedBlueStriped": 19, + "RedYellowStriped": 21, + "BlueYellowStriped": 22 +} +``` +::: + +::: {.varxml .rep} +### ##subisec Attribute `IsFlags` + +The value of `IsFlags` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +::: {.varxml .example} +Example ##ex: pattern values can be combined, and some combined values +have explicit names +```xml + + + + + + + + + + + + + + +``` +::: + +## ##subsec Enumeration Type Member + +Enumeration type values consist of discrete members. + +Each member is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within the +enumeration type. Names are case-sensitive, but service authors SHOULD +NOT choose names that differ only in case. + +Each member MUST specify an associated numeric value that MUST be a +valid value for the underlying type of the enumeration type. + +Enumeration types can have multiple members with the same value. Members +with the same numeric value compare as equal, and members with the same +numeric value can be used interchangeably. + +Enumeration members are sorted by their numeric value. + +For flag enumeration types the combined numeric value of simultaneously +selected members is the bitwise OR of the discrete numeric member +values. + +::: {.varjson .rep} +### ##isec Enumeration Member Object + +Enumeration type members are represented as JSON object members, where +the object member name is the enumeration member name and the object +member value is the enumeration member value. + +For members of [flags enumeration types](#FlagsEnumerationType) a +combined enumeration member value is equivalent to the bitwise OR of the +discrete values. + +Annotations for enumeration members are prefixed with the enumeration +member name. +::: + +::: {.varjson .example} +Example ##ex: `FirstClass` has a value of 0, `TwoDay` a value of 1, and +`Overnight` a value of 2. +```json +"ShippingMethod": { + "$Kind": "EnumType", + "FirstClass": 0, + "FirstClass@Core.Description": "Shipped with highest priority", + "TwoDay": 1, + "TwoDay@Core.Description": "Shipped within two days", + "Overnight": 2, + "Overnight@Core.Description": "Shipped overnight", + "@Core.Description": "Method of shipping" +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:Member` + +The `edm:Member` element MUST contain the `Name` attribute and it MAY +contain the `Value` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the enumeration member's name. + +### ##subisec Attribute `Value` + +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`false`, either all members MUST specify an integer value for the +`Value` attribute, or all members MUST NOT specify a value for the +`Value` attribute. If no values are specified, the members are assigned +consecutive integer values in the order of their appearance, starting +with zero for the first member. Client libraries MUST preserve elements +in document order. + +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`true`, a non-negative integer value MUST be specified for the `Value` +attribute. A combined value is equivalent to the bitwise OR of the +discrete values. +::: + +::: {.varxml .example} +Example ##ex: `FirstClass` has a value of `0`, `TwoDay` a value of 1, and +`Overnight` a value of 2. +```xml + + + + + + + + + + + +``` +::: + +------- + +# ##sec Type Definition + +A type definition defines a specialization of one of the [primitive +types](#PrimitiveTypes) or of the built-in abstract type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes). + +The type definition's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Type definitions can be used wherever a primitive type is used (other +than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions +defined using the same underlying type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden. + +::: {.varjson .rep} +### ##isec Type Definition Object + +A type definition is represented as a member of the schema object whose +name is the unqualified name of the type definition and whose value is +an object. + +The type definition object MUST contain the member `$Kind` with a string +value of `TypeDefinition` and the member +[`$UnderlyingType`](#UnderlyingPrimitiveType). It MAY contain the +members [`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID), +and it MAY contain [annotations](#Annotation). +::: + +::: {.varjson .example} +Example ##ex: +```json +"Length": { + "$Kind": "TypeDefinition", + "$UnderlyingType": "Edm.Int32", + "@Measures.Unit": "Centimeters" +}, +"Weight": { + "$Kind": "TypeDefinition", + "$UnderlyingType": "Edm.Int32", + "@Measures.Unit": "Kilograms" +}, +"Size": { + "$Kind": "ComplexType", + "Height": { + "$Nullable": true, + "$Type": "self.Length" + }, + "Weight": { + "$Nullable": true, + "$Type": "self.Weight" + } +} +``` +::: + +::: {.varxml .rep} +### ##isec Element `edm:TypeDefinition` + +The `edm:TypeDefinition` element MUST contain the `Name` and +[`UnderlyingType`](#UnderlyingPrimitiveType) attributes. + +It MAY contain [`edm:Annotation`](#Annotation) elements. + +### ##subisec Attribute `Name` + +The value of `Name` is the type definition's name. +::: + +::: {.varxml .example} +Example ##ex: +```xml + + + + + + + + + + + + +``` +::: + +## ##subsec Underlying Primitive Type + +The underlying type of a type definition MUST be a primitive type that +MUST NOT be another type definition. + +::: {.varjson .rep} +### ##subisec `$UnderlyingType` + +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + +: varjson +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), +[`$Scale`](#Scale), or [`$SRID`](#SRID). +: + +::: {.varxml .rep} +### ##subisec Attribute `UnderlyingType` + +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +: varxml +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), or +[`SRID`](#SRID). +: + +Additional facets appropriate for the underlying type MAY be specified +when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified. + +For a type definition with underlying type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes) no facets are applicable, +neither in the definition itself nor when the type definition is used, +and these should be ignored by the client. + +Where type definitions are used, the type definition is returned in +place of the primitive type wherever the type is specified in a +response. diff --git a/odata-csdl/Appendix.md b/odata-csdl/Appendix.md new file mode 100644 index 000000000..4ca64455a --- /dev/null +++ b/odata-csdl/Appendix.md @@ -0,0 +1,252 @@ +------- + +# Appendix ##asec References + + + +This appendix contains the normative and informative references that are used in this document. + +While any hyperlinks included in this appendix were valid at the time of publication, OASIS cannot guarantee their long-term validity. + +## ##subasec Normative References + +The following documents are referenced in such a way that some or all of their content constitutes requirements of this document. + +###### [OData-v4.02] +- _OData Version 4.02_. Edited by Michael Pizzo, Ralf Handl, and Heiko Theißen. A multi-part Work Product that includes: + - _OData Version 4.02 Part 1: Protocol_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part1-protocol.html + - _OData Version 4.02 Part 2: URL Conventions_. Latest stage. https://docs.oasis-open.org/odata/odata/v4.02/odata-v4.02-part2-url-conventions.html + +###### [ECMAScript] +_ECMAScript 2016 Language Specification, 7th Edition_. June 2016. Standard ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm. + +###### [EPSG] +_European Petroleum Survey Group (EPSG)_. http://www.epsg.org/. + +###### [OData-ABNF] +_OData ABNF Construction Rules Version 4.01_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-CSDL-Schema] +_OData CSDL JSON Schema_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-CSDL-JSON] +_OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-CSDL-XML] +_OData Common Schema Definition Language (CSDL) XML Representation Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-EDM] +_OData EDM XML Schema_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-EDMX] +_OData EDM XML Schema_. +See link in "[Additional artifacts](#AdditionalArtifacts)" section on cover page. + +###### [OData-JSON] +_OData JSON Format Version 4.01_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-Protocol] +_OData Version 4.01 Part 1: Protocol_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-URL] +_OData Version 4.01 Part 2: URL Conventions_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocCore] +_OData Vocabularies Version 4.0: Core Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocMeasures] +_OData Vocabularies Version 4.0: Measures Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [OData-VocValidation] +_OData Vocabularies Version 4.0: Validation Vocabulary_. +See link in "[Related work](#RelatedWork)" section on cover page. + +###### [RFC2119] +_Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997_. +https://www.rfc-editor.org/info/rfc2119. + +###### [RFC6570] +_Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template”, RFC 6570, March 2012_. +http://tools.ietf.org/html/rfc6570. + +###### [RFC7493] +_Bray, T., Ed., "The I-JSON Message Format", RFC7493, March 2015_. +https://tools.ietf.org/html/rfc7493. + +###### [RFC8174] +_Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017_. +http://www.rfc-editor.org/info/rfc8174. + +###### [RFC8259] +_Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, December 2017_. +http://tools.ietf.org/html/rfc8259. + +###### [XML-1.1] +_Extensible Markup Language (XML) 1.1 (Second Edition)_. F. Yergeau, E. Maler, J. Cowan, T. Bray, C. M. Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August 2006. +http://www.w3.org/TR/2006/REC-xml11-20060816. Latest version available at http://www.w3.org/TR/xml11/. + +###### [XML-Base] +_XML Base (Second Edition)_. J. Marsh, R. Tobin, Editors, W3C Recommendation, 28 January 2009. +http://www.w3.org/TR/2009/REC-xmlbase-20090128/. Latest version available at http://www.w3.org/TR/xmlbase/. + +###### [XML-Schema-1] +_W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures_. D. Beech, M. Maloney, C. M. Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, Editors, W3C Recommendation, 5 April 2012. +http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-1/. + +###### [XML-Schema-2] +_W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes_. D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April 2012. +http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/. Latest version available at http://www.w3.org/TR/xmlschema11-2/. + +## ##subasec Informative References + +###### [OpenUI5] +_OpenUI5 Version 1.40.10 - OData V4 Metadata JSON Format_. +https://openui5.hana.ondemand.com/1.40.10/#docs/guide/87aac894a40640f89920d7b2a414499b.html. + +------- + +: varjson +# Appendix ##asec Table of JSON Objects and Members +: +: varxml +# Appendix ##asec Table of XML Elements and Attributes +: + +::: toc +$$$isec$$$ +::: + +------- + +# Appendix ##asec Acknowledgments + +## ##subasec Special Thanks + +The work of the OpenUI5 team on the OData V4 Metadata JSON Format, see +[OpenUI5](#_OpenUI5), is gratefully acknowledged, +especially the contributions of +- Thomas Chadzelek (SAP SE) +- Jens Ittel (SAP SE) +- Patric Ksinsik (SAP SE) + +The contributions of the OASIS OData Technical Committee members, +enumerated in [ODataProtocol](#ODataProtocol), are gratefully +acknowledged. + +## ##subasec Participants + + + +The following individuals have participated in the creation of this specification and are gratefully acknowledged: + +**OpenC2 TC Members:** + +| First Name | Last Name | Company | +| :--- | :--- | :--- | +Philippe | Alman | Something Networks +Alex | Amirnovman | Company B +Kris | Anderman | Mini Micro +Darren | Anstman | Big Networks + +------- + +# Appendix ##asec Revision History + + + +| Revision | Date | Editor | Changes Made | +| :--- | :--- | :--- | :--- | +$$$subtitle$$$|$$$pubdateISO$$$|Michael Pizzo
    Ralf Handl
    Heiko Theißen| + + + +# Appendix ##asec Notices + + + +Copyright © OASIS Open 2023. All Rights Reserved.-------------- +Michael Pizzo +All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full [Policy](https://www.oasis-open.org/policies-guidelines/ipr/) may be found at the OASIS website. +Ralf Handl +This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. + +This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.-------------- +Michael Pizzo +As stated in the OASIS IPR Policy, the following three paragraphs in brackets apply to OASIS Standards Final Deliverable documents (Committee Specification, OASIS Standard, or Approved Errata). +Ralf Handl +[OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this deliverable.]-------------- +Michael Pizzo +[OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this OASIS Standards Final Deliverable by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this OASIS Standards Final Deliverable. OASIS may include such claims on its website, but disclaims any obligation to do so.] +Ralf Handl +[OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this OASIS Standards Final Deliverable or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Standards Final Deliverable, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims.] + +The name "OASIS" is a trademark of [OASIS](https://www.oasis-open.org/), the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark/ for above guidance. + + + + + + + + + + + + + + + + + + + +-------------- +Michael Pizzo + +Ralf Handl + + + +-------------- +Michael Pizzo + +Ralf Handl +-------------- +Michael Pizzo + +Ralf Handl \ No newline at end of file diff --git a/odata-csdl-json/meta.yaml b/odata-csdl/json.yaml similarity index 91% rename from odata-csdl-json/meta.yaml rename to odata-csdl/json.yaml index 3e2ea3ddb..e42264112 100644 --- a/odata-csdl-json/meta.yaml +++ b/odata-csdl/json.yaml @@ -1,5 +1,6 @@ pagetitle: OData Common Schema Definition Language (CSDL) JSON Representation Version 4.02 subtitle: Committee Specification Draft 01 +dirname: odata-csdl-json filename: odata-csdl-json-v4.02-csd01 stage: csd01 previousStage: n/a diff --git a/odata-csdl/temp/odata-csdl-json-v4.01-os-clean.html b/odata-csdl/temp/odata-csdl-json-v4.01-os-clean.html new file mode 100644 index 000000000..98b574b63 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-json-v4.01-os-clean.html @@ -0,0 +1,10339 @@ + + + + + + +OData Common Schema Definition Language (CSDL) JSON Representation +Version 4.01 + + + + + +

    ##sec Introduction

    + + + +

    OData services are described in terms of an Entity Model. The Common Schema Definition Language +(CSDL) defines a representation of the entity model exposed by an OData service +using the JavaScript Object Notation (JSON), see [RFC8259].

    + +

    This format is based on the OpenUI5 OData V4 Metadata JSON +Format, see [OpenUI5], with some +extensions and modifications made necessary to fully cover OData CSDL Version +4.01.

    + +

    ##subsec IPR Policy

    + +

    This specification is provided under the RF on +RAND Terms Mode of the OASIS IPR Policy, +the mode chosen when the Technical Committee was established. For information +on whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing terms, +please refer to the Intellectual Property Rights section of the TCs web page (https://www.oasis-open.org/committees/odata/ipr.php).

    + +

    ##subsec Terminology

    + +

    The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL +NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this +document are to be interpreted as described in [RFC2119].

    + +

    ##subsec Normative References

    + +

    [ECMAScript] ECMAScript +2016 Language Specification, 7th Edition, June 2016. Standard +ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm. +

    + +

    [EPSG] European +Petroleum Survey Group (EPSG). http://www.epsg.org/. +

    + +

    [OData-ABNF] OData +ABNF Construction Rules Version 4.01.
    +See link in Additional artifacts section on cover page.

    + +

    [OData-CSDL-Schema] OData CSDL JSON +Schema.
    +
    See link in Additional artifacts section on cover page.

    + +

    [OData-CSDLXML] OData Common Schema Definition Language +(CSDL) XML Representation Version 4.01.
    +See link in Related work section on cover page.

    + +

    [OData-JSON] OData JSON Format Version 4.01. +
    +See link in Related work section on cover page.

    + +

    [OData-Protocol] OData +Version 4.01 Part 1: Protocol.
    +See link in Related work section on cover page.

    + +

    OData-URL OData +Version 4.01 Part 2: URL Conventions.
    +See link in Related work section on cover page.

    + +

    OData-VocCore OData Vocabularies +Version 4.0: Core Vocabulary.
    +See link in Related work section on cover page.

    + +

    OData-VocMeasures OData +Vocabularies Version 4.0: Measures Vocabulary.
    +See link in Related work section on cover page.

    + +

    OData-VocValidation OData +Vocabularies Version 4.0: Validation Vocabulary.
    +See link in Related work section on cover page.

    + +

    [RFC2119] Bradner, +S., Key words for use in RFCs to Indicate Requirement Levels, BCP 14, RFC +2119, March 1997. https://tools.ietf.org/html/rfc2119.

    + +

    RFC6570 Gregorio, J., +Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, URI Template, RFC +6570, March 2012. http://tools.ietf.org/html/rfc6570. +

    + +

    [RFC7493] Bray, T., Ed., "The I-JSON +Message Format", RFC7493, March 2015. https://tools.ietf.org/html/rfc7493.

    + +

    [RFC8259] Bray, +T., Ed., The JavaScript Object Notation (JSON) Data Interchange Format, RFC 8259, +December 2017. http://tools.ietf.org/html/rfc8259. +

    + +

    [XML-Schema-2] W3C +XML Schema Definition Language (XSD) 1.1 Part 2: DatatypesW3C XML Schema +Definition Language (XSD) 1.1 Part 2: Datatypes, D. Peterson, S. Gao, C. M. +Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C +Recommendation, 5 April 2012, http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/.
    +Latest version available at http://www.w3.org/TR/xmlschema11-2/.

    + +

    ##subsec Non-Normative References

    + +

    [OpenUI5] OpenUI5 Version 1.40.10 OData V4 Metadata JSON Format, https://openui5.hana.ondemand.com/1.40.10/#docs/guide/87aac894a40640f89920d7b2a414499b.html

    + +

    ##subsec Typographical Conventions

    + +

    Keywords defined by this specification use this monospaced font.

    + +

    Normative source code uses this paragraph style.

    + +

    Some sections of this specification are illustrated with +non-normative examples.

    + +

    Example 1: text describing an example uses this paragraph +style

    + +
    + +

    Non-normative examples use this paragraph style.

    + +
    + +

    All examples in this document are non-normative and +informative only.

    + +

    Representation-specific text is indented and marked with +vertical lines.

    + +
    + +

    Representation-Specific +Headline

    + +
    + +
    + +

    Normative representation-specific text

    + +
    + +

    All other text is normative unless otherwise labeled.

    + + + +

    ##sec JSON Representation

    + + + +

    OData CSDL JSON is a full representation of the OData Common +Schema Definition Language in the JavaScript Object Notation (JSON) defined in [RFC8259]. It additionally follows the rules +for Internet JSON (I-JSON) defined in [RFC7493] +for e.g. objects, numbers, date values, and duration values.

    + +

    It is an alternative to the CSDL XML representation defined +in [OData-CSDLXML] and neither adds +nor removes features.

    + +

    ##subsec Requesting the JSON Representation

    + +

    The OData CSDL JSON representation can be requested using +the $format query option in the request URL with the +media type application/json, optionally followed by +media type parameters, or the case-insensitive abbreviation json which MUST NOT be followed by media type parameters.

    + +

    Alternatively, this representation can be requested using +the Accept header with the media type application/json, optionally followed by media type +parameters.

    + +

    If specified, $format overrides +any value specified in the Accept header.

    + +

    The response MUST contain the Content-Type +header with a value of application/json, optionally +followed by media type parameters.

    + +

    Possible media type parameters are:

    + +

    IEEE754Compatible

    + +

    metadata

    + +

    The names and values of these parameters are +case-insensitive.

    + +

    ##subsubsec Controlling the Representation +of Numbers

    + +

    The IEEE754Compatible=true +parameter indicates that the service MUST serialize Edm.Int64 +and Edm.Decimal numbers as strings. This is in +conformance with RFC7493. If not specified, or specified as IEEE754Compatible=false, all numbers MUST be serialized +as JSON numbers.

    + +

    This enables support for JavaScript numbers that are defined +to be 64-bit binary format IEEE 754 values [ECMAScript] +(see section +4.3.1.9) resulting in integers losing precision past 15 digits, and +decimals losing precision due to the conversion from base 10 to base 2.

    + +

    Responses that format Edm.Int64 +and Edm.Decimal values as strings MUST specify this +parameter in the media type returned in the Content-Type +header.

    + +

    ##subsubsec Controlling the Amount of +Control Information

    + +

    The representation of constant annotation values in CSDL JSON +documents closely follows the representation of data defined in OData‑JSON.

    + +

    A client application can use the metadata +format parameter in the Accept header when +requesting a CSDL JSON document to influence how much control information will +be included in the response.

    + +

    Other Accept header parameters +are orthogonal to the metadata parameter and are +therefore not mentioned in this section.

    + +

    ##subsubsubsec metadata=minimal

    + +

    The metadata=minimal format +parameter indicates that the service SHOULD remove computable control +information from the payload wherever possible.

    + +

    This means that the @type +control information is only included if the type of the containing object or +targeted property cannot be heuristically determined, e.g. for

    + +

    Terms or term properties with an abstract declared type,

    + +

    Terms or term properties with a declared type that has derived +types, or

    + +

    Dynamic properties of open types.

    + +

    See OData‑JSON for the +exact rules.

    + +

    ##subsubsubsec metadata=full

    + +

    The metadata=full format +parameter indicates that the service MUST include all control information +explicitly in the payload.

    + +

    This means that the @type +control information is included in annotation values except for primitive +values whose type can be heuristically determined from the representation of +the value, see OData‑JSON for the exact +rules.

    + +

    ##subsubsubsec metadata=none

    + +

    The metadata=none format +parameter indicates that the service SHOULD omit all control information.

    + +

    ##subsec Design Considerations

    + +

    CSDL JSON documents are designed for easy and efficient +lookup of model constructs by their name without having to know or guess what +kind of model element it is. Thus, all primary model elements (entity types, +complex types, type definitions, enumeration types, terms, actions, functions, +and the entity container) are direct members of their schema, using the +schema-unique name as the member name. Similarly, child elements of primary +model elements (properties, navigation properties, enumeration type members, +entity sets, singletons, action imports, and function imports) are direct +members of the objects describing their parent model element, using their +locally unique name as the member name.

    + +

    To avoid name collisions, all fixed member names are +prefixed with a dollar ($) sign and otherwise have +the same name and capitalization as their counterparts in the CSDL XML +representation [OData-CSDLXML] (with +one exception: the counterpart of the EntitySet +elements EntityType attribute is $Type, +to harmonize it with all other type references).

    + +

    Additional fixed members introduced by this specification +and without counterpart in [OData-CSDLXML] +are also prefixed with a dollar ($) sign and use +upper-camel-case names. One of these is $Kind which +represents the kind of model element. Its value is the upper-camel-case local +name of the XML element representing this kind of model element in [OData-CSDLXML], e.g. EntityType +or NavigationProperty.

    + +

    While the XML representation of CSDL allows referencing +model elements with alias-qualified names as well as with namespace-qualified +names, this JSON representation requires the use of alias-qualified names if an +alias is specified for an included or document-defined schema. Aliases are +usually shorter than namespaces, so this reduces text size of the JSON +document. Text size matters even if the actual HTTP messages are sent in +compressed form because the decompressed form needs to be reconstructed, and +clients not using a streaming JSON parser have to materialize the full JSON +document before parsing.

    + +

    To further reduce size the member $Kind +is optional for structural properties as +these are more common than navigation +properties, and the member $Type is optional for string properties, parameters, +and return types, as this type is more common than other primitive types.

    + +

    In general, all members that have a default value SHOULD be +omitted if they have the default value.

    + +

    ##subsec JSON Schema Definition

    + +

    The structure of CSDL JSON documents can be verified with +the JSON Schema [OData-CSDL-Schema] +provided as an additional artifact of this prose specification. This schema +only defines the shape of a well-formed CSDL JSON document but is not +descriptive enough to define what a correct CSDL JSON document MUST be in every +imaginable use case. This specification document defines additional rules that +correct CSDL JSON documents MUST fulfill. In case of doubt on what makes a CSDL +JSON document correct the rules defined in this specification document take +precedence.

    + + + +

    ##sec Entity Model

    + + + +

    An OData service exposes a single entity model. This model +may be distributed over several schemas, and these +schemas may be distributed over several documents.

    + +

    A service is defined by a single CSDL document which can be +accessed by sending a GET request to <serviceRoot>/$metadata. This document is called +the metadata document. It MAY reference other CSDL +documents.

    + +

    The metadata document contains a single entity container that defines the resources +exposed by this service. This entity container MAY extend an entity container defined +in a referenced document.

    + +

    The model of the service consists of all CSDL +constructs used in its entity containers.

    + +

    The scope of a CSDL document is the document itself +and all schemas included from directly referenced documents. All entity types, complex types +and other named model elements in scope (that is, defined in the +document itself or a schema of a directly referenced document) can be accessed +from a referencing document by their qualified names. This includes the built-in primitive and abstract types.

    + +

    Referencing another document may alter the model defined by +the referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, then an entity set of the service defined by the referencing +document may return entities of the derived type. This is identical to the +behavior if the derived type had been defined directly in the referencing +document.

    + +

    Note: referencing documents is not recursive. Only named +model elements defined in directly referenced documents can be used within the +schema. However, those elements may in turn include or reference model elements +defined in schemas referenced by their defining schema.

    + +

    ##subsec Nominal Types

    + +

    A nominal type has a name that MUST be a simple identifier. Nominal types are +referenced using their qualified name. The +qualified type name MUST be unique within a model as it facilitates references +to the element from other parts of the model.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    ##subsec Structured Types

    + +

    Structured types are composed of other model elements. +Structured types are common in entity models as the means of representing +entities and structured properties in an OData service. Entity types and complex +types are both structured types.

    + +

    Structured Types are composed of zero or more structural properties and navigation properties.

    + +

    Open entity types and open complex types allow properties to be added +dynamically to instances of the open type.

    + +

    ##subsec Primitive Types

    + +

    Structured types are composed of other structured types and +primitive types. OData defines the following primitive types:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Type

    +
    +

    Meaning

    +
    +

    Edm.Binary

    +
    +

    Binary data

    +
    +

    Edm.Boolean

    +
    +

    Binary-valued logic

    +
    +

    Edm.Byte

    +
    +

    Unsigned 8-bit integer

    +
    +

    Edm.Date

    +
    +

    Date without a time-zone offset

    +
    +

    Edm.DateTimeOffset

    +
    +

    Date and time with a time-zone offset, no leap seconds

    +
    +

    Edm.Decimal

    +
    +

    Numeric values with decimal representation

    +
    +

    Edm.Double

    +
    +

    IEEE 754 binary64 floating-point number (15-17 decimal + digits)

    +
    +

    Edm.Duration

    +
    +

    Signed duration in days, hours, minutes, and (sub)seconds

    +
    +

    Edm.Guid

    +
    +

    16-byte (128-bit) unique identifier

    +
    +

    Edm.Int16

    +
    +

    Signed 16-bit integer

    +
    +

    Edm.Int32

    +
    +

    Signed 32-bit integer

    +
    +

    Edm.Int64

    +
    +

    Signed 64-bit integer

    +
    +

    Edm.SByte

    +
    +

    Signed 8-bit integer

    +
    +

    Edm.Single

    +
    +

    IEEE 754 binary32 floating-point number (6-9 decimal + digits)

    +
    +

    Edm.Stream

    +
    +

    Binary data stream

    +
    +

    Edm.String

    +
    +

    Sequence of characters

    +
    +

    Edm.TimeOfDay

    +
    +

    Clock time 00:00-23:59:59.999999999999

    +
    +

    Edm.Geography

    +
    +

    Abstract base type for all Geography types

    +
    +

    Edm.GeographyPoint

    +
    +

    A point in a round-earth coordinate system

    +
    +

    Edm.GeographyLineString

    +
    +

    Line string in a round-earth coordinate system

    +
    +

    Edm.GeographyPolygon

    +
    +

    Polygon in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiPoint

    +
    +

    Collection of points in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiLineString

    +
    +

    Collection of line strings in a round-earth coordinate + system

    +
    +

    Edm.GeographyMultiPolygon

    +
    +

    Collection of polygons in a round-earth coordinate system

    +
    +

    Edm.GeographyCollection

    +
    +

    Collection of arbitrary Geography values

    +
    +

    Edm.Geometry

    +
    +

    Abstract base type for all Geometry types

    +
    +

    Edm.GeometryPoint

    +
    +

    Point in a flat-earth coordinate system

    +
    +

    Edm.GeometryLineString

    +
    +

    Line string in a flat-earth coordinate system

    +
    +

    Edm.GeometryPolygon

    +
    +

    Polygon in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiPoint

    +
    +

    Collection of points in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiLineString

    +
    +

    Collection of line strings in a flat-earth coordinate + system

    +
    +

    Edm.GeometryMultiPolygon

    +
    +

    Collection of polygons in a flat-earth coordinate system

    +
    +

    Edm.GeometryCollection

    +
    +

    Collection of arbitrary Geometry values

    +
    + +

    Edm.Date and Edm.DateTimeOffset follow [XML‑Schema‑2] +and use the proleptic Gregorian calendar, allowing the year 0000 (equivalent to 1 BCE) and negative years (year -0001 being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying persistency +layer, e.g. SQL only supports years 0001 to 9999.

    + +

    Edm.Decimal with a Scale value of floating, Edm.Double, and Edm.Single allow the special numeric values ‑INF, INF, and NaN.

    + +

    Edm.Stream is a primitive type +that can be used as a property of an entity type +or complex type, the underlying type for a type definition, or the binding parameter or +return type of an action or +function. Edm.Stream, +or a type definition whose underlying type is Edm.Stream, +cannot be used in collections or for non-binding parameters to functions or +actions.

    + +

    Some of these types allow facets, +defined in section Type Facets.

    + +

    See rule primitiveLiteral in OData‑ABNF for the representation of +primitive type values in URLs and OData‑JSON +for the representation in requests and responses.

    + +

    ##subsec Built-In Abstract Types

    + +

    The following built-in abstract types can be used within a +model:

    + +

    Edm.PrimitiveType

    + +

    Edm.ComplexType

    + +

    Edm.EntityType

    + +

    Edm.Untyped

    + +

    Conceptually, these are the abstract base types for +primitive types (including type definitions and enumeration types), complex +types, entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except:

    + +

    Edm.EntityType

    + +
      +
        +
      • cannot be used as the type of a singleton in an entity container + because it doesnt define a structure, which defeats the purpose of a + singleton.
      • +
      • cannot be used as the type of an entity set because all + entities in an entity set must have the same key fields to uniquely + identify them within the set.
      • +
      • cannot be the base type of an entity type or complex type.
      • +
      +
    + +

    Edm.ComplexType

    + +
      +
        +
      • cannot be the base type of an entity type or complex type.
      • +
      +
    + +

    Edm.PrimitiveType

    + +
      +
        +
      • cannot be used as the type of a key property of an entity + type or as the underlying type of an enumeration type.
      • +
      • cannot be used as the underlying type of a type + definition in a CSDL document with a version of 4.0.
      • +
      • can be used as the underlying type of a type definition + in a CSDL document with a version of 4.01 or greater.
      • +
      +
    + +

    Edm.Untyped

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      • cannot be used as the type of a key property of an entity + type.
      • +
      • cannot be the base type of an entity type or complex type.
      • +
      • cannot be used as the underlying type of a type + definition or enumeration type.
      • +
      +
    + +

    Collection(Edm.PrimitiveType)

    + +
      +
        +
      • cannot be used as the type of a property or term.
      • +
      • cannot be used as the type of a parameter or the return + type of an action or function.
      • +
      +
    + +

    Collection(Edm.Untyped)

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      +
    + +

    ##subsec Built-In Types for defining +Vocabulary Terms

    + +

    Vocabulary terms +can, in addition, use

    + +

    Edm.AnnotationPath

    + +

    Edm.PropertyPath

    + +

    Edm.NavigationPropertyPath

    + +

    Edm.AnyPropertyPath (Edm.PropertyPath or Edm.NavigationPropertyPath)

    + +

    Edm.ModelElementPath (any +model element, including Edm.AnnotationPath, Edm.NavigationPropertyPath, and Edm.PropertyPath)

    + +

    as the type of a primitive term, or the type of a property +of a complex type (recursively) that is exclusively used as the type of a term. +See section Path Expressions for details.

    + +

    ##subsec Annotations

    + +

    Many parts of the model can be decorated with additional +information using annotations. Annotations are +identified by their term name and an optional qualifier that allows applying +the same term multiple times to the same model element.

    + +

    A model element MUST NOT specify more than one annotation +for a given combination of term and qualifier.

    + + + +

    ##sec CSDL JSON Document

    + + + +
    + +

    Document Object

    + +
    + +
    + +

    A CSDL JSON document consists of a +single JSON object. This document object MUST contain the member $Version.

    + +

    The document object MAY contain the +member $Reference +to reference other CSDL documents.

    + +

    It also MAY contain members for schemas.

    + +

    If the CSDL JSON document is the +metadata document of an OData service, the document object MUST contain the +member $EntityContainer.

    + +
    + +
    + +

    $Version

    + +
    + +
    + +

    The value of $Version +is a string containing either 4.0 or 4.01.

    + +
    + + + +
    + +

    The value of $EntityContainer +is value is the namespace-qualified name of the entity container of that +service. This is the only place where a model element MUST be referenced with +its namespace-qualified name and use of the alias-qualified name is not +allowed.

    + +
    + +

    Example 2:

    + +
    + +

    {

    + +

    "$Version": +"4.01",

    + +

    "$EntityContainer": "org.example.DemoService",

    + +

    + +

    }

    + +
    + +

    ##subsec Reference

    + +

    A reference to an external CSDL document allows to bring +part of the referenced documents content into the scope of the referencing +document.

    + +

    A reference MUST specify a URI that uniquely identifies the +referenced document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be absolute +or relative URI; relative URLs are relative to the URL of the document +containing the reference, or relative to a base URL specified in a format-specific +way.

    + +

    A reference MAY be annotated.

    + +

    The Core.SchemaVersion annotation, +defined in OData-VocCore, MAY be used to +indicate a particular version of the referenced document. If the Core.SchemaVersion annotation is +present, the $schemaversion system query option, +defined OData‑Protocol, SHOULD +be used when retrieving the referenced schema document.

    + +
    + +

    $Reference

    + +
    + +
    + +

    The value of $Reference +is an object that contains one member per referenced CSDL document. The name of +the pair is a URI for the referenced document. The URI MAY be relative to the +document containing the $Reference. The value of +each member is a reference object.

    + +
    + +
    + +

    Reference Object

    + +
    + +
    + +

    The reference object MAY contain the +members $Include +and $IncludeAnnotations +as well as annotations.

    + +
    + +

    Example 3: references to other CSDL documents

    + +
    + +

    {

    + +

    + +

    "$Reference": {

    + +

    "http://vocabs.odata.org/capabilities/v1": +{

    + +

    + +

    },

    + +

    "http://vocabs.odata.org/core/v1": +{

    + +

    + +

    },

    + +

    "http://example.org/display/v1": +{

    + +

    + +

    }

    + +

    },

    + +

    + +

    }

    + +
    + +

    ##subsec Included Schema

    + +

    A reference MAY include zero or more schemas from the +referenced document.

    + +

    The included schemas are identified via their namespace. The same +namespace MUST NOT be included more than once, even if it is declared in more +than one referenced document.

    + +

    When including a schema, a simple +identifier value MAY be specified as an alias for the schema that is used +in qualified names instead of the namespace. For example, an alias of display might be assigned to the namespace org.example.vocabularies.display. An alias-qualified name +is resolved to a fully qualified name by examining aliases for included schemas +and schemas defined within the document.

    + +
    + +

    If an included schema specifies an +alias, the alias MUST be used in qualified names throughout the document to +identify model elements of the included schema. A mixed use of +namespace-qualified names and alias-qualified names is not allowed.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document.

    + +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +

    An alias is only valid within the document in which it is +declared; a referencing document may define its own aliases for included +schemas.

    + +
    + +

    $Include

    + +
    + +
    + +

    The value of $Include +is an array. Array items are objects that MUST contain the member $Namespace and MAY contain the member $Alias.

    + +

    The item objects MAY contain annotations.

    + +
    + +
    + +

    $Namespace

    + +
    + +
    + +

    The value of $Namespace +is a string containing the namespace of the included schema.

    + +
    + +
    + +

    $Alias

    + +
    + +
    + +

    The value of $Alias +is a string containing the alias for the included schema.

    + +
    + +

    Example 4: references to entity models containing +definitions of vocabulary terms

    + +
    + +

    {

    + +

    + +

    "$Reference": {

    + +

    "http://vocabs.odata.org/capabilities/v1": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": +"Org.OData.Capabilities.V1",

    + +

    "$Alias": +"Capabilities"

    + +

    }

    + +

    ]

    + +

    },

    + +

    "http://vocabs.odata.org/core/v1": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": +"Org.OData.Core.V1",

    + +

    "$Alias": +"Core",

    + +

    +"@Core.DefaultNamespace": true

    + +

    }

    + +

    ]

    + +

    },

    + +

    "http://example.org/display/v1": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "org.example.display",

    + +

    "$Alias": +"UI"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    + +

    }

    + +
    + +

    ##subsec Included Annotations

    + +

    In addition to including whole schemas with all model +constructs defined within that schema, annotations can be included with more +flexibility.

    + +

    Annotations are selectively included by specifying the namespace of the +annotations term. Consumers can opt not to inspect the referenced document if +none of the term namespaces is of interest for the consumer.

    + +

    In addition, the qualifier of +annotations to be included MAY be specified. For instance, a service author might +want to supply a different set of annotations for various device form factors. +If a qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of the +target namespace, if present) SHOULD be included. If no qualifier is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the target namespace, if present) SHOULD be +included.

    + +

    The qualifier also provides consumers insight about what +qualifiers are present in the referenced document. If the consumer is not +interested in that particular qualifier, the consumer can opt not to inspect +the referenced document.

    + +

    In addition, the namespace of the annotations target MAY be specified. If a target namespace is +specified, only those annotations which apply a term form the specified term +namespace to a model element of the target namespace (with the specified +qualifier, if present) SHOULD be included. If no target namespace is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the qualifier, if present) SHOULD be included.

    + +

    The target namespace also provides consumers insight about +what namespaces are present in the referenced document. If the consumer is not +interested in that particular target namespace, the consumer can opt not to +inspect the referenced document.

    + + + +
    + +

    The value of $IncludeAnnotations +is an array. Array items are objects that MUST contain the member $TermNamespace and MAY contain the members $Qualifier and $TargetNamespace.

    + +
    + + + +
    + +

    The value of $TermNamespace +is a namespace.

    + +
    + +
    + +

    $Qualifier

    + +
    + +
    + +

    The value of $Qualifier +is a simple identifier.

    + +
    + + + +
    + +

    The value of $TargetNamespace +is a namespace.

    + +
    + +

    Example 5: reference documents that contain annotations

    + +
    + +

    {

    + +

    + +

    "$Reference": {

    + +

    +"http://odata.org/ann/b": {

    + +

    "$IncludeAnnotations": +[

    + +

    {

    + +

    "$TermNamespace": +"org.example.validation"

    + +

    },

    + +

    {

    + +

    "$TermNamespace": +"org.example.display",

    + +

    "$Qualifier": +"Tablet"

    + +

    },

    + +

    {

    + +

    "$TermNamespace": +"org.example.hcm",

    + +

    +"$TargetNamespace": "com.example.Sales"

    + +

    },

    + +

    {

    + +

    "$TermNamespace": +"org.example.hcm",

    + +

    "$Qualifier": +"Tablet",

    + +

    +"$TargetNamespace": "com.example.Person"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    + +

    }

    + +
    + +

    The following annotations from http://odata.org/ann/b are included:

    + +

    Annotations that use a term from the org.example.validation +namespace, and

    + +

    Annotations that use a term from the org.example.display +namespace and specify a Tablet +qualifier and

    + +

    Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Sales +namespace and

    + +

    Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Person +namespace and specify a Tablet +qualifier.

    + + + +

    ##sec Schema

    + + + +

    One or more schemas describe the entity model exposed by an +OData service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms.

    + +

    A schema is identified by a namespace. +Schema namespaces MUST be unique within the scope of a document and SHOULD be +globally unique. A schema cannot span more than one document.

    + +

    The schemas namespace is combined with the name of elements +in the schema to create unique qualified names, so identifiers that are used to name types MUST be +unique within a namespace to prevent ambiguity.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    The namespace MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +
    + +

    Schema Object

    + +
    + +
    + +

    A schema is represented as a member of +the document object whose name is the schema namespace. Its value is an object +that MAY contain the members $Alias and $Annotations.

    + +

    The schema object MAY contain members +representing entity types, complex types, enumeration +types, type definitions, actions, functions, terms, and an entity +container.

    + +

    The schema object MAY also contain annotations that apply to the schema itself.

    + +
    + +

    ##subsec Alias

    + +

    A schema MAY specify an alias which MUST be a simple identifier.

    + +
    + +

    If a schema specifies an alias, the +alias MUST be used instead of the namespace within qualified names throughout +the document to identify model elements of that schema. A mixed use of +namespace-qualified names and alias-qualified names is not allowed.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the containing +document and are not restricted to the schema that defines them.

    + +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +
    + +

    $Alias

    + +
    + +
    + +

    The value of $Alias +is a string containing the alias for the schema.

    + +
    + +

    Example 6: document defining a +schema org.example with an alias and a description +for the schema

    + +
    + +

    {

    + +

    + +

    "org.example": {

    + +

    "$Alias": +"self",

    + +

    "@Core.Description": +"Example schema",

    + +

    + +

    },

    + +

    + +

    }

    + +
    + +

    ##subsec Annotations with External +Targeting

    + +
    + +

    $Annotations

    + +
    + +
    + +

    The value of $Annotations +is an object with one member per annotation target. +The member name is a path identifying the annotation +target, the member value is an object containing annotations +for that target.

    + +
    + +

    Example 7: annotations targeting the Person +type with qualifier Tablet

    + +
    + +

    "org.example": {

    + +

    "$Alias": +"self",

    + +

    "$Annotations": {

    + +

    "self.Person": {

    + +

    +"@Core.Description#Tablet": "Dummy",

    + +

    + +

    }

    + +

    }

    + +

    },

    + +
    + + + +

    ##sec Entity Type

    + + + +

    Entity types are nominal structured types with a key that consists of +one or more references to structural +properties. An entity type is the template for an entity: any uniquely +identifiable record such as a customer or order.

    + +

    The entity types name is a simple +identifier that MUST be unique within its schema.

    + +

    An entity type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, +complex, or enumeration types. A navigation +property is a named reference to another entity type or collection of +entity types.

    + +

    All properties MUST have a unique name within an entity +type. Properties MUST NOT have the same name as the declaring entity type. They +MAY have the same name as one of the direct or indirect base types or derived +types.

    + +
    + +

    Entity Type Object

    + +
    + +
    + +

    An entity type is represented as a +member of the schema object whose name is the unqualified name of the entity +type and whose value is an object.

    + +

    The entity type object MUST contain +the member $Kind with a string value of EntityType.

    + +

    It MAY contain the members $BaseType, +$Abstract, +$OpenType, +$HasStream, +and $Key.

    + +

    It also MAY contain members +representing structural properties and navigation properties as well as annotations.

    + +
    + +

    Example 8: +a simple entity type

    + +
    + +

    "Employee": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "FirstName": {},

    + +

    "LastName": {},

    + +

    "Manager": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Manager"

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Derived Entity Type

    + +

    An entity type can inherit from another entity type by +specifying it as its base type.

    + +

    An entity type inherits the key as +well as structural and navigation properties of its base type.

    + +

    An entity type MUST NOT introduce an inheritance cycle by +specifying a base type.

    + +
    + +

    $BaseType

    + +
    + +
    + +

    The value of $BaseType +is the qualified name of the base type.

    + +
    + +

    Example 9: a derived entity type based on the previous +example

    + +
    + +

    "Manager": {

    + +

    "$Kind": +"EntityType",

    + +

    "$BaseType": "self.Employee",

    + +

    "AnnualBudget": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    },

    + +

    "Employees": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Employee"

    + +

    }

    + +

    }

    + +
    + +

    Note: the derived type has the same name as one of the +properties of its base type.

    + +

    ##subsec Abstract Entity Type

    + +

    An entity type MAY indicate that it is abstract and cannot +have instances.

    + +

    For OData 4.0 responses a non-abstract entity type MUST +define a key or derive +from a base type with a defined key.

    + +

    An abstract entity type MUST NOT inherit from a non-abstract +entity type.

    + +
    + +

    $Abstract

    + +
    + +
    + +

    The value of $Abstract +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    ##subsec Open Entity Type

    + +

    An entity type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    An entity type derived from an open entity type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see OData‑Protocol.

    + +
    + +

    $OpenType

    + +
    + +
    + +

    The value of $OpenType +is one of the Boolean literals true or false. Absence of the member means false. +

    + +
    + +

     

    + +

    ##subsec Media Entity Type

    + +

    An entity type that does not specify a base type MAY +indicate that it is a media entity type. Media entities are entities +that represent a media stream, such as a photo. Use a media entity if the +out-of-band stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal entity +with one or more properties of type Edm.Stream if +the structured data of the entity is the main topic of interest and the stream +data is just additional information attached to the structured data. For more +information on media entities see OData‑Protocol.

    + +

    An entity type derived from a media entity type MUST +indicate that it is also a media entity type.

    + +

    Media entity types MAY specify a list of acceptable media +types using an annotation with term Core.AcceptableMediaTypes, see OData-VocCore.

    + +
    + +

    $HasStream

    + +
    + +
    + +

    The value of $HasStream +is one of the Boolean literals true or false. Absence of the member means false. +

    + +
    + +

    ##subsec Key

    + +

    An entity is uniquely identified within an entity set by its +key. A key MAY be specified if the entity type does not specify a base type that already has a key declared.

    + +

    In order to be specified as the type of an entity set or a collection-valued containment navigation property, +the entity type MUST either specify a key or inherit its key from its base type.

    + +

    In OData 4.01 responses entity types used for singletons or single-valued navigation properties do not require a key. +In OData 4.0 responses entity types used for singletons +or single-valued navigation properties +MUST have a key defined.

    + +

    An entity type (whether or not it is marked as abstract) MAY +define a key only if it doesnt inherit one.

    + +

    An entity types key refers to the set of properties whose +values uniquely identify an instance of the entity type within an entity set. +The key MUST consist of at least one property.

    + +

    Key properties MUST NOT be nullable and MUST be typed with +an enumeration type, +one of the following primitive types, or a type definition based on one of these primitive +types:

    + +
      +
    • Edm.Boolean
    • +
    • Edm.Byte
    • +
    • Edm.Date
    • +
    • Edm.DateTimeOffset
    • +
    • Edm.Decimal
    • +
    • Edm.Duration
    • +
    • Edm.Guid
    • +
    • Edm.Int16
    • +
    • Edm.Int32
    • +
    • Edm.Int64
    • +
    • Edm.SByte
    • +
    • Edm.String
    • +
    • Edm.TimeOfDay
    • +
    + +

    Key property values MAY be language-dependent, but their +values MUST be unique across all languages and the entity ids (defined in OData‑Protocol) MUST be language +independent.

    + +

    A key property MUST be a non-nullable primitive property of +the entity type itself, including non-nullable primitive properties of +non-nullable single-valued complex properties, recursively.

    + +

    In OData 4.01 the key properties of a directly related +entity type MAY also be part of the key if the navigation property is +single-valued and not nullable. This includes navigation properties of +non-nullable single-valued complex properties (recursively) of the entity type. +If a key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key.

    + +

    If the key property is a property of a complex property +(recursively) or of a directly related entity type, the key MUST specify an +alias for that property that MUST be a simple +identifier and MUST be unique within the set of aliases, structural and +navigation properties of the declaring entity type and any of its base types.

    + +

    An alias MUST NOT be defined if the key property is a +primitive property of the entity type itself.

    + +

    For key properties that are a property of a complex or +navigation property, the alias MUST be used in the key predicate of URLs +instead of the path to the property because the required percent-encoding of +the forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be used in +the query part of URLs, where paths to properties dont require special +encoding and are a standard constituent of expressions anyway.

    + +
    + +

    $Key

    + +
    + +
    + +

    The value of $Key +is an array with one item per key property.

    + +

    Key properties without a key alias are +represented as strings containing the property name.

    + +

    Key properties with a key alias are +represented as objects with one member whose name is the key alias and whose +value is a string containing the path to the property.

    + +
    + +

    Example 10: entity type with a simple key

    + +
    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true,

    + +

    "@Core.IsLanguageDependent": +true

    + +

    }

    + +

    }

    + +
    + +

    Example 11: +entity type with a simple key referencing a property of a complex type

    + +
    + +

    "Category": {

    + +

    "$Kind": "EntityType",

    + +

    "$Key": [

    + +

    {

    + +

    "EntityInfoID": +"Info/ID"

    + +

    }

    + +

    ],

    + +

    "Info": {

    + +

    "$Type": "self.EntityInfo"

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    }

    + +

    },

    + +

    "EntityInfo": {

    + +

    "$Kind": +"ComplexType",

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Created": {

    + +

    "$Type": +"Edm.DateTimeOffset",

    + +

    "$Precision": 0

    + +

    }

    + +

    }

    + +
    + +

    Example 12: entity type with a composite key

    + +
    + +

    "OrderLine": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "OrderID",

    + +

    "LineNumber"

    + +

    ],

    + +

    "OrderID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "LineNumber": {

    + +

    "$Type": +"Edm.Int32"

    + +

    }

    + +

    }

    + +
    + +

    Example 13 (based on example 11): +requests to an entity set Categories +of type Category must use the +alias

    + +
    + +

    GET http://host/service/Categories(EntityInfoID=1)

    + +
    + +

    Example 14 (based on example 11): +in a query part the value assigned to the name attribute must be used

    + +
    + +

    GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100

    + +
    + + + +

    ##sec Structural Property

    + + + +

    A structural property is a property of a structured type +that has one of the following types:

    + +

    Primitive type

    + +

    Complex type

    + +

    Enumeration type

    + +

    A collection of one of the above

    + +

    A structural property MUST specify a unique name as well as +a type.

    + +

    The propertys name MUST be a simple +identifier. It is used when referencing, +serializing or deserializing the property. It MUST be unique within the set of +structural and navigation properties of the declaring structured type, +and MUST NOT match the name of any navigation property in any of its base +types. If a structural property with the same name is defined in any of this +types base types, then the propertys type MUST be a type derived from the type +specified for the property of the base type and constrains this property to be +of the specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +
    + +

    Property Object

    + +
    + +
    + +

    Structural properties are represented +as members of the object representing a structured type. The member name is the +property name, the member value is an object.

    + +

    The property object MAY contain the +member $Kind with a string value of Property. This member SHOULD be omitted to reduce +document size.

    + +

    It MAY contain the member $Type, $Collection, +$Nullable, +$MaxLength, +$Unicode, +$Precision, +$Scale, +$SRID, +and $DefaultValue. +

    + +

    It also MAY contain annotations.

    + +
    + +

    Example 15: complex type with two properties Dimension and Length

    + +
    + +

    "Measurement": {

    + +

    "$Kind": +"ComplexType",

    + +

    "Dimension": {

    + +

    "$MaxLength": 50,

    + +

    "$DefaultValue": +"Unspecified"

    + +

    },

    + +

    "Length": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Precision": 18,

    + +

    "$Scale": 2

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Type

    + +

    The propertys type MUST be a primitive +type, complex type, or enumeration type in scope, or a collection of +one of these types.

    + +

    A collection-valued property MAY be annotated with the Core.Ordered +term, defined in
    +OData-VocCore), to specify that it +supports a stable ordering.

    + +

    A collection-valued property MAY be annotated with the Core.PositionalInsert +term, defined in OData-VocCore), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued properties the value +of $Type is the qualified name of the propertys +type.

    + +

    For collection-valued properties the +value of $Type is the qualified name of the +propertys item type, and the member $Collection +MUST be present with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String. This member +SHOULD be omitted for string properties to reduce document size.

    + +
    + +

    Example 16: property Units that +can have zero or more strings as its value

    + +
    + +

    "Units": {

    + +

    "$Collection": true

    + +

    }

    + +
    + +

    ##subsec Type Facets

    + +

    Facets modify or constrain the acceptable values of a +property.

    + +

    For single-valued properties the facets apply to the value +of the property. For collection-valued properties the facets apply to the items +in the collection.

    + +

    ##subsubsec Nullable

    + +

    A Boolean value specifying whether the property can have the +value null.

    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +

    For single-valued properties the value +true means that the property allows the null value.

    + +

    For collection-valued properties the +property value will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +
    + +

    ##subsubsec MaxLength

    + +

    A positive integer value specifying the maximum length of a +binary, stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length (number +of code points for Unicode).

    + +

    If no maximum length is specified, clients SHOULD expect +arbitrary length.

    + +
    + +

    $MaxLength

    + +
    + +
    + +

    The value of $MaxLength +is a positive integer.

    + +

    Note: [OData-CSDLXML] +defines a symbolic value max that is only allowed +in OData 4.0 responses. This symbolic value is not allowed in CDSL JSON +documents at all. Services MAY instead specify the concrete maximum length supported +for the type by the service or omit the member entirely.

    + +
    + +

    ##subsubsec Precision

    + +

    For a decimal value: the maximum number of significant +decimal digits of the propertys value; it MUST be a positive integer.

    + +

    For a temporal value (datetime-with-timezone-offset, +duration, or time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve.

    + +

    Note: service authors SHOULD be aware that some clients are +unable to support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential for data +loss when round-tripping values of greater precision. Updating via PATCH and exclusively specifying modified properties will +reduce the risk for unintended data loss.

    + +

    Note: duration properties supporting a granularity less than +seconds (e.g. minutes, hours, days) can be annotated with term Measures.DurationGranularity, see OData-VocMeasures.

    + +
    + +

    $Precision

    + +
    + +
    + +

    The value of $Precision +is a number.

    + +

    Absence of $Precision +means arbitrary precision.

    + +
    + +

    Example 17: Precision facet applied to the DateTimeOffset type

    + +
    + +

    "SuggestedTimes": {

    + +

    "$Type": Edm.DateTimeOffset",

    + +

    "$Collection": true,

    + +

    "$Precision": 6

    + +

    }

    + +
    + +

    ##subsubsec Scale

    + +

    A non-negative integer value specifying the maximum number +of digits allowed to the right of the decimal point, or one of the symbolic +values floating or variable.

    + +

    The value floating means that the +decimal property represents a decimal floating-point number whose number of +significant digits is the value of the Precision facet. OData 4.0 responses +MUST NOT specify the value floating.

    + +

    The value variable +means that the number of digits to the right of the decimal point can vary from +zero to the value of the Precision facet.

    + +

    An integer value means that the number of digits to the +right of the decimal point may vary from zero to the value of the Scale facet, and the number of digits to the left of the +decimal point may vary from one to the value of the Precision +facet minus the value of the Scale facet. If Precision is equal to Scale, +a single zero MUST precede the decimal point.

    + +

    The value of Scale MUST be less +than or equal to the value of Precision.

    + +

    Note: if the underlying data store allows negative scale, services +may use a Precision +with the absolute value of the negative scale added to the actual number of +significant decimal digits, and client-provided values may have to be rounded +before being stored.

    + +
    + +

    $Scale

    + +
    + +
    + +

    The value of $Scale +is a number or a string with one of the symbolic values floating +or variable.

    + +

    Services +SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner.

    + +

    Absence of $Scale +means variable.

    + +
    + +

    Example 18: Precision=3 and Scale=2. +
    +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3

    + +
    + +

    "Amount32": {

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 3,

    + +

    "$Scale": 2

    + +

    }

    + +
    + +

    Example 19: Precision=2 +equals Scale.
    +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2

    + +
    + +

    "Amount22": {

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 2,

    + +

    "$Scale": 2

    + +

    }

    + +
    + +

    Example 20: Precision=3 +and a variable Scale.
    +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed values: 12.34, +1234 and 123.4 due to the limited precision.

    + +
    + +

    "Amount3v": {

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 3

    + +

    }

    + +
    + +

    Example 21: Precision=7 +and a floating Scale.
    +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: 1e-102 +and 1e97 due to the limited precision.

    + +
    + +

    "Amount7f": +{

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 7,

    + +

    "$Scale": +"floating"

    + +

    }

    + +
    + +

    ##subsubsec Unicode

    + +

    For a string property the Unicode +facet indicates whether the property might contain and accept string values +with Unicode characters (code points) beyond the ASCII character set. The value +false indicates that the property will only contain +and accept string values with characters limited to the ASCII character set.

    + +

    If no value is specified, the Unicode +facet defaults to true.

    + +
    + +

    $Unicode

    + +
    + +
    + +

    The value of $Unicode +is one of the Boolean literals true or false. Absence of the member means true. +

    + +
    + +

    ##subsubsec SRID

    + +

    For a geometry or geography property the SRID facet identifies which spatial reference system is +applied to values of the property on type instances.

    + +

    The value of the SRID facet MUST +be a non-negative integer or the special value variable. +If no value is specified, the facet defaults to 0 +for Geometry types or 4326 +for Geography types.

    + +

    The valid values of the SRID +facet and their meanings are as defined by the European Petroleum Survey Group [EPSG].

    + +
    + +

    $SRID

    + +
    + +
    + +

    The value of $SRID +is a string containing a number or the symbolic value variable. +

    + +
    + +

    ##subsubsec Default Value

    + +

    A primitive or enumeration property MAY define a default +value that is used if the property is not explicitly represented in an +annotation or the body of a request or response.

    + +

    If no value is specified, the client SHOULD NOT assume a +default value.

    + + + +
    + +

    The value of $DefaultValue +is the type-specific JSON representation of the default value of the property, +see [OData-JSON]. For properties of +type Edm.Decimal and Edm.Int64 +the representation depends on the media type parameter IEEE754Compatible.

    + +
    + + + +

    ##sec Navigation Property

    + + + +

    A navigation property allows navigation to related entities. +It MUST specify a unique name as well as a type.

    + +

    The navigation propertys name MUST be a simple identifier. It +is used when referencing, serializing or deserializing the navigation property. +It MUST be unique within the set of structural and navigation properties of the +declaring structured type, and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the same name +is defined in any of this types base types, then the navigation propertys +type MUST be a type derived from the type specified for the navigation property +of the base type, and constrains this navigation property to be of the +specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +
    + +

    Navigation Property Object

    + +
    + +
    + +

    Navigation properties are represented +as members of the object representing a structured type. The member name is the +property name, the member value is an object.

    + +

    The navigation property object MUST +contain the member $Kind with a string value of NavigationProperty.

    + +

    It MUST contain the member $Type, +and it MAY contain the members $Collection, $Nullable, +$Partner, +$ContainsTarget, +$ReferentialConstraint, +and $OnDelete. +

    + +

    It also MAY contain annotations.

    + +
    + +

    Example 22: the Product entity +type has a navigation property to a Category, which +has a navigation link back to one or more products

    + +
    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "Category": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Category",

    + +

    "$Partner": +"Products",

    + +

    +"$ReferentialConstraint": {

    + +

    "CategoryID": +"ID"

    + +

    }

    + +

    },

    + +

    "Supplier": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Supplier"

    + +

    }

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "Products": {

    + +

    "$Kind": "NavigationProperty",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$Partner": +"Category",

    + +

    "$OnDelete": +"Cascade",

    + +

    "$OnDelete@Core.Description": +"Delete all related entities"

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Navigation +Property Type

    + +

    The navigation propertys type MUST be an entity type in scope, the abstract type Edm.EntityType, +or a collection of one of these types.

    + +

    If the type is a collection, an arbitrary number of entities +can be related. Otherwise there is at most one related entity.

    + +

    The related entities MUST be of the specified entity type or +one of its subtypes.

    + +

    For a collection-valued containment navigation property the +specified entity type MUST have a key defined.

    + +

    A collection-valued navigation property MAY be annotated +with the Core.Ordered +term, defined in OData-VocCore), to +specify that it supports a stable ordering.

    + +

    A collection-valued navigation property MAY be annotated +with the Core.PositionalInsert +term, defined in OData-VocCore), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued navigation +properties the value of $Type is the qualified name +of the navigation propertys type.

    + +

    For collection-valued navigation +properties the value of $Type is the qualified name +of the navigation propertys item type, and the member $Collection +MUST be present with the literal value true.

    + +
    + +

    ##subsec Nullable +Navigation Property

    + +

    A Boolean value specifying whether the declaring type MAY +have no related entity. If false, instances of the declaring structured type +MUST always have a related entity.

    + +

    Nullable MUST NOT be specified for a collection-valued +navigation property, a collection is allowed to have zero items.

    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    ##subsec Partner Navigation Property

    + +

    A navigation property of an entity +type MAY specify a partner navigation property. Navigation properties of +complex types MUST NOT specify a partner.

    + +

    If specified, the partner navigation property is identified +by a path relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that type or +a derived type. The path MAY traverse complex types, including derived complex +types, but MUST NOT traverse any navigation properties. The type of the partner +navigation property MUST be the declaring entity type of the current navigation +property or one of its parent entity types.

    + +

    If the partner navigation property +is single-valued, it MUST lead back to the source entity from all related +entities. If the partner navigation property is collection-valued, the source +entity MUST be part of that collection.

    + +

    If no partner navigation property +is specified, no assumptions can be made as to whether one of the navigation +properties on the target type will lead back to the source entity.

    + +

    If a partner navigation property +is specified, this partner navigation property MUST either specify the current +navigation property as its partner to define a bi-directional +relationship or it MUST NOT specify a partner navigation property. The latter +can occur if the partner navigation property is defined on a complex type, or +if the current navigation property is defined on a type derived from the type +of the partner navigation property.

    + +
    + +

    $Partner

    + +
    + +
    + +

    The value of $Partner +is a string containing the path to the partner navigation property.

    + +
    + +

    ##subsec Containment Navigation Property

    + +

    A navigation property MAY indicate that instances of its +declaring structured type contain the targets of the navigation property, in +which case the navigation property is called a containment navigation +property.

    + +

    Containment navigation properties define an implicit entity +set for each instance of its declaring structured type. This implicit entity +set is identified by the read URL of the navigation property for that structured +type instance.

    + +

    Instances of the structured type that declares the +navigation property, either directly or indirectly via a property of complex +type, contain the entities referenced by the containment navigation property. +The canonical URL for contained entities is the canonical URL of the containing +instance, followed by the path segment of the navigation property and the key +of the contained entity, see OData‑URL.

    + +

    Entity types used in collection-valued containment +navigation properties MUST have a key defined.

    + +

    For items of an ordered collection of complex types (those +annotated with the Core.Ordered +term defined in OData-VocCore), the +canonical URL of the item is the canonical URL of the collection appended with +a segment containing the zero-based ordinal of the item. Items within in an +unordered collection of complex types do not have a canonical URL. Services +that support unordered collections of complex types declaring a containment +navigation property, either directly or indirectly via a property of complex +type, MUST specify the URL for the navigation link within a payload +representing that item, according to format-specific rules.

    + +

    OData +4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued property.

    + +

    An entity cannot be referenced by more than one containment +relationship, and cannot both belong to an entity set declared within the +entity container and be referenced by a containment relationship.

    + +

    Containment navigation properties MUST NOT be specified as +the last path segment in the path of a navigation +property binding.

    + +

    When a containment navigation property navigates between +entity types in the same inheritance hierarchy, the containment is called recursive. +

    + +

    Containment navigation properties MAY specify a partner +navigation property. If the containment is recursive, the relationship defines +a tree, thus the partner navigation property MUST be nullable (for the root of the tree) +and single-valued (for the parent of a non-root entity). If the containment is +not recursive, the partner navigation property MUST NOT be nullable.

    + +

    An entity type inheritance chain MUST NOT contain more than +one navigation property with a partner navigation property that is a +containment navigation property.

    + +

    Note: without a partner navigation property, there is no +reliable way for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity can also +be reached via a non-containment navigation path.

    + + + +
    + +

    The value of $ContainsTarget +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    ##subsec Referential Constraint

    + +

    A single-valued navigation property MAY define one or more +referential constraints. A referential constraint asserts that the dependent +property (the property defined on the structured type declaring the +navigation property) MUST have the same value as the principal property +(the referenced property declared on the entity type that is the target of the +navigation).

    + +

    The type of the dependent property MUST match the type of +the principal property, or both types MUST be complex types.

    + +

    If the principle property references an entity, then the +dependent property must reference the same entity.

    + +

    If the principle propertys value is a complex type +instance, then the dependent propertys value must be a complex type instance +with the same properties, each with the same values.

    + +

    If the navigation property on which the referential +constraint is defined is nullable, or the principal property is nullable, then +the dependent property MUST also be nullable. If both the navigation property +and the principal property are not nullable, then the dependent property MUST +NOT be nullable.

    + + + +
    + +

    The value of $ReferentialConstraint +is an object with one member per referential constraint. The member name is the +path to the dependent property, this path is relative to the structured type +declaring the navigation property. The member value is a string containing the +path to the principal property, this path is relative to the entity type that +is the target of the navigation property.

    + +

    It also MAY contain annotations. These are prefixed with the path of the +dependent property of the annotated referential constraint.

    + +
    + +

    Example 23: the category must +exist for a product in that category to exist. The CategoryID +of the product is identical to the ID of the +category, and the CategoryKind property of the +product is identical to the Kind property of the +category.

    + +
    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "CategoryID": {},

    + +

    "CategoryKind": {},

    + +

    "Category": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Category",

    + +

    "$Partner": +"Products",

    + +

    +"$ReferentialConstraint": {

    + +

    "CategoryID": +"ID",

    + +

    "CategoryKind": +"Kind"

    + +

    "CategoryKind@Core.Description": +"Referential Constraint to non-key property"

    + +

    }

    + +

    }

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "Kind": {

    + +

    "$Nullable": true

    + +

    },

    + +

    + +

    }

    + +
    + +

    ##subsec On-Delete Action

    + +

    A navigation property MAY define an on-delete action that +describes the action the service will take on related entities when the entity +on which the navigation property is defined is deleted.

    + +

    The action can have one of the following values:

    + +
      +
    • Cascade, meaning the related + entities will be deleted if the source entity is deleted,
    • +
    • None, meaning a DELETE request on a source entity with related + entities will fail,
    • +
    • SetNull, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to null,
    • +
    • SetDefault, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to their default value.
    • +
    + +

    If no on-delete action is specified, the action taken by the +service is not predictable by the client and could vary per entity.

    + +
    + +

    $OnDelete

    + +
    + +
    + +

    The value of $OnDelete +is a string with one of the values Cascade, None, SetNull, or SetDefault.

    + +

    Annotations +for $OnDelete are prefixed with $OnDelete.

    + +
    + +

    Example 24: deletion of a +category implies deletion of the related products in that category

    + +
    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "Products": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$Partner": +"Category",

    + +

    "$OnDelete": +"Cascade",

    + +

    "$OnDelete@Core.Description": +"Delete all products in this category"

    + +

    }

    + +

    }

    + +
    + + + +

    ##sec Complex Type

    + + + +

    Complex types are keyless nominal +structured types. The lack of a key means +that instances of complex types cannot be referenced, created, updated or +deleted independently of an entity type. Complex types allow entity models to +group properties into common structures.

    + +

    The complex types name is a simple +identifier that MUST be unique within its schema.

    + +

    A complex type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, complex, +or enumeration types. A navigation property +is a named reference to an entity type or a collection of entity types.

    + +

    All properties MUST have a unique name within a complex +type. Properties MUST NOT have the same name as the declaring complex type. +They MAY have the same name as one of the direct or indirect base types or +derived types.

    + +
    + +

    Complex Type Object

    + +
    + +
    + +

    A complex type is represented as a +member of the schema object whose name is the unqualified name of the complex +type and whose value is an object.

    + +

    The complex type object MUST contain +the member $Kind with a string value of ComplexType. It MAY contain the members $BaseType, +$Abstract, +and $OpenType. +It also MAY contain members representing structural +properties and navigation properties +as well as annotations.

    + +
    + +

    Example 25: a complex type used by two entity types

    + +
    + +

    "Dimensions": {

    + +

    "$Kind": +"ComplexType",

    + +

    "Height": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    },

    + +

    "Weight": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    },

    + +

    "Length": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    }

    + +

    },

    + +

    "Product": {

    + +

    + +

    "ProductDimensions": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Dimensions"

    + +

    },

    + +

    "ShippingDimensions": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Dimensions"

    + +

    }

    + +

    },

    + +

    "ShipmentBox": {

    + +

    + +

    "Dimensions": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Dimensions"

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Derived Complex Type

    + +

    A complex type can inherit from another complex type by +specifying it as its base type.

    + +

    A complex type inherits the structural and navigation +properties of its base type.

    + +

    A complex type MUST NOT introduce an inheritance cycle by +specifying a base type.

    + +

    The rules for annotations of derived complex types are +described in section 14.2.

    + +
    + +

    $BaseType

    + +
    + +
    + +

    The value of $BaseType +is the qualified name of the base type.

    + +
    + +

    ##subsec Abstract Complex Type

    + +

    A complex type MAY indicate that it is abstract and cannot +have instances.

    + +
    + +

    $Abstract

    + +
    + +
    + +

    The value of $Abstract +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    ##subsec Open Complex Type

    + +

    A complex type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    A complex type derived from an open complex type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see OData‑Protocol.

    + +
    + +

    $OpenType

    + +
    + +
    + +

    The value of $OpenType +is one of the Boolean literals true or false. Absence of the member means false. +

    + +
    + + + +

    ##sec Enumeration Type

    + + + +

    Enumeration types are nominal +types that represent a non-empty series of related values. Enumeration types +expose these related values as members of the enumeration.

    + +

    The enumeration types name is a simple identifier that MUST be unique within +its schema.

    + +

    Although enumeration types have an underlying numeric value, +the preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the AllowedValues annotation defined +in OData-VocCore.

    + +

    Enumeration types marked as flags allow values that consist +of more than one enumeration member at a time.

    + +
    + +

    Enumeration Type Object

    + +
    + +
    + +

    An enumeration type is represented as +a member of the schema object whose name is the unqualified name of the +enumeration type and whose value is an object.

    + +

    The enumeration type object MUST +contain the member $Kind with a string value of EnumType.

    + +

    It MAY contain the members $UnderlyingType +and $IsFlags.

    + +

    The enumeration type object MUST +contain members representing the +enumeration type members.

    + +

    The enumeration type object MAY +contain annotations.

    + +
    + +

    Example 26: a simple flags-enabled enumeration

    + +
    + +

    "FileAccess": {

    + +

    "$Kind": +"EnumType",

    + +

    "$UnderlyingType": +"Edm.Int32",

    + +

    "$IsFlags": true,

    + +

    "Read": 1,

    + +

    "Write": 2,

    + +

    "Create": 4,

    + +

    "Delete": 8

    + +

    }

    + +
    + +

    ##subsec Underlying Integer Type

    + +

    An enumeration type MAY specify one of Edm.Byte, +Edm.SByte, Edm.Int16, Edm.Int32, or Edm.Int64 as +its underlying type.

    + +

    If not explicitly specified, Edm.Int32 +is used as the underlying type.

    + + + +
    + +

    The value of $UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    ##subsec Flags Enumeration Type

    + +

    An enumeration type MAY indicate that the enumeration type +allows multiple members to be selected simultaneously.

    + +

    If not explicitly specified, only one enumeration type +member MAY be selected simultaneously.

    + +
    + +

    $IsFlags

    + +
    + +
    + +

    The value of $IsFlags +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    Example 27: pattern values can +be combined, and some combined values have explicit names

    + +
    + +

    "Pattern": {

    + +

    "$Kind": +"EnumType",

    + +

    "$UnderlyingType": +"Edm.Int32",

    + +

    "$IsFlags": true,

    + +

    "Plain": 0,

    + +

    "Red": 1,

    + +

    "Blue": 2,

    + +

    "Yellow": 4,

    + +

    "Solid": 8,

    + +

    "Striped": 16,

    + +

    "SolidRed": 9,

    + +

    "SolidBlue": 10,

    + +

    "SolidYellow": 12,

    + +

    "RedBlueStriped": 19,

    + +

    "RedYellowStriped": 21,

    + +

    "BlueYellowStriped": 22

    + +

    }

    + +
    + +

    ##subsec Enumeration Type Member

    + +

    Enumeration type values consist of discrete members.

    + +

    Each member is identified by its name, a simple identifier that MUST be unique within +the enumeration type. Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    Each member MUST specify an associated numeric value that +MUST be a valid value for the underlying type of the enumeration type.

    + +

    Enumeration types can have multiple members with the same value. Members with the same numeric +value compare as equal, and members with the same numeric value can be used +interchangeably.

    + +

    Enumeration +members are sorted by their numeric value.

    + +

    For flag enumeration types the combined numeric value of +simultaneously selected members is the bitwise OR of the discrete numeric +member values.

    + +
    + +

    Enumeration Member Object

    + +
    + +
    + +

    Enumeration type members are +represented as JSON object members, where the object member name is the +enumeration member name and the object member value is the enumeration member +value.

    + +

    For members of flags enumeration types a combined +enumeration member value is equivalent to the bitwise OR of the discrete values.

    + +

    Annotations for enumeration members +are prefixed with the enumeration member name.

    + +
    + +

    Example 28: FirstClass has a value of 0, TwoDay a value of 1, and Overnight +a value of 2.

    + +
    + +

    "ShippingMethod": {

    + +

    "$Kind": +"EnumType",

    + +

    "FirstClass": 0,

    + +

    "FirstClass@Core.Description": +"Shipped with highest priority",

    + +

    "TwoDay": 1,

    + +

    "TwoDay@Core.Description": +"Shipped within two days",

    + +

    "Overnight": 2,

    + +

    "Overnight@Core.Description": +"Shipped overnight",

    + +

    "@Core.Description": "Method +of shipping"

    + +

    }

    + +
    + + + +

    ##sec Type Definition

    + + + +

    A type definition defines a specialization of one of the primitive types or of the built-in abstract type Edm.PrimitiveType.

    + +

    The type definitions name is a simple identifier that MUST be unique within +its schema.

    + +

    Type definitions can be used wherever a primitive type is +used (other than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions defined +using the same underlying type.

    + +

    It is up to the definition of a term to specify whether and +how annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden.

    + +
    + +

    Type Definition Object

    + +
    + +
    + +

    A type definition is represented as a +member of the schema object whose name is the unqualified name of the type +definition and whose value is an object.

    + +

    The type definition object MUST +contain the member $Kind with a string value of TypeDefinition and the member $UnderlyingType. +It MAY contain the members $MaxLength, $Unicode, $Precision, $Scale, and $SRID, and it MAY contain annotations.

    + +
    + +

    Example 29:

    + +
    + +

    "Length": {

    + +

    "$Kind": "TypeDefinition",

    + +

    "$UnderlyingType": "Edm.Int32",

    + +

    "@Measures.Unit": "Centimeters"

    + +

    },

    + +

    "Weight": {

    + +

    "$Kind": "TypeDefinition",

    + +

    "$UnderlyingType": "Edm.Int32",

    + +

    "@Measures.Unit": "Kilograms"

    + +

    },

    + +

    "Size": {

    + +

    "$Kind": "ComplexType",

    + +

    "Height": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Length"

    + +

    },

    + +

    "Weight": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Weight"

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Underlying Primitive Type

    + +

    The underlying type of a type definition MUST be a primitive +type that MUST NOT be another type definition.

    + + + +
    + +

    The value of $UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    The type definition MAY specify facets applicable to the +underlying type. Possible facets are: $MaxLength, $Unicode, +$Precision, $Scale, or $SRID.

    + +

    Additional facets appropriate for the underlying type MAY be +specified when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified.

    + +

    For a type definition with underlying type Edm.PrimitiveType +no facets are applicable, neither in the definition itself nor when the type +definition is used, and these should be ignored by the client.

    + +

    Where type definitions are used, the type definition is +returned in place of the primitive type wherever the type is specified in a +response.

    + + + +

    ##sec Action and Function

    + + + +

    ##subsec Action

    + +

    Actions are service-defined operations that MAY have +observable side effects and MAY return a single instance or a collection of +instances of any type.

    + +

    The actions name is a simple +identifier that MUST be unique within its schema.

    + +

    Actions cannot be composed with additional path segments.

    + +

    An action MAY specify a return +type that MUST be a primitive, entity or complex type, or a collection of +primitive, entity or complex types in scope.

    + +

    An action MAY define parameters +used during the execution of the action.

    + +

    ##subsec Action Overloads

    + +

    Bound +actions support overloading (multiple actions having the same name within the +same schema) by binding parameter type. The combination of action name and the +binding parameter type MUST be unique within a schema.

    + +

    Unbound +actions do not support overloads. The names of all unbound actions MUST be +unique within a schema.

    + +

    An unbound action MAY have the same name as a bound action.

    + +
    + +

    Action Overload Object

    + +
    + +
    + +

    An action is represented as a member +of the schema object whose name is the unqualified name of the action and whose +value is an array. The array contains one object per action overload.

    + +

    The action overload object MUST +contain the member $Kind with a string value of Action.

    + +

    It MAY contain the members $IsBound, +$EntitySetPath, +$Parameter, +and $ReturnType, +and it MAY contain annotations.

    + +
    + +

    ##subsec Function

    + +

    Functions are service-defined operations that MUST NOT have +observable side effects and MUST return a single instance or a collection of +instances of any type.

    + +

    The functions name is a simple +identifier that MUST be unique within its schema.

    + +

    Functions MAY be composable.

    + +

    The function MUST specify a return +type which MUST be a primitive, entity or complex type, or a collection of +primitive, entity or complex types in scope.

    + +

    A function MAY define parameters +used during the execution of the function.

    + +

    ##subsec Function Overloads

    + +

    Bound +functions support overloading (multiple functions having the same name within +the same schema) subject to the following rules:

    + +

    The combination of function name, binding parameter type, and +unordered set of non-binding parameter names MUST be unique within a schema.

    + +

    The combination of function name, binding parameter type, and +ordered set of parameter types MUST be unique within a schema.

    + +

    All bound functions with the same function name and binding +parameter type within a schema MUST specify the same return type.

    + +

    Unbound +functions support overloading subject to the following rules:

    + +

    The combination of function name and unordered set of parameter +names MUST be unique within a schema.

    + +

    The combination of function name and ordered set of parameter +types MUST be unique within a schema.

    + +

    All unbound functions with the same function name within a schema +MUST specify the same return type.

    + +

    An unbound +function MAY have the same name as a bound function.

    + +

    Note that type definitions +can be used to disambiguate overloads for both bound and unbound functions, +even if they specify the same underlying type.

    + +
    + +

    Function Overload Object

    + +
    + +
    + +

    A function is represented as a member +of the schema object whose name is the unqualified name of the function and +whose value is an array. The array contains one object per function overload.

    + +

    The function overload object MUST +contain the member $Kind with a string value of Function.

    + +

    It MUST contain the member $ReturnType, +and it MAY contain the members $IsBound, +$EntitySetPath, +and $Parameter, and it MAY contain annotations.

    + +
    + +

    ##subsec Bound or Unbound Action or +Function Overloads

    + +

    An action or function overload MAY indicate that it is +bound. If not explicitly indicated, it is unbound.

    + +

    Bound actions or functions are invoked on resources matching +the type of the binding parameter. The binding parameter can be of any type, +and it MAY be nullable.

    + +

    Unbound actions are invoked from the entity container through +an action import.

    + +

    Unbound functions are invoked as static functions within a +filter or orderby expression, or from the entity container through a function import.

    + +
    + +

    $IsBound

    + +
    + +
    + +

    The value of $IsBound +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    ##subsec Entity Set Path

    + +

    Bound actions and functions that return an entity or a +collection of entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter value.

    + +

    The entity set path consists of a series of segments joined +together with forward slashes.

    + +

    The first segment of the entity set path MUST be the name of +the binding parameter. The remaining segments of the entity set path MUST +represent navigation segments or type casts.

    + +

    A navigation segment names the simple identifier of the navigation property to be traversed. A +type-cast segment names the qualified name of +the entity type that should be returned from the type cast.

    + + + +
    + +

    The value of $EntitySetPath +is a string containing the entity set path.

    + +
    + +

    ##subsec Composable Function

    + +

    A function MAY indicate that it is composable. If not +explicitly indicated, it is not composable.

    + +

    A composable function can be invoked with additional path +segments or key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for the type +returned by the composable function.

    + + + +
    + +

    The value of $IsComposable +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    ##subsec Return Type

    + +

    The return type of an action or function overload MAY be any +type in scope, or a collection of any type in scope.

    + +

    The facets Nullable, MaxLength, Precision, Scale, and SRID can be used as appropriate to +specify value restrictions of the return type, as well as the Unicode +facet for 4.01 and greater payloads.

    + +

    For a single-valued return type the facets apply to the +returned value. For a collection-valued return type the facets apply to the +items in the returned collection.

    + +
    + +

    $ReturnType

    + +
    + +
    + +

    The value of $ReturnType +is an object. It MAY contain the members $Type, +$Collection, $Nullable, $MaxLength, $Unicode, $Precision, $Scale, and $SRID.

    + +

    It also MAY contain annotations.

    + +
    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued return types the +value of $Type is the qualified name of the +returned type.

    + +

    For collection-valued return types the +value of $Type is the qualified name of the +returned item type, and the member $Collection MUST +be present with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String.

    + +
    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +

    If the return +type is a collection of entity types, the $Nullable +member has no meaning and MUST NOT be specified.

    + +

    For other collection-valued return +types the result will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +

    For single-valued return types the +value true means that the action or function MAY +return a single null value. The value false means that the action or function will never return +a null value and instead will fail with an error +response if it cannot compute a result.

    + +
    + +

    ##subsec Parameter

    + +

    An action or function overload MAY specify parameters.

    + +

    A bound action or function overload MUST specify at least +one parameter; the first parameter is its binding parameter. The order of parameters +MUST NOT change unless the schema version changes.

    + +

    Each parameter MUST have a name that is a simple identifier. The parameter name MUST be +unique within the action or function overload.

    + +

    The parameter MUST specify a type. It MAY be any type in +scope, or a collection of any type in scope.

    + +

    The facets MaxLength, Precision, Scale, or SRID can be used as appropriate to +specify value restrictions of the parameter, as well as the Unicode +facet for 4.01 and greater payloads.

    + +

    For single-valued parameters the facets apply to the +parameter value. If the parameter value is a collection, the facets apply to +the items in the collection.

    + +
    + +

    $Parameter

    + +
    + +
    + +

    The value of $Parameter +is an array. The array contains one object per parameter.

    + +
    + +
    + +

    Parameter Object

    + +
    + +
    + +

    A parameter object MUST contain the +member $Name, and it MAY contain +the members $Type, $Collection, $Nullable, $MaxLength, $Unicode, $Precision, $Scale, and $SRID.

    + +

    Parameter objects MAY also contain annotations.

    + +
    + +
    + +

    $Name

    + +
    + +
    + +

    The value of $Name +is a string containing the parameter name.

    + +
    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued parameters the value +of $Type is the qualified name of the accepted +type.

    + +

    For collection-valued parameters the +value of $Type is the qualified name of the +accepted item type, and the member $Collection MUST +be present with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String.

    + +
    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +

    For single-valued parameters the value +true means that the parameter accepts a null value.

    + +

    For collection-valued parameters the +parameter value will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +
    + +

    Example 30: a function returning the top-selling products +for a given year. In this case the year must be specified as a parameter of the +function with the edm:Parameter element.

    + +
    + +

    "TopSellingProducts": [

    + +

    {

    + +

    "$Kind": "Function",

    + +

    "$Parameter": [

    + +

    {

    + +

    "$Name": "Year",

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 4,

    + +

    "$Scale": 0

    + +

    }

    + +

    ],

    + +

    "$ReturnType": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product"

    + +

    }

    + +

    }

    + +

    ]

    + +
    + + + +

    ##sec Entity Container

    + + + +

    Each metadata document used to describe an OData service +MUST define exactly one entity container.

    + +

    The entity containers name is a simple identifier that MUST be unique within +its schema.

    + +

    Entity containers define the entity sets, singletons, +function and action imports exposed by the service.

    + +

    Entity set, singleton, action import, and function import +names MUST be unique within an entity container.

    + +

    An entity +set allows access to entity type instances. Simple entity models +frequently have one entity set per entity type.

    + +

    Example 31: one entity set per entity type

    + +
    + +

    "Products": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product"

    + +

    },

    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category"

    + +

    }

    + +
    + +

    Other entity models may +expose multiple entity sets per type.

    + +

    Example 32: three entity sets referring to the two entity +types

    + +
    + +

    "StandardCustomers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Customer",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Orders": "Orders"

    + +

    }

    + +

    },

    + +

    "PreferredCustomers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Customer",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Orders": "Orders"

    + +

    }

    + +

    },

    + +

    "Orders": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Order"

    + +

    }

    + +
    + +

    There are separate entity sets for standard customers and +preferred customers, but only one entity set for orders. The entity sets for standard +customers and preferred customers both have navigation property bindings to the +orders entity set, but the orders entity set does not have a navigation +property binding for the Customer navigation property, since it could lead to +either set of customers.

    + +

    An entity set can expose instances of the specified entity +type as well as any entity type inherited from the specified entity type.

    + +

    A singleton allows +addressing a single entity directly from the entity container without having to +know its key, and without requiring an entity set.

    + +

    A function import or an action import is used to expose a function +or action defined in an entity model as a top level resource.

    + +
    + +

    Entity Container Object

    + +
    + +
    + +

    An entity container is represented as +a member of the schema object whose name is the unqualified name of the entity +container and whose value is an object.

    + +

    The entity container object MUST +contain the member $Kind with a string value of EntityContainer.

    + +

    The entity container object MAY +contain the member $Extends, members representing entity sets, singletons, +action imports, and function imports, as well as annotations.

    + +
    + +

    Example 33: An entity container aggregates entity sets, +singletons, action imports, and function imports.

    + +
    + +

    "DemoService": {

    + +

    "$Kind": +"EntityContainer",

    + +

    "Products": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Category": "Categories",

    + +

    "Supplier": +"Suppliers"

    + +

    },

    + +

    "@UI.DisplayName": +"Product Catalog"

    + +

    },

    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products"

    + +

    }

    + +

    },

    + +

    "Suppliers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Supplier",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Products": "Products"

    + +

    },

    + +

    "@UI.DisplayName": +"Supplier Directory"

    + +

    },

    + +

    "MainSupplier": {

    + +

    "$Type": "self.Supplier"

    + +

    },

    + +

    "LeaveRequestApproval": {

    + +

    "$Action": "self.Approval"

    + +

    },

    + +

    "ProductsByRating": {

    + +

    "$EntitySet": +"Products",

    + +

    "$Function": "self.ProductsByRating"

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Extending an Entity Container

    + +

    An entity container MAY specify that it extends another +entity container in scope. All children of the base entity container are +added to the extending entity container.

    + +

    If the extending entity container defines an entity set +with the same name as defined in any of its base containers, then the entity +sets type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the base container. The same holds +for singletons. Action imports and function imports cannot be redefined, nor +can the extending container define a child with the same name as a child of a +different kind in a base container.

    + +

    Note: services should not introduce cycles by extending +entity containers. Clients should be prepared to process cycles introduced by +extending entity containers.

    + +
    + +

    $Extends

    + +
    + +
    + +

    The value of $Extends +is the qualified name of the entity container to be extended.

    + +
    + +

    Example 34: the entity +container Extending will contain all child elements +that it defines itself, plus all child elements of the Base +entity container located in SomeOtherSchema

    + +
    + +

    "Extending": {

    + +

    "$Kind": +"EntityContainer",

    + +

    "$Extends": "Some.Other.Schema.Base",

    + +

    + +

    }

    + +
    + +

    ##subsec Entity +Set

    + +

    Entity sets are top-level collection-valued resources.

    + +

    An entity set is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An entity set MUST specify a type that MUST be an entity +type in scope.

    + +

    An entity set MUST contain only instances of its specified +entity type or its subtypes. The entity type MAY be abstract but MUST have a key +defined.

    + +

    An entity set MAY indicate whether it is included in the +service document. If not explicitly indicated, it is included.

    + +

    Entity sets that cannot be queried without specifying +additional query options SHOULD NOT be included in the service document.

    + +
    + +

    Entity Set Object

    + +
    + +
    + +

    An entity set is represented as a +member of the entity container object whose name is the name of the entity set +and whose value is an object.

    + +

    The entity set object MUST contain the +members $Collection and $Type.

    + +

    It MAY contain the members $IncludeInServiceDocument and $NavigationPropertyBinding +as well as annotations.

    + +
    + +
    + +

    $Collection

    + +
    + +
    + +

    The value of $Collection +is the Booelan value true.

    + +
    + +
    + +

    $Type

    + +
    + +
    + +

    The value of $Type +is the qualified name of an entity type.

    + +
    + + + +
    + +

    The value of $IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the member means true.

    + +
    + +

    ##subsec Singleton

    + +

    Singletons are top-level single-valued resources.

    + +

    A singleton is identified by its name, a simple identifier that MUST be unique within its +entity container.

    + +

    A singleton MUST specify a type that MUST be an entity type +in scope.

    + +

    A singleton MUST reference an instance its entity type.

    + +
    + +

    Singleton Object

    + +
    + +
    + +

    A singleton is represented as a member +of the entity container object whose name is the name of the singleton and +whose value is an object.

    + +

    The singleton object MUST contain the +member $Type and it MAY contain the member $Nullable.

    + +

    It MAY contain the member $NavigationPropertyBinding +as well as annotations.

    + +
    + +
    + +

    $Type

    + +
    + +
    + +

    The value of $Type +is the qualified name of an entity type.

    + +
    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.In +OData 4.0 responses this member MUST NOT be specified.

    + +
    + +

    ##subsec Navigation Property Binding

    + +

    If the entity type of an entity set or singleton declares +navigation properties, a navigation property binding allows describing which +entity set or singleton will contain the related entities.

    + +

    An entity set or a singleton SHOULD specify a navigation property +binding for each navigation property of +its entity type, including navigation properties defined on complex typed +properties or derived types.

    + +

    If omitted, clients MUST assume that the target entity set +or singleton can vary per related entity.

    + +

    ##subsubsec Navigation Property Path +Binding

    + +

    A navigation property binding MUST specify a path to a +navigation property of the entity sets or singleton's declared entity type, or +a navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation property is +defined on a subtype, the path MUST contain the qualified +name of the subtype, followed by a forward slash, followed by the +navigation property name. If the navigation property is defined on a complex +type used in the definition of the entity sets entity type, the path MUST +contain a forward-slash separated list of complex property names and qualified +type names that describe the path leading to the navigation property.

    + +

    The path can traverse one or more containment navigation +properties, but the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment.

    + +

    If the path traverses collection-valued complex properties +or collection-valued containment navigation properties, the binding applies to +all items of these collections.

    + +

    If the path contains a recursive sub-path (i.e. a path +leading back to the same structured type, the binding applies recursively to +any positive number of cycles through that sub-path.

    + +

    OData 4.01 services MAY have a type-cast segment as the last +path segment, allowing to bind instances of different sub-types to different +targets.

    + +

    The same navigation property path MUST NOT be specified in +more than one navigation property binding; navigation property bindings are +only used when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths that +differ only in a type-cast segment, allowing to bind instances of different +sub-types to different targets. If paths differ only in type-cast segments, the +most specific path applies.

    + +

    ##subsubsec Binding Target

    + +

    A navigation property binding MUST specify a target via a simple identifier or target +path. It specifies the entity set, +singleton, or containment navigation property that contains the related +entities.

    + +

    If the target is a simple +identifier, it MUST resolve to an entity set or singleton defined in the +same entity container.

    + +

    If the target is a target path, +it MUST resolve to an entity set, singleton, or direct or indirect containment +navigation property of a singleton in scope. The path can traverse +single-valued containment navigation properties or single-valued complex +properties before ending in a containment navigation property, and there MUST +NOT be any non-containment navigation properties prior to the final segment.

    + + + +
    + +

    The value of $NavigationPropertyBinding +is an object. It consists of members whose name is the navigation property +binding path and whose value is a string containing the navigation property +binding target. If the target is in the same entity container, the target MUST +NOT be prefixed with the qualified entity container name.

    + +
    + +

    Example 35: for an entity set in the same container as the +enclosing entity set Categories

    + +
    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"SomeSet"

    + +

    }

    + +

    }

    + +
    + +

    Example 36: for an entity set in any container in scope

    + +
    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Products": +"SomeModel.SomeContainer/SomeSet"

    + +

    }

    + +

    }

    + +
    + +

    Example 37: binding Supplier on Products +contained within Categories binding applies to all suppliers of +all products of all categories

    + +
    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Products/Supplier": +"Suppliers"

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Action Import

    + +

    Action imports sets are top-level resources that are never +included in the service document.

    + +

    An action import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An action import MUST specify the name of an unbound action +in scope.

    + +

    If the imported action returns an entity or a collection of +entities, a simple identifier or target path value MAY be specified to identify the +entity set that contains the returned entities. If a simple identifier is specified, it MUST +resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an +entity set in scope.

    + +
    + +

    Action Import Object

    + +
    + +
    + +

    An action import is represented as a +member of the entity container object whose name is the name of the action +import and whose value is an object.

    + +

    The action import object MUST contain +the member $Action.

    + +

    It MAY contain the member $EntitySet.

    + +

    It MAY also contain annotations.

    + +
    + +
    + +

    $Action

    + +
    + +
    + +

    The value of $Action +is a string containing the qualified name of an unbound action.

    + +
    + +
    + +

    $EntitySet

    + +
    + +
    + +

    The value of $EntitySet +is a string containing either the unqualified name of an entity set in the same +entity container or a path to an entity set in a different entity container.

    + +
    + +

    ##subsec Function Import

    + +

    Function imports sets are top-level resources.

    + +

    A function import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    A function import MUST specify the name of an unbound +function in scope. All unbound +overloads of the imported function can be invoked from the entity +container.

    + +

    If the imported function returns an entity or a collection +of entities, a simple identifier or target path value MAY be specified to identify the +entity set that contains the returned entities. If a simple identifier is specified, it MUST +resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an +entity set in scope.

    + +

    A function import for a parameterless function MAY indicate +whether it is included in the service document. If not explicitly indicated, it +is not included.

    + +
    + +

    Function Import Object

    + +
    + +
    + +

    A function import is represented as a +member of the entity container object whose name is the name of the function +import and whose value is an object.

    + +

    The function import object MUST +contain the member $Function.

    + +

    It MAY contain the members $EntitySet and $IncludeInServiceDocument.

    + +

    It MAY also contain annotations.

    + +
    + +
    + +

    $Function

    + +
    + +
    + +

    The value of $Function +is a string containing the qualified name of an unbound function.

    + +
    + +
    + +

    $EntitySet

    + +
    + +
    + +

    The value of $EntitySet +is a string containing either the unqualified name of an entity set in the same +entity container or a path to an entity set in a different entity container.

    + +
    + + + +
    + +

    The value of $IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + + + +

    ##sec Vocabulary and Annotation

    + + + +

    Vocabularies and annotations provide the ability to annotate +metadata as well as instance data, and define a powerful extensibility point +for OData. An annotation applies a term to a +model element and defines how to calculate a value for the applied term.

    + +

    Metadata annotations are terms applied to model +elements. Behaviors or constraints described by a metadata annotation must be +consistent with the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity type, +property, function, action, or parameter. For example, a metadata annotation +may define ranges of valid values for a particular property. Metadata +annotations are applied in CSDL documents describing or referencing an entity +model.

    + +

    Instance annotations are terms applied to a +particular instance within an OData payload, such as described in OData‑JSON. An instance annotation can be +used to define additional information associated with a particular result, +entity, property, or error. For example, whether a property is read-only for a +particular instance. Where the same annotation is defined at both the metadata +and instance level, the instance-level annotation overrides the annotation +specified at the metadata level. Annotations that apply across instances should +be specified as metadata annotations.

    + +

    A vocabulary is a schema containing a set of terms +where each term is a named metadata extension. Anyone +can define a vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary OData-VocCore.

    + +

    A term can be used to:

    + +

    Extend model elements and type instances with additional +information.

    + +

    Map instances of annotated structured types to an interface +defined by the term type; i.e. annotations allow viewing instances of a +structured type as instances of a differently structured type specified by the +applied term.

    + +

    A service SHOULD NOT require a client to interpret +annotations. Clients SHOULD ignore invalid or unknown terms and silently treat unexpected +or invalid values (including invalid type, invalid literal expression, invalid +targets, etc.) as an unknown value for the term. Unknown or invalid annotations +should never result in an error, as long as the payload remains well-formed.

    + +

    Example 38: the Product entity type is extended with a DisplayName by a metadata annotation +that binds the term DisplayName to the value of the property Name. The Product +entity type also includes an annotation that allows its instances to be viewed +as instances of the type specified by the term SearchResult

    + +
    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "Description": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "@UI.DisplayName": {

    + +

    "$Path": +"Name"

    + +

    },

    + +

    +"@SearchVocabulary.SearchResult": {

    + +

    "Title": {

    + +

    "$Path": +"Name"

    + +

    },

    + +

    "Abstract": {

    + +

    "$Path": +"Description"

    + +

    },

    + +

    "Url": {

    + +

    "$Apply": [

    + +

    "Products(",

    + +

    {

    + +

    "$Path": +"ID"

    + +

    },

    + +

    ")"

    + +

    ],

    + +

    "$Function": +"odata.concat"

    + +

    }

    + +

    }

    + +

    }

    + +
    + +

    ##subsec Term

    + +

    A term allows annotating a model element or OData resource +representation with additional data.

    + +

    The terms name is a simple +identifier that MUST be unique within its schema.

    + +

    The terms type MUST be a type in scope, or a collection of a +type in scope.

    + +
    + +

    Term Object

    + +
    + +
    + +

    A term is represented as a member of +the schema object whose name is the unqualified name of the term and whose +value is an object.

    + +

    The term object MUST contain the +member $Kind with a string value of Term.

    + +

    It MAY contain the members $Type, $Collection, +$AppliesTo, +$Nullable, +$MaxLength, +$Precision, +$Scale, +$SRID, +and $DefaultValue, as well as $Unicode +for 4.01 and greater payloads.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued terms the value of $Type is the qualified name of the terms type.

    + +

    For collection-valued terms the value +of $Type is the qualified name of the terms item +type, and the member $Collection MUST be present +with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String.

    + +
    + + + +
    + +

    The value of $DefaultValue +is the type-specific JSON representation of the default value of the term, see [OData-JSON].

    + +

    Note: the $DefaultValue +member is purely for documentation and isomorphy to [OData-CSDLXML]. +Annotations in CSDL JSON documents MUST always specify an explicit value.

    + +
    + +

    ##subsubsec Specialized Term

    + +

    A term MAY specialize another term in scope by specifying it +as its base term.

    + +

    When applying a specialized term, the base term MUST also be +applied with the same qualifier, and so on until a term without a base term is +reached.

    + +
    + +

    $BaseTerm

    + +
    + +
    + +

    The value of $BaseTerm +is the qualified name of the base term.

    + +
    + +

    ##subsubsec Applicability

    + +

    The applicability of a term MAY be restricted to a list of +model elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be extended in +future versions of the vocabulary. As the intended usage may evolve over time, +clients SHOULD be prepared for any term to be applied to any model element and +SHOULD be prepared to handle unknown values within the list of model +constructs. Applicability is expressed using the following symbolic values:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Symbolic Value

    +
    +

    Model Element

    +
    +

    Action

    +
    +

    Action

    +
    +

    ActionImport

    +
    +

    Action Import

    +
    +

    Annotation

    +
    +

    Annotation

    +
    +

    Apply

    +
    +

    Application of a client-side function in an annotation

    +
    +

    Cast

    +
    +

    Type Cast annotation expression

    +
    +

    Collection

    +
    +

    Entity Set or collection-valued Property or Navigation + Property

    +
    +

    ComplexType

    +
    +

    Complex Type

    +
    +

    EntityContainer

    +
    +

    Entity Container

    +
    +

    EntitySet

    +
    +

    Entity Set

    +
    +

    EntityType

    +
    +

    Entity Type

    +
    +

    EnumType

    +
    +

    Enumeration Type

    +
    +

    Function

    +
    +

    Function

    +
    +

    FunctionImport

    +
    +

    Function Import

    +
    +

    If

    +
    +

    Conditional annotation expression

    +
    +

    Include

    +
    +

    Reference to an Included Schema

    +
    +

    IsOf

    +
    +

    Type Check annotation expression

    +
    +

    LabeledElement

    +
    +

    Labeled Element expression

    +
    +

    Member

    +
    +

    Enumeration Member

    +
    +

    NavigationProperty

    +
    +

    Navigation Property

    +
    +

    Null

    +
    +

    Null annotation expression

    +
    +

    OnDelete

    +
    +

    On-Delete Action of a navigation property

    +
    +

    Parameter

    +
    +

    Action of Function Parameter

    +
    +

    Property

    +
    +

    Property of a structured type

    +
    +

    PropertyValue

    +
    +

    Property value of a Record annotation expression

    +
    +

    Record

    +
    +

    Record annotation expression

    +
    +

    Reference

    +
    +

    Reference to another CSDL document

    +
    +

    ReferentialConstraint

    +
    +

    Referential Constraint of a navigation property

    +
    +

    ReturnType

    +
    +

    Return Type of an Action or Function

    +
    +

    Schema

    +
    +

    Schema

    +
    +

    Singleton

    +
    +

    Singleton

    +
    +

    Term

    +
    +

    Term

    +
    +

    TypeDefinition

    +
    +

    Type Definition

    +
    +

    UrlRef

    +
    +

    UrlRef annotation expression

    +
    + +
    + +

    $AppliesTo

    + +
    + +
    + +

    The value of $AppliesTo +is an array whose items are strings containing symbolic values from the table +above that identify model elements the term is intended to be applied to.

    + +
    + +

    Example 39: the IsURL term can +be applied to properties and terms that are of type Edm.String +(the Core.Tag type and the two Core terms +are defined in OData‑VocCore)

    + +
    + +

    "IsURL": {

    + +

    "$Kind": "Term",

    + +

    "$Type": "Core.Tag",

    + +

    "$DefaultValue": true,

    + +

    "$AppliesTo": [

    + +

    "Property"

    + +

    ],

    + +

    "@Core.Description": "Properties and terms +annotated with this term MUST contain a valid URL",

    + +

    "@Core.RequiresType": "Edm.String"

    + +

    }

    + +
    + +

    ##subsec Annotation

    + +

    An annotation applies a term to a model element and defines how to calculate a +value for the term application. Both term and model element MUST be in scope. +Section 14.1.2 specifies which model elements MAY be annotated with a term.

    + +

    The value of an annotation is specified as an annotation +expression, which is either a constant +expression representing a constant value, or a dynamic expression. The most common construct for assigning an +annotation value is a path expression that refers to a property of the same or a related +structured type.

    + +
    + +

    Annotation Member

    + +
    + +
    + +

    An annotation is represented as a +member whose name consists of an at (@) character, +followed by the qualified name of a term, optionally followed by a hash (#) and a qualifier.

    + +

    The value of the annotation MUST be a constant expression or dynamic expression.

    + +

    The annotation can be a member of the +object representing the model element it annotates, or a second-level member of +the $Annotations member of a schema object.

    + +

    An annotation can itself be annotated. +Annotations on annotations are represented as a member whose name consists of +the annotation name (including the optional qualifier), followed by an at (@) character, followed by the qualified name of a term, optionally followed by a hash (#) and a qualifier.

    + +
    + +

    Example 40: term Measures.ISOCurrency, +once applied with a constant value, once with a path value

    + +
    + +

    "AmountInReportingCurrency": +{

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0,

    + +

    "@Measures.ISOCurrency": +"USD",

    + +

    "@Measures.ISOCurrency@Core.Description": +"The parent companys currency"

    + +

    },

    + +

    "AmountInTransactionCurrency": +{

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0,

    + +

    "@Measures.ISOCurrency": {

    + +

    "$Path": +"Currency"

    + +

    }

    + +

    },

    + +

    "Currency": {

    + +

    "$Nullable": true,

    + +

    "$MaxLength": 3

    + +

    }

    + +
    + +

    If an entity type or complex type is annotated with a term +that itself has a structured type, an instance of the annotated type may be +viewed as an instance of the term, and the qualified term name may be used as +a term-cast segment in path expressions.

    + +

    Structured types inherit annotations from their direct or +indirect base types. If both the type and one of its base types is annotated +with the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or collection-valued +annotation values are not merged. Similarly, properties of a structured type +inherit annotations from identically named properties of a base type.

    + +

    It is up to the definition of a term to specify whether and +how annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a "Label" +annotation for a UI can propagate from a type definition to all properties +using that type definition and may be overridden at each property with a more +specific label, whereas an annotation marking a type definition as containing a +phone number will propagate to all using properties but may not be overridden.

    + +

    ##subsubsec Qualifier

    + +

    A term can be applied multiple times to the same model +element by providing a qualifier to distinguish the annotations. The qualifier +is a simple identifier.

    + +

    The combination of target model +element, term, and qualifier uniquely identifies an annotation.

    + +

    Example 41: annotation should only be applied to tablet +devices

    + +
    + +

    "@UI.DisplayName#Tablet": {

    + +

    "$Path": +"FirstName"

    + +

    }

    + +
    + +

    ##subsubsec Target

    + +

    The target of an annotation is the model element the term is +applied to.

    + +

    The target of an annotation MAY be specified indirectly by +nesting the annotation within the model element. Whether and how this is +possible is described per model element in this specification.

    + +

    The target of an annotation MAY also be specified directly; +this allows defining an annotation in a different schema than the targeted +model element.

    + +

    This external targeting is only possible for model elements that are uniquely identified within +their parent, and all their ancestor elements are uniquely identified within +their parent:

    + + + +

    These are the +direct children of a schema with a unique name (i.e. except actions and +functions whose overloads to not possess a natural identifier), and all direct +children of an entity container.

    + +

    External targeting is possible for +actions, functions, their parameters, and their return type, either in a way that applies to all overloads of the +action or function or all parameters of that name across all overloads, or in a way that identifies a single overload.

    + +

    External +targeting is also possible for properties and navigation properties of +singletons or entities in a particular entity set. These annotations override +annotations on the properties or navigation properties targeted via the +declaring structured type.

    + +

    The allowed path +expressions are:

    + +

    qualified +name of schema child

    + +

    qualified +name of schema child followed +by a forward slash and name of child element

    + +

    qualified +name of structured type followed +by zero or more property, navigation property, or type-cast segments, each +segment starting with a forward slash

    + +

    qualified +name of an entity +container followed by a segment containing a singleton or entity set name and +zero or more property, navigation property, or type-cast segments

    + +

    qualified +name of an action +followed by parentheses containing the qualified name of the binding parameter type of a bound action +overload to identify that bound overload, or by empty parentheses to identify +the unbound overload

    + +

    qualified +name of a function +followed by parentheses containing the comma-separated list of qualified names of the parameter types of a bound +or unbound function overload in the order of their definition in the function +overload

    + +

    qualified +name of an action or +function, optionally followed by parentheses as described in the two previous +bullet points to identify a single overload, followed by a forward slash and +either a parameter name or $ReturnType

    + +

    qualified +name of an entity +container followed by a segment containing an action or function import name, +optionally followed by a forward slash and either a parameter name or $ReturnType

    + +
      +
    • One of the + preceding, followed by a forward slash, an at (@), the qualified name of a term, and optionally a hash (#) and the + qualifier of an annotation
    • +
    + +

    All qualified names used in a target path MUST be in scope.

    + +

    Example 42: Target expressions

    + +
    + +

    MySchema.MyEntityType

    + +

    MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityType/MyNavigationProperty

    + +

    MySchema.MyComplexType

    + +

    MySchema.MyComplexType/MyProperty

    + +

    MySchema.MyComplexType/MyNavigationProperty

    + +

    MySchema.MyEnumType

    + +

    MySchema.MyEnumType/MyMember

    + +

    MySchema.MyTypeDefinition

    + +

    MySchema.MyTerm

    + +

    MySchema.MyEntityContainer

    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MyActionImport

    + +

    MySchema.MyEntityContainer/MyFunctionImport

    + +

    MySchema.MyAction

    + +

    MySchema.MyAction(MySchema.MyBindingType)

    + +

    MySchema.MyAction()

    + +

    MySchema.MyFunction

    + +

    MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType)

    + +

    MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType)

    + +

    MySchema.MyFunction/MyParameter

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty

    + +
    + +

    ##subsec Constant Expression

    + +

    Constant expressions allow assigning a constant value to an +applied term.

    + +

    ##subsubsec Binary

    + +
    + +

    Binary expressions are represented as +a string containing the base64url-encoded binary value.

    + +
    + +

    Example 43: base64url-encoded binary value (OData)

    + +
    + +

    "@UI.Thumbnail": +"T0RhdGE"

    + +
    + +

    ##subsubsec Boolean

    + +
    + +

    Boolean expressions are represented as +the literals true or false.

    + +
    + +

    Example 44:

    + +
    + +

    "@UI.ReadOnly": true

    + +
    + +

    ##subsubsec Date

    + +
    + +

    Date expressions are represented as a +string containing the date value. The value MUST conform to type xs:date, see [XML‑Schema‑2], +section 3.3.9. The value +MUST also conform to rule dateValue in OData‑ABNF, i.e. it MUST NOT contain a +time-zone offset.

    + +
    + +

    Example 45:

    + +
    + +

    "@vCard.birthDay": +"2000-01-01"

    + +
    + +

    ##subsubsec DateTimeOffset

    + +
    + +

    Datetimestamp expressions are +represented as a string containing the timestamp value. The value MUST conform +to type xs:dateTimeStamp, see [XML‑Schema‑2], section 3.4.28. +The value MUST also conform to rule dateTimeOffsetValue +in OData‑ABNF, i.e. it MUST NOT contain an +end-of-day fragment (24:00:00).

    + +
    + +

    Example 46:

    + +
    + +

    "@UI.LastUpdated": +"2000-01-01T16:00:00.000Z"

    + +
    + +

    ##subsubsec Decimal

    + +
    + +

    Decimal expressions are represented as +either a number or a string. The special values INF, +-INF, or NaN are +represented as strings. Numeric values are represented as numbers or strings +depending on the media type parameter IEEE754Compatible.

    + +
    + +

    Example 47: default representation as a number

    + +
    + +

    "@UI.Width": 3.14

    + +
    + +

    Example 48: safe +representation as a string

    + +
    + +

    "@UI.Width": +"3.14"

    + +
    + +

    ##subsubsec Duration

    + +
    + +

    Duration expressions are represented +as a string containing the duration value. The value MUST conform to type xs:dayTimeDuration, see [XML‑Schema‑2], +section 3.4.27.

    + +
    + +

    Example 49:

    + +
    + +

    "@task.duration": +"P7D"

    + +
    + +

    ##subsubsec Enumeration Member

    + +
    + +

    Enumeration member expressions are +represented as a string containing the numeric or symbolic enumeration value.

    + +
    + +

    Example 50: single value Red +with numeric value and symbolic value

    + +
    + +

    "@self.HasPattern": "1"

    + +
    + +

     

    + +
    + +

    "@self.HasPattern": "Red"

    + +
    + +

    Example 51: combined value Red,Striped +with numeric value 1 + 16 and symbolic value

    + +
    + +

    "@self.HasPattern": "17"

    + +
    + +

     

    + +
    + +

    "@self.HasPattern": "Red,Striped"

    + +
    + +

    ##subsubsec Floating-Point Number

    + +
    + +

    Floating-point expressions are +represented as a number or as a string containing one of the special values INF, -INF, or NaN.

    + +
    + +

    Example 52:

    + +
    + +

    "@UI.FloatWidth": 3.14

    + +
    + +

     

    + +
    + +

    "@UI.FloatWidth": +"INF"

    + +
    + +

    ##subsubsec Guid

    + +
    + +

    Guid expressions are represented as a +string containing the uuid value. The value MUST conform to the rule guidValue in OData‑ABNF.

    + +
    + +

    Example 53:

    + +
    + +

    "@UI.Id": "21EC2020-3AEA-1069-A2DD-08002B30309D"

    + +
    + +

    ##subsubsec Integer

    + +
    + +

    Integer expressions are represented as +either a number or a string, depending on the media type parameter IEEE754Compatible.

    + +
    + +

    Example 54: default representation as a number

    + +
    + +

    "@An.Int": 42

    + +
    + +

    Example 55: safe +representation as a string

    + +
    + +

    "@A.Very.Long.Int": +"9007199254740992"

    + +
    + +

    ##subsubsec String

    + +
    + +

    String expressions are represented as +a JSON string.

    + +
    + +

    Example 56:

    + +
    + +

    "@UI.DisplayName": +"Product Catalog"

    + +
    + +

    ##subsubsec Time of Day

    + +
    + +

    Time-of-day expressions are +represented as a string containing the time-of-day value. The value MUST +conform to the rule timeOfDayValue in OData‑ABNF.

    + +
    + +

    Example 57:

    + +
    + +

    "@UI.EndTime": "21:45:00"

    + +
    + +

    ##subsec Dynamic Expression

    + +

    Dynamic expressions allow assigning a calculated value to an +applied term.

    + +

    ##subsubsec Path Expressions

    + +

    Path expressions allow +assigning a value to an applied term or term component. There are two kinds of +path expressions:

    + +

    A +model path is used within Annotation +Path, Model Element Path, Navigation Property Path, and Property Path expressions to traverse the model of +a service and resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the built-in types Edm.AnnotationPath, Edm.NavigationPropertyPath, +Edm.PropertyPath, and their base types Edm.AnyPropertyPath and Edm.ModelElementPath.

    + +

    An instance path is used within a Value +Path expression to traverse a graph of type instances and resolves to the +value identified by the path. It allows assigning values to terms or term +properties of built-in types other than the Edm.*Path +types, or of any model-defined type.

    + +

    ##subsubsubsec Path Syntax

    + +

    Model paths and instance paths share a common syntax which +is derived from the path expression syntax of URLs, see OData‑URL.

    + +

    A path MUST be composed of zero or more path segments joined +together by forward slashes (/).

    + +

    Paths starting with a forward slash (/) +are absolute paths, and the first path segment MUST be the qualified name of a +model element, e.g. an entity container. The remaining path after the second +forward slash is interpreted relative to that model element.

    + +

    Example 58: absolute path to an entity set

    + +
    + +

    /My.Schema.MyEntityContainer/MyEntitySet

    + +
    + +

    Paths not starting with a forward slash are interpreted +relative to the annotation target, following the rules specified in section Path Evaluation.

    + +

    Example 59: relative path to a property

    + +
    + +

    Address/City

    + +
    + +

    If a path segment is a qualified +name, it represents a type cast, and the +segment MUST be the name of a type in scope. If the type or instance identified +by the preceding path part cannot be cast to the specified type, the path +expression evaluates to the null value.

    + +

    Example 60: type-cast segment

    + +
    + +

    /self.Manager/

    + +
    + +

    If a path segment starts with an at (@) +character, it represents a term cast. The at +(@) character MUST be followed by a qualified name that +MAY be followed by a hash (#) character and a simple identifier. The qualified name preceding +the hash character MUST resolve to a term that is in scope, the simple identifier following +the hash sign is interpreted as a qualifier for +the term. If the model element or instance identified by the preceding path +part has not been annotated with that term (and if present, with that +qualifier), the term cast evaluates to the null value. Four special terms are implicitly +annotated for media entities and stream properties:

    + +
      +
    • odata.mediaEditLink
    • +
    • odata.mediaReadLink
    • +
    • odata.mediaContentType
    • +
    • odata.mediaEtag
    • +
    + +

    Example 61: term-cast segments

    + +
    + +

    /@Capabilities.SortRestrictions/

    + +
    + +

    If a path segment is a simple +identifier, it MUST be the name of a child model element of the model +element identified by the preceding path part, or a structural or navigation +property of the instance identified by the preceding path part. A sequence of +navigation segments can traverse multiple CSDL documents. The document +containing the path expression only needs to reference the next traversed +document to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document.

    + +

    A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path.

    + +

    Example 62: property segments in model path

    + +
    + +

    /Orders/Items/Product/

    + +
    + +

    An instance path MUST NOT contain +more than one segment representing a collection-valued construct, e.g. an +entity set or a collection-valued navigation property that is not followed by a +key predicate, or a collection-valued structural +property that is not followed by an index segment. The result of the +expression is the collection of instances resulting from applying any remaining +path segments that operate on a single-valued expression to each instance in +the collection-valued segment.

    + +

    An instance path MAY +terminate in a $count segment if the previous +segment is collection-valued, in which case the path evaluates to the number of +items in the collection identified by the preceding segment.

    + +

    Example 63: property segments in instance path

    + +
    + +

    /Addresses/Street

    + +

    /Addresses/$count

    + +
    + +

    A model path MAY contain path segments starting with a +navigation property, then followed by an at (@) +character, then followed by the qualified name of a term in scope, and optionally followed by a +hash (#) character and a simple identifier which is interpreted as a qualifier for the term. If the navigation property +has not been annotated with that term (and if present, with that qualifier), +the path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity type +specified by the navigation property are addressed via a term-cast +segment.

    + +

    Example 64: model path addressing an annotation on a +navigation property

    + +
    + +

    /Items@Capabilities.InsertRestrictions/Insertable

    + +
    + +

    An instance path MAY contain path segments starting with an +entity set or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see OData‑URL. +The key values are either primitive literals or instance paths. If the key +value is a relative instance path, it is interpreted according to the same rule +below as the instance path it is part of, not relative to the instance +identified by the preceding path part.

    + +

    Example 65: instance path with entity set and key predicate

    + +
    + +

    /self.container/SettingsCollection('FeatureXxx')/IsAvailable +

    + +

    /self.container/Products(ID=ProductID)/Name

    + +
    + +

    An instance path MAY contain an +index segment immediately following a path segment representing an ordered +collection-valued structural property. The index is zero-based and MUST be an +integer literal. Negative integers count from the end of the collection, with +-1 representing the last item in the collection. Remaining path segments are +evaluated relative to the identified item of the collection.

    + +

    Example 66: instance path with collection-valued structural +property and index segment

    + +
    + +

    Addresses/1

    + +

    Addresses/-1/Street

    + +
    + +

    ##subsubsubsec Path Evaluation

    + +

    Annotations MAY be embedded within their target, or +specified separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as targeting +in the remainder of this section.

    + +

    For annotations embedded within or targeting an entity +container, the path is evaluated starting at the entity container, i.e. an +empty path resolves to the entity container, and non-empty paths MUST start +with a segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules for +paths targeting the corresponding child element.

    + +

    For annotations embedded within or targeting an entity set +or a singleton, the path is evaluated starting at the entity set or singleton, +i.e. an empty path resolves to the entity set or singleton, and non-empty paths +MUST follow the rules for annotations targeting the declared entity type of the +entity set or singleton.

    + +

    For annotations embedded within or targeting an entity type +or complex type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be a +structural or navigation property of the type, a type +cast, or a term cast.

    + +

    For annotations embedded within a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the directly enclosing type. This allows e.g. specifying the value of an annotation +on one property to be calculated from values of other properties of the same +type. An empty path resolves to the enclosing type, and non-empty paths MUST +follow the rules for annotations targeting the directly enclosing type.

    + +

    For annotations targeting a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the outermost entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the first +segment of a non-empty path MUST be a structural or navigation property of the +outermost type, a type cast, or a term cast.

    + +

    For annotations embedded within or targeting an action, +action import, function, function import, parameter, or return type, the first +segment of the path MUST be a parameter name or $ReturnType.

    + +

    ##subsubsubsec Annotation Path

    + +

    The annotation path expression provides a value for terms or +term properties that specify the built-in types Edm.AnnotationPath or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    A +non-null path MUST resolve to an annotation.

    + +

    A term or term property of type Edm.AnnotationPath +can be annotated with term Validation.AllowedTerms +(see OData-VocValidation) if its intended +value is an annotation path that ends in a term cast with one of the listed +terms.

    + +

    The value of the annotation path expression is the path +itself, not the value of the annotation identified by the path. This is useful +for terms that reuse or refer to other terms.

    + +
    + +

    Annotation path expressions are +represented as a string containing a path.

    + +
    + +

    Example 67:

    + +
    + +

    "@UI.ReferenceFacet": +"Product/Supplier/@UI.LineItem",

    + +

    "@UI.CollectionFacet#Contacts": +[

    + +

    +"Supplier/@Communication.Contact",

    + +

    +"Customer/@Communication.Contact"

    + +

    ]

    + +
    + +

    ##subsubsubsec Model Element Path

    + +

    The model element path expression provides a value for terms +or term properties that specify the built-in type Edm.ModelElementPath. Its argument is a model path.

    + +

    The value of the model element path expression is the path +itself, not the instance(s) identified by the path.

    + +
    + +

    Model element path expressions are +represented as a string containing a path.

    + +
    + +

    Example 68:

    + +
    + +

    "@org.example.MyFavoriteModelElement": +"/self.someAction"

    + +
    + +

    ##subsubsubsec Navigation Property Path

    + +

    The navigation property path +expression provides a value for terms or term properties that specify the built-in types Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    A non-null path MUST resolve to a model element whose type is an +entity type, or a collection of entity types, e.g. a navigation property.

    + +

    The value of the navigation property path expression is the +path itself, not the entitiy or collection of entities identified by the path.

    + +
    + +

    Navigation property path expressions +are represented as a string containing a path.

    + +
    + +

    Example 69:

    + +
    + +

    "@UI.HyperLink": +"Supplier",

    + +

     

    + +

    "@Capabilities.UpdateRestrictions": +{

    + +

    +"NonUpdatableNavigationProperties": [

    + +

    "Supplier",

    + +

    "Category"

    + +

    ]

    + +

    }

    + +
    + +

    ##subsubsubsec Property Path

    + +

    The property path expression provides a value for terms or +term properties that specify one of the built-in types Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    A non-null path MUST resolve to a model element whose type is a primitive or complex type, an +enumeration type, a type definition, or a collection of one of these +types.

    + +

    The value of the property path expression is the path +itself, not the value of the structural property or the value of the term cast identified +by the path.

    + +
    + +

    Property path expressions are +represented as a string containing a path.

    + +
    + +

    Example 70:

    + +
    + +

    "@UI.RefreshOnChangeOf": +"ChangedAt",

    + +

     

    + +

    "@Capabilities.UpdateRestrictions": +{

    + +

    "NonUpdatableProperties": +[

    + +

    "CreatedAt",

    + +

    "ChangedAt"

    + +

    ]

    + +

    }

    + +
    + +

    ##subsubsubsec Value Path

    + +

    The value path expression allows assigning a value by +traversing an object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation properties of +structured types, and structural properties of structured types. Its argument +is an instance path.

    + +

    The value of the path expression is the instance or +collection of instances identified by the path.

    + +
    + +

    $Path

    + +
    + +
    + +

    Path expressions are represented as an +object with a single member $Path whose value is a +string containing a path.

    + +
    + +

    Example 71:

    + +
    + +

    "@UI.DisplayName": {

    + +

    "$Path": +"FirstName"

    + +

    },

    + +

     

    + +

    "@UI.DisplayName#second": {

    + +

    "$Path": +"@vCard.Address#work/FullName"

    + +

    }

    + +
    + +

    ##subsubsec Comparison and Logical Operators

    + +

    Annotations MAY use the following logical and comparison +expressions which evaluate to a Boolean value. These expressions MAY be +combined and they MAY be used anywhere instead of a Boolean expression.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Logical Operators

    +
    +

    And

    +
    +

    Logical + and

    +
    +

    Or

    +
    +

    Logical + or

    +
    +

    Not

    +
    +

    Logical + negation

    +
    +

    Comparison Operators

    +
    +

    Eq

    +
    +

    Equal

    +
    +

    Ne

    +
    +

    Not + equal

    +
    +

    Gt

    +
    +

    Greater + than

    +
    +

    Ge

    +
    +

    Greater + than or equal

    +
    +

    Lt

    +
    +

    Less than

    +
    +

    Le

    +
    +

    Less + than or equal

    +
    +

    Has

    +
    +

    Has + enumeration flag(s) set

    +
    +

    In

    +
    +

    Is + in collection

    +
    + +

    The And and Or operators require two operand expressions that +evaluate to Boolean values. The Not operator +requires a single operand expression that evaluates to a Boolean value. For +details on null handling for comparison operators see OData‑URL.

    + +

    The other comparison operators require two operand +expressions that evaluate to comparable values.

    + +
    + +

    $And and $Or

    + +
    + +
    + +

    The And +and Or logical expressions are represented as an +object with a single member whose value is an array with two annotation +expressions. The member name is one of $And, or $Or.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Not

    + +
    + +
    + +

    Negation expressions are represented +as an object with a single member $Not whose value +is an annotation expression.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Eq, $Ne, +$Gt, $Ge, $Lt, +$Le, $Has, and $In

    + +
    + +
    + +

    All comparison expressions are +represented as an object with a single member whose value is an array with two +annotation expressions. The member name is one of $Eq, +$Ne, $Gt, $Ge, $Lt, $Le, $Has, or $In.

    + +

    They MAY contain annotations.

    + +
    + +

    Example 72:

    + +
    + +

    {

    + +

    "$And": [

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    },

    + +

    {

    + +

    "$Path": +"IsMarried"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Or": [

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    },

    + +

    {

    + +

    "$Path": +"IsMarried"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Not": {

    + +

    "$Path": +"IsMale"

    + +

    }

    + +

    },

    + +

    {

    + +

    "$Eq": [

    + +

    null,

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Ne": [

    + +

    null,

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Gt": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    20

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Ge": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    10

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Lt": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    20

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Le": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    100

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Has": [

    + +

    {

    + +

    "$Path": +"Fabric"

    + +

    },

    + +

    "Red"

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$In": [

    + +

    {

    + +

    "$Path": +"Size"

    + +

    },

    + +

    [

    + +

    "XS",

    + +

    "S"

    + +

    ]

    + +

    ]

    + +

    }

    + +
    + +

    ##subsubsec Arithmetic Operators

    + +

    Annotations MAY use the following arithmetic expressions +which evaluate to a numeric value. These expressions MAY be combined, and they MAY +be used anywhere instead of a numeric expression of the appropriate type. The +semantics and evaluation rules for each arithmetic expression is identical to +the corresponding arithmetic operator defined in OData‑URL.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Add

    +
    +

    Addition

    +
    +

    Sub

    +
    +

    Subtraction

    +
    +

    Neg

    +
    +

    Negation

    +
    +

    Mul

    +
    +

    Multiplication

    +
    +

    Div

    +
    +

    Division + (with integer result for integer operands)

    +
    +

    DivBy

    +
    +

    Division + (with fractional result also for integer operands)

    +
    +

    Mod

    +
    +

    Modulo

    +
    + +

    The Neg operator requires a +single operand expression that evaluates to a numeric value. The other arithmetic +operators require two operand expressions that evaluate to numeric values.

    + +
    + +

    $Neg

    + +
    + +
    + +

    Negation expressions are represented +as an object with a single member $Neg whose value +is an annotation expression.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Add, $Sub, +$Mul, $Div, $DivBy, +and $Mod

    + +
    + +
    + +

    These arithmetic expressions are +represented as an object with as single member whose value is an array with two +annotation expressions. The member name is one of $Add, +$Sub, $Neg, $Mul, $Div, $DivBy, or $Mod.

    + +

    They MAY contain annotations.

    + +
    + +

    Example 73:

    + +
    + +

    {

    + +

    "$Add": [

    + +

    {

    + +

    "$Path": +"StartDate"

    + +

    },

    + +

    {

    + +

    "$Path": +"Duration"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Sub": [

    + +

    {

    + +

    "$Path": +"Revenue"

    + +

    },

    + +

    {

    + +

    "$Path": "Cost"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Neg": {

    + +

    "$Path": +"Height"

    + +

    }

    + +

    },

    + +

    {

    + +

    "$Mul": [

    + +

    {

    + +

    "$Path": +"NetPrice"

    + +

    },

    + +

    {

    + +

    "$Path": +"TaxRate"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Div": [

    + +

    {

    + +

    "$Path": +"Quantity"

    + +

    },

    + +

    {

    + +

    "$Path": "QuantityPerParcel"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$DivBy": [

    + +

    {

    + +

    "$Path": +"Quantity"

    + +

    },

    + +

    {

    + +

    "$Path": +"QuantityPerParcel"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Mod": [

    + +

    {

    + +

    "$Path": +"Quantity"

    + +

    },

    + +

    {

    + +

    "$Path": +"QuantityPerParcel"

    + +

    }

    + +

    ]

    + +

    }

    + +
    + +

    ##subsubsec Apply Client-Side Functions

    + +

    The apply expression enables a value to be obtained by +applying a client-side function. The apply expression MAY have operand +expressions. The operand expressions are used as parameters to the client-side +function.

    + +
    + +

    $Apply

    + +
    + +
    + +

    Apply expressions are represented as +an object with a member $Apply whose value is an +array of annotation expressions, and a member $Function +whose value is a string containing the qualified +name of the client-side function to be applied.

    + +

    It MAY contain +annotations.

    + +
    + +

    OData defines the following functions. Services MAY support +additional functions that MUST be qualified with a namespace other than odata. Function names qualified with odata are reserved for this specification and its future +versions.

    + +

    ##subsubsubsec Canonical Functions

    + +

    All canonical functions defined in OData‑URL +can be used as client-side functions, qualified with the namespace odata. The semantics of these client-side functions is +identical to their counterpart function defined in OData‑URL.

    + +

    For example, the odata.concat +client-side function takes two or more expressions as arguments. Each argument +MUST evaluate to a primitive or enumeration type. It returns a value of type Edm.String that is the concatenation of the literal representations +of the results of the argument expressions. Values of primitive types other +than Edm.String are represented according to the +appropriate alternative in the primitiveValue rule +of OData‑ABNF, i.e. Edm.Binary +as binaryValue, Edm.Boolean +as booleanValue etc.

    + +

    Example 74:

    + +
    + +

    "@UI.DisplayName": {

    + +

    "$Apply": [

    + +

    "Product: ",

    + +

    {

    + +

    "$Path": +"ProductName"

    + +

    },

    + +

    " (",

    + +

    {

    + +

    "$Path": +"Available/Quantity"

    + +

    },

    + +

    " ",

    + +

    {

    + +

    "$Path": +"Available/Unit"

    + +

    },

    + +

    " available)"

    + +

    ],

    + +

    "$Function": +"odata.concat"

    + +

    }

    + +
    + +

    ProductName is of type String, Quantity in complex +type Available is of type Decimal, +and Unit in Available +is of type enumeration, so the result of the Path +expression is represented as the member name of the enumeration value.

    + +

    ##subsubsubsec Function odata.fillUriTemplate

    + +

    The odata.fillUriTemplate +client-side function takes two or more expressions as arguments and returns a +value of type Edm.String.

    + +

    The first argument MUST be of type Edm.String +and specifies a URI template according to RFC6570, +the other arguments MUST be labeled element +expressions. Each labeled element expression +specifies the template parameter name as its name and evaluates to the template +parameter value.

    + +

    RFC6570 defines three +kinds of template parameters: simple values, lists of values, and key-value +maps.

    + +

    Simple values are represented as labeled element expressions that evaluate to a +single primitive value. The literal representation of this value according to OData‑ABNF is used to fill the +corresponding template parameter.

    + +

    Lists of values are represented as labeled element expressions that evaluate to a +collection of primitive values.

    + +

    Key-value maps are represented as labeled element expressions that evaluate to a +collection of complex types with two properties that are used in lexicographic +order. The first property is used as key, the second property as value.

    + +

    Example 75: assuming there are no special characters in +values of the Name property of the Actor entity

    + +
    + +

    {

    + +

    "$Apply": [

    + +

    "http://host/someAPI/Actors/{actorName}/CV",

    + +

    {

    + +

    "$LabeledElement": {

    + +

    "$Path": "Actor/Name"

    + +

    },

    + +

    "$Name": "self.actorName"

    + +

    }

    + +

    ],

    + +

    "$Function": "odata.fillUriTemplate"

    + +

    }

    + +
    + +

    ##subsubsubsec Function odata.matchesPattern

    + +

    The odata.matchesPattern +client-side function takes two string expressions as arguments and returns a +Boolean value.

    + +

    The function returns true if the second expression evaluates +to an [ECMAScript] (JavaScript) regular +expression and the result of the first argument expression matches that regular +expression, using syntax and semantics of [ECMAScript] +regular expressions.

    + +

    Example 76: all non-empty FirstName +values not containing the letters b, c, or d evaluate to true

    + +
    + +

    {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": "FirstName"

    + +

    },

    + +

    "^[^b-d]+$"

    + +

    ],

    + +

    "$Function": "odata.matchesPattern"

    + +

    }

    + +
    + +

    ##subsubsubsec Function odata.uriEncode

    + +

    The odata.uriEncode client-side +function takes one argument of primitive type and returns the URL-encoded OData +literal that can be used as a key value in OData URLs or in the query part of +OData URLs.

    + +

    Note: string literals are surrounded by single quotes as +required by the paren-style key syntax.

    + +

    Example 77:

    + +
    + +

    {

    + +

    "$Apply": [

    + +

    "http://host/service/Genres({genreName})",

    + +

    {

    + +

    "$LabeledElement": {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": "NameOfMovieGenre"

    + +

    }

    + +

    ],

    + +

    "$Function": "odata.uriEncode"

    + +

    },

    + +

    "$Name": "self.genreName"

    + +

    }

    + +

    ],

    + +

    "$Function": "odata.fillUriTemplate"

    + +

    }

    + +
    + +

    ##subsubsec Cast

    + +

    The cast expression casts the value obtained from its single +child expression to the specified type. The cast expression follows the same +rules as the cast canonical function defined in OData‑URL.

    + +
    + +

    $Cast

    + +
    + +
    + +

    Cast expressions are represented as an +object with a member $Cast whose value is an +annotation expression, a member $Type whose value +is a string containing the qualified type name, and optionally a member $Collection with a value of true.

    + +

    It MAY contain annotations.

    + +

    If the specified type is a primitive +type or a collection of primitive types, the facet members $MaxLength, +$Unicode, $Precision, +$Scale, +and $SRID +MAY be specified if applicable to the specified primitive type. If the facet +members are not specified, their values are considered unspecified.

    + +
    + +

    Example 78:

    + +
    + +

    "@UI.Threshold": {

    + +

    "$Cast": {

    + +

    "$Path": +"Average"

    + +

    },

    + +

    "$Type": +"Edm.Decimal"

    + +

    }

    + +
    + +

    ##subsubsec Collection

    + +

    The collection expression enables a value to be obtained +from zero or more item expressions. The value calculated by the collection +expression is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type compatible.

    + +
    + +

    Collection expressions are represented +as arrays with one array item per item expression within the collection +expression.

    + +
    + +

    Example 79:

    + +
    + +

    "@seo.SeoTerms": [

    + +

    "Product",

    + +

    "Supplier",

    + +

    "Customer"

    + +

    ]

    + +
    + +

    ##subsubsec If-Then-Else

    + +

    The if-then-else expression enables a value to be obtained +by evaluating a condition expression. It MUST contain exactly three +child expressions. There is one exception to this rule: if and only if the if-then-else +expression is an item of a collection expression, the third child expression +MAY be omitted, reducing it to an if-then expression. This can be used to +conditionally add an element to a collection.

    + +

    The first child expression is the condition and MUST +evaluate to a Boolean result, e.g. the comparison and logical operators +can be used.

    + +

    The second and third child expressions are evaluated +conditionally. The result MUST be type compatible with the type expected by the +surrounding expression.

    + +

    If the first expression evaluates to true, +the second expression MUST be evaluated and its value MUST be returned as the +result of the if-then-else expression. If the first expression evaluates to false and a third child element is present, it MUST be +evaluated and its value MUST be returned as the result of the if-then-else +expression. If no third expression is present, nothing is added to the +surrounding collection.

    + +
    + +

    $If

    + +
    + +
    + +

    Conditional expressions are +represented as an object with a member $If whose +value is an array of two or three annotation expressions.

    + +

    It MAY contain annotations.

    + +
    + +

    Example 80: the condition is a value +path expression referencing the Boolean property IsFemale +,whose value then determines the value of the $If +expression

    + +
    + +

    "@person.Gender": {

    + +

    "$If": [

    + +

    {

    + +

    "$Path": +"IsFemale"

    + +

    },

    + +

    "Female",

    + +

    "Male"

    + +

    ]

    + +

    }

    + +
    + +

    ##subsubsec Is-Of

    + +

    The is-of +expression checks whether the value obtained from its single child expression +is compatible with the specified type. It returns true +if the child expression returns a type that is compatible with the specified +type, and false otherwise.

    + +
    + +

    $IsOf

    + +
    + +
    + +

    Is-of expressions are represented as +an object with a member $IsOf whose value is an +annotation expression, a member $Type whose value +is a string containing an qualified type name, and optionally a member $Collection with a value of true.

    + +

    It MAY contain annotations.

    + +

    If the specified type is a primitive +type or a collection of primitive types, the facet members $MaxLength, +$Unicode, $Precision, +$Scale, +and $SRID +MAY be specified if applicable to the specified primitive type. If the facet +members are not specified, their values are considered unspecified.

    + +
    + +

    Example 81:

    + +
    + +

    "@Self.IsPreferredCustomer": +{

    + +

    "$IsOf": {

    + +

    "$Path": +"Customer"

    + +

    },

    + +

    "$Type": "self.PreferredCustomer"

    + +

    }

    + +
    + +

    ##subsubsec Labeled Element

    + +

    The labeled element expression assigns a name to its single +child expression. The value of the child expression can then be reused +elsewhere with a labeled element +reference expression.

    + +

    A labeled element expression MUST contain exactly one child +expression. The value of the child expression is also the value of the labeled +element expression.

    + +

    A labeled element expression MUST provide a simple identifier value as its name that MUST +be unique within the schema containing the expression.

    + + + +
    + +

    Labeled element expressions are +represented as an object with a member $LabeledElement +whose value is an annotation expression, and a member $Name +whose value is a string containing the labeled elements name.

    + +

    It MAY contain annotations.

    + +
    + +

    Example 82:

    + +
    + +

    "@UI.DisplayName": {

    + +

    "$LabeledElement": {

    + +

    "$Path": +"FirstName"

    + +

    },

    + +

    "$Name": +"CustomerFirstName"

    + +

    }

    + +
    + +

    ##subsubsec Labeled Element Reference

    + +

    The labeled element reference expression MUST specify the qualified name of a labeled +element expression in scope and returns the value of the identified labeled +element expression as its value.

    + + + +
    + +

    Labeled element reference expressions +are represented as an object with a member $LabeledElementReference +whose value is a string containing an qualified name.

    + +
    + +

    Example 83:

    + +
    + +

    "@UI.DisplayName": {

    + +

    +"$LabeledElementReference": "self.CustomerFirstName"

    + +

    }

    + +
    + +

    ##subsubsec Null

    + +

    The null expression indicates the absence of a value. The null +expression MAY be annotated.

    + +
    + +

    Null expressions that do not contain +annotations are represented as the literal null.

    + +
    + +

    Example 84:

    + +
    + +

    "@UI.DisplayName": null,

    + +
    + +
    + +

    $Null

    + +
    + +
    + +

    Null expression containing annotations are represented as an object with a +member $Null whose value is the literal null.

    + +
    + +

    Example 85:

    + +
    + +

    "@UI.Address": {

    + +

    "$Null": null,

    + +

    "@self.Reason": +"Private"

    + +

    }

    + +
    + +

    ##subsubsec Record

    + +

    The record expression enables a new entity type or complex +type instance to be constructed.

    + +

    A record expression MAY specify the structured type of its +result, which MUST be an entity type or complex type in scope. If not +explicitly specified, the type is derived from the expressions context.

    + +

    A record expression contains zero or more property value +expressions. For each single-valued structural or navigation property of the +record expressions type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if the +record expression is the value of an annotation for a term that has a base term whose type is structured and directly +or indirectly inherits from the type of its base term. In this case, property +values that already have been specified in the annotation for the base term or +its base term etc. need not be specified again.

    + +

    For collection-valued properties the absence of a property +value expression is equivalent to specifying an empty collection as its value.

    + +
    + +

    Record expressions are represented as +objects with one member per property value expression. The member name is the +property name, and the member value is the property value expression.

    + +

    The type of a record expression is +represented as the @type control information, see OData‑JSON.

    + +

    It MAY contain annotations for itself and its members. +Annotations for record members are prefixed with the member name.

    + +
    + +

    Example 86: this annotation morphs the entity type from +example 8 into a structured type with two structural properties GivenName and Surname and two +navigation properties DirectSupervisor and CostCenter. The first three properties simply rename +properties of the annotated entity type, the fourth adds a calculated +navigation property that is pointing to a different service

    + +
    + +

    "@person.Employee": {

    + +

    "@type": +"https://example.org/vocabs/person#org.example.person.Manager",

    + +

    "@Core.Description": +"Annotation on record",

    + +

    "GivenName": {

    + +

    "$Path": +"FirstName"

    + +

    },

    + +

    "GivenName@Core.Description": +"Annotation on record member",

    + +

    "Surname": {

    + +

    "$Path": +"LastName"

    + +

    },

    + +

    "DirectSupervisor": {

    + +

    "$Path": +"Manager"

    + +

    },

    + +

    "CostCenter": {

    + +

    "$UrlRef": {

    + +

    "$Apply": [

    + +

    +"http://host/anotherservice/CostCenters('{ccid}')",

    + +

    {

    + +

    "$LabeledElement": +{

    + +

    "$Path": +"CostCenterID"

    + +

    },

    + +

    "$Name": +"ccid"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.fillUriTemplate"

    + +

    }

    + +

    }

    + +

    }

    + +
    + +

    ##subsubsec URL Reference

    + +

    The URL reference expression enables a value to be obtained +by sending a GET request.

    + +

    The URL reference expression MUST contain exactly one +expression of type Edm.String. Its value is treated +as a URL that MAY be relative or absolute; relative URLs are relative to the +URL of the document containing the URL reference expression, or relative to a +base URL specified in a format-specific way.

    + +

    The response body of the GET +request MUST be returned as the result of the URL reference expression. +The result of the +URL reference expression MUST be type compatible with the type +expected by the surrounding expression.

    + +
    + +

    $UrlRef

    + +
    + +
    + +

    URL reference expressions are +represented as an object with a single member $UrlRef +whose value is an annotation expression.

    + +

    It MAY contain annotations.

    + +
    + +

    Example 87:

    + +
    + +

    "@org.example.person.Supplier": +{

    + +

    "$UrlRef": {

    + +

    "$Apply": [

    + +

    +"http://host/service/Suppliers({suppID})",

    + +

    {

    + +

    "$LabeledElement": {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": +"SupplierId"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.uriEncode"

    + +

    },

    + +

    "$Name": +"suppID"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.fillUriTemplate"

    + +

    }

    + +

    },

    + +

     

    + +

    "@Core.LongDescription#element": +{

    + +

    "$UrlRef": "http://host/wiki/HowToUse"

    + +

    }

    + +
    + + + +

    ##sec Identifier and Path Values

    + + + +

    ##subsec Namespace

    + +

    A namespace is a dot-separated sequence of simple identifiers with a maximum length of +511 Unicode characters (code points).

    + +

    ##subsec Simple Identifier

    + +

    A simple identifier is a Unicode +character sequence with the following restrictions:

    + +
      +
    • It consists of at least one and at most 128 Unicode + characters (code points).
    • +
    • The first character MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L) or Letter + number (Nl).
    • +
    • The remaining characters MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L), Letter + number (Nl), Decimal number (Nd), Non-spacing mark (Mn), Combining + spacing mark (Mc), Connector punctuation (Pc), and Other, format + (Cf).
    • +
    + +

    Non-normatively speaking it starts with a letter or +underscore, followed by at most 127 letters, underscores or digits.

    + +

    ##subsec Qualified Name

    + +

    For model elements that are direct children of a schema: the +namespace or alias of the schema that defines the model element, followed by a +dot and the name of the model element, see rule qualifiedTypeName +in OData‑ABNF.

    + +

    For built-in primitive types: +the name of the type, prefixed with Edm followed by +a dot.

    + +

    ##subsec Target Path

    + +

    Target paths are +used to refer to other model elements.

    + +

    The allowed path +expressions are:

    + +

    The qualified name of an entity container, followed by a +forward slash and the name of a container child element

    + +

    The target path of a +container child followed by a forward slash and one or more forward-slash +separated property, navigation property, or type-cast segments

    + +

    Example 88: Target expressions

    + +
    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp

    + +
    + + + +

    ##sec CSDL Examples

    + + + +

    Following are two basic examples of valid EDM models as +represented in CSDL JSON. These examples demonstrate many of the topics covered +above.

    + +

    ##subsec Products and Categories Example

    + +

    Example 89:

    + +
    + +

    {

    + +

    "$Version": +"4.0",

    + +

    "$EntityContainer": +"ODataDemo.DemoService",

    + +

    "$Reference": {

    + +

    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "Org.OData.Core.V1",

    + +

    "$Alias": +"Core",

    + +

    "@Core.DefaultNamespace": +true

    + +

    }

    + +

    ]

    + +

    },

    + +

    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.json": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "Org.OData.Measures.V1",

    + +

    "$Alias": +"Measures"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    "ODataDemo": {

    + +

    "$Alias": +"self",

    + +

    +"@Core.DefaultNamespace": true,

    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    "$HasStream": true,

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "Description": {

    + +

    "$Nullable": true,

    + +

    "@Core.IsLanguageDependent": +true

    + +

    },

    + +

    "ReleaseDate": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Date"

    + +

    },

    + +

    "DiscontinuedDate": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Date"

    + +

    },

    + +

    "Rating": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Price": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "@Measures.ISOCurrency": +{

    + +

    "$Path": +"Currency"

    + +

    }

    + +

    },

    + +

    "Currency": {

    + +

    "$Nullable": true,

    + +

    "$MaxLength": 3

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Category",

    + +

    "$Partner": +"Products"

    + +

    },

    + +

    "Supplier": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Supplier",

    + +

    "$Partner": +"Products"

    + +

    }

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Name": {

    + +

    "@Core.IsLanguageDependent": +true

    + +

    },

    + +

    "Products": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Partner": +"Category",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$OnDelete": +"Cascade"

    + +

    }

    + +

    },

    + +

    "Supplier": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "Address": {

    + +

    "$Type": "self.Address"

    + +

    },

    + +

    "Concurrency": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Products": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Partner": +"Supplier",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product"

    + +

    }

    + +

    },

    + +

    "Country": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "Code"

    + +

    ],

    + +

    "Code": {

    + +

    "$MaxLength": 2

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    }

    + +

    },

    + +

    "Address": {

    + +

    "$Kind": +"ComplexType",

    + +

    "Street": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "City": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "State": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "ZipCode": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "CountryName": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "Country": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Country",

    + +

    "$ReferentialConstraint": +{

    + +

    "CountryName": +"Name"

    + +

    }

    + +

    }

    + +

    },

    + +

    "ProductsByRating": [

    + +

    {

    + +

    "$Kind": +"Function",

    + +

    "$Parameter": [

    + +

    {

    + +

    "$Name": +"Rating",

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Int32"

    + +

    }

    + +

    ],

    + +

    "$ReturnType": {

    + +

    "$Collection": +true,

    + +

    "$Type": "self.Product"

    + +

    }

    + +

    }

    + +

    ],

    + +

    "DemoService": {

    + +

    "$Kind": +"EntityContainer",

    + +

    "Products": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Category": +"Categories"

    + +

    }

    + +

    },

    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products"

    + +

    },

    + +

    "@Core.Description": +"Product Categories"

    + +

    },

    + +

    "Suppliers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Supplier",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products",

    + +

    "Address/Country": +"Countries"

    + +

    },

    + +

    "@Core.OptimisticConcurrency": +[

    + +

    "Concurrency"

    + +

    ]

    + +

    },

    + +

    "Countries": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Country"

    + +

    },

    + +

    "MainSupplier": {

    + +

    "$Type": "self.Supplier",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products"

    + +

    },

    + +

    "@Core.Description": +"Primary Supplier"

    + +

    },

    + +

    "ProductsByRating": {

    + +

    "$EntitySet": +"Products",

    + +

    "$Function": "self.ProductsByRating"

    + +

    }

    + +

    }

    + +

    }

    + +

    }

    + +
    + +

    Annotations for +Products and Categories Example

    + +

    Example 90:

    + +
    + +

    {

    + +

    "$Version": +"4.01",

    + +

    "$Reference": {

    + +

    "http://host/service/$metadata": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "ODataDemo",

    + +

    "$Alias": +"target"

    + +

    }

    + +

    ]

    + +

    },

    + +

    +"http://somewhere/Vocabulary/V1": {

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "Some.Vocabulary.V1",

    + +

    "$Alias": +"Vocabulary1"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    "External.Annotations": {

    + +

    "$Annotations": {

    + +

    "target.Supplier": {

    + +

    "@Vocabulary1.EMail": +null,

    + +

    +"@Vocabulary1.AccountID": {

    + +

    "$Path": "ID"

    + +

    },

    + +

    +"@Vocabulary1.Title": "Supplier Info",

    + +

    +"@Vocabulary1.DisplayName": {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": +"Name"

    + +

    },

    + +

    " in ",

    + +

    {

    + +

    "$Path": +"Address/CountryName"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.concat"

    + +

    }

    + +

    },

    + +

    "target.Product": {

    + +

    "@Vocabulary1.Tags": +[

    + +

    "MasterData"

    + +

    ]

    + +

    }

    + +

    }

    + +

    }

    + +

    }

    + +
    + + + +

    ##sec Conformance

    + + + +

    Conforming services MUST follow all rules of this +specification document for the types, sets, functions, actions, containers and +annotations they expose.

    + +

    In addition, conforming services MUST NOT return 4.01 CSDL +constructs for requests made with OData-MaxVersion:4.0.

    + +

    Specifically, they

    + +

    1. MUST NOT include properties in derived types that overwrite a property +defined in the base type

    + +

    2. MUST NOT include Edm.Untyped +

    + +

    3. MUST NOT use path syntax added with 4.01

    + +

    4. MUST NOT use Edm.ModelElementPath +and Edm.AnyPropertyPath

    + +

    5. MUST NOT specify referential +constraints to +complex types and navigation properties

    + +

    6. MUST NOT include a non-abstract entity type with no inherited or defined +entity key

    + +

    7. MUST NOT include the Core.DefaultNamespace annotation +on included schemas

    + +

    8. MUST NOT return the Unicode facet for terms, parameters, and return +types

    + +

    9. MUST NOT include collections of Edm.ComplexType +or Edm.Untyped

    + +

    10. MUST NOT specify a key as a property of a related entity

    + +

    11. SHOULD NOT include new/unknown values for $AppliesTo

    + +

    12. MAY include new CSDL annotations

    + +

    In addition, OData 4.01 services:

    + +

    13. SHOULD NOT have identifiers +within a uniqueness scope (e.g. a schema, a structural type, or an entity +container) that differ only by case

    + +

    Conforming clients MUST be prepared to consume a model that +uses any or all constructs defined in this specification, including custom +annotations, and MUST ignore constructs not defined in this version of the +specification.

    + + + +

    Appendix A. Acknowledgments

    + + + +

    The work of the OpenUI5 team on the OData V4 Metadata JSON +Format, see [OpenUI5], is +gratefully acknowledged, especially the contributions of

    + +

    Thomas Chadzelek (SAP SE)

    + +

    Jens Ittel (SAP SE)

    + +

    Patric Ksinsik (SAP SE)

    + +

    The contributions of the OASIS OData Technical Committee +members, enumerated in ODataProtocol, are +gratefully acknowledged.

    + + + +

    Appendix B. Table +of JSON Objects and Members

    + + + + + +
    +
    + +
    + +

    Document Object 16

    + +

    $Version. 16

    + +

    $EntityContainer. 16

    + +

    $Reference. 16

    + +

    Reference Object 16

    + +

    $Include. 17

    + +

    $Namespace. 17

    + +

    $Alias. 17

    + +

    $IncludeAnnotations. 18

    + +

    $TermNamespace. 19

    + +

    $Qualifier. 19

    + +

    $TargetNamespace. 19

    + +

    Schema Object 20

    + +

    $Alias. 20

    + +

    $Annotations. 21

    + +

    Entity Type Object 22

    + +

    $BaseType. 22

    + +

    $Abstract. 23

    + +

    $OpenType. 23

    + +

    $HasStream. 23

    + +

    $Key. 25

    + +

    Property Object 27

    + +

    $Type +and $Collection. 28

    + +

    $Nullable. 28

    + +

    $MaxLength. 28

    + +

    $Precision. 29

    + +

    $Scale. 29

    + +

    $Unicode. 30

    + +

    $SRID. 30

    + +

    $DefaultValue. 31

    + +

    Navigation Property Object 32

    + +

    $Type +and $Collection. 33

    + +

    $Nullable. 33

    + +

    $Partner. 34

    + +

    $ContainsTarget. 34

    + +

    $ReferentialConstraint. 35

    + +

    $OnDelete. 36

    + +

    Complex Type Object 37

    + +

    $BaseType. 38

    + +

    $Abstract. 38

    + +

    $OpenType. 38

    + +

    Enumeration Type Object 39

    + +

    $UnderlyingType. 39

    + +

    $IsFlags. 39

    + +

    Enumeration Member Object 40

    + +

    Type Definition Object 41

    + +

    $UnderlyingType. 41

    + +

    Action Overload Object 43

    + +

    Function Overload Object 44

    + +

    $IsBound. 44

    + +

    $EntitySetPath. 44

    + +

    $IsComposable. 45

    + +

    $ReturnType. 45

    + +

    $Type +and $Collection. 45

    + +

    $Nullable. 45

    + +

    $Parameter. 46

    + +

    Parameter Object 46

    + +

    $Name. 46

    + +

    $Type +and $Collection. 46

    + +

    $Nullable. 46

    + +

    Entity Container Object 47

    + +

    $Extends. 48

    + +

    Entity Set Object 49

    + +

    $Collection. 49

    + +

    $Type. 49

    + +

    $IncludeInServiceDocument. 49

    + +

    Singleton Object 49

    + +

    $Type. 50

    + +

    $Nullable. 50

    + +

    $NavigationPropertyBinding. 51

    + +

    Action Import Object 51

    + +

    $Action. 51

    + +

    $EntitySet. 52

    + +

    Function Import Object 52

    + +

    $Function. 52

    + +

    $EntitySet. 52

    + +

    $IncludeInServiceDocument. 52

    + +

    Term Object 54

    + +

    $Type +and $Collection. 54

    + +

    $DefaultValue. 54

    + +

    $BaseTerm. 54

    + +

    $AppliesTo. 56

    + +

    Annotation Member 56

    + +

    $Path. 65

    + +

    $And +and $Or. 66

    + +

    $Not. 66

    + +

    $Eq, +$Ne, $Gt, $Ge, $Lt, $Le, +$Has, and $In. 66

    + +

    $Neg. 68

    + +

    $Add, +$Sub, $Mul, $Div, +$DivBy, and $Mod. 69

    + +

    $Apply. 70

    + +

    $Cast. 72

    + +

    $If. 73

    + +

    $IsOf. 73

    + +

    $LabeledElement. 74

    + +

    $LabeledElementReference. 74

    + +

    $Null. 75

    + +

    $UrlRef. 76

    + +

     

    + +
    + +
    +
    + +
    + + + +

    Appendix C. Revision +History

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Revision

    +
    +

    Date

    +
    +

    Editor

    +
    +

    Changes Made

    +
    +

    Working Draft 01

    +
    +

    2016-11-16

    +
    +

    Ralf Handl

    +
    +

    Initial version

    +
    +

    Committee Specification Draft 01

    +
    +

    2017-06-08

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Integrated 4.01 features

    +
    +

    Committee Specification Draft 02

    +
    +

    2017-09-22

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +

    Changed defaults of $Nullable, + $Scale, and $Precision

    +
    +

    Committee Specification Draft 03

    +
    +

    2017-11-10

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +

    Stable order of action and function parameters

    +
    +

    Committee Specification 01

    +
    +

    2017-12-19

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-Material Changes

    +
    +

    Committee Specification Draft 04

    +
    +

    2019-06-21

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    External targeting for annotations on action/function + overloads, parameters, and return types

    +

    Key and index segments for path expressions in annotations

    +

    Nullable singletons

    +

    Simplified syntax of entity container children and + constant annotation expressions

    +
    +

    Committee Specification Draft 05

    +
    +

    2019-09-26

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Redefining entity sets and singletons when extending + entity containers

    +
    +

    Committee Specification 02

    +
    +

    2019-11-05

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    +

    Candidate OASIS Standard 02

    +
    +

    2020-04-09

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    + +

     

    + +
    + + + + diff --git a/odata-csdl/temp/odata-csdl-json-v4.01-os-raw.md b/odata-csdl/temp/odata-csdl-json-v4.01-os-raw.md new file mode 100644 index 000000000..6083b34e0 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-json-v4.01-os-raw.md @@ -0,0 +1,7615 @@ +# ##sec Introduction + +OData services are described in terms of an [Entity +Model](#EntityModel). The Common Schema Definition Language (CSDL) +defines a representation of the entity model exposed by an OData service +using the JavaScript Object Notation (JSON)[, see[ +]{.apple-converted-space}]{style="color:black"}**\[**[**RFC8259**](#rfc8259)**\]**. + +This format is based on the OpenUI5 OData V4 Metadata JSON Format, see +**\[**[**OpenUI5**](#OpenUI5)**\]**, with some extensions and +modifications made necessary to fully cover OData CSDL Version 4.01. + +## ##subsec IPR Policy + +This specification is provided under the [RF on RAND +Terms](https://www.oasis-open.org/policies-guidelines/ipr#RF-on-RAND-Mode) +Mode of the [OASIS IPR +Policy](https://www.oasis-open.org/policies-guidelines/ipr), the mode +chosen when the Technical Committee was established. For information on +whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing +terms, please refer to the Intellectual Property Rights section of the +TC's web page (). + +## ##subsec Terminology + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", +"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this +document are to be interpreted as described in +**\[**[**RFC2119**](#rfc2119)**\]**. + +## ##subsec Normative References + +[\[ECMAScript\]]{.Refterm}[[         +]{style="font-weight:normal"}]{.Refterm}*ECMAScript 2016 Language +Specification, 7^th^ Edition,* June 2016. Standard ECMA-262. +. + +[\[EPSG\]                   ]{.Refterm}European Petroleum Survey Group +(EPSG). . + +[\[OData-ABNF\]]{.Refterm}         *OData ABNF Construction Rules +Version 4.01*.\ +See link in "Additional artifacts" section on cover +page[.]{style="color: +#222222"} + +**[\[OData-CSDL-Schema]{lang="DE" +style="color:windowtext"}**[**[\]]{lang="DE" +style="color:windowtext"}**]{.Hyperlink1}[       ]{lang="DE" +style="color:windowtext"}*[OData CSDL JSON Schema.]{lang="DE"}*[\ +]{lang="DE"}See link in "Additional artifacts" section on cover page. + +**\[OData-CSDLXML**[**\]**]{.Hyperlink1}  OData Common Schema Definition +Language (CSDL) XML Representation Version 4.01.\ +See link in "Related work" section on cover page. + +**\[OData-JSON**[**\]**]{.Hyperlink1}         *OData JSON Format Version +4.01.*\ +See link in "Related work" section on cover page. + +[\[OData-Protocol\]]{.Refterm}     *OData Version 4.01 Part 1: +Protocol*.\ +See link in "Related work" section on cover +page[.]{style="color:#222222"} + +OData-URL           *OData Version 4.01 Part 2: URL Conventions*.\ +See link in "Related work" section on cover page. + +OData-VocCore     *OData Vocabularies Version 4.0: Core Vocabulary.*\ +See link in "Related work" section on cover page. + +OData-VocMeasures         *OData Vocabularies Version 4.0: Measures +Vocabulary.*\ +See link in "Related work" section on cover page. + +OData-VocValidation        *OData Vocabularies Version 4.0: Validation +Vocabulary.*\ +See link in "Related work" section on cover page. + +[\[RFC2119\]]{.Refterm}               Bradner, S., "Key words for use in +RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. +. + +RFC6570               Gregorio, J., Fielding, R., Hadley, M., +Nottingham, M., and D. Orchard, "URI Template", RFC 6570, March 2012. +. + +[\[RFC7493\]]{.Refterm}[[               +]{style="font-weight:normal"}]{.Refterm}[[Bray, T., Ed., \"The I-JSON +Message Format\", RFC7493, March 2015.]{style="font-weight:normal"} +]{.Refterm}. + +[\[RFC8259\]]{.Refterm}               Bray, T., Ed., "The JavaScript +Object Notation (JSON) Data Interchange Format", RFC 8259, December +2017. . + +[\[XML-Schema-2\]]{.Refterm}     W3C XML Schema Definition Language +(XSD) 1.1 Part 2: DatatypesW3C XML Schema Definition Language (XSD) 1.1 +Part 2: Datatypes, D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. +Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April +2012, .\ +Latest version available at . + +## ##subsec Non-Normative References + +[\[OpenUI5\]]{.Refterm}[[               +]{style="font-weight:normal"}]{.Refterm}[OpenUI5 Version[ +]{.apple-converted-space}[1.40.10 -- +]{.sapuitv}]{style="background:white"}[[OData V4 Metadata JSON Format, +]{style="font-weight:normal"}]{.Refterm}[[ +]{style="font-weight:normal"}]{.Refterm} + +## ##subsec Typographical Conventions + +Keywords defined by this specification use this `monospaced` font. + +`Normative source code uses this paragraph style.` + +Some sections of this specification are illustrated with non-normative +examples. + +Example 1: text describing an example uses this paragraph style + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +Non-normative examples use this paragraph style. +::: + +All examples in this document are non-normative and informative only. + +Representation-specific text is indented and marked with vertical lines. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Representation-Specific Headline +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Normative representation-specific text +::: + +All other text is normative unless otherwise labeled. + +# ##sec JSON Representation + +OData CSDL JSON is a full representation of the OData Common Schema +Definition Language in the JavaScript Object Notation (JSON) defined in +**\[**[**RFC8259**](#rfc8259)**\]**. It additionally follows the rules +for "Internet JSON" (I-JSON) defined in +**\[**[**RFC7493**](#rfc7493)**\]** for e.g. objects, numbers, date +values, and duration values. + +It is an alternative to the CSDL XML representation defined in +**\[**[**OData-CSDLXML**](#ODataCSDL)**\]** and neither adds nor removes +features. + +## ##subsec Requesting the JSON Representation + +The OData CSDL JSON representation can be requested using the `$format` +query option in the request URL with the media type `application/json`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `json` which MUST NOT be followed by media type parameters. + +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/json`, optionally followed by +media type parameters. + +If specified, `$format` overrides any value specified in the `Accept` +header. + +The response MUST contain the `Content-Type` header with a value of +`application/json`, optionally followed by media type parameters. + +Possible media type parameters are: + +[[· +]{style="font-family:Symbol;color:windowtext"}]{.MsoHyperlink}[`IEEE754Compatible`](#ControllingtheRepresentationofNumber) + +[[· +]{style="font-family:Symbol;color:windowtext"}]{.MsoHyperlink}[`metadata`](#ControllingtheAmountofControlInforma) + +The names and values of these parameters are case-insensitive. + +### ##subsubsec Controlling the Representation of Numbers + +The `IEEE754Compatible=true` parameter indicates that the service MUST +serialize `Edm.Int64` and `Edm.Decimal` numbers as strings. This is in +conformance with [RFC7493](#rfc7493). If not specified, or specified as +`IEEE754Compatible=false`, all numbers MUST be serialized as JSON +numbers. + +This enables support for JavaScript numbers that are defined to be +64-bit binary format IEEE 754 values [**\[ECMAScript\]**](#ECMAScript) +(see [section +4.3.1.9](http://www.ecma-international.org/ecma-262/5.1/#sec-4.3.19)) +resulting in integers losing precision past 15 digits, and decimals +losing precision due to the conversion from base 10 to base 2. + +Responses that format `Edm.Int64` and `Edm.Decimal` values as strings +MUST specify this parameter in the media type returned in the +`Content-Type` header. + +### ##subsubsec Controlling the Amount of Control Information + +The representation of constant annotation values in CSDL JSON documents +closely follows the representation of data defined in +[OData‑JSON](#ODataJSON). + +A client application can use the `metadata` format parameter in the +`Accept` header when requesting a CSDL JSON document to influence how +much control information will be included in the response. + +Other `Accept` header parameters are orthogonal to the `metadata` +parameter and are therefore not mentioned in this section. + +#### ##subsubsubsec `metadata=minimal` + +The `metadata=minimal` format parameter indicates that the service +SHOULD remove computable control information from the payload wherever +possible. + +This means that the `@type` control information is only included if the +type of the containing object or targeted property cannot be +heuristically determined, e.g. for + +[· ]{style="font-family: +Symbol"}Terms or term properties with an abstract declared type, + +[· ]{style="font-family: +Symbol"}Terms or term properties with a declared type that has derived +types, or + +[· ]{style="font-family: +Symbol"}Dynamic properties of open types. + +See [OData‑JSON](#ODataJSON) for the exact rules. + +#### ##subsubsubsec `metadata=full` + +The `metadata=full` format parameter indicates that the service MUST +include all control information explicitly in the payload. + +This means that the `@type` control information is included in +annotation values except for primitive values whose type can be +heuristically determined from the representation of the value, see +[OData‑JSON](#ODataJSON) for the exact rules. + +#### ##subsubsubsec `metadata=none` + +The `metadata=none` format parameter indicates that the service SHOULD +omit all control information. + +## ##subsec Design Considerations + +CSDL JSON documents are designed for easy and efficient lookup of model +constructs by their name without having to know or guess what kind of +model element it is. Thus, all primary model elements (entity types, +complex types, type definitions, enumeration types, terms, actions, +functions, and the entity container) are direct members of their schema, +using the schema-unique name as the member name. Similarly, child +elements of primary model elements (properties, navigation properties, +enumeration type members, entity sets, singletons, action imports, and +function imports) are direct members of the objects describing their +parent model element, using their locally unique name as the member +name. + +To avoid name collisions, all fixed member names are prefixed with a +dollar (`$`) sign and otherwise have the same name and capitalization as +their counterparts in the CSDL XML representation +**\[**[**OData-CSDLXML**](#ODataCSDL)**\]** (with one exception: the +counterpart of the `EntitySet` element's `EntityType` attribute is +[`$Type`](#EntitySet), to harmonize it with all other type references). + +Additional fixed members introduced by this specification and without +counterpart in **\[**[**OData-CSDLXML**](#ODataCSDL)**\]** are also +prefixed with a dollar (`$`) sign and use upper-camel-case names. One of +these is `$Kind` which represents the kind of model element. Its value +is the upper-camel-case local name of the XML element representing this +kind of model element in **\[**[**OData-CSDLXML**](#ODataCSDL)**\]**, +e.g. `EntityType` or `NavigationProperty`. + +While the XML representation of CSDL allows referencing model elements +with alias-qualified names as well as with namespace-qualified names, +this JSON representation requires the use of alias-qualified names if an +alias is specified for an included or document-defined schema. Aliases +are usually shorter than namespaces, so this reduces text size of the +JSON document. Text size matters even if the actual HTTP messages are +sent in compressed form because the decompressed form needs to be +reconstructed, and clients not using a streaming JSON parser have to +materialize the full JSON document before parsing. + +To further reduce size the member `$Kind` is optional for [structural +properties](#StructuralProperty) as these are more common than +[navigation properties](#NavigationProperty), and the member +[`$Type`](#Type) is optional for string properties, parameters, and +return types, as this type is more common than other primitive types. + +In general, all members that have a default value SHOULD be omitted if +they have the default value. + +## ##subsec JSON Schema Definition + +The structure of CSDL JSON documents can be verified with the JSON +Schema **\[**[**OData-CSDL-Schema**](#CSDLschema)**\]** provided as an +additional artifact of this prose specification. This schema only +defines the shape of a well-formed CSDL JSON document but is not +descriptive enough to define what a correct CSDL JSON document MUST be +in every imaginable use case. This specification document defines +additional rules that correct CSDL JSON documents MUST fulfill. In case +of doubt on what makes a CSDL JSON document correct the rules defined in +this specification document take precedence. + +# ##sec Entity Model + +An OData service exposes a single entity model. This model may be +distributed over several [schemas](#Schema), and these schemas may be +distributed over several documents. + +A service is defined by a single CSDL document which can be accessed by +sending a `GET` request to `/$metadata`. This document is +called the metadata document. It MAY [reference](#Reference) other CSDL +documents. + +The metadata document contains a single [entity +container](#EntityContainer) that defines the resources exposed by this +service. This entity container MAY [extend](#ExtendinganEntityContainer) +an entity container defined in a [referenced document](#Reference). + +The *model* of the service consists of all CSDL constructs used in its +entity containers. + +The *scope* of a CSDL document is the document itself and all schemas +[included](#IncludedSchema) from directly [referenced +documents](#Reference). All entity types, complex types and other named +model elements *in scope* (that is, defined in the document itself or a +schema of a directly referenced document) can be accessed from a +referencing document by their qualified names. This includes the +[built-in primitive](#PrimitiveTypes) and [abstract +types](#BuiltInAbstractTypes). + +Referencing another document may alter the model defined by the +referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, +then an [entity set](#EntitySet) of the service defined by the +referencing document may return entities of the derived type. This is +identical to the behavior if the derived type had been defined directly +in the referencing document. + +Note: referencing documents is not recursive. Only named model elements +defined in directly referenced documents can be used within the schema. +However, those elements may in turn include or reference model elements +defined in schemas referenced by their defining schema. + +## ##subsec Nominal Types + +A nominal type has a name that MUST be a [simple +identifier](#SimpleIdentifier). Nominal types are referenced using their +[qualified name](#QualifiedName). The qualified type name MUST be unique +within a model as it facilitates references to the element from other +parts of the model. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +## ##subsec Structured Types + +Structured types are composed of other model elements. Structured types +are common in entity models as the means of representing entities and +structured properties in an OData service. [Entity types](#EntityType) +and [complex types](#ComplexType) are both structured types. + +Structured Types are composed of zero or more [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty). + +[Open entity types](#OpenEntityType) and [open complex +types](#OpenComplexType) allow properties to be added dynamically to +instances of the open type. + +## ##subsec Primitive Types + +Structured types are composed of other structured types and primitive +types. OData defines the following primitive types: + + **Type** **Meaning** + -------------------------------- ---------------------------------------------------------------- + `Edm.Binary` Binary data + `Edm.Boolean` Binary-valued logic + `Edm.Byte` Unsigned 8-bit integer + `Edm.Date` Date without a time-zone offset + `Edm.DateTimeOffset` Date and time with a time-zone offset, no leap seconds + `Edm.Decimal` Numeric values with decimal representation + `Edm.Double` IEEE 754 binary64 floating-point number (15-17 decimal digits) + `Edm.Duration` Signed duration in days, hours, minutes, and (sub)seconds + `Edm.Guid` 16-byte (128-bit) unique identifier + `Edm.Int16 ` Signed 16-bit integer + `Edm.Int32` Signed 32-bit integer + `Edm.Int64` Signed 64-bit integer + `Edm.SByte` Signed 8-bit integer + `Edm.Single` IEEE 754 binary32 floating-point number (6-9 decimal digits) + `Edm.Stream` Binary data stream + `Edm.String` Sequence of characters + `Edm.TimeOfDay` Clock time 00:00-23:59:59.999999999999 + `Edm.Geography` Abstract base type for all Geography types + `Edm.GeographyPoint` A point in a round-earth coordinate system + `Edm.GeographyLineString` Line string in a round-earth coordinate system + `Edm.GeographyPolygon` Polygon in a round-earth coordinate system + `Edm.GeographyMultiPoint` Collection of points in a round-earth coordinate system + `Edm.GeographyMultiLineString` Collection of line strings in a round-earth coordinate system + `Edm.GeographyMultiPolygon` Collection of polygons in a round-earth coordinate system + `Edm.GeographyCollection` Collection of arbitrary Geography values + `Edm.Geometry` Abstract base type for all Geometry types + `Edm.GeometryPoint` Point in a flat-earth coordinate system + `Edm.GeometryLineString` Line string in a flat-earth coordinate system + `Edm.GeometryPolygon` Polygon in a flat-earth coordinate system + `Edm.GeometryMultiPoint` Collection of points in a flat-earth coordinate system + `Edm.GeometryMultiLineString` Collection of line strings in a flat-earth coordinate system + `Edm.GeometryMultiPolygon` Collection of polygons in a flat-earth coordinate system + `Edm.GeometryCollection` Collection of arbitrary Geometry values + +`Edm.Date` and `Edm.DateTimeOffset` follow +[**\[XML‑Schema‑2\]**](#BMXMLSchema2) and use the proleptic Gregorian +calendar, allowing the year `0000` (equivalent to 1 BCE) and negative +years (year `-0001` being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying +persistency layer, e.g. SQL only supports years `0001` to `9999`. + +`Edm.Decimal with a `[`Scale`](#Scale)` value of floating`, +`Edm.Double`, and `Edm.Single` allow the special numeric values `‑INF`, +`INF`, and `NaN`. + +`Edm.Stream` is a primitive type that can be used as a property of an +[entity type](#EntityType) or [complex type](#ComplexType), the +underlying type for a [type definition](#TypeDefinition), or the binding +parameter or return type of an [action](#Action) or +[function](#Function). `Edm.Stream`, or a type definition whose +underlying type is `Edm.Stream`, cannot be used in collections or for +non-binding parameters to functions or actions. + +Some of these types allow [facets](#TypeFacets), defined in section +"[Type Facets](#TypeFacets)". + +See rule `primitiveLiteral` in [OData‑ABNF](#ODataABNF) for the +representation of primitive type values in URLs and +[OData‑JSON](#ODataJSON) for the representation in requests and +responses. + +## ##subsec Built-In Abstract Types + +The following built-in abstract types can be used within a model: + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.PrimitiveType` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.ComplexType` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.EntityType` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.Untyped` + +Conceptually, these are the abstract base types for primitive types +(including type definitions and enumeration types), complex types, +entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except: + +[· ]{style="font-family:Symbol"}`Edm.EntityType` + +- - cannot be used as the type of a singleton in an entity container + because it doesn't define a structure, which defeats the purpose + of a singleton. + - cannot be used as the type of an entity set because all entities + in an entity set must have the same key fields to uniquely + identify them within the set. + - cannot be the base type of an entity type or complex type. + +[· ]{style="font-family:Symbol"}`Edm.ComplexType` + +- - cannot be the base type of an entity type or complex type. + +[· ]{style="font-family:Symbol"}`Edm.PrimitiveType` + +- - cannot be used as the type of a key property of an entity type + or as the underlying type of an enumeration type. + - cannot be used as the underlying type of a type definition in a + CSDL document with a version of `4.0`. + - can be used as the underlying type of a type definition in a + CSDL document with a version of `4.01` or greater. + +[· ]{style="font-family:Symbol"}`Edm.Untyped` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + - cannot be used as the type of a key property of an entity type. + - cannot be the base type of an entity type or complex type. + - cannot be used as the underlying type of a type definition or + enumeration type. + +[[· +]{style="font-family:Symbol"}]{.Datatype}`Collection(Edm.PrimitiveType)` + +- - cannot be used as the type of a property or term. + - cannot be used as the type of a parameter or the return type of + an action or function. + +[· ]{style="font-family:Symbol"}`Collection(Edm.Untyped)` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + +## ##subsec Built-In Types for defining Vocabulary Terms + +[Vocabulary terms](#VocabularyandAnnotation) can, in addition, use + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.AnnotationPath` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.PropertyPath` + +[[· +]{style="font-family:Symbol"}]{.Datatype}`Edm.NavigationPropertyPath` + +[[· +]{style="font-family:Symbol"}]{.Datatype}`Edm.AnyPropertyPath `(`Edm.PropertyPath `or +`Edm.NavigationPropertyPath`) + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.ModelElementPath `(any +model element, including +`Edm.AnnotationPath`,` Edm.NavigationPropertyPath`, and +`Edm.PropertyPath`) + +as the type of a primitive term, or the type of a property of a complex +type (recursively) that is exclusively used as the type of a term. See +section "[Path Expressions](#PathExpressions)" for details. + +## ##subsec Annotations + +Many parts of the model can be decorated with additional information +using [annotations](#Annotation). Annotations are identified by their +term name and an optional qualifier that allows applying the same term +multiple times to the same model element. + +A model element MUST NOT specify more than one annotation for a given +combination of term and qualifier. + +# ##sec CSDL JSON Document + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Document Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A CSDL JSON document consists of a single JSON object. This document +object MUST contain the member `$Version`. + +The document object MAY contain the member [`$Reference`](#Reference) to +reference other CSDL documents. + +It also MAY contain members for [schemas](#Schema). + +If the CSDL JSON document is the metadata document of an OData service, +the document object MUST contain the member `$EntityContainer`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Version`]{#_Toc37317365} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Version` is a string containing either `4.0` or `4.01`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$EntityContainer`]{#_Toc37317366} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$EntityContainer` is value is the namespace-qualified name +of the entity container of that service. This is the only place where a +model element MUST be referenced with its namespace-qualified name and +use of the alias-qualified name is not allowed. +::: + +Example 2: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  "$Version": "4.01",` + +`  "$EntityContainer": "org.example.DemoService",` + +`  … ` + +`}` +::: + +## ##subsec Reference + +A reference to an external CSDL document allows to bring part of the +referenced document's content into the scope of the referencing +document. + +A reference MUST specify a URI that uniquely identifies the referenced +document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be +absolute or relative URI; relative URLs are relative to the URL of the +document containing the reference, or relative to a base URL specified +in a format-specific way. + +A reference MAY be annotated. + +The +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation, defined in [OData-VocCore](#ODataVocCore), MAY be used to +indicate a particular version of the referenced document. If the +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation is present, the `$schemaversion` system query option, defined +[OData‑Protocol](#ODataProtocol), SHOULD be used when retrieving the +referenced schema document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Reference`]{#_Toc37317367} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Reference` is an object that contains one member per +referenced CSDL document. The name of the pair is a URI for the +referenced document. The URI MAY be relative to the document containing +the `$Reference`. The value of each member is a reference object. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Reference Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The reference object MAY contain the members +[`$Include`](#IncludedSchema) and +[`$IncludeAnnotations`](#IncludedAnnotations) as well as +[annotations](#Annotation). +::: + +Example 3: references to other CSDL documents + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  …` + +`  "$Reference": {` + +`    "http://vocabs.odata.org/capabilities/v1": {` + +`      …` + +`    },` + +`    "http://vocabs.odata.org/core/v1": {` + +`      …` + +`    },` + +`    "http://example.org/display/v1": {` + +`      …` + +`    }` + +`  },` + +`  …` + +`}` +::: + +## ##subsec Included Schema + +A reference MAY include zero or more schemas from the referenced +document. + +The included schemas are identified via their [namespace](#Namespace). +The same namespace MUST NOT be included more than once, even if it is +declared in more than one referenced document. + +When including a schema, a [simple identifier](#SimpleIdentifier) value +MAY be specified as an alias for the schema that is used in qualified +names instead of the namespace. For example, an alias of `display` might +be assigned to the namespace `org.example.vocabularies.display`. An +alias-qualified name is resolved to a fully qualified name by examining +aliases for included schemas and schemas defined within the document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +If an included schema specifies an alias, the alias MUST be used in +qualified names throughout the document to identify model elements of +the included schema. A mixed use of namespace-qualified names and +alias-qualified names is not allowed. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +An alias is only valid within the document in which it is declared; a +referencing document may define its own aliases for included schemas. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Include`]{#_Toc37317369} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Include` is an array. Array items are objects that MUST +contain the member `$Namespace` and MAY contain the member `$Alias`. + +The item objects MAY contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Namespace`]{#_Toc37317370} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Namespace` is a string containing the namespace of the +included schema. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Alias`]{#_Toc37317371} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Alias` is a string containing the alias for the included +schema. +::: + +Example 4: references to entity models containing definitions of +vocabulary terms + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  …` + +`  "$Reference": {` + +`    "http://vocabs.odata.org/capabilities/v1": {` + +`      "$Include": [` + +`        {` + +`          "$Namespace": "Org.OData.Capabilities.V1",` + +`          "$Alias": "Capabilities"` + +`        }` + +`      ]` + +`    },` + +`    "http://vocabs.odata.org/core/v1": {` + +`      "$Include": [` + +`        {` + +`          "$Namespace": "Org.OData.Core.V1",` + +`          "$Alias": "Core",` + +`          "@Core.DefaultNamespace": true` + +`        }` + +`      ]` + +`    },` + +`    "http://example.org/display/v1": {` + +`      "$Include": [` + +`        {` + +`          "$Namespace": "org.example.display",` + +`          "$Alias": "UI"` + +`        }` + +`      ]` + +`    }` + +`  },` + +`  …` + +`}` +::: + +## ##subsec Included Annotations + +In addition to including whole schemas with all model constructs defined +within that schema, annotations can be included with more flexibility. + +Annotations are selectively included by specifying the +[namespace](#Namespace) of the annotations' term. Consumers can opt not +to inspect the referenced document if none of the term namespaces is of +interest for the consumer. + +In addition, the [qualifier](#Qualifier) of annotations to be included +MAY be specified. For instance, a service author might want to supply a +different set of annotations for various device form factors. If a +qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of +the target namespace, if present) SHOULD be included. If no qualifier is +specified, all annotations within the referenced document from the +specified term namespace (taking into account the target namespace, if +present) SHOULD be included. + +The qualifier also provides consumers insight about what qualifiers are +present in the referenced document. If the consumer is not interested in +that particular qualifier, the consumer can opt not to inspect the +referenced document. + +In addition, the namespace of the annotations' [target](#Target) MAY be +specified. If a target namespace is specified, only those annotations +which apply a term form the specified term namespace to a model element +of the target namespace (with the specified qualifier, if present) +SHOULD be included. If no target namespace is specified, all annotations +within the referenced document from the specified term namespace (taking +into account the qualifier, if present) SHOULD be included. + +The target namespace also provides consumers insight about what +namespaces are present in the referenced document. If the consumer is +not interested in that particular target namespace, the consumer can opt +not to inspect the referenced document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$IncludeAnnotations`]{#_Toc37317372} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$IncludeAnnotations` is an array. Array items are objects +that MUST contain the member `$TermNamespace` and MAY contain the +members `$Qualifier` and `$TargetNamespace`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$TermNamespace`]{#_Toc37317373} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$TermNamespace` is a namespace. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Qualifier`]{#_Toc37317374} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Qualifier` is a simple identifier. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$TargetNamespace`]{#_Toc37317375} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$TargetNamespace` is a namespace. +::: + +Example 5: reference documents that contain annotations + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  …` + +`  "$Reference": {` + +`    "http://odata.org/ann/b": {` + +`      "$IncludeAnnotations": [` + +`        {` + +`          "$TermNamespace": "org.example.validation"` + +`        },` + +`        {` + +`          "$TermNamespace": "org.example.display",` + +`          "$Qualifier": "Tablet"` + +`        },` + +`        {` + +`          "$TermNamespace": "org.example.hcm",` + +`          "$TargetNamespace": "com.example.Sales"` + +`        },` + +`        {` + +`          "$TermNamespace": "org.example.hcm",` + +`          "$Qualifier": "Tablet",` + +`          "$TargetNamespace": "com.example.Person"` + +`        }` + +`      ]` + +`    }` + +`  },` + +`  …` + +`}` +::: + +The following annotations from `http://odata.org/ann/b` are included: + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that use a +term from the `org.example.validation` namespace, and + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that use a +term from the `org.example.display` namespace and specify a `Tablet` +qualifier and + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Sales` namespace and + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Person` namespace and specify a `Tablet` qualifier. + +# ##sec Schema + +One or more schemas describe the entity model exposed by an OData +service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms. + +A schema is identified by a [namespace](#Namespace). Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally +unique. A schema cannot span more than one document. + +The schema's namespace is combined with the name of elements in the +schema to create unique [qualified names](#QualifiedName), so +identifiers that are used to name types MUST be unique within a +namespace to prevent ambiguity. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +The namespace MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Schema Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A schema is represented as a member of the document object whose name is +the schema namespace. Its value is an object that MAY contain the +members [`$Alias`](#Alias) and +[`$Annotations`](#AnnotationswithExternalTargeting). + +The schema object MAY contain members representing [entity +types](#EntityType), [complex types](#ComplexType), [enumeration +types](#EnumerationType), [type definitions](#TypeDefinition), +[actions](#Action), [functions](#Function), [terms](#Term), and an +[entity container](#EntityContainer). + +The schema object MAY also contain [annotations](#Annotation) that apply +to the schema itself. +::: + +## ##subsec Alias + +A schema MAY specify an alias which MUST be a [simple +identifier](#SimpleIdentifier). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +If a schema specifies an alias, the alias MUST be used instead of the +namespace within qualified names throughout the document to identify +model elements of that schema. A mixed use of namespace-qualified names +and alias-qualified names is not allowed. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the +containing document and are not restricted to the schema that defines +them. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Alias`]{#_Toc37317377} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Alias` is a string containing the alias for the schema. +::: + +Example 6: document defining a schema `org.example` with an alias and a +description for the schema + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  …` + +`  "org.example": {` + +`    "$Alias": "self", ` + +`    "@Core.Description": "Example schema",` + +`    … ` + +`  },` + +`  … ` + +`}` +::: + +## ##subsec Annotations with External Targeting + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Annotations`]{#_Toc37317378} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Annotations` is an object with one member per [annotation +target](#Target). The member name is a path identifying the [annotation +target](#Target), the member value is an object containing +[annotations](#Annotation) for that target. +::: + +Example 7: annotations targeting the `Person` type with qualifier +`Tablet` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"org.example": {` + +`  "$Alias": "self", ` + +`  "$Annotations": {` + +`    "self.Person": {` + +`      "@Core.Description#Tablet": "Dummy",` + +`      …` + +`    }` + +`  } ` + +`},` +::: + +# ##sec Entity Type + +Entity types are [nominal](#NominalTypes) [structured +types](#StructuredTypes) with a key that consists of one or more +references to [structural properties](#StructuralProperty). An entity +type is the template for an entity: any uniquely identifiable record +such as a customer or order. + +The entity type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +An entity type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to another entity type or collection of entity types. + +All properties MUST have a unique name within an entity type. Properties +MUST NOT have the same name as the declaring entity type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Entity Type Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +An entity type is represented as a member of the schema object whose +name is the unqualified name of the entity type and whose value is an +object. + +The entity type object MUST contain the member `$Kind` with a string +value of `EntityType`. + +It MAY contain the members [`$BaseType`](#DerivedEntityType), +[`$Abstract`](#AbstractEntityType), [`$OpenType`](#OpenEntityType), +[`$HasStream`](#MediaEntityType), and [`$Key`](#Key). + +It also MAY contain members representing [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty) as well as [annotations](#Annotation). +::: + +Example 8: a simple entity type + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Employee": {` + +`  "$Kind": "EntityType",` + +`  "$Key": [` + +`    "ID"` + +`  ],` + +`  "ID": {},` + +`  "FirstName": {},` + +`  "LastName": {},` + +`  "Manager": {` + +`    "$Kind": "NavigationProperty",` + +`    "$Nullable": true,` + +`    "$Type": "self.Manager"` + +`  }` + +`}` +::: + +## ##subsec Derived Entity Type + +An entity type can inherit from another entity type by specifying it as +its base type. + +An entity type inherits the [key](#Key) as well as structural and +navigation properties of its base type. + +An entity type MUST NOT introduce an inheritance cycle by specifying a +base type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$BaseType`]{#_Toc37317380} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$BaseType` is the qualified name of the base type. +::: + +Example 9: a derived entity type based on the previous example + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Manager": {` + +`  "$Kind": "EntityType",` + +`  "$BaseType": "self.Employee",` + +`  "AnnualBudget": {` + +`    "$Nullable": true,` + +`    "$Type": "Edm.Decimal",` + +`    "$Scale": 0` + +`  },` + +`  "Employees": {` + +`    "$Kind": "NavigationProperty",` + +`    "$Collection": true,` + +`    "$Type": "self.Employee"` + +`  }` + +`}` +::: + +Note: the derived type has the same name as one of the properties of its +base type. + +## ##subsec Abstract Entity Type + +An entity type MAY indicate that it is abstract and cannot have +instances. + +For OData 4.0 responses a non-abstract entity type MUST define a +[key](#Key) or derive from a [base type](#DerivedEntityType) with a +defined key. + +An abstract entity type MUST NOT inherit from a non-abstract entity +type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Abstract`]{#_Toc37317381} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Open Entity Type + +An entity type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +An entity type derived from an open entity type MUST indicate that it is +also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$OpenType`]{#_Toc37317382} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +  + +## ##subsec Media Entity Type + +An entity type that does not specify a base type MAY indicate that it is +a media entity type. *Media entities* are entities that represent a +media stream, such as a photo. Use a media entity if the out-of-band +stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal +entity with one or more properties of type `Edm.Stream` if the +structured data of the entity is the main topic of interest and the +stream data is just additional information attached to the structured +data. For more information on media entities see +[OData‑Protocol](#ODataProtocol). + +An entity type derived from a media entity type MUST indicate that it is +also a media entity type. + +Media entity types MAY specify a list of acceptable media types using an +annotation with term +[`Core.AcceptableMediaTypes`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#AcceptableMediaTypes), +see [OData-VocCore](#ODataVocCore). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$HasStream`]{#_Toc37317383} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$HasStream `is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Key + +An entity is uniquely identified within an entity set by its key. A key +MAY be specified if the entity type does not specify a [base +type](#DerivedEntityType) that already has a key declared. + +In order to be specified as the type of an [entity set](#EntitySet) or a +collection-valued [containment navigation +property](#ContainmentNavigationProperty), the entity type MUST either +specify a key or inherit its key from its [base +type](#DerivedEntityType). + +In OData 4.01 responses entity types used for [singletons](#Singleton) +or single-valued [navigation properties](#NavigationProperty) do not +require a key. In OData 4.0 responses entity types used for +[singletons](#Singleton) or single-valued [navigation +properties](#NavigationProperty) MUST have a key defined. + +An entity type (whether or not it is marked as abstract) MAY define a +key only if it doesn't inherit one. + +An entity type's key refers to the set of properties whose values +uniquely identify an instance of the entity type within an entity set. +The key MUST consist of at least one property. + +Key properties MUST NOT be nullable and MUST be typed with an +[enumeration type](#EnumerationType), one of the following [primitive +types](#PrimitiveTypes), or a [type definition](#TypeDefinition) based +on one of these primitive types: + +- `Edm.Boolean ` +- `Edm.Byte ` +- `Edm.Date ` +- `Edm.DateTimeOffset ` +- `Edm.Decimal ` +- `Edm.Duration ` +- `Edm.Guid ` +- `Edm.Int16 ` +- `Edm.Int32 ` +- `Edm.Int64 ` +- `Edm.SByte ` +- `Edm.String ` +- `Edm.TimeOfDay` + +Key property values MAY be language-dependent, but their values MUST be +unique across all languages and the entity ids (defined in +[OData‑Protocol](#ODataProtocol)) MUST be language independent. + +A key property MUST be a non-nullable primitive property of the entity +type itself, including non-nullable primitive properties of non-nullable +single-valued complex properties, recursively. + +In OData 4.01 the key properties of a directly related entity type MAY +also be part of the key if the navigation property is single-valued and +not nullable. This includes navigation properties of non-nullable +single-valued complex properties (recursively) of the entity type. If a +key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key. + +If the key property is a property of a complex property (recursively) or +of a directly related entity type, the key MUST specify an alias for +that property that MUST be a [simple identifier](#SimpleIdentifier) and +MUST be unique within the set of aliases, structural and navigation +properties of the declaring entity type and any of its base types. + +An alias MUST NOT be defined if the key property is a primitive property +of the entity type itself. + +For key properties that are a property of a complex or navigation +property, the alias MUST be used in the key predicate of URLs instead of +the path to the property because the required percent-encoding of the +forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be +used in the query part of URLs, where paths to properties don't require +special encoding and are a standard constituent of expressions anyway. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Key`]{#_Toc37317384} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Key` is an array with one item per key property. + +Key properties without a key alias are represented as strings containing +the property name. + +Key properties with a key alias are represented as objects with one +member whose name is the key alias and whose value is a string +containing the path to the property. +::: + +Example 10: entity type with a simple key + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Category": {` + +`  "$Kind": "EntityType",` + +`  "$Key": [` + +`    "ID"` + +`  ],` + +`  "ID": {` + +`    "$Type": "Edm.Int32"` + +`  },` + +`  "Name": {` + +`    "$Nullable": true,` + +`    "@Core.IsLanguageDependent": true` + +`  }` + +`}` +::: + +Example 11: entity type with a simple key referencing a property of a +[complex type](#ComplexType) + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Category": {` + +`  "$Kind": "EntityType",` + +`  "$Key": [` + +`    {` + +`      "EntityInfoID": "Info/ID"` + +`    }` + +`  ],` + +`  "Info": {` + +`    "$Type": "self.EntityInfo"` + +`  },` + +`  "Name": {` + +`    "$Nullable": true` + +`  }` + +`},` + +`"EntityInfo": {` + +`  "$Kind": "ComplexType",` + +`  "ID": {` + +`    "$Type": "Edm.Int32"` + +`  },` + +`  "Created": {` + +`    "$Type": "Edm.DateTimeOffset",` + +`    "$Precision": 0` + +`  }` + +`}` +::: + +Example 12: entity type with a composite key + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"OrderLine": {` + +`  "$Kind": "EntityType",` + +`  "$Key": [` + +`    "OrderID",` + +`    "LineNumber"` + +`  ],` + +`  "OrderID": {` + +`    "$Type": "Edm.Int32"` + +`  },` + +`  "LineNumber": {` + +`    "$Type": "Edm.Int32"` + +`  }` + +`}` +::: + +Example 13 (based on example 11): requests to an entity set `Categories` +of type `Category` must use the alias + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +GET http://host/service/Categories(EntityInfoID=1) +::: + +Example 14 (based on example 11): in a query part the value assigned to +the name attribute must be used + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +GET http://example.org/OData.svc/Categories?\$filter=Info/ID le 100 +::: + +# ##sec Structural Property + +A structural property is a property of a structured type that has one of +the following types: + +[· ]{style="font-family:Symbol"}[Primitive type](#PrimitiveTypes) + +[· ]{style="font-family:Symbol"}[Complex type](#ComplexType) + +[· ]{style="font-family:Symbol"}[Enumeration type](#EnumerationType) + +[· ]{style="font-family:Symbol"}A collection of one of the above + +A structural property MUST specify a unique name as well as a +[type](#Type). + +The property's name MUST be a [simple identifier](#SimpleIdentifier). It +is used when referencing, serializing or deserializing the property. It +MUST be unique within the set of structural and navigation properties of +the declaring [structured type](#StructuredTypes), and MUST NOT match +the name of any navigation property in any of its base types. If a +structural property with the same name is defined in any of this type's +base types, then the property's type MUST be a type derived from the +type specified for the property of the base type and constrains this +property to be of the specified subtype for instances of this structured +type. The name MUST NOT match the name of any structural or navigation +property of any of this type's base types for OData 4.0 responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Property Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Structural properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The property object MAY contain the member `$Kind` with a string value +of `Property`. This member SHOULD be omitted to reduce document size. + +It MAY contain the member [`$Type`](#Type), [`$Collection`](#Type), +[`$Nullable`](#Nullable), [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +[`$SRID`](#SRID), and [`$DefaultValue`](#DefaultValue). + +It also MAY contain [annotations](#Annotation). +::: + +Example 15: complex type with two properties `Dimension` and `Length` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Measurement": {` + +`  "$Kind": "ComplexType",` + +`  "Dimension": {` + +`    "$MaxLength": 50,` + +`    "$DefaultValue": "Unspecified"` + +`  },` + +`  "Length": {` + +`    "$Type": "Edm.Decimal",` + +`    "$Precision": 18,` + +`    "$Scale": 2` + +`  }` + +`}` +::: + +## ##subsec Type + +The property's type MUST be a [primitive type](#PrimitiveTypes), +[complex type](#ComplexType), or [enumeration type](#EnumerationType) in +scope, or a collection of one of these types. + +A collection-valued property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in\ +[OData-VocCore](#ODataVocCore)**)**, to specify that it supports a +stable ordering. + +A collection-valued property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Type` and]{#_Toc37317386} `$Collection` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued properties the value of `$Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `$Type` is the qualified +name of the property's item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. This +member SHOULD be omitted for string properties to reduce document size. +::: + +Example 16: property `Units` that can have zero or more strings as its +value + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Units": {` + +`  "$Collection": true` + +`}` +::: + +## ##subsec Type Facets + +Facets modify or constrain the acceptable values of a property. + +For single-valued properties the facets apply to the value of the +property. For collection-valued properties the facets apply to the items +in the collection. + +### ##subsubsec Nullable + +A Boolean value specifying whether the property can have the value +`null`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Nullable`]{#_Toc37317387} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + +### ##subsubsec MaxLength + +A positive integer value specifying the maximum length of a binary, +stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length +(number of code points for Unicode). + +If no maximum length is specified, clients SHOULD expect arbitrary +length. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$MaxLength`]{#_Toc37317388} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$MaxLength` is a positive integer. + +Note: **\[**[**OData-CSDLXML**](#ODataCSDL)**\]** defines a symbolic +value `max` that is only allowed in OData 4.0 responses. This symbolic +value is not allowed in CDSL JSON documents at all. Services MAY instead +specify the concrete maximum length supported for the type by the +service or omit the member entirely. +::: + +### ##subsubsec Precision + +For a decimal value: the maximum number of significant decimal digits of +the property's value; it MUST be a positive integer. + +For a temporal value (datetime-with-timezone-offset, duration, or +time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve. + +Note: service authors SHOULD be aware that some clients are unable to +support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential +for data loss when round-tripping values of greater precision. Updating +via `PATCH` and exclusively specifying modified properties will reduce +the risk for unintended data loss. + +Note: duration properties supporting a granularity less than seconds +(e.g. minutes, hours, days) can be annotated with term +[`Measures.DurationGranularity`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Measures.V1.md#DurationGranularity), +see [OData-VocMeasures](#ODataVocMeasures). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Precision`]{#_Toc37317389} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Precision` is a number. + +Absence of `$Precision` means arbitrary precision. +::: + +Example 17: `Precision` facet applied to the `DateTimeOffset` type + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"SuggestedTimes": {` + +`  "$Type": Edm.DateTimeOffset",` + +`  "$Collection": true,` + +`  "$Precision": 6` + +`}` +::: + +### ##subsubsec Scale + +A non-negative integer value specifying the maximum number of digits +allowed to the right of the decimal point, or one of the symbolic values +`floating` or `variable`. + +The value `floating` means that the decimal property represents a +decimal floating-point number whose number of significant digits is the +value of the [`Precision`](#Precision) facet. OData 4.0 responses MUST +NOT specify the value `floating`. + +The value `variable` means that the number of digits to the right of the +decimal point can vary from zero to the value of the +[`Precision`](#Precision) facet. + +An integer value means that the number of digits to the right of the +decimal point may vary from zero to the value of the `Scale` facet, and +the number of digits to the left of the decimal point may vary from one +to the value of the `Precision` facet minus the value of the `Scale` +facet. If `Precision` is equal to `Scale`, a single zero MUST precede +the decimal point. + +The value of `Scale` MUST be less than or equal to the value of +[`Precision`](#Precision). + +Note: if the underlying data store allows negative scale, services may +use a [`Precision`](#Precision) with the absolute value of the negative +scale added to the actual number of significant decimal digits, and +client-provided values may have to be rounded before being stored. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Scale`]{#_Toc37317390} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Scale` is a number or a string with one of the symbolic +values `floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +Absence of `$Scale` means `variable`. +::: + +Example 18: [`Precision`](#Precision)`=3` and `Scale=2`.\ +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Amount32": {` + +`  "$Nullable": true,` + +`  "$Type": "Edm.Decimal",` + +`  "$Precision": 3,` + +`  "$Scale": 2` + +`}` +::: + +Example 19: `Precision=2` equals `Scale`.\ +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Amount22": {` + +`  "$Nullable": true,` + +`  "$Type": "Edm.Decimal",` + +`  "$Precision": 2,` + +`  "$Scale": 2` + +`}` +::: + +Example 20: `Precision=3` and a variable `Scale`.\ +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Amount3v": {` + +`  "$Nullable": true,` + +`  "$Type": "Edm.Decimal",` + +`  "$Precision": 3` + +`}` +::: + +Example 21: `Precision=7` and a floating `Scale`.\ +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[`"Amount7f": {`]{#_Toc475623943} + +`  "$Nullable": true,` + +`  "$Type": "Edm.Decimal",` + +`  "$Precision": 7,` + +`  "$Scale": "floating"` + +`}` +::: + +### ##subsubsec Unicode + +For a string property the `Unicode` facet indicates whether the property +might contain and accept string values with Unicode characters (code +points) beyond the ASCII character set. The value `false` indicates that +the property will only contain and accept string values with characters +limited to the ASCII character set. + +If no value is specified, the `Unicode` facet defaults to `true`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Unicode`]{#_Toc37317391} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Unicode` is one of the Boolean literals `true` or +`false`. Absence of the member means `true`. +::: + +### ##subsubsec SRID + +For a geometry or geography property the `SRID` facet identifies which +spatial reference system is applied to values of the property on type +instances. + +The value of the `SRID` facet MUST be a non-negative integer or the +special value `variable`. If no value is specified, the facet defaults +to `0` for `Geometry` types or `4326` for `Geography` types. + +The valid values of the `SRID` facet and their meanings are as defined +by the European Petroleum Survey Group [**\[EPSG\]**](#BMEPSG)**.** + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$SRID`]{#_Toc37317392} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$SRID` is a string containing a number or the symbolic +value `variable`. +::: + +### ##subsubsec [Default Value](#DefaultValue) + +A primitive or enumeration property MAY define a default value that is +used if the property is not explicitly represented in an annotation or +the body of a request or response. + +If no value is specified, the client SHOULD NOT assume a default value. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$DefaultValue`]{#_Toc37317393} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the property, see +**\[**[**OData-JSON**](#ODataJSON)**\]**. For properties of type +`Edm.Decimal` and `Edm.Int64` the representation depends on the media +type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumber). +::: + +# ##sec Navigation Property + +A navigation property allows navigation to related entities. It MUST +specify a unique name as well as a type. + +The navigation property's name MUST be a [simple +identifier](#SimpleIdentifier). It is used when referencing, serializing +or deserializing the navigation property. It MUST be unique within the +set of structural and navigation properties of the declaring [structured +type](#StructuredTypes), and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the +same name is defined in any of this type's base types, then the +navigation property's type MUST be a type derived from the type +specified for the navigation property of the base type, and constrains +this navigation property to be of the specified subtype for instances of +this structured type. The name MUST NOT match the name of any structural +or navigation property of any of this type's base types for OData 4.0 +responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Navigation Property Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Navigation properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The navigation property object MUST contain the member `$Kind` with a +string value of `NavigationProperty`. + +It MUST contain the member [`$Type`](#NavigationPropertyType), and it +MAY contain the members [`$Collection`](#NavigationPropertyType), +[`$Nullable`](#NullableNavigationProperty), +[`$Partner`](#PartnerNavigationProperty), +[`$ContainsTarget`](#ContainmentNavigationProperty), +[`$ReferentialConstraint`](#ReferentialConstraint), and +[`$OnDelete`](#OnDeleteAction). + +It also MAY contain [annotations](#Annotation). +::: + +Example 22: the `Product` entity type has a navigation property to a +`Category`, which has a navigation link back to one or more products + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Product": {` + +`  "$Kind": "EntityType",` + +`  …` + +`  "Category": {` + +`    "$Kind": "NavigationProperty",` + +`    "$Type": "self.Category",` + +`    "$Partner": "Products",` + +`    "$ReferentialConstraint": {` + +`      "CategoryID": "ID"` + +`    }` + +`  },` + +`  "Supplier": {` + +`    "$Kind": "NavigationProperty",` + +`    "$Type": "self.Supplier"` + +`  }` + +`},` + +`"Category": {` + +`  "$Kind": "EntityType",` + +`  …` + +`  "Products": {` + +`    "$Kind": "NavigationProperty",` + +`    "$Collection": true,` + +`    "$Type": "self.Product",` + +`    "$Partner": "Category",` + +`    "$OnDelete": "Cascade",` + +`    "$OnDelete@Core.Description": "Delete all related entities"` + +`  }` + +`}` +::: + +## ##subsec Navigation Property Type + +The navigation property's type MUST be an [entity type](#EntityType) in +scope, the [abstract type](#BuiltInAbstractTypes) `Edm.EntityType`, or a +collection of one of these types. + +If the type is a collection, an arbitrary number of entities can be +related. Otherwise there is at most one related entity. + +The related entities MUST be of the specified entity type or one of its +subtypes. + +For a collection-valued containment navigation property the specified +entity type MUST have a [key](#Key) defined. + +A collection-valued navigation property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-VocCore](#ODataVocCore)**)**, to specify that it +supports a stable ordering. + +A collection-valued navigation property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Type` and]{#_Toc37317395} `$Collection` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's item type, and the member +`$Collection` MUST be present with the literal value `true`. +::: + +## ##subsec Nullable Navigation Property + +A Boolean value specifying whether the declaring type MAY have no +related entity. If false, instances of the declaring structured type +MUST always have a related entity. + +Nullable MUST NOT be specified for a collection-valued navigation +property, a collection is allowed to have zero items. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Nullable`]{#_Toc37317396} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Partner Navigation Property + +A navigation property of an [entity type](#EntityType) MAY specify a +partner navigation property. Navigation properties of complex types MUST +NOT specify a partner. + +If specified, the partner navigation property is identified by a path +relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that +type or a derived type. The path MAY traverse complex types, including +derived complex types, but MUST NOT traverse any navigation properties. +The type of the partner navigation property MUST be the declaring entity +type of the current navigation property or one of its parent entity +types. + +If the partner navigation property is single-valued, it MUST lead back +to the source entity from all related entities. If the partner +navigation property is collection-valued, the source entity MUST be part +of that collection. + +If no partner navigation property is specified, no assumptions can be +made as to whether one of the navigation properties on the target type +will lead back to the source entity. + +If a partner navigation property is specified, this partner navigation +property MUST either specify the current navigation property as its +partner to define a bi-directional relationship or it MUST NOT specify a +partner navigation property. The latter can occur if the partner +navigation property is defined on a complex type, or if the current +navigation property is defined on a type derived from the type of the +partner navigation property. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Partner`]{#_Toc37317397} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Partner` is a string containing the path to the partner +navigation property. +::: + +## ##subsec Containment Navigation Property + +A navigation property MAY indicate that instances of its declaring +structured type contain the targets of the navigation property, in which +case the navigation property is called a *containment navigation +property*. + +Containment navigation properties define an implicit entity set for each +instance of its declaring structured type. This implicit entity set is +identified by the read URL of the navigation property for that +structured type instance. + +Instances of the structured type that declares the navigation property, +either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The +canonical URL for contained entities is the canonical URL of the +containing instance, followed by the path segment of the navigation +property and the key of the contained entity, see +[OData‑URL](#ODataURL). + +Entity types used in collection-valued containment navigation properties +MUST have a [key](#Key) defined. + +For items of an ordered collection of complex types (those annotated +with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term defined in [OData-VocCore](#ODataVocCore)**)**, the canonical URL +of the item is the canonical URL of the collection appended with a +segment containing the zero-based ordinal of the item. Items within in +an unordered collection of complex types do not have a canonical URL. +Services that support unordered collections of complex types declaring a +containment navigation property, either directly or indirectly via a +property of complex type, MUST specify the URL for the navigation link +within a payload representing that item, according to format-specific +rules. + +OData 4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued +property. + +An entity cannot be referenced by more than one containment +relationship, and cannot both belong to an entity set declared within +the entity container and be referenced by a containment relationship. + +Containment navigation properties MUST NOT be specified as the last path +segment in the path of a [navigation property +binding](#NavigationPropertyBinding). + +When a containment navigation property navigates between entity types in +the same inheritance hierarchy, the containment is called *recursive*. + +Containment navigation properties MAY specify a partner navigation +property. If the containment is recursive, the relationship defines a +tree, thus the partner navigation property MUST be +[nullable](#NullableNavigationProperty) (for the root of the tree) and +single-valued (for the parent of a non-root entity). If the containment +is not recursive, the partner navigation property MUST NOT be nullable. + +An entity type inheritance chain MUST NOT contain more than one +navigation property with a partner navigation property that is a +containment navigation property. + +Note: without a partner navigation property, there is no reliable way +for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity +can also be reached via a non-containment navigation path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$ContainsTarget`]{#_Toc37317398} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Referential Constraint + +A single-valued navigation property MAY define one or more referential +constraints. A referential constraint asserts that the *dependent +property* (the property defined on the structured type declaring the +navigation property) MUST have the same value as the *principal +property* (the referenced property declared on the entity type that is +the target of the navigation). + +The type of the dependent property MUST match the type of the principal +property, or both types MUST be complex types. + +If the principle property references an entity, then the dependent +property must reference the same entity. + +If the principle property's value is a complex type instance, then the +dependent property's value must be a complex type instance with the same +properties, each with the same values. + +If the navigation property on which the referential constraint is +defined is nullable, or the principal property is nullable, then the +dependent property MUST also be nullable. If both the navigation +property and the principal property are not nullable, then the dependent +property MUST NOT be nullable. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$ReferentialConstraint`]{#_Toc37317399} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$ReferentialConstraint` is an object with one member per +referential constraint. The member name is the path to the dependent +property, this path is relative to the structured type declaring the +navigation property. The member value is a string containing the path to +the principal property, this path is relative to the entity type that is +the target of the navigation property. + +It also MAY contain [annotations](#Annotation). These are prefixed with +the path of the dependent property of the annotated referential +constraint. +::: + +Example 23: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Product": {` + +`  "$Kind": "EntityType",` + +`  …` + +`  "CategoryID": {},` + +`  "CategoryKind": {},` + +`  "Category": {` + +`    "$Kind": "NavigationProperty",` + +`    "$Type": "self.Category",` + +`    "$Partner": "Products",` + +`    "$ReferentialConstraint": {` + +`      "CategoryID": "ID",` + +`      "CategoryKind": "Kind"` + +`      "CategoryKind@Core.Description": "Referential Constraint to non-key property"` + +`    }` + +`  }` + +`},` + +`"Category": {` + +`  "$Kind": "EntityType",` + +`  "$Key": [` + +`    "ID"` + +`  ],` + +`  "ID": {},` + +`  "Kind": {` + +`    "$Nullable": true` + +`  },` + +`  …` + +`}` +::: + +## ##subsec On-Delete Action + +A navigation property MAY define an on-delete action that describes the +action the service will take on related entities when the entity on +which the navigation property is defined is deleted. + +The action can have one of the following values: + +- `Cascade`, meaning the related entities will be deleted if the + source entity is deleted, +- `None`, meaning a `DELETE` request on a source entity with related + entities will fail, +- `SetNull`, meaning all properties of related entities that are tied + to properties of the source entity via a referential constraint and + that do not participate in other referential constraints will be set + to null, +- `SetDefault`, meaning all properties of related entities that are + tied to properties of the source entity via a referential constraint + and that do not participate in other referential constraints will be + set to their default value. + +If no on-delete action is specified, the action taken by the service is +not predictable by the client and could vary per entity. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$OnDelete`]{#_Toc37317400} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$OnDelete` is a string with one of the values `Cascade`, +`None`, `SetNull`, or `SetDefault`. + +[Annotations](#Annotation) for `$OnDelete` are prefixed with +`$OnDelete`. +::: + +Example 24: deletion of a category implies deletion of the related +products in that category + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Category": {` + +`  "$Kind": "EntityType",` + +`  …` + +`  "Products": {` + +`    "$Kind": "NavigationProperty",` + +`    "$Collection": true,` + +`    "$Type": "self.Product",` + +`    "$Partner": "Category",` + +`    "$OnDelete": "Cascade",` + +`    "$OnDelete@Core.Description": "Delete all products in this category"` + +`  }` + +`}` +::: + +# ##sec Complex Type + +Complex types are keyless [nominal](#NominalTypes) [structured +types](#StructuredTypes). The lack of a key means that instances of +complex types cannot be referenced, created, updated or deleted +independently of an entity type. Complex types allow entity models to +group properties into common structures. + +The complex type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +A complex type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to an entity type or a collection of entity types. + +All properties MUST have a unique name within a complex type. Properties +MUST NOT have the same name as the declaring complex type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Complex Type Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A complex type is represented as a member of the schema object whose +name is the unqualified name of the complex type and whose value is an +object. + +The complex type object MUST contain the member `$Kind` with a string +value of `ComplexType`. It MAY contain the members +[`$BaseType`](#DerivedComplexType), [`$Abstract`](#AbstractComplexType), +and [`$OpenType`](#OpenComplexType). It also MAY contain members +representing [structural properties](#StructuralProperty) and +[navigation properties](#NavigationProperty) as well as +[annotations](#Annotation). +::: + +Example 25: a complex type used by two entity types + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Dimensions": {` + +`  "$Kind": "ComplexType",` + +`  "Height": {` + +`    "$Type": "Edm.Decimal",` + +`    "$Scale": 0` + +`  },` + +`  "Weight": {` + +`    "$Type": "Edm.Decimal",` + +`    "$Scale": 0` + +`  },` + +`  "Length": {` + +`    "$Type": "Edm.Decimal",` + +`    "$Scale": 0` + +`  }` + +`},` + +`"Product": {` + +`  …` + +`  "ProductDimensions": {` + +`    "$Nullable": true,` + +`    "$Type": "self.Dimensions"` + +`  },` + +`  "ShippingDimensions": {` + +`    "$Nullable": true,` + +`    "$Type": "self.Dimensions"` + +`  }` + +`},` + +`"ShipmentBox": {` + +`  …` + +`  "Dimensions": {` + +`    "$Nullable": true,` + +`    "$Type": "self.Dimensions"` + +`  }` + +`}` +::: + +## ##subsec Derived Complex Type + +A complex type can inherit from another complex type by specifying it as +its base type. + +A complex type inherits the structural and navigation properties of its +base type. + +A complex type MUST NOT introduce an inheritance cycle by specifying a +base type. + +The rules for annotations of derived complex types are described in +section 14.2. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$BaseType`]{#_Toc37317402} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$BaseType` is the qualified name of the base type. +::: + +## ##subsec Abstract Complex Type + +A complex type MAY indicate that it is abstract and cannot have +instances. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Abstract`]{#_Toc37317403} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Open Complex Type + +A complex type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +A complex type derived from an open complex type MUST indicate that it +is also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$OpenType`]{#_Toc37317404} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +# ##sec Enumeration Type + +Enumeration types are [nominal](#NominalTypes) types that represent a +non-empty series of related values. Enumeration types expose these +related values as members of the enumeration. + +The enumeration type's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Although enumeration types have an underlying numeric value, the +preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the `AllowedValues` annotation defined in +[OData-VocCore](#ODataVocCore). + +Enumeration types marked as flags allow values that consist of more than +one enumeration member at a time. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Enumeration Type Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +An enumeration type is represented as a member of the schema object +whose name is the unqualified name of the enumeration type and whose +value is an object. + +The enumeration type object MUST contain the member `$Kind` with a +string value of `EnumType`. + +It MAY contain the members [`$UnderlyingType`](#UnderlyingIntegerType) +and [`$IsFlags`](#FlagsEnumerationType). + +The enumeration type object MUST contain members representing [the +enumeration type members](#EnumerationTypeMember). + +The enumeration type object MAY contain [annotations](#Annotation). +::: + +Example 26: a simple flags-enabled enumeration + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"FileAccess": {` + +`  "$Kind": "EnumType",` + +`  "$UnderlyingType": "Edm.Int32",` + +`  "$IsFlags": true,` + +`  "Read": 1,` + +`  "Write": 2,` + +`  "Create": 4,` + +`  "Delete": 8` + +`}` +::: + +## ##subsec Underlying Integer Type + +An enumeration type MAY specify one of `Edm.Byte`, `Edm.SByte`, +`Edm.Int16`, `Edm.Int32`, or `Edm.Int64` as its underlying type. + +If not explicitly specified, `Edm.Int32` is used as the underlying type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$UnderlyingType`]{#_Toc37317406} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + +## ##subsec Flags Enumeration Type + +An enumeration type MAY indicate that the enumeration type allows +multiple members to be selected simultaneously. + +If not explicitly specified, only one enumeration type member MAY be +selected simultaneously. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$IsFlags`]{#_Toc37317407} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$IsFlags` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +Example 27: pattern values can be combined, and some combined values +have explicit names + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Pattern": {` + +`  "$Kind": "EnumType",` + +`  "$UnderlyingType": "Edm.Int32",` + +`  "$IsFlags": true,` + +`  "Plain": 0,` + +`  "Red": 1,` + +`  "Blue": 2,` + +`  "Yellow": 4,` + +`  "Solid": 8,` + +`  "Striped": 16,` + +`  "SolidRed": 9,` + +`  "SolidBlue": 10,` + +`  "SolidYellow": 12,` + +`  "RedBlueStriped": 19,` + +`  "RedYellowStriped": 21,` + +`  "BlueYellowStriped": 22` + +`}` +::: + +## ##subsec Enumeration Type Member + +Enumeration type values consist of discrete members. + +Each member is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within the +enumeration type. Names are case-sensitive, but service authors SHOULD +NOT choose names that differ only in case. + +Each member MUST specify an associated numeric value that MUST be a +valid value for the underlying type of the enumeration type. + +Enumeration types can have multiple members with the same value. Members +with the same numeric value compare as equal, and members with the same +numeric value can be used interchangeably. + +Enumeration members are sorted by their numeric value. + +For flag enumeration types the combined numeric value of simultaneously +selected members is the bitwise OR of the discrete numeric member +values. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Enumeration Member Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Enumeration type members are represented as JSON object members, where +the object member name is the enumeration member name and the object +member value is the enumeration member value. + +For members of [flags enumeration types](#FlagsEnumerationType) a +combined enumeration member value is equivalent to the bitwise OR of the +discrete values. + +Annotations for enumeration members are prefixed with the enumeration +member name. +::: + +Example 28: `FirstClass` has a value of `0`, `TwoDay` a value of 1, and +`Overnight` a value of 2. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"ShippingMethod": {` + +`  "$Kind": "EnumType",` + +`  "FirstClass": 0,` + +`  "FirstClass@Core.Description": "Shipped with highest priority",` + +`  "TwoDay": 1,` + +`  "TwoDay@Core.Description": "Shipped within two days",` + +`  "Overnight": 2,` + +`  "Overnight@Core.Description": "Shipped overnight",` + +`  "@Core.Description": "Method of shipping"` + +`}` +::: + +# ##sec Type Definition + +A type definition defines a specialization of one of the [primitive +types](#PrimitiveTypes) or of the built-in abstract type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes). + +The type definition's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Type definitions can be used wherever a primitive type is used (other +than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions +defined using the same underlying type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Type Definition Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A type definition is represented as a member of the schema object whose +name is the unqualified name of the type definition and whose value is +an object. + +The type definition object MUST contain the member `$Kind` with a string +value of `TypeDefinition` and the member +[`$UnderlyingType`](#UnderlyingPrimitiveType). It MAY contain the +members [`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID), +and it MAY contain [annotations](#Annotation). +::: + +Example 29: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\"Length\": { + +  \"\$Kind\": \"TypeDefinition\", + +  \"\$UnderlyingType\": \"Edm.Int32\", + +  \"@Measures.Unit\": \"Centimeters\" + +}, + +\"Weight\": { + +  \"\$Kind\": \"TypeDefinition\", + +  \"\$UnderlyingType\": \"Edm.Int32\", + +  \"@Measures.Unit\": \"Kilograms\" + +}, + +\"Size\": { + +  \"\$Kind\": \"ComplexType\", + +  \"Height\": { + +`    "$Nullable": true,` + +    \"\$Type\": \"self.Length\" + +  }, + +  \"Weight\": { + +`    "$Nullable": true,` + +    \"\$Type\": \"self.Weight\" + +  } + +} +::: + +## ##subsec Underlying Primitive Type + +The underlying type of a type definition MUST be a primitive type that +MUST NOT be another type definition. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$UnderlyingType`]{#_Toc37317410} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`$MaxLength`](#MaxLength), +`$`[`Unicode`](#Unicode), `$`[`Precision`](#Precision), +`$`[`Scale`](#Scale), or `$`[`SRID`](#SRID). + +Additional facets appropriate for the underlying type MAY be specified +when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified. + +For a type definition with underlying type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes) no facets are applicable, +neither in the definition itself nor when the type definition is used, +and these should be ignored by the client. + +Where type definitions are used, the type definition is returned in +place of the primitive type wherever the type is specified in a +response. + +# ##sec Action and Function + +## ##subsec Action + +Actions are service-defined operations that MAY have observable side +effects and MAY return a single instance or a collection of instances of +any type. + +The action's name is a [simple identifier](#SimpleIdentifier) that MUST +be unique within its schema. + +Actions cannot be composed with additional path segments. + +An action MAY specify a [return type](#ReturnType) that MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +An action MAY define [parameters](#Parameter) used during the execution +of the action. + +## ##subsec Action Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) actions support +overloading (multiple actions having the same name within the same +schema) by binding parameter type. The combination of action name and +the binding parameter type MUST be unique within a schema. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) actions do not support +overloads. The names of all unbound actions MUST be unique within a +schema. + +An unbound action MAY have the same name as a bound action. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Action Overload Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +An action is represented as a member of the schema object whose name is +the unqualified name of the action and whose value is an array. The +array contains one object per action overload. + +The action overload object MUST contain the member `$Kind` with a string +value of `Action`. + +It MAY contain the members +[`$IsBound`](#BoundorUnboundActionorFunctionOverlo), +[`$EntitySetPath`](#EntitySetPath), [`$Parameter`](#Parameter), and +[`$ReturnType`](#ReturnType), and it MAY contain +[annotations](#Annotation). +::: + +## ##subsec Function + +Functions are service-defined operations that MUST NOT have observable +side effects and MUST return a single instance or a collection of +instances of any type. + +The function's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +Functions MAY be [composable](#ComposableFunction). + +The function MUST specify a [return type](#ReturnType) which MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +A function MAY define [parameters](#Parameter) used during the execution +of the function. + +## ##subsec Function Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading (multiple functions having the same name within the same +schema) subject to the following rules: + +[· ]{style="font-family:Symbol"}The combination of function name, +binding parameter type, and unordered set of non-binding parameter names +MUST be unique within a schema. + +[· ]{style="font-family:Symbol"}The combination of function name, +binding parameter type, and ordered set of parameter types MUST be +unique within a schema. + +[· ]{style="font-family:Symbol"}All bound functions with the same +function name and binding parameter type within a schema MUST specify +the same return type. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading subject to the following rules: + +[· ]{style="font-family:Symbol"}The combination of function name and +unordered set of parameter names MUST be unique within a schema. + +[· ]{style="font-family:Symbol"}The combination of function name and +ordered set of parameter types MUST be unique within a schema. + +[· ]{style="font-family:Symbol"}All unbound functions with the same +function name within a schema MUST specify the same return type. + +An unbound function MAY have the same name as a bound function. + +Note that [type definitions](#TypeDefinition) can be used to +disambiguate overloads for both bound and unbound functions, even if +they specify the same underlying type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Function Overload Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A function is represented as a member of the schema object whose name is +the unqualified name of the function and whose value is an array. The +array contains one object per function overload. + +The function overload object MUST contain the member `$Kind` with a +string value of `Function`. + +It MUST contain the member [`$ReturnType`](#ReturnType), and it MAY +contain the members [`$IsBound`](#BoundorUnboundActionorFunctionOverlo), +[`$EntitySetPath`](#EntitySetPath), and` `[`$Parameter`](#Parameter), +and it MAY contain [annotations](#Annotation). +::: + +## ##subsec Bound or Unbound Action or Function Overloads + +An action or function overload MAY indicate that it is bound. If not +explicitly indicated, it is unbound. + +Bound actions or functions are invoked on resources matching the type of +the binding parameter. The binding parameter can be of any type, and it +MAY be [nullable](#Nullable). + +Unbound actions are invoked from the entity container through an [action +import](#ActionImport). + +Unbound functions are invoked as static functions within a filter or +orderby expression, or from the entity container through a [function +import](#FunctionImport). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$IsBound`]{#_Toc37317413} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$IsBound` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Entity Set Path + +Bound actions and functions that return an entity or a collection of +entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter +value. + +The entity set path consists of a series of segments joined together +with forward slashes. + +The first segment of the entity set path MUST be the name of the binding +parameter. The remaining segments of the entity set path MUST represent +navigation segments or type casts. + +A navigation segment names the [simple identifier](#SimpleIdentifier) of +the [navigation property](#NavigationProperty) to be traversed. A +type-cast segment names the [qualified name](#QualifiedName) of the +entity type that should be returned from the type cast. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$EntitySetPath`]{#_Toc37317414} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$EntitySetPath` is a string containing the entity set +path. +::: + +## ##subsec Composable Function + +A function MAY indicate that it is composable. If not explicitly +indicated, it is not composable. + +A composable function can be invoked with additional path segments or +key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for +the type returned by the composable function. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$IsComposable`]{#_Toc37317415} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Return Type + +The return type of an action or function overload MAY be any type in +scope, or a collection of any type in scope. + +The facets [`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID) can be +used as appropriate to specify value restrictions of the return type, as +well as the [`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For a single-valued return type the facets apply to the returned value. +For a collection-valued return type the facets apply to the items in the +returned collection. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$ReturnType`]{#_Toc37317416} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$ReturnType` is an object. It MAY contain the members +`$Type`, `$Collection`, `$Nullable`, [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID). + +It also MAY contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Type` and]{#_Toc37317417} `$Collection` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued return types the value of `$Type` is the qualified +name of the returned type. + +For collection-valued return types the value of `$Type` is the qualified +name of the returned item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Nullable`]{#_Toc444868540} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +If the return type is a collection of entity types, the `$Nullable` +member has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + +## ##subsec Parameter + +An action or function overload MAY specify parameters. + +A bound action or function overload MUST specify at least one parameter; +the first parameter is its binding parameter. The order of parameters +MUST NOT change unless the schema version changes. + +Each parameter MUST have a name that is a [simple +identifier](#SimpleIdentifier). The parameter name MUST be unique within +the action or function overload. + +The parameter MUST specify a type. It MAY be any type in scope, or a +collection of any type in scope. + +The facets [`MaxLength`](#MaxLength), [`Precision`](#Precision), +[`Scale`](#Scale), or [`SRID`](#SRID) can be used as appropriate to +specify value restrictions of the parameter, as well as the +[`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For single-valued parameters the facets apply to the parameter value. If +the parameter value is a collection, the facets apply to the items in +the collection. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Parameter`]{#_Toc37317419} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Parameter` is an array. The array contains one object per +parameter. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Parameter Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A parameter object MUST contain the member `$Name`, and it MAY contain +the members `$Type`, `$Collection`, `$Nullable`, +[`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID). + +Parameter objects MAY also contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Name`]{#_Toc37317421} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Name` is a string containing the parameter name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Type` and]{#_Toc37317422} `$Collection` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued parameters the value of `$Type` is the qualified name +of the accepted type. + +For collection-valued parameters the value of `$Type` is the qualified +name of the accepted item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Nullable`]{#_Toc444868544} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued parameters the value `true` means that the parameter +accepts a `null` value. + +For collection-valued parameters the parameter value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + +Example 30: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `edm:Parameter` element. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\"TopSellingProducts\": \[ + +  { + +    \"\$Kind\": \"Function\", + +    \"\$Parameter\": \[ + +      { + +        \"\$Name\": \"Year\", + +        \"\$Nullable\": true, + +        \"\$Type\": \"Edm.Decimal\", + +        \"\$Precision\": 4, + +        \"\$Scale\": 0 + +      } + +    \], + +    \"\$ReturnType\": { + +      \"\$Collection\": true, + +      \"\$Type\": \"self.Product\" + +    } + +  } + +\] +::: + +# ##sec Entity Container + +Each metadata document used to describe an OData service MUST define +exactly one entity container. + +The entity container's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Entity containers define the entity sets, singletons, function and +action imports exposed by the service. + +Entity set, singleton, action import, and function import names MUST be +unique within an entity container. + +An [*entity set*](#EntitySet) allows access to entity type instances. +Simple entity models frequently have one entity set per entity type. + +Example 31: one entity set per entity type + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Products": {` + +`  "$Collection": true,` + +`  "$Type": "self.Product"` + +`},` + +`"Categories": {` + +`  "$Collection": true,` + +`  "$Type": "self.Category"` + +`}` +::: + +Other entity models may expose multiple entity sets per type. + +Example 32: three entity sets referring to the two entity types + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"StandardCustomers": {` + +`  "$Collection": true,` + +`  "$Type": "self.Customer",` + +`  "$NavigationPropertyBinding": {` + +`    "Orders": "Orders"` + +`  }` + +`},` + +`"PreferredCustomers": {` + +`  "$Collection": true,` + +`  "$Type": "self.Customer",` + +`  "$NavigationPropertyBinding": {` + +`    "Orders": "Orders"` + +`  }` + +`},` + +`"Orders": {` + +`  "$Collection": true,` + +`  "$Type": "self.Order"` + +`}` +::: + +There are separate entity sets for standard customers and preferred +customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have [navigation +property bindings](#NavigationPropertyBinding) to the orders entity set, +but the orders entity set does not have a navigation property binding +for the Customer navigation property, since it could lead to either set +of customers. + +An entity set can expose instances of the specified entity type as well +as any entity type inherited from the specified entity type. + +A [*singleton*](#Singleton) allows addressing a single entity directly +from the entity container without having to know its key, and without +requiring an entity set. + +A [*function import*](#FunctionImport) or an [*action +import*](#ActionImport) is used to expose a function or action defined +in an entity model as a top level resource. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Entity Container Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +An entity container is represented as a member of the schema object +whose name is the unqualified name of the entity container and whose +value is an object. + +The entity container object MUST contain the member `$Kind` with a +string value of `EntityContainer`. + +The entity container object MAY contain the member +[`$Extends`](#ExtendinganEntityContainer), members representing [entity +sets](#EntitySet), [singletons](#Singleton), [action +imports](#ActionImport), and [function imports](#FunctionImport), as +well as [annotations](#Annotation). +::: + +Example 33: An entity container aggregates entity sets, singletons, +action imports, and function imports. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"DemoService": {` + +`  "$Kind": "EntityContainer",` + +`  "Products": {` + +`    "$Collection": true,` + +`    "$Type": "self.Product",` + +`    "$NavigationPropertyBinding": {` + +`      "Category": "Categories",` + +`      "Supplier": "Suppliers"` + +`    },` + +`    "@UI.DisplayName": "Product Catalog"` + +`  },` + +`  "Categories": {` + +`    "$Collection": true,` + +`    "$Type": "self.Category",` + +`    "$NavigationPropertyBinding": {` + +`      "Products": "Products"` + +`    }` + +`  },` + +`  "Suppliers": {` + +`    "$Collection": true,` + +`    "$Type": "self.Supplier",` + +`    "$NavigationPropertyBinding": {` + +`      "Products": "Products"` + +`    },` + +`    "@UI.DisplayName": "Supplier Directory"` + +`  },` + +`  "MainSupplier": {` + +`    "$Type": "self.Supplier"` + +`  },` + +`  "LeaveRequestApproval": {` + +`    "$Action": "self.Approval"` + +`  },` + +`  "ProductsByRating": {` + +`    "$EntitySet": "Products",` + +`    "$Function": "self.ProductsByRating"` + +`  }` + +`}` +::: + +## ##subsec Extending an Entity Container + +An entity container MAY specify that it extends another entity container +in scope. All children of the "base" entity container are added to the +"extending" entity container. + +If the "extending" entity container defines an entity set with the same +name as defined in any of its "base" containers, then the entity set's +type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the "base" container. The same +holds for singletons. Action imports and function imports cannot be +redefined, nor can the "extending" container define a child with the +same name as a child of a different kind in a "base" container. + +Note: services should not introduce cycles by extending entity +containers. Clients should be prepared to process cycles introduced by +extending entity containers. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Extends`]{#_Toc37317425} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Extends` is the qualified name of the entity container to +be extended. +::: + +Example 34: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\"Extending\": { + +`  "$Kind": "EntityContainer",` + +  \"\$Extends\": \"Some.Other.Schema.Base\", + +   `…` + +} +::: + +## ##subsec Entity Set + +Entity sets are top-level collection-valued resources. + +An entity set is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An entity set MUST specify a type that MUST be an entity type in scope. + +An entity set MUST contain only instances of its specified entity type +or its subtypes. The entity type MAY be [abstract](#AbstractEntityType) +but MUST have a [key](#Key) defined. + +An entity set MAY indicate whether it is included in the service +document. If not explicitly indicated, it is included. + +Entity sets that cannot be queried without specifying additional query +options SHOULD NOT be included in the service document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Entity Set Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +An entity set is represented as a member of the entity container object +whose name is the name of the entity set and whose value is an object. + +The entity set object MUST contain the members `$Collection` and +`$Type`. + +It MAY contain the members `$IncludeInServiceDocument` and +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Collection`]{#_Toc37317427} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Collection` is the Booelan value `true`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Type`]{#_Toc37317428} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Type` is the qualified name of an entity type. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$IncludeInServiceDocument`]{#_Toc37317429} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `true`. +::: + +## ##subsec Singleton + +Singletons are top-level single-valued resources. + +A singleton is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A singleton MUST specify a type that MUST be an entity type in scope. + +A singleton MUST reference an instance its entity type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Singleton Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A singleton is represented as a member of the entity container object +whose name is the name of the singleton and whose value is an object. + +The singleton object MUST contain the member `$Type` and it MAY contain +the member `$Nullable`. + +It MAY contain the member +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Type`]{#_Toc37317431} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Type` is the qualified name of an entity type. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Nullable`]{#_Toc37317432} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`.In OData 4.0 responses this +member MUST NOT be specified. +::: + +## ##subsec Navigation Property Binding + +If the entity type of an entity set or singleton declares navigation +properties, a navigation property binding allows describing which entity +set or singleton will contain the related entities. + +An [entity set](#EntitySet) or a [singleton](#Singleton) SHOULD specify +a navigation property binding for each [navigation +property](#NavigationProperty) of its entity type, including navigation +properties defined on complex typed properties or derived types. + +If omitted, clients MUST assume that the target entity set or singleton +can vary per related entity. + +### ##subsubsec Navigation Property Path Binding + +A navigation property binding MUST specify a path to a navigation +property of the entity set's or singleton\'s declared entity type, or a +navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation +property is defined on a subtype, the path MUST contain the [qualified +name](#QualifiedName) of the subtype, followed by a forward slash, +followed by the navigation property name. If the navigation property is +defined on a complex type used in the definition of the entity set's +entity type, the path MUST contain a forward-slash separated list of +complex property names and qualified type names that describe the path +leading to the navigation property. + +The path can traverse one or more containment navigation properties, but +the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment. + +If the path traverses collection-valued complex properties or +collection-valued containment navigation properties, the binding applies +to all items of these collections. + +If the path contains a recursive sub-path (i.e. a path leading back to +the same structured type, the binding applies recursively to any +positive number of cycles through that sub-path. + +OData 4.01 services MAY have a type-cast segment as the last path +segment, allowing to bind instances of different sub-types to different +targets. + +The same navigation property path MUST NOT be specified in more than one +navigation property binding; navigation property bindings are only used +when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths +that differ only in a type-cast segment, allowing to bind instances of +different sub-types to different targets. If paths differ only in +type-cast segments, the most specific path applies. + +### ##subsubsec Binding Target + +A navigation property binding MUST specify a target via a [simple +identifier](#SimpleIdentifier) or [target path](#TargetPath). It +specifies the entity set, singleton, or containment navigation property +that contains the related entities. + +If the target is a [simple identifier](#SimpleIdentifier), it MUST +resolve to an entity set or singleton defined in the same entity +container. + +If the target is a [target path](#TargetPath), it MUST resolve to an +entity set, singleton, or direct or indirect containment navigation +property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties +before ending in a containment navigation property, and there MUST NOT +be any non-containment navigation properties prior to the final segment. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$NavigationPropertyBinding`]{#_Toc37317433} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$NavigationPropertyBinding` is an object. It consists of +members whose name is the navigation property binding path and whose +value is a string containing the navigation property binding target. If +the target is in the same entity container, the target MUST NOT be +prefixed with the qualified entity container name. +::: + +Example 35: for an entity set in the same container as the enclosing +entity set `Categories` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Categories": {` + +`  "$Collection": true,` + +`  "$Type": "self.Category",` + +`  "$NavigationPropertyBinding": {` + +`    "Products": "SomeSet"` + +`  }` + +`}` +::: + +Example 36: for an entity set in any container in scope + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Categories": {` + +`  "$Collection": true,` + +`  "$Type": "self.Category",` + +`  "$NavigationPropertyBinding": {` + +`    "Products": "SomeModel.SomeContainer/SomeSet"` + +`  }` + +`}` +::: + +Example 37: binding `Supplier` on `Products` contained within +`Categories – binding applies to all suppliers of all products of all categories` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Categories": {` + +`  "$Collection": true,` + +`  "$Type": "self.Category",` + +`  "$NavigationPropertyBinding": {` + +`    "Products/Supplier": "Suppliers"` + +`  }` + +`}` +::: + +## ##subsec Action Import + +Action imports sets are top-level resources that are never included in +the service document. + +An action import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An action import MUST specify the name of an unbound action in scope. + +If the imported action returns an entity or a collection of entities, a +[simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Action Import Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +An action import is represented as a member of the entity container +object whose name is the name of the action import and whose value is an +object. + +The action import object MUST contain the member `$Action`. + +It MAY contain the member `$EntitySet`. + +It MAY also contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Action`]{#_Toc37317435} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Action` is a string containing the qualified name of an +unbound action. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$EntitySet`]{#_Toc37317436} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. +::: + +## ##subsec Function Import + +Function imports sets are top-level resources. + +A function import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A function import MUST specify the name of an unbound function in scope. +All [unbound overloads](#BoundorUnboundActionorFunctionOverlo) of the +imported function can be invoked from the entity container. + +If the imported function returns an entity or a collection of entities, +a [simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +A function import for a parameterless function MAY indicate whether it +is included in the service document. If not explicitly indicated, it is +not included. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Function Import Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A function import is represented as a member of the entity container +object whose name is the name of the function import and whose value is +an object. + +The function import object MUST contain the member `$Function`. + +It MAY contain the members `$EntitySet` and `$IncludeInServiceDocument`. + +It MAY also contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Function`]{#_Toc37317438} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$Function` is a string containing the qualified name of an +unbound function. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$EntitySet`]{#_Toc37317439} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$IncludeInServiceDocument`]{#_Toc37317440} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `false`. +::: + +# ##sec Vocabulary and Annotation + +Vocabularies and annotations provide the ability to annotate metadata as +well as instance data, and define a powerful extensibility point for +OData. An [*annotation*](#Annotation) applies a [*term*](#Term) to a +model element and defines how to calculate a value for the applied term. + +*Metadata annotations* are terms applied to model elements. Behaviors or +constraints described by a metadata annotation must be consistent with +the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity +type, property, function, action, or parameter. For example, a metadata +annotation may define ranges of valid values for a particular property. +Metadata annotations are applied in CSDL documents describing or +referencing an entity model. + +*Instance annotations* are terms applied to a particular instance within +an OData payload, such as described in [OData‑JSON](#ODataJSON). An +instance annotation can be used to define additional information +associated with a particular result, entity, property, or error. For +example, whether a property is read-only for a particular instance. +Where the same annotation is defined at both the metadata and instance +level, the instance-level annotation overrides the annotation specified +at the metadata level. Annotations that apply across instances should be +specified as metadata annotations. + +A *vocabulary* is a schema containing a set of terms where each +[term](#Term) is a named metadata extension. Anyone can define a +vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary +[OData-VocCore](#ODataVocCore). + +A [term](#Term) can be used to: + +[· ]{style="font-family:Symbol"}Extend model elements and type instances +with additional information. + +[· ]{style="font-family:Symbol"}Map instances of annotated structured +types to an interface defined by the term type; i.e. annotations allow +viewing instances of a structured type as instances of a differently +structured type specified by the applied term. + +A service SHOULD NOT require a client to interpret annotations. Clients +SHOULD ignore invalid or unknown terms and silently treat unexpected or +invalid values (including invalid type, invalid literal expression, +invalid targets, etc.) as an unknown value for the term. Unknown or +invalid annotations should never result in an error, as long as the +payload remains well-formed. + +Example 38: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"Product": {` + +`  "$Kind": "EntityType",` + +`  "$Key": [` + +`    "ID"` + +`  ],` + +`  "ID": {` + +`    "$Type": "Edm.Int32"` + +`  },` + +`  "Name": {` + +`    "$Nullable": true` + +`  },` + +`  "Description": {` + +`    "$Nullable": true` + +`  },` + +`  "@UI.DisplayName": {` + +`    "$Path": "Name"` + +`  },` + +`  "@SearchVocabulary.SearchResult": {` + +`    "Title": {` + +`      "$Path": "Name"` + +`    },` + +`    "Abstract": {` + +`      "$Path": "Description"` + +`    },` + +`    "Url": {` + +`      "$Apply": [` + +`        "Products(",` + +`        {` + +`          "$Path": "ID"` + +`        },` + +`        ")"` + +`      ],` + +`      "$Function": "odata.concat"` + +`    }` + +`  }` + +`}` +::: + +## ##subsec Term + +A term allows annotating a model element or OData resource +representation with additional data. + +The term's name is a [simple identifier](#SimpleIdentifier) that MUST be +unique within its schema. + +The term's type MUST be a type in scope, or a collection of a type in +scope. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Term Object +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +A term is represented as a member of the schema object whose name is the +unqualified name of the term and whose value is an object. + +The term object MUST contain the member `$Kind` with a string value of +`Term`. + +It MAY contain the members `$Type`, `$Collection`, +[`$AppliesTo`](#Applicability), [`$Nullable`](#Nullable), +[`$MaxLength`](#MaxLength), [`$Precision`](#Precision), +[`$Scale`](#Scale), [`$SRID`](#SRID), and `$DefaultValue`, as well as +[`$Unicode`](#Unicode) for 4.01 and greater payloads. + +It MAY contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Type` and]{#_Toc37317442} `$Collection` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued terms the value of `$Type` is the qualified name of +the term's type. + +For collection-valued terms the value of `$Type` is the qualified name +of the term's item type, and the member `$Collection` MUST be present +with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$DefaultValue`]{#_Toc37317443} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the term, see +**\[**[**OData-JSON**](#ODataJSON)**\]**. + +Note: the `$DefaultValue` member is purely for documentation and +isomorphy to **\[**[**OData-CSDLXML**](#ODataCSDL)**\]**. Annotations in +CSDL JSON documents MUST always specify an explicit value. +::: + +### ##subsubsec Specialized Term + +A term MAY specialize another term in scope by specifying it as its base +term. + +When applying a specialized term, the base term MUST also be applied +with the same qualifier, and so on until a term without a base term is +reached. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$BaseTerm`]{#_Toc37317444} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$BaseTerm` is the qualified name of the base term. +::: + +### ##subsubsec Applicability + +The applicability of a term MAY be restricted to a list of model +elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be +extended in future versions of the vocabulary. As the intended usage may +evolve over time, clients SHOULD be prepared for any term to be applied +to any model element and SHOULD be prepared to handle unknown values +within the list of model constructs. Applicability is expressed using +the following symbolic values: + + **Symbolic Value** **Model Element** + ------------------------- ----------------------------------------------------------------- + `Action` Action + `ActionImport` Action Import + `Annotation` Annotation + `Apply` Application of a client-side function in an annotation + `Cast` Type Cast annotation expression + `Collection` Entity Set or collection-valued Property or Navigation Property + `ComplexType` Complex Type + `EntityContainer` Entity Container + `EntitySet` Entity Set + `EntityType` Entity Type + `EnumType` Enumeration Type + `Function` Function + `FunctionImport` Function Import + `If` Conditional annotation expression + `Include` Reference to an Included Schema + `IsOf` Type Check annotation expression + `LabeledElement` Labeled Element expression + `Member` Enumeration Member + `NavigationProperty` Navigation Property + `Null` Null annotation expression + `OnDelete` On-Delete Action of a navigation property + `Parameter` Action of Function Parameter + `Property` Property of a structured type + `PropertyValue` Property value of a Record annotation expression + `Record` Record annotation expression + `Reference` Reference to another CSDL document + `ReferentialConstraint` Referential Constraint of a navigation property + `ReturnType` Return Type of an Action or Function + `Schema` Schema + `Singleton` Singleton + `Term` Term + `TypeDefinition` Type Definition + `UrlRef` UrlRef annotation expression + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$AppliesTo`]{#_Toc37317445} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$AppliesTo` is an array whose items are strings containing +symbolic values from the table above that identify model elements the +term is intended to be applied to. +::: + +Example 39: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData‑VocCore](#ODataVocCore)) + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\"IsURL\": { + +  \"\$Kind\": \"Term\", + +  \"\$Type\": \"Core.Tag\", + +  \"\$DefaultValue\": true, + +  \"\$AppliesTo\": \[ + +    \"Property\" + +  \], + +  \"@Core.Description\": \"Properties and terms annotated with this term +MUST contain a valid URL\", + +  \"@Core.RequiresType\": \"Edm.String\" + +`}` +::: + +## ##subsec Annotation + +An annotation applies a [term](#Term) to a model element and defines how +to calculate a value for the term application. Both term and model +element MUST be in scope. Section 14.1.2 specifies which model elements +MAY be annotated with a term. + +The value of an annotation is specified as an *annotation expression*, +which is either a [constant expression](#ConstantExpression) +representing a constant value, or a [dynamic +expression](#DynamicExpression). The most common construct for assigning +an annotation value is a [path expression](#ValuePath) that refers to a +property of the same or a related structured type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Annotation Member +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +An annotation is represented as a member whose name consists of an at +(`@`) character, followed by the qualified name of a term, optionally +followed by a hash (`#`) and a [qualifier](#Qualifier). + +The value of the annotation MUST be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +The annotation can be a member of the object representing the model +element it annotates, or a second-level member of the +[`$Annotations`](#AnnotationswithExternalTargeting) member of a schema +object. + +An annotation can itself be annotated. Annotations on annotations are +represented as a member whose name consists of the annotation name +(including the optional qualifier), followed by an at (`@`) character, +followed by the qualified name of a term, optionally followed by a hash +(`#`) and a [qualifier](#Qualifier). +::: + +Example 40: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"AmountInReportingCurrency": {` + +`  "$Nullable": true,` + +`  "$Type": "Edm.Decimal",` + +`  "$Scale": 0,` + +`  "@Measures.ISOCurrency": "USD",` + +`  "@Measures.ISOCurrency@Core.Description": "The parent company’s currency"` + +`},` + +`"AmountInTransactionCurrency": {` + +`  "$Nullable": true,` + +`  "$Type": "Edm.Decimal",` + +`  "$Scale": 0,` + +`  "@Measures.ISOCurrency": {` + +`    "$Path": "Currency"` + +`  }` + +`},` + +`"Currency": {` + +`  "$Nullable": true,` + +`  "$MaxLength": 3` + +`}` +::: + +If an entity type or complex type is annotated with a term that itself +has a structured type, an instance of the annotated type may be viewed +as an "instance" of the term, and the qualified term name may be used as +a [term-cast segment](#ref_TermCast) in path expressions. + +Structured types "inherit" annotations from their direct or indirect +base types. If both the type and one of its base types is annotated with +the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or +collection-valued annotation values are not merged. Similarly, +properties of a structured type inherit annotations from identically +named properties of a base type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a \"Label\" +annotation for a UI can propagate from a type definition to all +properties using that type definition and may be overridden at each +property with a more specific label, whereas an annotation marking a +type definition as containing a phone number will propagate to all using +properties but may not be overridden. + +### ##subsubsec Qualifier + +A term can be applied multiple times to the same model element by +providing a qualifier to distinguish the annotations. The qualifier is a +[simple identifier](#SimpleIdentifier). + +The combination of target model element, term, and qualifier uniquely +identifies an annotation. + +Example 41: annotation should only be applied to tablet devices + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.DisplayName#Tablet": {` + +`  "$Path": "FirstName"` + +`}` +::: + +### ##subsubsec Target + +The target of an annotation is the model element the term is applied to. + +The target of an annotation MAY be specified indirectly by "nesting" the +annotation within the model element. Whether and how this is possible is +described per model element in this specification. + +The target of an annotation MAY also be specified directly; this allows +defining an annotation in a different schema than the targeted model +element. + +This external targeting is only possible for model elements that are +uniquely identified within their parent, and all their ancestor elements +are uniquely identified within their parent: + +- [Action](#Action)[ (]{style="color:black; + background:white"}single or all overloads) +- [Action Import](#ActionImport) +- [Complex Type](#ComplexType) +- [Entity Container](#EntityContainer) +- [Entity Set](#EntitySet) +- [Entity Type](#EntityType) +- [Enumeration Type](#EnumerationType) +- [Enumeration Type Member](#EnumerationTypeMember) +- [Function](#Function)[ (single or all + overloads)]{style="color:black;background:white"} +- [Function Import](#FunctionImport) +- [Navigation Property](#NavigationProperty) (via type, entity set, or + singleton) +- [Parameter](#Parameter)[ of an action or function (single overloads + or all overloads defining the + parameter)]{style="color:black;background:white"} +- [Property](#StructuralProperty) (via type, entity set, or singleton) +- [Return Type](#ReturnType)[ of an action or function (single or all + overloads)]{style="color:black;background:white"} +- [Singleton](#Singleton) +- [Type Definition](#TypeDefinition) + +These are the direct children of a schema with a unique name (i.e. +except actions and functions whose overloads to not possess a natural +identifier), and all direct children of an entity container. + +External targeting is possible for actions, functions, their parameters, +and their return type, either in a way that applies to all overloads of +the action or function or all parameters of that name across all +overloads, or in a way that identifies a single overload. + +External targeting is also possible for properties and navigation +properties of singletons or entities in a particular entity set. These +annotations override annotations on the properties or navigation +properties targeted via the declaring structured type. + +The allowed path expressions are: + +[[· ]{style="font-size:9.0pt;font-family:Symbol; +color:black"}]{.apple-converted-space}[qualified name](#QualifiedName) +of schema child + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName) of schema child followed by a forward slash and +name of child element + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName) of structured type followed by zero or more +property, navigation property, or type-cast segments, each segment +starting with a forward slash + +[[· ]{style="font-size:9.0pt;font-family:Symbol; +color:black"}]{.apple-converted-space}[qualified name](#QualifiedName) +of an entity container followed by a segment containing a singleton or +entity set name and zero or more property, navigation property, or +type-cast segments + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName) of an action followed by parentheses containing +the [qualified name](#QualifiedName)[ of the binding parameter *type* of +a bound action overload to identify that bound overload, or by empty +parentheses to identify the unbound overload]{style="color:black; +background:white"} + +[[· ]{style="font-size:9.0pt;font-family:Symbol; +color:black"}]{#_Hlk525241110}[qualified name](#QualifiedName) of a +function followed by parentheses containing the comma-separated list of +[qualified names](#QualifiedName)[ of the parameter *types* of a bound +or unbound function overload in the order of their definition in the +function overload]{style="color:black;background:white"} + +[[· +]{style="font-size:9.0pt;font-family:Symbol;color:black"}]{.Keyword}[qualified +name](#QualifiedName) of an action or function, optionally followed by +parentheses as described in the two previous bullet points to identify a +single overload, followed by a forward slash and either a parameter name +or `$ReturnType` + +[[· +]{style="font-size:9.0pt;font-family:Symbol;color:black"}]{.Keyword}[qualified +name](#QualifiedName) of an entity container followed by a segment +containing an action or function import name, optionally followed by a +forward slash and either a parameter name or `$ReturnType` + +- One of the preceding, followed by a forward slash, an at (`@`), the + [qualified name](#QualifiedName)[ of a term, and optionally a hash + (]{style="color:black;background:white"}`#`) and the qualifier of an + annotation + +All [qualified names](#QualifiedName) used in a target path MUST be in +scope. + +Example 42: Target expressions + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +MySchema.MyEntityType + +MySchema.MyEntityType/MyProperty + +MySchema.MyEntityType/MyNavigationProperty + +MySchema.MyComplexType + +MySchema.MyComplexType/MyProperty + +MySchema.MyComplexType/MyNavigationProperty + +MySchema.MyEnumType + +MySchema.MyEnumType/MyMember + +MySchema.MyTypeDefinition + +MySchema.MyTerm + +MySchema.MyEntityContainer + +MySchema.MyEntityContainer/MyEntitySet + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MyActionImport + +MySchema.MyEntityContainer/MyFunctionImport + +MySchema.MyAction + +MySchema.MyAction(MySchema.MyBindingType) + +MySchema.MyAction() + +MySchema.MyFunction + +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType) + +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType) + +MySchema.MyFunction/MyParameter + +MySchema.MyEntityContainer/MyEntitySet/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty +::: + +## ##subsec Constant Expression + +Constant expressions allow assigning a constant value to an applied +term. + +### ##subsubsec Binary + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Binary expressions are represented as a string containing the +base64url-encoded binary value. +::: + +Example 43: base64url-encoded binary value (OData) + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.Thumbnail": "T0RhdGE"` +::: + +### ##subsubsec Boolean + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Boolean expressions are represented as the literals `true` or `false`. +::: + +Example 44: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.ReadOnly": true` +::: + +### ##subsubsec Date + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Date expressions are represented as a string containing the date value. +The value MUST conform to type `xs:date`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData‑ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. +::: + +Example 45: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@vCard.birthDay": "2000-01-01"` +::: + +### ##subsubsec DateTimeOffset + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Datetimestamp expressions are represented as a string containing the +timestamp value. The value MUST conform to type `xs:dateTimeStamp`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData‑ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). +::: + +Example 46: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.LastUpdated": "2000-01-01T16:00:00.000Z"` +::: + +### ##subsubsec Decimal + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Decimal expressions are represented as either a number or a string. The +special values `INF`, `-INF`, or `NaN` are represented as strings. +Numeric values are represented as numbers or strings depending on the +media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumber). +::: + +Example 47: default representation as a number + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.Width": 3.14` +::: + +Example 48: "safe" representation as a string + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.Width": "3.14"` +::: + +### ##subsubsec Duration + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Duration expressions are represented as a string containing the duration +value. The value MUST conform to type `xs:dayTimeDuration`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). +::: + +Example 49: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@task.duration": "P7D"` +::: + +### ##subsubsec Enumeration Member + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Enumeration member expressions are represented as a string containing +the numeric or symbolic enumeration value. +::: + +Example 50: single value `Red` with numeric value and symbolic value + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@self.HasPattern": "1"` +::: + +` ` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@self.HasPattern": "Red"` +::: + +Example 51: combined value `Red,Striped` with numeric value 1 + 16 and +symbolic value + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@self.HasPattern": "17"` +::: + +` ` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@self.HasPattern": "Red,Striped"` +::: + +### ##subsubsec Floating-Point Number + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Floating-point expressions are represented as a number or as a string +containing one of the special values `INF`, `-INF`, or `NaN`. +::: + +Example 52: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.FloatWidth": 3.14` +::: + +` ` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.FloatWidth": "INF"` +::: + +### ##subsubsec Guid + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Guid expressions are represented as a string containing the uuid value. +The value MUST conform to the rule `guidValue` in +[OData‑ABNF](#ODataABNF). +::: + +Example 53: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.Id": "21EC2020-3AEA-1069-A2DD-08002B30309D"` +::: + +### ##subsubsec Integer + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Integer expressions are represented as either a number or a string, +depending on the media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumber). +::: + +Example 54: default representation as a number + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@An.Int": 42` +::: + +Example 55: "safe" representation as a string + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@A.Very.Long.Int": "9007199254740992"` +::: + +### ##subsubsec String + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +String expressions are represented as a JSON string. +::: + +Example 56: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.DisplayName": "Product Catalog"` +::: + +### ##subsubsec Time of Day + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Time-of-day expressions are represented as a string containing the +time-of-day value. The value MUST conform to the rule `timeOfDayValue` +in [OData‑ABNF](#ODataABNF). +::: + +Example 57: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.EndTime": "21:45:00"` +::: + +## ##subsec Dynamic Expression + +Dynamic expressions allow assigning a calculated value to an applied +term. + +### ##subsubsec Path Expressions + +Path expressions allow assigning a value to an applied term or term +component. There are two kinds of path expressions: + +[· ]{style="font-family:Symbol"}[[A *model path* is used within +]{style="font-family:\"Arial\",sans-serif"}]{.Datatype}[Annotation +Path](#AnnotationPath), [Model Element Path](#ModelElementPath), +[Navigation Property Path](#NavigationPropertyPath), and [Property +Path](#PropertyPath) expressions to traverse the model of a service and +resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) `Edm.AnnotationPath`, +`Edm.NavigationPropertyPath`, `Edm.PropertyPath`, and their base types +`Edm.AnyPropertyPath` and `Edm.ModelElementPath`. + +[· ]{style="font-family:Symbol"}An *instance path* is used within a +[Value Path](#ValuePath) expression to traverse a graph of type +instances and resolves to the value identified by the path. It allows +assigning values to terms or term properties of built-in types other +than the `Edm.*Path` types, or of any model-defined type. + +#### ##subsubsubsec Path Syntax + +Model paths and instance paths share a common syntax which is derived +from the path expression syntax of URLs, see [OData‑URL](#ODataURL). + +A path MUST be composed of zero or more path segments joined together by +forward slashes (`/`). + +Paths starting with a forward slash (`/`) are absolute paths, and the +first path segment MUST be the qualified name of a model element, e.g. +an entity container. The remaining path after the second forward slash +is interpreted relative to that model element. + +Example 58: absolute path to an entity set + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +/My.Schema.MyEntityContainer/MyEntitySet +::: + +Paths not starting with a forward slash are interpreted relative to the +annotation target, following the rules specified in section "[Path +Evaluation](#PathEvaluation)". + +Example 59: relative path to a property + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +Address/City +::: + +If a path segment is a [qualified name](#QualifiedName), it represents a +[*type cast*]{#ref_TypeCast}, and the segment MUST be the name of a type +in scope. If the type or instance identified by the preceding path part +cannot be cast to the specified type, the path expression evaluates to +the null value. + +Example 60: type-cast segment + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../self.Manager/... +::: + +If a path segment starts with an at (`@`) character, it represents a +[*term cast*]{#ref_TermCast}. The at (`@`) character MUST be followed by +a [qualified name](#QualifiedName) that MAY be followed by a hash (`#`) +character and a [simple identifier](#SimpleIdentifier). The [qualified +name](#QualifiedName) preceding the hash character MUST resolve to a +term that is in scope, the [simple identifier](#SimpleIdentifier) +following the hash sign is interpreted as a [qualifier](#Qualifier) for +the term. If the model element or instance identified by the preceding +path part has not been annotated with that term (and if present, with +that qualifier), the term cast evaluates to the null value. Four special +terms are implicitly "annotated" for media entities and stream +properties: + +- `odata.mediaEditLink` +- `odata.mediaReadLink` +- `odata.mediaContentType` +- `odata.mediaEtag` + +Example 61: term-cast segments + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../@Capabilities.SortRestrictions/... +::: + +If a path segment is a [simple identifier](#SimpleIdentifier), it MUST +be the name of a child model element of the model element identified by +the preceding path part, or a structural or navigation property of the +instance identified by the preceding path part. A sequence of navigation +segments can traverse multiple CSDL documents. The document containing +the path expression only needs to reference the next traversed document +to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document. + +A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path. + +Example 62: property segments in model path + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../Orders/Items/Product/... +::: + +An instance path MUST NOT contain more than one segment representing a +collection-valued construct, e.g. an entity set or a collection-valued +navigation property that is not followed by a key predicate, or a +collection-valued structural property that is not followed by an index +segment. The result of the expression is the collection of instances +resulting from applying any remaining path segments that operate on a +single-valued expression to each instance in the collection-valued +segment. + +An instance path MAY terminate in a `$count` segment if the previous +segment is collection-valued, in which case the path evaluates to the +number of items in the collection identified by the preceding segment. + +Example 63: property segments in instance path + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../Addresses/Street + +.../Addresses/\$count +::: + +A model path MAY contain path segments starting with a navigation +property, then followed by an at (`@`) character, then followed by the +[qualified name](#QualifiedName) of a term in scope, and optionally +followed by a hash (`#`) character and a [simple +identifier](#SimpleIdentifier) which is interpreted as a +[qualifier](#Qualifier) for the term. If the navigation property has not +been annotated with that term (and if present, with that qualifier), the +path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity +type specified by the navigation property are addressed via a [term-cast +segment](#ref_TermCast). + +Example 64: model path addressing an annotation on a navigation property + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../Items@Capabilities.InsertRestrictions/Insertable +::: + +An instance path MAY contain path segments starting with an entity set +or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see +[OData‑URL](#ODataURL). The key values are either primitive literals or +instance paths. If the key value is a relative instance path, it is +interpreted according to the same rule below as the instance path it is +part of, *not* relative to the instance identified by the preceding path +part. + +Example 65: instance path with entity set and key predicate + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +/self.container/SettingsCollection(\'FeatureXxx\')/IsAvailable + +/self.container/Products(ID=ProductID)/Name +::: + +An instance path MAY contain an index segment immediately following a +path segment representing an ordered collection-valued structural +property. The index is zero-based and MUST be an integer literal. +Negative integers count from the end of the collection, with -1 +representing the last item in the collection. Remaining path segments +are evaluated relative to the identified item of the collection. + +Example 66: instance path with collection-valued structural property and +index segment + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +Addresses/1 + +Addresses/-1/Street +::: + +#### ##subsubsubsec Path Evaluation + +Annotations MAY be embedded within their target, or specified +separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as +*targeting* in the remainder of this section. + +For annotations embedded within or targeting an entity container, the +path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a +segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules +for paths targeting the corresponding child element. + +For annotations embedded within or targeting an entity set or a +singleton, the path is evaluated starting at the entity set or +singleton, i.e. an empty path resolves to the entity set or singleton, +and non-empty paths MUST follow the rules for annotations targeting the +declared entity type of the entity set or singleton. + +For annotations embedded within or targeting an entity type or complex +type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be +a structural or navigation property of the type, a [type +cast](#ref_TypeCast), or a [term cast](#ref_TermCast). + +For annotations embedded within a structural or navigation property of +an entity type or complex type, the path is evaluated starting at the +directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other +properties of the same type. An empty path resolves to the enclosing +type, and non-empty paths MUST follow the rules for annotations +targeting the directly enclosing type. + +For annotations targeting a structural or navigation property of an +entity type or complex type, the path is evaluated starting at the +*outermost* entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the +first segment of a non-empty path MUST be a structural or navigation +property of the outermost type, a [type cast](#ref_TypeCast), or a [term +cast](#ref_TermCast). + +For annotations embedded within or targeting an action, action import, +function, function import, parameter, or return type, the first segment +of the path MUST be a parameter name or `$ReturnType`. + +#### ##subsubsubsec Annotation Path + +The annotation path expression provides a value for terms or term +properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.AnnotationPath or Edm.ModelElementPath`. Its argument is a [model +path](#PathExpressions) with the following restriction: + +[[· +]{style="font-family:Symbol"}]{.Datatype}`A non-null path MUST resolve to an annotation. ` + +A term or term property of type `Edm.AnnotationPath` can be annotated +with term `Validation.AllowedTerms` (see +[OData-VocValidation](#ODataVocValidation)) if its intended value is an +annotation path that ends in a term cast with one of the listed terms. + +The value of the annotation path expression is the path itself, not the +value of the annotation identified by the path. This is useful for terms +that reuse or refer to other terms. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Annotation path expressions are represented as a string containing a +path. +::: + +Example 67: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.ReferenceFacet": "Product/Supplier/@UI.LineItem",` + +`"@UI.CollectionFacet#Contacts": [` + +`  "Supplier/@Communication.Contact",` + +`  "Customer/@Communication.Contact"` + +`]` +::: + +#### ##subsubsubsec Model Element Path + +The model element path expression provides a value for terms or term +properties that specify the [built-in +type](#BuiltInTypesfordefiningVocabularyTer)` Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions). + +The value of the model element path expression is the path itself, not +the instance(s) identified by the path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Model element path expressions are represented as a string containing a +path. +::: + +Example 68: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@org.example.MyFavoriteModelElement": "/self.someAction"` +::: + +#### ##subsubsubsec Navigation Property Path + +The navigation property path expression provides a value for terms or +term properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. +Its argument is a [model path](#PathExpressions) with the following +restriction: + +[· ]{style="font-family:Symbol"}A non-null path MUST resolve to a model +element whose type is an entity type, or a collection of entity types, +e.g. a navigation property. + +The value of the navigation property path expression is the path itself, +not the entitiy or collection of entities identified by the path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Navigation property path expressions are represented as a string +containing a path. +::: + +Example 69: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.HyperLink": "Supplier",` + +` ` + +`"@Capabilities.UpdateRestrictions": {` + +`  "NonUpdatableNavigationProperties": [` + +`    "Supplier",` + +`    "Category"` + +`  ]` + +`}` +::: + +#### ##subsubsubsec Property Path + +The property path expression provides a value for terms or term +properties that specify one of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions) with the following +restriction: + +[· ]{style="font-family:Symbol"}A non-null path MUST resolve to a model +element whose type is a primitive or complex type, an enumeration type, +a type definition, or a collection of one of these types. + +The value of the property path expression is the path itself, not the +value of the structural property or the value of the term cast +identified by the path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Property path expressions are represented as a string containing a path. +::: + +Example 70: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.RefreshOnChangeOf": "ChangedAt",` + +` ` + +`"@Capabilities.UpdateRestrictions": {` + +`  "NonUpdatableProperties": [` + +`    "CreatedAt",` + +`    "ChangedAt"` + +`  ]` + +`}` +::: + +#### ##subsubsubsec Value Path + +The value path expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation +properties of structured types, and structural properties of structured +types. Its argument is an [instance path](#PathExpressions). + +The value of the path expression is the instance or collection of +instances identified by the path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Path`]{#_Toc37317447} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Path expressions are represented as an object with a single member +`$Path` whose value is a string containing a path. +::: + +Example 71: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.DisplayName": {` + +`  "$Path": "FirstName"` + +`},` + +` ` + +`"@UI.DisplayName#second": {` + +`  "$Path": "@vCard.Address#work/FullName"` + +`}` +::: + +### ##subsubsec Comparison and Logical Operators + +Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and +they MAY be used anywhere instead of a Boolean expression. + + **Operator** **Description** + -------------------------- ------------------------------- + **Logical Operators** + `And` `Logical and` + `Or` `Logical or` + `Not` `Logical negation` + **Comparison Operators** + `Eq` `Equal` + `Ne` `Not equal` + `Gt` `Greater than` + `Ge` `Greater than or equal` + `Lt` Less than + `Le` `Less than or equal` + `Has` `Has enumeration flag(s) set` + `In` `Is in collection` + +The `And` and `Or` operators require two operand expressions that +evaluate to Boolean values. The `Not` operator requires a single operand +expression that evaluates to a Boolean value. For details on null +handling for comparison operators see [OData‑URL](#ODataURL). + +The other comparison operators require two operand expressions that +evaluate to comparable values. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$And and `]{#_Toc37317448}`$Or` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `And` and `Or` logical expressions are represented as an object with +a single member whose value is an array with two annotation expressions. +The member name is one of `$And`, or `$Or`. + +It MAY contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Not`]{#_Toc37317449} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Negation expressions are represented as an object with a single member +`$Not` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Eq, `]{#_Toc37317450}`$Ne, $Gt, $Ge, $Lt, $Le, $Has, and $In` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +All comparison expressions are represented as an object with a single +member whose value is an array with two annotation expressions. The +member name is one of `$Eq`, `$Ne`, `$Gt`, `$Ge`, `$Lt`, `$Le`, `$Has`, +or `$In`. + +They MAY contain [annotations](#Annotation). +::: + +Example 72: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  "$And": [` + +`    {` + +`      "$Path": "IsMale"` + +`    },` + +`    {` + +`      "$Path": "IsMarried"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Or": [` + +`    {` + +`      "$Path": "IsMale"` + +`    },` + +`    {` + +`      "$Path": "IsMarried"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Not": {` + +`    "$Path": "IsMale"` + +`  }` + +`},` + +`{` + +`  "$Eq": [` + +`    null,` + +`    {` + +`      "$Path": "IsMale"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Ne": [` + +`    null,` + +`    {` + +`      "$Path": "IsMale"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Gt": [` + +`    {` + +`      "$Path": "Price"` + +`    },` + +`    20` + +`  ]` + +`},` + +`{` + +`  "$Ge": [` + +`    {` + +`      "$Path": "Price"` + +`    },` + +`    10` + +`  ]` + +`},` + +`{` + +`  "$Lt": [` + +`    {` + +`      "$Path": "Price"` + +`    },` + +`    20` + +`  ]` + +`},` + +`{` + +`  "$Le": [` + +`    {` + +`      "$Path": "Price"` + +`    },` + +`    100` + +`  ]` + +`},` + +`{` + +`  "$Has": [` + +`    {` + +`      "$Path": "Fabric"` + +`    },` + +`    "Red"` + +`  ]` + +`},` + +`{` + +`  "$In": [` + +`    {` + +`      "$Path": "Size"` + +`    },` + +`    [` + +`      "XS",` + +`      "S"` + +`    ]` + +`  ]` + +`} ` +::: + +### ##subsubsec Arithmetic Operators + +Annotations MAY use the following arithmetic expressions which evaluate +to a numeric value. These expressions MAY be combined, and they MAY be +used anywhere instead of a numeric expression of the appropriate type. +The semantics and evaluation rules for each arithmetic expression is +identical to the corresponding arithmetic operator defined in +[OData‑URL](#ODataURL). + + **Operator** **Description** + -------------- --------------------------------------------------------------- + `Add` `Addition` + `Sub` `Subtraction` + `Neg` `Negation` + `Mul` `Multiplication` + `Div` `Division (with integer result for integer operands)` + `DivBy` `Division (with fractional result also for integer operands)` + `Mod` `Modulo` + +The `Neg` operator requires a single operand expression that evaluates +to a numeric value. The other arithmetic operators require two operand +expressions that evaluate to numeric values. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Neg`]{#_Toc37317451} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Negation expressions are represented as an object with a single member +`$Neg` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Add, `]{#_Toc37317452}`$Sub, $Mul, $Div, $DivBy, and $Mod` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +These arithmetic expressions are represented as an object with as single +member whose value is an array with two annotation expressions. The +member name is one of `$Add`, `$Sub`, `$Neg`, `$Mul`, `$Div`, `$DivBy`, +or `$Mod`. + +They MAY contain [annotations](#Annotation). +::: + +Example 73: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  "$Add": [` + +`    {` + +`      "$Path": "StartDate"` + +`    },` + +`    {` + +`      "$Path": "Duration"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Sub": [` + +`    {` + +`      "$Path": "Revenue"` + +`    },` + +`    {` + +`      "$Path": "Cost"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Neg": {` + +`    "$Path": "Height"` + +`  }` + +`},` + +`{` + +`  "$Mul": [` + +`    {` + +`      "$Path": "NetPrice"` + +`    },` + +`    {` + +`      "$Path": "TaxRate"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Div": [` + +`    {` + +`      "$Path": "Quantity"` + +`    },` + +`    {` + +`      "$Path": "QuantityPerParcel"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$DivBy": [` + +`    {` + +`      "$Path": "Quantity"` + +`    },` + +`    {` + +`      "$Path": "QuantityPerParcel"` + +`    }` + +`  ]` + +`},` + +`{` + +`  "$Mod": [` + +`    {` + +`      "$Path": "Quantity"` + +`    },` + +`    {` + +`      "$Path": "QuantityPerParcel"` + +`    }` + +`  ]` + +`}` +::: + +### ##subsubsec Apply Client-Side Functions + +The apply expression enables a value to be obtained by applying a +client-side function. The apply expression MAY have operand expressions. +The operand expressions are used as parameters to the client-side +function. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Apply`]{#_Toc37317453} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Apply expressions are represented as an object with a member `$Apply` +whose value is an array of annotation expressions, and a member +`$Function` whose value is a string containing the [qualified +name](#QualifiedName) of the client-side function to be applied. + +It MAY contain [annotations](#Annotation). +::: + +OData defines the following functions. Services MAY support additional +functions that MUST be qualified with a namespace other than `odata`. +Function names qualified with `odata` are reserved for this +specification and its future versions. + +#### ##subsubsubsec Canonical Functions + +All canonical functions defined in [OData‑URL](#ODataURL) can be used as +client-side functions, qualified with the namespace `odata`. The +semantics of these client-side functions is identical to their +counterpart function defined in [OData‑URL](#ODataURL). + +For example, the `odata.concat` client-side function takes two or more +expressions as arguments. Each argument MUST evaluate to a primitive or +enumeration type. It returns a value of type `Edm.String` that is the +concatenation of the literal representations of the results of the +argument expressions. Values of primitive types other than `Edm.String` +are represented according to the appropriate alternative in the +`primitiveValue` rule of [OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as +`binaryValue`, `Edm.Boolean` as `booleanValue` etc. + +Example 74: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.DisplayName": {` + +`  "$Apply": [` + +`    "Product: ",` + +`    {` + +`      "$Path": "ProductName"` + +`    },` + +`    " (",` + +`    {` + +`      "$Path": "Available/Quantity"` + +`    },` + +`    " ",` + +`    {` + +`      "$Path": "Available/Unit"` + +`    },` + +`    " available)"` + +`  ],` + +`  "$Function": "odata.concat"` + +`}` +::: + +`ProductName` is of type `String`, `Quantity` in complex type +`Available` is of type `Decimal`, and `Unit` in `Available` is of type +enumeration, so the result of the `Path` expression is represented as +the member name of the enumeration value. + +#### ##subsubsubsec Function `odata.fillUriTemplate` + +The `odata.fillUriTemplate` client-side function takes two or more +expressions as arguments and returns a value of type `Edm.String.` + +The first argument MUST be of type `Edm.String` and specifies a URI +template according to [RFC6570](#rfc6570), the other arguments MUST be +[labeled element expressions](#LabeledElement). Each [labeled element +expression](#LabeledElement) specifies the template parameter name as +its name and evaluates to the template parameter value. + +[RFC6570](#rfc6570) defines three kinds of template parameters: simple +values, lists of values, and key-value maps. + +Simple values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a single primitive value. +The literal representation of this value according to +[OData‑ABNF](#ODataABNF) is used to fill the corresponding template +parameter. + +Lists of values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of primitive +values. + +Key-value maps are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of complex +types with two properties that are used in lexicographic order. The +first property is used as key, the second property as value. + +Example 75: assuming there are no special characters in values of the +`Name property of the Actor` entity + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +{ + +  \"\$Apply\": \[ + +    \"http://host/someAPI/Actors/{actorName}/CV\", + +    { + +      \"\$LabeledElement\": { + +        \"\$Path\": \"Actor/Name\" + +      }, + +      \"\$Name\": \"self.actorName\" + +    } + +  \], + +  \"\$Function\": \"odata.fillUriTemplate\" + +} +::: + +#### ##subsubsubsec [Function `odata.matchesPattern`](#FunctionodatamatchesPattern) + +The `odata.matchesPattern` client-side function takes two string +expressions as arguments and returns a Boolean value`.` + +The function returns true if the second expression evaluates to an +[**\[ECMAScript\]**](#ECMAScript) (JavaScript) regular expression and +the result of the first argument expression matches that regular +expression, using syntax and semantics of +[**\[ECMAScript\]**](#ECMAScript) regular expressions. + +Example 76: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +{ + +  \"\$Apply\": \[ + +    { + +      \"\$Path\": \"FirstName\" + +    }, + +    \"\^\[\^b-d\]+\$\" + +  \], + +  \"\$Function\": \"odata.matchesPattern\" + +} +::: + +#### ##subsubsubsec Function `odata.uriEncode` + +The `odata.uriEncode `client-side function takes one argument of +primitive type and returns the URL-encoded OData literal that can be +used as a key value in OData URLs or in the query part of OData URLs. + +Note: string literals are surrounded by single quotes as required by the +paren-style key syntax. + +Example 77: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +{ + +  \"\$Apply\": \[ + +    \"http://host/service/Genres({genreName})\", + +    { + +      \"\$LabeledElement\": { + +        \"\$Apply\": \[ + +          { + +            \"\$Path\": \"NameOfMovieGenre\" + +          } + +        \], + +        \"\$Function\": \"odata.uriEncode\" + +      }, + +      \"\$Name\": \"self.genreName\" + +    } + +  \], + +  \"\$Function\": \"odata.fillUriTemplate\" + +} +::: + +### ##subsubsec Cast + +The cast expression casts the value obtained from its single child +expression to the specified type. The cast expression follows the same +rules as the `cast` canonical function defined in +[OData‑URL](#ODataURL). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Cast`]{#_Toc37317454} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Cast expressions are represented as an object with a member `$Cast` +whose value is an annotation expression, a member `$Type` whose value is +a string containing the qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +Example 78: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.Threshold": {` + +`  "$Cast": {` + +`    "$Path": "Average"` + +`  },` + +`  "$Type": "Edm.Decimal"` + +`}` +::: + +### ##subsubsec Collection + +The collection expression enables a value to be obtained from zero or +more item expressions. The value calculated by the collection expression +is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type +compatible. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Collection expressions are represented as arrays with one array item per +item expression within the collection expression. +::: + +Example 79: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@seo.SeoTerms": [` + +`  "Product",` + +`  "Supplier",` + +`  "Customer"` + +`]` +::: + +### ##subsubsec If-Then-Else + +The if-then-else expression enables a value to be obtained by evaluating +a *condition expression*. It MUST contain exactly three child +expressions. There is one exception to this rule: if and only if the +if-then-else expression is an item of a collection expression, the third +child expression MAY be omitted, reducing it to an if-then expression. +This can be used to conditionally add an element to a collection. + +The first child expression is the condition and MUST evaluate to a +Boolean result, e.g. the [comparison and logical +operators](#ComparisonandLogicalOperators) can be used. + +The second and third child expressions are evaluated conditionally. The +result MUST be type compatible with the type expected by the surrounding +expression. + +If the first expression evaluates to `true`, the second expression MUST +be evaluated and its value MUST be returned as the result of the +if-then-else expression. If the first expression evaluates to `false` +and a third child element is present, it MUST be evaluated and its value +MUST be returned as the result of the if-then-else expression. If no +third expression is present, nothing is added to the surrounding +collection. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$If`]{#_Toc37317455} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Conditional expressions are represented as an object with a member `$If` +whose value is an array of two or three annotation expressions. + +It MAY contain [annotations](#Annotation). +::: + +Example 80: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale` ,whose value then determines +the value of the `$If` expression + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@person.Gender": {` + +`  "$If": [` + +`    {` + +`      "$Path": "IsFemale"` + +`    },` + +`    "Female",` + +`    "Male"` + +`  ]` + +`}` +::: + +### ##subsubsec Is-Of + +The i`s-of` expression checks whether the value obtained from its single +child expression is compatible with the specified type. It returns +`true` if the child expression returns a type that is compatible with +the specified type, and `false` otherwise. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$IsOf`]{#_Toc37317456} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Is-of expressions are represented as an object with a member `$IsOf` +whose value is an annotation expression, a member `$Type` whose value is +a string containing an qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +Example 81: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@Self.IsPreferredCustomer": {` + +`  "$IsOf": {` + +`    "$Path": "Customer"` + +`  },` + +`  "$Type": "self.PreferredCustomer"` + +`}` +::: + +### ##subsubsec Labeled Element + +The labeled element expression assigns a name to its single child +expression. The value of the child expression can then be reused +elsewhere with a [labeled element reference +expression](#LabeledElementReference). + +A labeled element expression MUST contain exactly one child expression. +The value of the child expression is also the value of the labeled +element expression. + +A labeled element expression MUST provide a [simple +identifier](#SimpleIdentifier) value as its name that MUST be unique +within the schema containing the expression. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$LabeledElement`]{#_Toc37317457} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Labeled element expressions are represented as an object with a member +`$LabeledElement` whose value is an annotation expression, and a member +`$Name` whose value is a string containing the labeled element's name. + +It MAY contain [annotations](#Annotation). +::: + +Example 82: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.DisplayName": {` + +`  "$LabeledElement": {` + +`    "$Path": "FirstName"` + +`  },` + +`  "$Name": "CustomerFirstName"` + +`}` +::: + +### ##subsubsec Labeled Element Reference + +The labeled element reference expression MUST specify the [qualified +name](#QualifiedName) of a [labeled element expression](#LabeledElement) +in scope and returns the value of the identified labeled element +expression as its value. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$LabeledElementReference`]{#_Toc37317458} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Labeled element reference expressions are represented as an object with +a member `$LabeledElementReference` whose value is a string containing +an qualified name. +::: + +Example 83: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.DisplayName": {` + +`  "$LabeledElementReference": "self.CustomerFirstName"` + +`}` +::: + +### ##subsubsec Null + +The null expression indicates the absence of a value. The null +expression MAY be annotated. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Null expressions that do not contain annotations are represented as the +literal `null`. +::: + +Example 84: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.DisplayName": null,` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$Null`]{#_Toc37317459} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Null expression containing [annotations](#Annotations) are represented +as an object with a member `$Null` whose value is the literal `null`. +::: + +Example 85: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@UI.Address": {` + +`  "$Null": null,` + +`  "@self.Reason": "Private"` + +`}` +::: + +### ##subsubsec Record + +The record expression enables a new entity type or complex type instance +to be constructed. + +A record expression MAY specify the structured type of its result, which +MUST be an entity type or complex type in scope. If not explicitly +specified, the type is derived from the expression's context. + +A record expression contains zero or more property value expressions. +For each single-valued structural or navigation property of the record +expression's type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if +the record expression is the value of an annotation for a term that has +a [base term](#SpecializedTerm) whose type is structured and directly or +indirectly inherits from the type of its base term. In this case, +property values that already have been specified in the annotation for +the base term or its base term etc. need not be specified again. + +For collection-valued properties the absence of a property value +expression is equivalent to specifying an empty collection as its value. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Record expressions are represented as objects with one member per +property value expression. The member name is the property name, and the +member value is the property value expression. + +The type of a record expression is represented as the `@type` control +information, see  [OData‑JSON](#ODataJSON). + +It MAY contain [annotations](#Annotation) for itself and its members. +Annotations for record members are prefixed with the member name. +::: + +Example 86: this annotation "morphs" the entity type from example 8 into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@person.Employee": {` + +`  "@type": "https://example.org/vocabs/person#org.example.person.Manager",` + +`  "@Core.Description": "Annotation on record",` + +`  "GivenName": {` + +`    "$Path": "FirstName"` + +`  },` + +`  "GivenName@Core.Description": "Annotation on record member",` + +`  "Surname": {` + +`    "$Path": "LastName"` + +`  },` + +`  "DirectSupervisor": {` + +`    "$Path": "Manager"` + +`  },` + +`  "CostCenter": {` + +`    "$UrlRef": {` + +`      "$Apply": [` + +`        "http://host/anotherservice/CostCenters('{ccid}')",` + +`        {` + +`          "$LabeledElement": {` + +`            "$Path": "CostCenterID"` + +`          },` + +`          "$Name": "ccid"` + +`        }` + +`      ],` + +`      "$Function": "odata.fillUriTemplate"` + +`    }` + +`  }` + +`}` +::: + +### ##subsubsec URL Reference + +The URL reference expression enables a value to be obtained by sending a +`GET` request. + +The URL reference expression MUST contain exactly one expression of type +`Edm.String`. Its value is treated as a URL that MAY be relative or +absolute; relative URLs are relative to the URL of the document +containing the URL reference expression, or relative to a base URL +specified in a format-specific way. + +The response body of the `GET` request MUST be returned as the result of +the` `URL reference expression. The result of the` `URL reference +expression MUST be type compatible with the type expected by the +surrounding expression. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`$UrlRef`]{#_Toc37317460} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +URL reference expressions are represented as an object with a single +member `$UrlRef` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +Example 87: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`"@org.example.person.Supplier": {` + +`  "$UrlRef": {` + +`    "$Apply": [` + +`      "http://host/service/Suppliers({suppID})",` + +`      {` + +`        "$LabeledElement": {` + +`          "$Apply": [` + +`            {` + +`              "$Path": "SupplierId"` + +`            }` + +`          ],` + +`          "$Function": "odata.uriEncode"` + +`        },` + +`        "$Name": "suppID"` + +`      }` + +`    ],` + +`    "$Function": "odata.fillUriTemplate"` + +`  }` + +`},` + +` ` + +`"@Core.LongDescription#element": {` + +`  "$UrlRef": "http://host/wiki/HowToUse"` + +`}` +::: + +# ##sec Identifier and Path Values + +## ##subsec Namespace + +A namespace is a dot-separated sequence of [simple +identifier](#SimpleIdentifier)s with a maximum length of 511 Unicode +characters (code points). + +## ##subsec Simple Identifier + +A simple identifier is a Unicode character sequence with the following +restrictions: + +- It consists of at least one and at most 128 Unicode characters (code + points). +- The first character MUST be the underscore character (U+005F) or any + character in the Unicode category "Letter (L)" or "Letter number + (Nl)". +- The remaining characters MUST be the underscore character (U+005F) + or any character in the Unicode category "Letter (L)", "Letter + number (Nl)", "Decimal number (Nd)", "Non-spacing mark (Mn)", + "Combining spacing mark (Mc)", "Connector punctuation (Pc)", and + "Other, format (Cf)". + +Non-normatively speaking it starts with a letter or underscore, followed +by at most 127 letters, underscores or digits. + +## ##subsec Qualified Name + +For model elements that are direct children of a schema: the namespace +or alias of the schema that defines the model element, followed by a dot +and the name of the model element, see rule `qualifiedTypeName` in +[OData‑ABNF](#ODataABNF). + +For built-in [primitive types](#PrimitiveTypes): the name of the type, +prefixed with `Edm` followed by a dot. + +## ##subsec Target Path + +Target paths are used to refer to other model elements. + +The allowed path expressions are: + +[[· ]{style="font-size:9.0pt;font-family:Symbol; +color:black"}]{.apple-converted-space}The [qualified +name](#QualifiedName) of an entity container, followed by a forward +slash and the name of a container child element + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}The target +path of a container child followed by a forward slash and one or more +forward-slash separated property, navigation property, or type-cast +segments + +Example 88: Target expressions + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +MySchema.MyEntityContainer/MyEntitySet + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty + +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp +::: + +# ##sec [CSDL Examples](#CSDLExamples) + +Following are two basic examples of valid EDM models as represented in +CSDL JSON. These examples demonstrate many of the topics covered above. + +## ##subsec [Products and Categories Example](#ProductsandCategoriesExample) + +Example 89: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  "$Version": "4.0",` + +`  "$EntityContainer": "ODataDemo.DemoService",` + +`  "$Reference": {` + +`    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": {` + +`      "$Include": [` + +`        {` + +`          "$Namespace": "Org.OData.Core.V1",` + +`          "$Alias": "Core",` + +`          "@Core.DefaultNamespace": true` + +`        }` + +`      ]` + +`    },` + +`    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.json": {` + +`      "$Include": [` + +`        {` + +`          "$Namespace": "Org.OData.Measures.V1",` + +`          "$Alias": "Measures"` + +`        }` + +`      ]` + +`    }` + +`  },` + +`  "ODataDemo": {` + +`    "$Alias": "self",` + +`    "@Core.DefaultNamespace": true,` + +`    "Product": {` + +`      "$Kind": "EntityType",` + +`      "$HasStream": true,` + +`      "$Key": [` + +`        "ID"` + +`      ],` + +`      "ID": {},` + +`      "Description": {` + +`        "$Nullable": true,` + +`        "@Core.IsLanguageDependent": true` + +`      },` + +`      "ReleaseDate": {` + +`        "$Nullable": true,` + +`        "$Type": "Edm.Date"` + +`      },` + +`      "DiscontinuedDate": {` + +`        "$Nullable": true,` + +`        "$Type": "Edm.Date"` + +`      },` + +`      "Rating": {` + +`        "$Nullable": true,` + +`        "$Type": "Edm.Int32"` + +`      },` + +`      "Price": {` + +`        "$Nullable": true,` + +`        "$Type": "Edm.Decimal",` + +`        "@Measures.ISOCurrency": {` + +`          "$Path": "Currency"` + +`        }` + +`      },` + +`      "Currency": {` + +`        "$Nullable": true,` + +`        "$MaxLength": 3` + +`      },` + +`      "Category": {` + +`        "$Kind": "NavigationProperty",` + +`        "$Type": "self.Category",` + +`        "$Partner": "Products"` + +`      },` + +`      "Supplier": {` + +`        "$Kind": "NavigationProperty",` + +`        "$Nullable": true,` + +`        "$Type": "self.Supplier",` + +`        "$Partner": "Products"` + +`      }` + +`    },` + +`    "Category": {` + +`      "$Kind": "EntityType",` + +`      "$Key": [` + +`        "ID"` + +`      ],` + +`      "ID": {` + +`        "$Type": "Edm.Int32"` + +`      },` + +`      "Name": {` + +`        "@Core.IsLanguageDependent": true` + +`      },` + +`      "Products": {` + +`        "$Kind": "NavigationProperty",` + +`        "$Partner": "Category",` + +`        "$Collection": true,` + +`        "$Type": "self.Product",` + +`        "$OnDelete": "Cascade"` + +`      }` + +`    },` + +`    "Supplier": {` + +`      "$Kind": "EntityType",` + +`      "$Key": [` + +`        "ID"` + +`      ],` + +`      "ID": {},` + +`      "Name": {` + +`        "$Nullable": true` + +`      },` + +`      "Address": {` + +`        "$Type": "self.Address"` + +`      },` + +`      "Concurrency": {` + +`        "$Type": "Edm.Int32"` + +`      },` + +`      "Products": {` + +`        "$Kind": "NavigationProperty",` + +`        "$Partner": "Supplier",` + +`        "$Collection": true,` + +`        "$Type": "self.Product"` + +`      }` + +`    },` + +`    "Country": {` + +`      "$Kind": "EntityType",` + +`      "$Key": [` + +`        "Code"` + +`      ],` + +`      "Code": {` + +`        "$MaxLength": 2` + +`      },` + +`      "Name": {` + +`        "$Nullable": true` + +`      }` + +`    },` + +`    "Address": {` + +`      "$Kind": "ComplexType",` + +`      "Street": {` + +`        "$Nullable": true` + +`      },` + +`      "City": {` + +`        "$Nullable": true` + +`      },` + +`      "State": {` + +`        "$Nullable": true` + +`      },` + +`      "ZipCode": {` + +`        "$Nullable": true` + +`      },` + +`      "CountryName": {` + +`        "$Nullable": true` + +`      },` + +`      "Country": {` + +`        "$Kind": "NavigationProperty",` + +`        "$Nullable": true,` + +`        "$Type": "self.Country",` + +`        "$ReferentialConstraint": {` + +`          "CountryName": "Name"` + +`        }` + +`      }` + +`    },` + +`    "ProductsByRating": [` + +`      {` + +`        "$Kind": "Function",` + +`        "$Parameter": [` + +`          {` + +`            "$Name": "Rating",` + +`            "$Nullable": true,` + +`            "$Type": "Edm.Int32"` + +`          }` + +`        ],` + +`        "$ReturnType": {` + +`          "$Collection": true,` + +`          "$Type": "self.Product"` + +`        }` + +`      }` + +`    ],` + +`    "DemoService": {` + +`      "$Kind": "EntityContainer",` + +`      "Products": {` + +`        "$Collection": true,` + +`        "$Type": "self.Product",` + +`        "$NavigationPropertyBinding": {` + +`          "Category": "Categories"` + +`        }` + +`      },` + +`      "Categories": {` + +`        "$Collection": true,` + +`        "$Type": "self.Category",` + +`        "$NavigationPropertyBinding": {` + +`          "Products": "Products"` + +`        },` + +`        "@Core.Description": "Product Categories"` + +`      },` + +`      "Suppliers": {` + +`        "$Collection": true,` + +`        "$Type": "self.Supplier",` + +`        "$NavigationPropertyBinding": {` + +`          "Products": "Products",` + +`          "Address/Country": "Countries"` + +`        },` + +`        "@Core.OptimisticConcurrency": [` + +`          "Concurrency"` + +`        ]` + +`      },` + +`      "Countries": {` + +`        "$Collection": true,` + +`        "$Type": "self.Country"` + +`      },` + +`      "MainSupplier": {` + +`        "$Type": "self.Supplier",` + +`        "$NavigationPropertyBinding": {` + +`          "Products": "Products"` + +`        },` + +`        "@Core.Description": "Primary Supplier"` + +`      },` + +`      "ProductsByRating": {` + +`        "$EntitySet": "Products",` + +`        "$Function": "self.ProductsByRating"` + +`      }` + +`    }` + +`  }` + +`}` +::: + +## [Annotations for Products and Categories Example](#AnnotationsforProductsandCategoriesE) {#annotations-for-products-and-categories-example style="margin-left:28.9pt;text-indent:-28.9pt"} + +Example 90: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`{` + +`  "$Version": "4.01",` + +`  "$Reference": {` + +`    "http://host/service/$metadata": {` + +`      "$Include": [` + +`        {` + +`          "$Namespace": "ODataDemo",` + +`          "$Alias": "target"` + +`        }` + +`      ]` + +`    },` + +`    "http://somewhere/Vocabulary/V1": {` + +`      "$Include": [` + +`        {` + +`          "$Namespace": "Some.Vocabulary.V1",` + +`          "$Alias": "Vocabulary1"` + +`        }` + +`      ]` + +`    }` + +`  },` + +`  "External.Annotations": {` + +`    "$Annotations": {` + +`      "target.Supplier": {` + +`        "@Vocabulary1.EMail": null,` + +`        "@Vocabulary1.AccountID": {` + +`          "$Path": "ID"` + +`        },` + +`        "@Vocabulary1.Title": "Supplier Info",` + +`        "@Vocabulary1.DisplayName": {` + +`          "$Apply": [` + +`            {` + +`              "$Path": "Name"` + +`            },` + +`            " in ",` + +`            {` + +`              "$Path": "Address/CountryName"` + +`            }` + +`          ],` + +`          "$Function": "odata.concat"` + +`        }` + +`      },` + +`      "target.Product": {` + +`        "@Vocabulary1.Tags": [` + +`          "MasterData"` + +`        ]` + +`      }` + +`    }` + +`  }` + +`} ` +::: + +# ##sec Conformance + +Conforming services MUST follow all rules of this specification document +for the types, sets, functions, actions, containers and annotations they +expose. + +In addition, conforming services MUST NOT return 4.01 CSDL constructs +for requests made with `OData-MaxVersion:4.0`. + +Specifically, they + +1\. MUST NOT include properties in derived types that overwrite a +property defined in the base type + +2\. MUST NOT include `Edm.Untyped` + +3\. MUST NOT use [path syntax](#PathSyntax) added with 4.01 + +4\. MUST NOT use `Edm.ModelElementPath` and `Edm.AnyPropertyPath` + +5\. MUST NOT specify [referential constraints](#ReferentialConstraint) +to complex types and navigation properties + +6\. MUST NOT include a non-abstract entity type with no inherited or +defined [entity key](#Key) + +7\. MUST NOT include the +[`Core.DefaultNamespace`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#DefaultNamespace) +annotation on [included schemas](#IncludedSchema) + +8\. MUST NOT return the Unicode facet for terms, parameters, and return +types + +9\. MUST NOT include collections of `Edm.ComplexType` or `Edm.Untyped` + +10\. MUST NOT specify a key as a property of a related entity + +11\. SHOULD NOT include new/unknown values for +[`$AppliesTo`](#Applicability) + +12\. MAY include new CSDL annotations + +In addition, OData 4.01 services: + +13\. SHOULD NOT have identifiers within a uniqueness scope (e.g. a +schema, a structural type, or an entity container) that differ only by +case + +Conforming clients MUST be prepared to consume a model that uses any or +all constructs defined in this specification, including custom +annotations, and MUST ignore constructs not defined in this version of +the specification. + +Appendix A. [Acknowledgments](#Acknowledgments) + +The work of the OpenUI5 team on the OData V4 Metadata JSON Format, see +**\[**[**OpenUI5**](#OpenUI5)**\]**, is gratefully acknowledged, +especially the contributions of + +[· ]{style="font-family: +Symbol"}Thomas Chadzelek (SAP SE) + +[· ]{style="font-family: +Symbol"}Jens Ittel (SAP SE) + +[· ]{style="font-family: +Symbol"}Patric Ksinsik (SAP SE) + +The contributions of the OASIS OData Technical Committee members, +enumerated in [ODataProtocol](#ODataProtocol), are gratefully +acknowledged. + +Appendix B. [Table of JSON Objects and +Members](#TableofJSONObjectsandMembers) + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection2 +[Document Object[ ]{style="color: +windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317364) + +[`$Version`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317365) + +[`$EntityContainer`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317366) + +[`$Reference`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317367) + +[Reference Object[ +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317368) + +[`$Include`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37317369) + +[`$Namespace`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37317370) + +[`$Alias`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37317371) + +[`$IncludeAnnotations`[. +]{style="color:windowtext;display:none"}[18]{style="color:windowtext;display:none"}](#_Toc37317372) + +[`$TermNamespace`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37317373) + +[`$Qualifier`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37317374) + +[`$TargetNamespace`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37317375) + +[Schema Object[ ]{style="color:windowtext; +display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37317376) + +[`$Alias`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37317377) + +[`$Annotations`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37317378) + +[Entity Type Object[ +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37317379) + +[`$BaseType`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37317380) + +[`$Abstract`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37317381) + +[`$OpenType`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37317382) + +[`$HasStream`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37317383) + +[`$Key`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37317384) + +[Property Object[ ]{style="color: +windowtext;display:none"}[27]{style="color:windowtext;display:none"}](#_Toc37317385) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37317386) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37317387) + +[`$MaxLength`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37317388) + +[`$Precision`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37317389) + +[`$Scale`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37317390) + +[`$Unicode`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37317391) + +[`$SRID`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37317392) + +[`$DefaultValue`[. +]{style="color:windowtext;display:none"}[31]{style="color:windowtext;display:none"}](#_Toc37317393) + +[Navigation Property Object[ +]{style="color:windowtext;display:none"}[32]{style="color:windowtext;display:none"}](#_Toc37317394) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37317395) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37317396) + +[`$Partner`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37317397) + +[`$ContainsTarget`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37317398) + +[`$ReferentialConstraint`[. +]{style="color:windowtext;display:none"}[35]{style="color:windowtext;display:none"}](#_Toc37317399) + +[`$OnDelete`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37317400) + +[Complex Type Object[ +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37317401) + +[`$BaseType`[. +]{style="color:windowtext;display:none"}[38]{style="color:windowtext;display:none"}](#_Toc37317402) + +[`$Abstract`[. +]{style="color:windowtext;display:none"}[38]{style="color:windowtext;display:none"}](#_Toc37317403) + +[`$OpenType`[. +]{style="color:windowtext;display:none"}[38]{style="color:windowtext;display:none"}](#_Toc37317404) + +[Enumeration Type Object[ +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37317405) + +[`$UnderlyingType`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37317406) + +[`$IsFlags`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37317407) + +[Enumeration Member Object[ +]{style="color:windowtext;display:none"}[40]{style="color:windowtext;display:none"}](#_Toc37317408) + +[Type Definition Object[ +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37317409) + +[`$UnderlyingType`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37317410) + +[Action Overload Object[ +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37317411) + +[Function Overload Object[ +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37317412) + +[`$IsBound`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37317413) + +[`$EntitySetPath`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37317414) + +[`$IsComposable`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317415) + +[`$ReturnType`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317416) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317417) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317418) + +[`$Parameter`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317419) + +[Parameter Object[ +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317420) + +[`$Name`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317421) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317422) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317423) + +[Entity Container Object[ +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37317424) + +[`$Extends`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37317425) + +[Entity Set Object[ +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317426) + +[`$Collection`[. +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317427) + +[`$Type`[. +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317428) + +[`$IncludeInServiceDocument`[. +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317429) + +[Singleton Object[ +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317430) + +[`$Type`[. +]{style="color:windowtext;display:none"}[50]{style="color:windowtext;display:none"}](#_Toc37317431) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[50]{style="color:windowtext;display:none"}](#_Toc37317432) + +[`$NavigationPropertyBinding`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37317433) + +[Action Import Object[ +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37317434) + +[`$Action`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37317435) + +[`$EntitySet`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317436) + +[Function Import Object[ +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317437) + +[`$Function`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317438) + +[`$EntitySet`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317439) + +[`$IncludeInServiceDocument`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317440) + +[Term Object[ ]{style="color:windowtext; +display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317441) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317442) + +[`$DefaultValue`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317443) + +[`$BaseTerm`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317444) + +[`$AppliesTo`[. +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37317445) + +[Annotation Member[ +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37317446) + +[`$Path`[. +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37317447) + +[`$And` and `$Or`[. ]{style="color:windowtext; +display:none"}[66]{style="color:windowtext;display:none"}](#_Toc37317448) + +[`$Not`[. +]{style="color:windowtext;display:none"}[66]{style="color:windowtext;display:none"}](#_Toc37317449) + +[`$Eq`, `$Ne`, `$Gt`, `$Ge`, `$Lt`, `$Le`, `$Has`, and `$In`[. +]{style="color:windowtext; +display:none"}[66]{style="color:windowtext;display:none"}](#_Toc37317450) + +[`$Neg`[. +]{style="color:windowtext;display:none"}[68]{style="color:windowtext;display:none"}](#_Toc37317451) + +[`$Add`, `$Sub`, `$Mul`, `$Div`, `$DivBy`, and `$Mod`[. +]{style="color:windowtext; +display:none"}[69]{style="color:windowtext;display:none"}](#_Toc37317452) + +[`$Apply`[. +]{style="color:windowtext;display:none"}[70]{style="color:windowtext;display:none"}](#_Toc37317453) + +[`$Cast`[. +]{style="color:windowtext;display:none"}[72]{style="color:windowtext;display:none"}](#_Toc37317454) + +[`$If`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37317455) + +[`$IsOf`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37317456) + +[`$LabeledElement`[. +]{style="color:windowtext;display:none"}[74]{style="color:windowtext;display:none"}](#_Toc37317457) + +[`$LabeledElementReference`[. +]{style="color:windowtext;display:none"}[74]{style="color:windowtext;display:none"}](#_Toc37317458) + +[`$Null`[. +]{style="color:windowtext;display:none"}[75]{style="color:windowtext;display:none"}](#_Toc37317459) + +[`$UrlRef`[. +]{style="color:windowtext;display:none"}[76]{style="color:windowtext;display:none"}](#_Toc37317460) + +  +::: + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection3 +Appendix C. [Revision History](#RevisionHistory) + ++-----------------+-----------------+-----------------+-----------------+ +| **Revision** | **Date** | **Editor** | **Changes | +| | | | Made** | ++-----------------+-----------------+-----------------+-----------------+ +| Working Draft | 2016-11-16 | Ralf Handl | Initial version | +| 01 | | | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-06-08 | Michael Pizzo | Integrated 4.01 | +| Specification | | | features | +| Draft 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-09-22 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 02 | | Ralf Handl | | +| | | | Changed | +| | | | defaults of | +| | | | `$Nullable`, | +| | | | `$Scale`, and | +| | | | `$Precision` | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-11-10 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 03 | | Ralf Handl | | +| | | | Stable order of | +| | | | action and | +| | | | function | +| | | | parameters | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-12-19 | Michael Pizzo | Non-Material | +| Specification | | | Changes | +| 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-06-21 | Michael Pizzo | External | +| Specification | | | targeting for | +| Draft 04 | | Ralf Handl | annotations on | +| | | | action/function | +| | | | overloads, | +| | | | parameters, and | +| | | | return types | +| | | | | +| | | | Key and index | +| | | | segments for | +| | | | path | +| | | | expressions in | +| | | | annotations | +| | | | | +| | | | Nullable | +| | | | singletons | +| | | | | +| | | | Simplified | +| | | | syntax of | +| | | | entity | +| | | | container | +| | | | children and | +| | | | constant | +| | | | annotation | +| | | | expressions | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-09-26 | Michael Pizzo | Redefining | +| Specification | | | entity sets and | +| Draft 05 | | Ralf Handl | singletons when | +| | | | extending | +| | | | entity | +| | | | containers | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-11-05 | Michael Pizzo | Non-material | +| Specification | | | changes | +| 02 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Candidate OASIS | 2020-04-09 | Michael Pizzo | Non-material | +| Standard 02 | | | changes | +| | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ + +  +::: diff --git a/odata-csdl/temp/odata-csdl-json-v4.01-os.html b/odata-csdl/temp/odata-csdl-json-v4.01-os.html new file mode 100644 index 000000000..95ed751f4 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-json-v4.01-os.html @@ -0,0 +1,16520 @@ + + + + + + +OData Common Schema Definition Language (CSDL) JSON Representation +Version 4.01 + + + + + + +
    + +

    +OASIS logo

    + +
    + +

    OData Common Schema Definition Language (CSDL) JSON +Representation Version 4.01

    + +

    OASIS Standard

    + +

    11 May 2020

    + +
    + +

    This stage:

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/os/odata-csdl-json-v4.01-os.docx +(Authoritative)

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/os/odata-csdl-json-v4.01-os.html

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/os/odata-csdl-json-v4.01-os.pdf

    + +

    Previous stage:

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/cos01/odata-csdl-json-v4.01-cos01.docx +(Authoritative)

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/cos01/odata-csdl-json-v4.01-cos01.html

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/cos01/odata-csdl-json-v4.01-cos01.pdf

    + +

    Latest stage:

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.docx +(Authoritative)

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html

    + +

    https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.pdf

    + +

    Technical Committee:

    + +

    OASIS +Open Data Protocol (OData) TC

    + +

    Chairs:

    + +

    Ralf Handl (ralf.handl@sap.com), SAP SE

    + +

    Michael Pizzo (mikep@microsoft.com), +Microsoft

    + +

    Editors:

    + +

    Michael Pizzo (mikep@microsoft.com), Microsoft

    + +

    Ralf Handl (ralf.handl@sap.com), +SAP SE

    + +

    Martin Zurmuehl (martin.zurmuehl@sap.com), SAP SE

    + +

    Additional artifacts:

    + +

    This prose specification is one component of +a Work Product that also includes:

    + +

             +JSON schemas; OData CSDL JSON schema. https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/os/schemas/.

    + +

    Related work:

    + +

    This specification is related to:

    + +

             +OData Version 4.01. Edited by Michael Pizzo, Ralf Handl, +and Martin Zurmuehl. A multi-part Work Product which includes:

    + +

    o    OData +Version 4.01. Part 1: Protocol. Latest stage: https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html.

    + +

    o    OData +Version 4.01. Part 2: URL Conventions. Latest stage: https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html.

    + +

    o    ABNF +components: OData ABNF Construction Rules Version 4.01 and OData ABNF Test +Cases. https://docs.oasis-open.org/odata/odata/v4.01/os/abnf/.

    + +

             +OData Common Schema Definition Language (CSDL) XML +Representation Version 4.01. Edited by Michael Pizzo, Ralf Handl, and +Martin Zurmuehl. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html.

    + +

             +OData Vocabularies Version 4.0. Edited by Michael +Pizzo, Ralf Handl, and Ram Jeyaraman. Latest stage: http://docs.oasis-open.org/odata/odata-vocabularies/v4.0/odata-vocabularies-v4.0.html.

    + +

             +OData JSON Format Version 4.01. Edited by Michael Pizzo, +Ralf Handl, and Mark Biamonte. Latest stage: https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html.

    + +

    Abstract:

    + +

    OData services are described by an Entity Model (EDM). The +Common Schema Definition Language (CSDL) defines specific representations of +the entity data model exposed by an OData service, using XML, JSON, and other +formats. This document (OData CSDL JSON Representation) specifically defines +the JSON representation of CSDL.

    + +

    Status:

    + +

    This document was last revised or approved by the membership +of OASIS on the above date. The level of approval is also listed above. Check +the Latest stage location noted above for possible later revisions of this +document. Any other numbered Versions and other technical work produced by the +Technical Committee (TC) are listed at https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=odata#technical.

    + +

    TC members should send comments on this specification to the +TCs email list. Others should send comments to the TCs public comment list, +after subscribing to it by following the instructions at the Send +A Comment button on the TCs web page at https://www.oasis-open.org/committees/odata/.

    + +

    This specification is provided under the RF on +RAND Terms Mode of the OASIS IPR Policy, +the mode chosen when the Technical Committee was established. For information +on whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing terms, +please refer to the Intellectual Property Rights section of the TCs web page (https://www.oasis-open.org/committees/odata/ipr.php).

    + +

    Note that any machine-readable content (Computer +Language Definitions) declared Normative for this Work Product is provided +in separate plain text files. In the event of a discrepancy between any such +plain text file and display content in the Work Product's prose narrative +document(s), the content in the separate plain text file prevails.

    + +

    Citation format:

    + +

    When referencing this specification the following citation format +should be used:

    + +

    [OData-CSDL-JSON-v4.01]

    + +

    OData Common Schema Definition Language (CSDL) JSON +Representation Version 4.01. Edited by Michael Pizzo, Ralf Handl, and Martin +Zurmuehl. 11 May 2020. OASIS Standard. https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/os/odata-csdl-json-v4.01-os.html. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html.

    + +
    + +

    Notices

    + +
    + +

    Copyright OASIS Open 2020. All Rights Reserved.

    + +

    All capitalized terms in the following text have the +meanings assigned to them in the OASIS Intellectual Property Rights Policy (the +"OASIS IPR Policy"). The full Policy may be +found at the OASIS website.

    + +

    This document and translations of it may be copied and +furnished to others, and derivative works that comment on or otherwise explain +it or assist in its implementation may be prepared, copied, published, and +distributed, in whole or in part, without restriction of any kind, provided +that the above copyright notice and this section are included on all such +copies and derivative works. However, this document itself may not be modified +in any way, including by removing the copyright notice or references to OASIS, +except as needed for the purpose of developing any document or deliverable +produced by an OASIS Technical Committee (in which case the rules applicable to +copyrights, as set forth in the OASIS IPR Policy, must be followed) or as +required to translate it into languages other than English.

    + +

    The limited permissions granted above are perpetual and will +not be revoked by OASIS or its successors or assigns.

    + +

    This document and the information contained herein is +provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF +THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED +WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

    + +

    OASIS requests that any OASIS Party or any other party that +believes it has patent claims that would necessarily be infringed by +implementations of this OASIS Committee Specification or OASIS Standard, to +notify OASIS TC Administrator and provide an indication of its willingness to +grant patent licenses to such patent claims in a manner consistent with the IPR +Mode of the OASIS Technical Committee that produced this specification.

    + +

    OASIS invites any party to contact the OASIS TC +Administrator if it is aware of a claim of ownership of any patent claims that +would necessarily be infringed by implementations of this specification by a +patent holder that is not willing to provide a license to such patent claims in +a manner consistent with the IPR Mode of the OASIS Technical Committee that +produced this specification. OASIS may include such claims on its website, but +disclaims any obligation to do so.

    + +

    OASIS takes no position regarding the validity or scope of +any intellectual property or other rights that might be claimed to pertain to +the implementation or use of the technology described in this document or the +extent to which any license under such rights might or might not be available; +neither does it represent that it has made any effort to identify any such +rights. Information on OASIS' procedures with respect to rights in any document +or deliverable produced by an OASIS Technical Committee can be found on the +OASIS website. Copies of claims of rights made available for publication and +any assurances of licenses to be made available, or the result of an attempt +made to obtain a general license or permission for the use of such proprietary +rights by implementers or users of this OASIS Committee Specification or OASIS +Standard, can be obtained from the OASIS TC Administrator. OASIS makes no +representation that any information or list of intellectual property rights +will at any time be complete, or that any claims in such list are, in fact, +Essential Claims.

    + +

    The name "OASIS" is a trademark of OASIS, the owner and developer of this +specification, and should be used only to refer to the organization and its +official outputs. OASIS welcomes reference to, and implementation and use of, +specifications, while reserving the right to enforce its marks against +misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark +for above guidance.

    + +
    + +

    Table of Contents

    + +
    + +

    1 Introduction. 8

    + +

    1.1 IPR Policy. 8

    + +

    1.2 Terminology. 8

    + +

    1.3 Normative References. 8

    + +

    1.4 Non-Normative References. 9

    + +

    1.5 Typographical Conventions. 9

    + +

    2 JSON +Representation. 10

    + +

    2.1 Requesting the JSON Representation. 10

    + +

    2.1.1 Controlling the Representation +of Numbers. 10

    + +

    2.1.2 Controlling the Amount of +Control Information. 10

    + +

    2.1.2.1 +metadata=minimal. 10

    + +

    2.1.2.2 +metadata=full. 11

    + +

    2.1.2.3 +metadata=none. 11

    + +

    2.2 Design Considerations. 11

    + +

    2.3 JSON Schema Definition. 11

    + +

    3 Entity Model 12

    + +

    3.1 Nominal Types. 12

    + +

    3.2 Structured Types. 12

    + +

    3.3 Primitive Types. 12

    + +

    3.4 Built-In Abstract Types. 14

    + +

    3.5 Built-In Types for defining +Vocabulary Terms. 15

    + +

    3.6 Annotations. 15

    + +

    4 CSDL JSON +Document 16

    + +

    4.1 Reference. 16

    + +

    4.2 Included Schema. 17

    + +

    4.3 Included Annotations. 18

    + +

    5 Schema. 20

    + +

    5.1 Alias. 20

    + +

    5.2 Annotations with External +Targeting. 21

    + +

    6 Entity Type. 22

    + +

    6.1 Derived Entity Type. 22

    + +

    6.2 Abstract Entity Type. 23

    + +

    6.3 Open Entity Type. 23

    + +

    6.4 Media Entity Type. 23

    + +

    6.5 Key. 24

    + +

    7 Structural +Property. 27

    + +

    7.1 Type. 27

    + +

    7.2 Type Facets. 28

    + +

    7.2.1 Nullable. 28

    + +

    7.2.2 MaxLength. 28

    + +

    7.2.3 Precision. 28

    + +

    7.2.4 Scale. 29

    + +

    7.2.5 Unicode. 30

    + +

    7.2.6 SRID. 30

    + +

    7.2.7 Default Value. 31

    + +

    8 Navigation Property. 32

    + +

    8.1 Navigation Property Type. 33

    + +

    8.2 Nullable Navigation Property. 33

    + +

    8.3 Partner Navigation Property. 33

    + +

    8.4 Containment Navigation Property. 34

    + +

    8.5 Referential Constraint 34

    + +

    8.6 On-Delete Action. 35

    + +

    9 Complex Type. 37

    + +

    9.1 Derived Complex Type. 38

    + +

    9.2 Abstract Complex Type. 38

    + +

    9.3 Open Complex Type. 38

    + +

    10 Enumeration +Type. 39

    + +

    10.1 Underlying Integer Type. 39

    + +

    10.2 Flags Enumeration Type. 39

    + +

    10.3 Enumeration Type Member 40

    + +

    11 Type Definition. 41

    + +

    11.1 Underlying Primitive Type. 41

    + +

    12 Action and +Function. 43

    + +

    12.1 Action. 43

    + +

    12.2 Action Overloads. 43

    + +

    12.3 Function. 43

    + +

    12.4 Function Overloads. 43

    + +

    12.5 Bound or Unbound Action or +Function Overloads. 44

    + +

    12.6 Entity Set Path. 44

    + +

    12.7 Composable Function. 44

    + +

    12.8 Return Type. 45

    + +

    12.9 Parameter 45

    + +

    13 Entity +Container 47

    + +

    13.1 Extending an Entity Container 48

    + +

    13.2 Entity Set 49

    + +

    13.3 Singleton. 49

    + +

    13.4 Navigation Property Binding. 50

    + +

    13.4.1 Navigation Property Path +Binding. 50

    + +

    13.4.2 Binding Target 50

    + +

    13.5 Action Import 51

    + +

    13.6 Function Import 52

    + +

    14 Vocabulary and +Annotation. 53

    + +

    14.1 Term.. 54

    + +

    14.1.1 Specialized Term.. 54

    + +

    14.1.2 Applicability. 55

    + +

    14.2 Annotation. 56

    + +

    14.2.1 Qualifier 57

    + +

    14.2.2 Target 57

    + +

    14.3 Constant Expression. 59

    + +

    14.3.1 Binary. 59

    + +

    14.3.2 Boolean. 59

    + +

    14.3.3 Date. 59

    + +

    14.3.4 DateTimeOffset 60

    + +

    14.3.5 Decimal 60

    + +

    14.3.6 Duration. 60

    + +

    14.3.7 Enumeration Member 60

    + +

    14.3.8 Floating-Point Number 60

    + +

    14.3.9 Guid. 61

    + +

    14.3.10 Integer 61

    + +

    14.3.11 String. 61

    + +

    14.3.12 Time of Day. 61

    + +

    14.4 Dynamic Expression. 61

    + +

    14.4.1 Path Expressions. 61

    + +

    14.4.1.1 Path Syntax. 62

    + +

    14.4.1.2 Path Evaluation. 63

    + +

    14.4.1.3 Annotation Path. 64

    + +

    14.4.1.4 Model Element Path. 64

    + +

    14.4.1.5 Navigation Property Path. 64

    + +

    14.4.1.6 Property Path. 65

    + +

    14.4.1.7 Value Path. 65

    + +

    14.4.2 Comparison and Logical +Operators. 66

    + +

    14.4.3 Arithmetic Operators. 68

    + +

    14.4.4 Apply Client-Side Functions. 70

    + +

    14.4.4.1 Canonical Functions. 70

    + +

    14.4.4.2 Function odata.fillUriTemplate. 71

    + +

    14.4.4.3 Function odata.matchesPattern. 71

    + +

    14.4.4.4 Function odata.uriEncode. 72

    + +

    14.4.5 Cast 72

    + +

    14.4.6 Collection. 72

    + +

    14.4.7 If-Then-Else. 73

    + +

    14.4.8 Is-Of 73

    + +

    14.4.9 Labeled Element 74

    + +

    14.4.10 Labeled Element Reference. 74

    + +

    14.4.11 Null 74

    + +

    14.4.12 Record. 75

    + +

    14.4.13 URL Reference. 76

    + +

    15 Identifier and +Path Values. 77

    + +

    15.1 Namespace. 77

    + +

    15.2 Simple Identifier 77

    + +

    15.3 Qualified Name. 77

    + +

    15.4 Target Path. 77

    + +

    16 CSDL Examples. 78

    + +

    16.1 Products and Categories Example. 78

    + +

    16.2 Annotations for Products and +Categories Example. 81

    + +

    17 Conformance. 83

    + +

    Appendix A. Acknowledgments. 84

    + +

    Appendix B. Table of JSON Objects and +Members. 85

    + +

    Appendix C. Revision History. 87

    + +

     

    + + + +

    OData services are described in terms of an Entity Model. The Common Schema Definition Language +(CSDL) defines a representation of the entity model exposed by an OData service +using the JavaScript Object Notation (JSON), see [RFC8259].

    + +

    This format is based on the OpenUI5 OData V4 Metadata JSON +Format, see [OpenUI5], with some +extensions and modifications made necessary to fully cover OData CSDL Version +4.01.

    + +

    1.1 IPR Policy

    + +

    This specification is provided under the RF on +RAND Terms Mode of the OASIS IPR Policy, +the mode chosen when the Technical Committee was established. For information +on whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing terms, +please refer to the Intellectual Property Rights section of the TCs web page (https://www.oasis-open.org/committees/odata/ipr.php).

    + +

    1.2 Terminology

    + +

    The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL +NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this +document are to be interpreted as described in [RFC2119].

    + +

    1.3 Normative References

    + +

    [ECMAScript] ECMAScript +2016 Language Specification, 7th Edition, June 2016. Standard +ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm. +

    + +

    [EPSG] European +Petroleum Survey Group (EPSG). http://www.epsg.org/. +

    + +

    [OData-ABNF] OData +ABNF Construction Rules Version 4.01.
    +See link in Additional artifacts section on cover page.

    + +

    [OData-CSDL-Schema] OData CSDL JSON +Schema.
    +
    See link in Additional artifacts section on cover page.

    + +

    [OData-CSDLXML] OData Common Schema Definition Language +(CSDL) XML Representation Version 4.01.
    +See link in Related work section on cover page.

    + +

    [OData-JSON] OData JSON Format Version 4.01. +
    +See link in Related work section on cover page.

    + +

    [OData-Protocol] OData +Version 4.01 Part 1: Protocol.
    +See link in Related work section on cover page.

    + +

    [OData-URL] OData +Version 4.01 Part 2: URL Conventions.
    +See link in Related work section on cover page.

    + +

    [OData-VocCore] OData Vocabularies +Version 4.0: Core Vocabulary.
    +See link in Related work section on cover page.

    + +

    [OData-VocMeasures] OData +Vocabularies Version 4.0: Measures Vocabulary.
    +See link in Related work section on cover page.

    + +

    [OData-VocValidation] OData +Vocabularies Version 4.0: Validation Vocabulary.
    +See link in Related work section on cover page.

    + +

    [RFC2119] Bradner, +S., Key words for use in RFCs to Indicate Requirement Levels, BCP 14, RFC +2119, March 1997. https://tools.ietf.org/html/rfc2119.

    + +

    [RFC6570] Gregorio, J., +Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, URI Template, RFC +6570, March 2012. http://tools.ietf.org/html/rfc6570. +

    + +

    [RFC7493] Bray, T., Ed., "The I-JSON +Message Format", RFC7493, March 2015. https://tools.ietf.org/html/rfc7493.

    + +

    [RFC8259] Bray, +T., Ed., The JavaScript Object Notation (JSON) Data Interchange Format, RFC 8259, +December 2017. http://tools.ietf.org/html/rfc8259. +

    + +

    [XML-Schema-2] W3C +XML Schema Definition Language (XSD) 1.1 Part 2: DatatypesW3C XML Schema +Definition Language (XSD) 1.1 Part 2: Datatypes, D. Peterson, S. Gao, C. M. +Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C +Recommendation, 5 April 2012, http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/.
    +Latest version available at http://www.w3.org/TR/xmlschema11-2/.

    + +

    1.4 Non-Normative References

    + +

    [OpenUI5] OpenUI5 Version 1.40.10 OData V4 Metadata JSON Format, https://openui5.hana.ondemand.com/1.40.10/#docs/guide/87aac894a40640f89920d7b2a414499b.html

    + +

    1.5 Typographical Conventions

    + +

    Keywords defined by this specification use this monospaced font.

    + +

    Normative source code uses this paragraph style.

    + +

    Some sections of this specification are illustrated with +non-normative examples.

    + +

    Example 1: text describing an example uses this paragraph +style

    + +
    + +

    Non-normative examples use this paragraph style.

    + +
    + +

    All examples in this document are non-normative and +informative only.

    + +

    Representation-specific text is indented and marked with +vertical lines.

    + +
    + +

    Representation-Specific +Headline

    + +
    + +
    + +

    Normative representation-specific text

    + +
    + +

    All other text is normative unless otherwise labeled.

    + + + +

    OData CSDL JSON is a full representation of the OData Common +Schema Definition Language in the JavaScript Object Notation (JSON) defined in [RFC8259]. It additionally follows the rules +for Internet JSON (I-JSON) defined in [RFC7493] +for e.g. objects, numbers, date values, and duration values.

    + +

    It is an alternative to the CSDL XML representation defined +in [OData-CSDLXML] and neither adds +nor removes features.

    + +

    2.1 Requesting the JSON Representation

    + +

    The OData CSDL JSON representation can be requested using +the $format query option in the request URL with the +media type application/json, optionally followed by +media type parameters, or the case-insensitive abbreviation json which MUST NOT be followed by media type parameters.

    + +

    Alternatively, this representation can be requested using +the Accept header with the media type application/json, optionally followed by media type +parameters.

    + +

    If specified, $format overrides +any value specified in the Accept header.

    + +

    The response MUST contain the Content-Type +header with a value of application/json, optionally +followed by media type parameters.

    + +

    Possible media type parameters are:

    + +

             +IEEE754Compatible

    + +

             +metadata

    + +

    The names and values of these parameters are +case-insensitive.

    + +

    2.1.1 Controlling the Representation +of Numbers

    + +

    The IEEE754Compatible=true +parameter indicates that the service MUST serialize Edm.Int64 +and Edm.Decimal numbers as strings. This is in +conformance with [RFC7493]. If not specified, or specified as IEEE754Compatible=false, all numbers MUST be serialized +as JSON numbers.

    + +

    This enables support for JavaScript numbers that are defined +to be 64-bit binary format IEEE 754 values [ECMAScript] +(see section +4.3.1.9) resulting in integers losing precision past 15 digits, and +decimals losing precision due to the conversion from base 10 to base 2.

    + +

    Responses that format Edm.Int64 +and Edm.Decimal values as strings MUST specify this +parameter in the media type returned in the Content-Type +header.

    + +

    2.1.2 Controlling the Amount of +Control Information

    + +

    The representation of constant annotation values in CSDL JSON +documents closely follows the representation of data defined in [OData‑JSON].

    + +

    A client application can use the metadata +format parameter in the Accept header when +requesting a CSDL JSON document to influence how much control information will +be included in the response.

    + +

    Other Accept header parameters +are orthogonal to the metadata parameter and are +therefore not mentioned in this section.

    + +

    2.1.2.1 metadata=minimal

    + +

    The metadata=minimal format +parameter indicates that the service SHOULD remove computable control +information from the payload wherever possible.

    + +

    This means that the @type +control information is only included if the type of the containing object or +targeted property cannot be heuristically determined, e.g. for

    + +

             +Terms or term properties with an abstract declared type,

    + +

             +Terms or term properties with a declared type that has derived +types, or

    + +

             +Dynamic properties of open types.

    + +

    See [OData‑JSON] for the +exact rules.

    + +

    2.1.2.2 +metadata=full

    + +

    The metadata=full format +parameter indicates that the service MUST include all control information +explicitly in the payload.

    + +

    This means that the @type +control information is included in annotation values except for primitive +values whose type can be heuristically determined from the representation of +the value, see [OData‑JSON] for the exact +rules.

    + +

    2.1.2.3 metadata=none

    + +

    The metadata=none format +parameter indicates that the service SHOULD omit all control information.

    + +

    2.2 Design Considerations

    + +

    CSDL JSON documents are designed for easy and efficient +lookup of model constructs by their name without having to know or guess what +kind of model element it is. Thus, all primary model elements (entity types, +complex types, type definitions, enumeration types, terms, actions, functions, +and the entity container) are direct members of their schema, using the +schema-unique name as the member name. Similarly, child elements of primary +model elements (properties, navigation properties, enumeration type members, +entity sets, singletons, action imports, and function imports) are direct +members of the objects describing their parent model element, using their +locally unique name as the member name.

    + +

    To avoid name collisions, all fixed member names are +prefixed with a dollar ($) sign and otherwise have +the same name and capitalization as their counterparts in the CSDL XML +representation [OData-CSDLXML] (with +one exception: the counterpart of the EntitySet +elements EntityType attribute is $Type, +to harmonize it with all other type references).

    + +

    Additional fixed members introduced by this specification +and without counterpart in [OData-CSDLXML] +are also prefixed with a dollar ($) sign and use +upper-camel-case names. One of these is $Kind which +represents the kind of model element. Its value is the upper-camel-case local +name of the XML element representing this kind of model element in [OData-CSDLXML], e.g. EntityType +or NavigationProperty.

    + +

    While the XML representation of CSDL allows referencing +model elements with alias-qualified names as well as with namespace-qualified +names, this JSON representation requires the use of alias-qualified names if an +alias is specified for an included or document-defined schema. Aliases are +usually shorter than namespaces, so this reduces text size of the JSON +document. Text size matters even if the actual HTTP messages are sent in +compressed form because the decompressed form needs to be reconstructed, and +clients not using a streaming JSON parser have to materialize the full JSON +document before parsing.

    + +

    To further reduce size the member $Kind +is optional for structural properties as +these are more common than navigation +properties, and the member $Type is optional for string properties, parameters, +and return types, as this type is more common than other primitive types.

    + +

    In general, all members that have a default value SHOULD be +omitted if they have the default value.

    + +

    2.3 JSON Schema Definition

    + +

    The structure of CSDL JSON documents can be verified with +the JSON Schema [OData-CSDL-Schema] +provided as an additional artifact of this prose specification. This schema +only defines the shape of a well-formed CSDL JSON document but is not +descriptive enough to define what a correct CSDL JSON document MUST be in every +imaginable use case. This specification document defines additional rules that +correct CSDL JSON documents MUST fulfill. In case of doubt on what makes a CSDL +JSON document correct the rules defined in this specification document take +precedence.

    + + + +

    An OData service exposes a single entity model. This model +may be distributed over several schemas, and these +schemas may be distributed over several documents.

    + +

    A service is defined by a single CSDL document which can be +accessed by sending a GET request to <serviceRoot>/$metadata. This document is called +the metadata document. It MAY reference other CSDL +documents.

    + +

    The metadata document contains a single entity container that defines the resources +exposed by this service. This entity container MAY extend an entity container defined +in a referenced document.

    + +

    The model of the service consists of all CSDL +constructs used in its entity containers.

    + +

    The scope of a CSDL document is the document itself +and all schemas included from directly referenced documents. All entity types, complex types +and other named model elements in scope (that is, defined in the +document itself or a schema of a directly referenced document) can be accessed +from a referencing document by their qualified names. This includes the built-in primitive and abstract types.

    + +

    Referencing another document may alter the model defined by +the referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, then an entity set of the service defined by the referencing +document may return entities of the derived type. This is identical to the +behavior if the derived type had been defined directly in the referencing +document.

    + +

    Note: referencing documents is not recursive. Only named +model elements defined in directly referenced documents can be used within the +schema. However, those elements may in turn include or reference model elements +defined in schemas referenced by their defining schema.

    + +

    3.1 Nominal Types

    + +

    A nominal type has a name that MUST be a simple identifier. Nominal types are +referenced using their qualified name. The +qualified type name MUST be unique within a model as it facilitates references +to the element from other parts of the model.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    3.2 Structured Types

    + +

    Structured types are composed of other model elements. +Structured types are common in entity models as the means of representing +entities and structured properties in an OData service. Entity types and complex +types are both structured types.

    + +

    Structured Types are composed of zero or more structural properties and navigation properties.

    + +

    Open entity types and open complex types allow properties to be added +dynamically to instances of the open type.

    + +

    3.3 Primitive Types

    + +

    Structured types are composed of other structured types and +primitive types. OData defines the following primitive types:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Type

    +
    +

    Meaning

    +
    +

    Edm.Binary

    +
    +

    Binary data

    +
    +

    Edm.Boolean

    +
    +

    Binary-valued logic

    +
    +

    Edm.Byte

    +
    +

    Unsigned 8-bit integer

    +
    +

    Edm.Date

    +
    +

    Date without a time-zone offset

    +
    +

    Edm.DateTimeOffset

    +
    +

    Date and time with a time-zone offset, no leap seconds

    +
    +

    Edm.Decimal

    +
    +

    Numeric values with decimal representation

    +
    +

    Edm.Double

    +
    +

    IEEE 754 binary64 floating-point number (15-17 decimal + digits)

    +
    +

    Edm.Duration

    +
    +

    Signed duration in days, hours, minutes, and (sub)seconds

    +
    +

    Edm.Guid

    +
    +

    16-byte (128-bit) unique identifier

    +
    +

    Edm.Int16

    +
    +

    Signed 16-bit integer

    +
    +

    Edm.Int32

    +
    +

    Signed 32-bit integer

    +
    +

    Edm.Int64

    +
    +

    Signed 64-bit integer

    +
    +

    Edm.SByte

    +
    +

    Signed 8-bit integer

    +
    +

    Edm.Single

    +
    +

    IEEE 754 binary32 floating-point number (6-9 decimal + digits)

    +
    +

    Edm.Stream

    +
    +

    Binary data stream

    +
    +

    Edm.String

    +
    +

    Sequence of characters

    +
    +

    Edm.TimeOfDay

    +
    +

    Clock time 00:00-23:59:59.999999999999

    +
    +

    Edm.Geography

    +
    +

    Abstract base type for all Geography types

    +
    +

    Edm.GeographyPoint

    +
    +

    A point in a round-earth coordinate system

    +
    +

    Edm.GeographyLineString

    +
    +

    Line string in a round-earth coordinate system

    +
    +

    Edm.GeographyPolygon

    +
    +

    Polygon in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiPoint

    +
    +

    Collection of points in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiLineString

    +
    +

    Collection of line strings in a round-earth coordinate + system

    +
    +

    Edm.GeographyMultiPolygon

    +
    +

    Collection of polygons in a round-earth coordinate system

    +
    +

    Edm.GeographyCollection

    +
    +

    Collection of arbitrary Geography values

    +
    +

    Edm.Geometry

    +
    +

    Abstract base type for all Geometry types

    +
    +

    Edm.GeometryPoint

    +
    +

    Point in a flat-earth coordinate system

    +
    +

    Edm.GeometryLineString

    +
    +

    Line string in a flat-earth coordinate system

    +
    +

    Edm.GeometryPolygon

    +
    +

    Polygon in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiPoint

    +
    +

    Collection of points in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiLineString

    +
    +

    Collection of line strings in a flat-earth coordinate + system

    +
    +

    Edm.GeometryMultiPolygon

    +
    +

    Collection of polygons in a flat-earth coordinate system

    +
    +

    Edm.GeometryCollection

    +
    +

    Collection of arbitrary Geometry values

    +
    + +

    Edm.Date and Edm.DateTimeOffset follow [XML‑Schema‑2] +and use the proleptic Gregorian calendar, allowing the year 0000 (equivalent to 1 BCE) and negative years (year -0001 being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying persistency +layer, e.g. SQL only supports years 0001 to 9999.

    + +

    Edm.Decimal with a Scale value of floating, Edm.Double, and Edm.Single allow the special numeric values ‑INF, INF, and NaN.

    + +

    Edm.Stream is a primitive type +that can be used as a property of an entity type +or complex type, the underlying type for a type definition, or the binding parameter or +return type of an action or +function. Edm.Stream, +or a type definition whose underlying type is Edm.Stream, +cannot be used in collections or for non-binding parameters to functions or +actions.

    + +

    Some of these types allow facets, +defined in section Type Facets.

    + +

    See rule primitiveLiteral in [OData‑ABNF] for the representation of +primitive type values in URLs and [OData‑JSON] +for the representation in requests and responses.

    + +

    3.4 Built-In Abstract Types

    + +

    The following built-in abstract types can be used within a +model:

    + +

             +Edm.PrimitiveType

    + +

             +Edm.ComplexType

    + +

             +Edm.EntityType

    + +

             +Edm.Untyped

    + +

    Conceptually, these are the abstract base types for +primitive types (including type definitions and enumeration types), complex +types, entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except:

    + +

             +Edm.EntityType

    + +
      +
        +
      • cannot be used as the type of a singleton in an entity container + because it doesnt define a structure, which defeats the purpose of a + singleton.
      • +
      • cannot be used as the type of an entity set because all + entities in an entity set must have the same key fields to uniquely + identify them within the set.
      • +
      • cannot be the base type of an entity type or complex type.
      • +
      +
    + +

             +Edm.ComplexType

    + +
      +
        +
      • cannot be the base type of an entity type or complex type.
      • +
      +
    + +

             +Edm.PrimitiveType

    + +
      +
        +
      • cannot be used as the type of a key property of an entity + type or as the underlying type of an enumeration type.
      • +
      • cannot be used as the underlying type of a type + definition in a CSDL document with a version of 4.0.
      • +
      • can be used as the underlying type of a type definition + in a CSDL document with a version of 4.01 or greater.
      • +
      +
    + +

             +Edm.Untyped

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      • cannot be used as the type of a key property of an entity + type.
      • +
      • cannot be the base type of an entity type or complex type.
      • +
      • cannot be used as the underlying type of a type + definition or enumeration type.
      • +
      +
    + +

             +Collection(Edm.PrimitiveType)

    + +
      +
        +
      • cannot be used as the type of a property or term.
      • +
      • cannot be used as the type of a parameter or the return + type of an action or function.
      • +
      +
    + +

             +Collection(Edm.Untyped)

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      +
    + +

    3.5 Built-In Types for defining +Vocabulary Terms

    + +

    Vocabulary terms +can, in addition, use

    + +

             +Edm.AnnotationPath

    + +

             +Edm.PropertyPath

    + +

             +Edm.NavigationPropertyPath

    + +

             +Edm.AnyPropertyPath (Edm.PropertyPath or Edm.NavigationPropertyPath)

    + +

             +Edm.ModelElementPath (any +model element, including Edm.AnnotationPath, Edm.NavigationPropertyPath, and Edm.PropertyPath)

    + +

    as the type of a primitive term, or the type of a property +of a complex type (recursively) that is exclusively used as the type of a term. +See section Path Expressions for details.

    + +

    3.6 Annotations

    + +

    Many parts of the model can be decorated with additional +information using annotations. Annotations are +identified by their term name and an optional qualifier that allows applying +the same term multiple times to the same model element.

    + +

    A model element MUST NOT specify more than one annotation +for a given combination of term and qualifier.

    + + + + + +
    + +

    A CSDL JSON document consists of a +single JSON object. This document object MUST contain the member $Version.

    + +

    The document object MAY contain the +member $Reference +to reference other CSDL documents.

    + +

    It also MAY contain members for schemas.

    + +

    If the CSDL JSON document is the +metadata document of an OData service, the document object MUST contain the +member $EntityContainer.

    + +
    + +
    + +

    $Version

    + +
    + +
    + +

    The value of $Version +is a string containing either 4.0 or 4.01.

    + +
    + + + +
    + +

    The value of $EntityContainer +is value is the namespace-qualified name of the entity container of that +service. This is the only place where a model element MUST be referenced with +its namespace-qualified name and use of the alias-qualified name is not +allowed.

    + +
    + +

    Example 2:

    + +
    + +

    {

    + +

    "$Version": +"4.01",

    + +

    "$EntityContainer": "org.example.DemoService",

    + +

    + +

    }

    + +
    + +

    4.1 Reference

    + +

    A reference to an external CSDL document allows to bring +part of the referenced documents content into the scope of the referencing +document.

    + +

    A reference MUST specify a URI that uniquely identifies the +referenced document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be absolute +or relative URI; relative URLs are relative to the URL of the document +containing the reference, or relative to a base URL specified in a format-specific +way.

    + +

    A reference MAY be annotated.

    + +

    The Core.SchemaVersion annotation, +defined in [OData-VocCore], MAY be used to +indicate a particular version of the referenced document. If the Core.SchemaVersion annotation is +present, the $schemaversion system query option, +defined [OData‑Protocol], SHOULD +be used when retrieving the referenced schema document.

    + +
    + +

    $Reference

    + +
    + +
    + +

    The value of $Reference +is an object that contains one member per referenced CSDL document. The name of +the pair is a URI for the referenced document. The URI MAY be relative to the +document containing the $Reference. The value of +each member is a reference object.

    + +
    + + + +
    + +

    The reference object MAY contain the +members $Include +and $IncludeAnnotations +as well as annotations.

    + +
    + +

    Example 3: references to other CSDL documents

    + +
    + +

    {

    + +

    + +

    "$Reference": {

    + +

    "http://vocabs.odata.org/capabilities/v1": +{

    + +

    + +

    },

    + +

    "http://vocabs.odata.org/core/v1": +{

    + +

    + +

    },

    + +

    "http://example.org/display/v1": +{

    + +

    + +

    }

    + +

    },

    + +

    + +

    }

    + +
    + +

    4.2 Included Schema

    + +

    A reference MAY include zero or more schemas from the +referenced document.

    + +

    The included schemas are identified via their namespace. The same +namespace MUST NOT be included more than once, even if it is declared in more +than one referenced document.

    + +

    When including a schema, a simple +identifier value MAY be specified as an alias for the schema that is used +in qualified names instead of the namespace. For example, an alias of display might be assigned to the namespace org.example.vocabularies.display. An alias-qualified name +is resolved to a fully qualified name by examining aliases for included schemas +and schemas defined within the document.

    + +
    + +

    If an included schema specifies an +alias, the alias MUST be used in qualified names throughout the document to +identify model elements of the included schema. A mixed use of +namespace-qualified names and alias-qualified names is not allowed.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document.

    + +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +

    An alias is only valid within the document in which it is +declared; a referencing document may define its own aliases for included +schemas.

    + +
    + +

    $Include

    + +
    + +
    + +

    The value of $Include +is an array. Array items are objects that MUST contain the member $Namespace and MAY contain the member $Alias.

    + +

    The item objects MAY contain annotations.

    + +
    + +
    + +

    $Namespace

    + +
    + +
    + +

    The value of $Namespace +is a string containing the namespace of the included schema.

    + +
    + +
    + +

    $Alias

    + +
    + +
    + +

    The value of $Alias +is a string containing the alias for the included schema.

    + +
    + +

    Example 4: references to entity models containing +definitions of vocabulary terms

    + +
    + +

    {

    + +

    + +

    "$Reference": {

    + +

    "http://vocabs.odata.org/capabilities/v1": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": +"Org.OData.Capabilities.V1",

    + +

    "$Alias": +"Capabilities"

    + +

    }

    + +

    ]

    + +

    },

    + +

    "http://vocabs.odata.org/core/v1": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": +"Org.OData.Core.V1",

    + +

    "$Alias": +"Core",

    + +

    +"@Core.DefaultNamespace": true

    + +

    }

    + +

    ]

    + +

    },

    + +

    "http://example.org/display/v1": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "org.example.display",

    + +

    "$Alias": +"UI"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    + +

    }

    + +
    + +

    4.3 Included Annotations

    + +

    In addition to including whole schemas with all model +constructs defined within that schema, annotations can be included with more +flexibility.

    + +

    Annotations are selectively included by specifying the namespace of the +annotations term. Consumers can opt not to inspect the referenced document if +none of the term namespaces is of interest for the consumer.

    + +

    In addition, the qualifier of +annotations to be included MAY be specified. For instance, a service author might +want to supply a different set of annotations for various device form factors. +If a qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of the +target namespace, if present) SHOULD be included. If no qualifier is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the target namespace, if present) SHOULD be +included.

    + +

    The qualifier also provides consumers insight about what +qualifiers are present in the referenced document. If the consumer is not +interested in that particular qualifier, the consumer can opt not to inspect +the referenced document.

    + +

    In addition, the namespace of the annotations target MAY be specified. If a target namespace is +specified, only those annotations which apply a term form the specified term +namespace to a model element of the target namespace (with the specified +qualifier, if present) SHOULD be included. If no target namespace is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the qualifier, if present) SHOULD be included.

    + +

    The target namespace also provides consumers insight about +what namespaces are present in the referenced document. If the consumer is not +interested in that particular target namespace, the consumer can opt not to +inspect the referenced document.

    + + + +
    + +

    The value of $IncludeAnnotations +is an array. Array items are objects that MUST contain the member $TermNamespace and MAY contain the members $Qualifier and $TargetNamespace.

    + +
    + + + +
    + +

    The value of $TermNamespace +is a namespace.

    + +
    + +
    + +

    $Qualifier

    + +
    + +
    + +

    The value of $Qualifier +is a simple identifier.

    + +
    + + + +
    + +

    The value of $TargetNamespace +is a namespace.

    + +
    + +

    Example 5: reference documents that contain annotations

    + +
    + +

    {

    + +

    + +

    "$Reference": {

    + +

    +"http://odata.org/ann/b": {

    + +

    "$IncludeAnnotations": +[

    + +

    {

    + +

    "$TermNamespace": +"org.example.validation"

    + +

    },

    + +

    {

    + +

    "$TermNamespace": +"org.example.display",

    + +

    "$Qualifier": +"Tablet"

    + +

    },

    + +

    {

    + +

    "$TermNamespace": +"org.example.hcm",

    + +

    +"$TargetNamespace": "com.example.Sales"

    + +

    },

    + +

    {

    + +

    "$TermNamespace": +"org.example.hcm",

    + +

    "$Qualifier": +"Tablet",

    + +

    +"$TargetNamespace": "com.example.Person"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    + +

    }

    + +
    + +

    The following annotations from http://odata.org/ann/b are included:

    + +

             +Annotations that use a term from the org.example.validation +namespace, and

    + +

             +Annotations that use a term from the org.example.display +namespace and specify a Tablet +qualifier and

    + +

             +Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Sales +namespace and

    + +

             +Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Person +namespace and specify a Tablet +qualifier.

    + + + +

    One or more schemas describe the entity model exposed by an +OData service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms.

    + +

    A schema is identified by a namespace. +Schema namespaces MUST be unique within the scope of a document and SHOULD be +globally unique. A schema cannot span more than one document.

    + +

    The schemas namespace is combined with the name of elements +in the schema to create unique qualified names, so identifiers that are used to name types MUST be +unique within a namespace to prevent ambiguity.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    The namespace MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + + + +
    + +

    A schema is represented as a member of +the document object whose name is the schema namespace. Its value is an object +that MAY contain the members $Alias and $Annotations.

    + +

    The schema object MAY contain members +representing entity types, complex types, enumeration +types, type definitions, actions, functions, terms, and an entity +container.

    + +

    The schema object MAY also contain annotations that apply to the schema itself.

    + +
    + +

    5.1 Alias

    + +

    A schema MAY specify an alias which MUST be a simple identifier.

    + +
    + +

    If a schema specifies an alias, the +alias MUST be used instead of the namespace within qualified names throughout +the document to identify model elements of that schema. A mixed use of +namespace-qualified names and alias-qualified names is not allowed.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the containing +document and are not restricted to the schema that defines them.

    + +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +
    + +

    $Alias

    + +
    + +
    + +

    The value of $Alias +is a string containing the alias for the schema.

    + +
    + +

    Example 6: document defining a +schema org.example with an alias and a description +for the schema

    + +
    + +

    {

    + +

    + +

    "org.example": {

    + +

    "$Alias": +"self",

    + +

    "@Core.Description": +"Example schema",

    + +

    + +

    },

    + +

    + +

    }

    + +
    + +

    5.2 Annotations with External +Targeting

    + +
    + +

    $Annotations

    + +
    + +
    + +

    The value of $Annotations +is an object with one member per annotation target. +The member name is a path identifying the annotation +target, the member value is an object containing annotations +for that target.

    + +
    + +

    Example 7: annotations targeting the Person +type with qualifier Tablet

    + +
    + +

    "org.example": {

    + +

    "$Alias": +"self",

    + +

    "$Annotations": {

    + +

    "self.Person": {

    + +

    +"@Core.Description#Tablet": "Dummy",

    + +

    + +

    }

    + +

    }

    + +

    },

    + +
    + + + +

    Entity types are nominal structured types with a key that consists of +one or more references to structural +properties. An entity type is the template for an entity: any uniquely +identifiable record such as a customer or order.

    + +

    The entity types name is a simple +identifier that MUST be unique within its schema.

    + +

    An entity type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, +complex, or enumeration types. A navigation +property is a named reference to another entity type or collection of +entity types.

    + +

    All properties MUST have a unique name within an entity +type. Properties MUST NOT have the same name as the declaring entity type. They +MAY have the same name as one of the direct or indirect base types or derived +types.

    + + + +
    + +

    An entity type is represented as a +member of the schema object whose name is the unqualified name of the entity +type and whose value is an object.

    + +

    The entity type object MUST contain +the member $Kind with a string value of EntityType.

    + +

    It MAY contain the members $BaseType, +$Abstract, +$OpenType, +$HasStream, +and $Key.

    + +

    It also MAY contain members +representing structural properties and navigation properties as well as annotations.

    + +
    + +

    Example 8: +a simple entity type

    + +
    + +

    "Employee": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "FirstName": {},

    + +

    "LastName": {},

    + +

    "Manager": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Manager"

    + +

    }

    + +

    }

    + +
    + +

    6.1 Derived Entity Type

    + +

    An entity type can inherit from another entity type by +specifying it as its base type.

    + +

    An entity type inherits the key as +well as structural and navigation properties of its base type.

    + +

    An entity type MUST NOT introduce an inheritance cycle by +specifying a base type.

    + +
    + +

    $BaseType

    + +
    + +
    + +

    The value of $BaseType +is the qualified name of the base type.

    + +
    + +

    Example 9: a derived entity type based on the previous +example

    + +
    + +

    "Manager": {

    + +

    "$Kind": +"EntityType",

    + +

    "$BaseType": "self.Employee",

    + +

    "AnnualBudget": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    },

    + +

    "Employees": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Employee"

    + +

    }

    + +

    }

    + +
    + +

    Note: the derived type has the same name as one of the +properties of its base type.

    + +

    6.2 Abstract Entity Type

    + +

    An entity type MAY indicate that it is abstract and cannot +have instances.

    + +

    For OData 4.0 responses a non-abstract entity type MUST +define a key or derive +from a base type with a defined key.

    + +

    An abstract entity type MUST NOT inherit from a non-abstract +entity type.

    + +
    + +

    $Abstract

    + +
    + +
    + +

    The value of $Abstract +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    6.3 Open Entity Type

    + +

    An entity type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    An entity type derived from an open entity type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see [OData‑Protocol].

    + +
    + +

    $OpenType

    + +
    + +
    + +

    The value of $OpenType +is one of the Boolean literals true or false. Absence of the member means false. +

    + +
    + +

     

    + +

    6.4 Media Entity Type

    + +

    An entity type that does not specify a base type MAY +indicate that it is a media entity type. Media entities are entities +that represent a media stream, such as a photo. Use a media entity if the +out-of-band stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal entity +with one or more properties of type Edm.Stream if +the structured data of the entity is the main topic of interest and the stream +data is just additional information attached to the structured data. For more +information on media entities see [OData‑Protocol].

    + +

    An entity type derived from a media entity type MUST +indicate that it is also a media entity type.

    + +

    Media entity types MAY specify a list of acceptable media +types using an annotation with term Core.AcceptableMediaTypes, see [OData-VocCore].

    + +
    + +

    $HasStream

    + +
    + +
    + +

    The value of $HasStream +is one of the Boolean literals true or false. Absence of the member means false. +

    + +
    + +

    6.5 Key

    + +

    An entity is uniquely identified within an entity set by its +key. A key MAY be specified if the entity type does not specify a base type that already has a key declared.

    + +

    In order to be specified as the type of an entity set or a collection-valued containment navigation property, +the entity type MUST either specify a key or inherit its key from its base type.

    + +

    In OData 4.01 responses entity types used for singletons or single-valued navigation properties do not require a key. +In OData 4.0 responses entity types used for singletons +or single-valued navigation properties +MUST have a key defined.

    + +

    An entity type (whether or not it is marked as abstract) MAY +define a key only if it doesnt inherit one.

    + +

    An entity types key refers to the set of properties whose +values uniquely identify an instance of the entity type within an entity set. +The key MUST consist of at least one property.

    + +

    Key properties MUST NOT be nullable and MUST be typed with +an enumeration type, +one of the following primitive types, or a type definition based on one of these primitive +types:

    + +
      +
    • Edm.Boolean
    • +
    • Edm.Byte
    • +
    • Edm.Date
    • +
    • Edm.DateTimeOffset
    • +
    • Edm.Decimal
    • +
    • Edm.Duration
    • +
    • Edm.Guid
    • +
    • Edm.Int16
    • +
    • Edm.Int32
    • +
    • Edm.Int64
    • +
    • Edm.SByte
    • +
    • Edm.String
    • +
    • Edm.TimeOfDay
    • +
    + +

    Key property values MAY be language-dependent, but their +values MUST be unique across all languages and the entity ids (defined in [OData‑Protocol]) MUST be language +independent.

    + +

    A key property MUST be a non-nullable primitive property of +the entity type itself, including non-nullable primitive properties of +non-nullable single-valued complex properties, recursively.

    + +

    In OData 4.01 the key properties of a directly related +entity type MAY also be part of the key if the navigation property is +single-valued and not nullable. This includes navigation properties of +non-nullable single-valued complex properties (recursively) of the entity type. +If a key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key.

    + +

    If the key property is a property of a complex property +(recursively) or of a directly related entity type, the key MUST specify an +alias for that property that MUST be a simple +identifier and MUST be unique within the set of aliases, structural and +navigation properties of the declaring entity type and any of its base types.

    + +

    An alias MUST NOT be defined if the key property is a +primitive property of the entity type itself.

    + +

    For key properties that are a property of a complex or +navigation property, the alias MUST be used in the key predicate of URLs +instead of the path to the property because the required percent-encoding of +the forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be used in +the query part of URLs, where paths to properties dont require special +encoding and are a standard constituent of expressions anyway.

    + +
    + +

    $Key

    + +
    + +
    + +

    The value of $Key +is an array with one item per key property.

    + +

    Key properties without a key alias are +represented as strings containing the property name.

    + +

    Key properties with a key alias are +represented as objects with one member whose name is the key alias and whose +value is a string containing the path to the property.

    + +
    + +

    Example 10: entity type with a simple key

    + +
    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true,

    + +

    "@Core.IsLanguageDependent": +true

    + +

    }

    + +

    }

    + +
    + +

    Example 11: +entity type with a simple key referencing a property of a complex type

    + +
    + +

    "Category": {

    + +

    "$Kind": "EntityType",

    + +

    "$Key": [

    + +

    {

    + +

    "EntityInfoID": +"Info/ID"

    + +

    }

    + +

    ],

    + +

    "Info": {

    + +

    "$Type": "self.EntityInfo"

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    }

    + +

    },

    + +

    "EntityInfo": {

    + +

    "$Kind": +"ComplexType",

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Created": {

    + +

    "$Type": +"Edm.DateTimeOffset",

    + +

    "$Precision": 0

    + +

    }

    + +

    }

    + +
    + +

    Example 12: entity type with a composite key

    + +
    + +

    "OrderLine": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "OrderID",

    + +

    "LineNumber"

    + +

    ],

    + +

    "OrderID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "LineNumber": {

    + +

    "$Type": +"Edm.Int32"

    + +

    }

    + +

    }

    + +
    + +

    Example 13 (based on example 11): +requests to an entity set Categories +of type Category must use the +alias

    + +
    + +

    GET http://host/service/Categories(EntityInfoID=1)

    + +
    + +

    Example 14 (based on example 11): +in a query part the value assigned to the name attribute must be used

    + +
    + +

    GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100

    + +
    + + + +

    A structural property is a property of a structured type +that has one of the following types:

    + +

             +Primitive type

    + +

             +Complex type

    + +

             +Enumeration type

    + +

             +A collection of one of the above

    + +

    A structural property MUST specify a unique name as well as +a type.

    + +

    The propertys name MUST be a simple +identifier. It is used when referencing, +serializing or deserializing the property. It MUST be unique within the set of +structural and navigation properties of the declaring structured type, +and MUST NOT match the name of any navigation property in any of its base +types. If a structural property with the same name is defined in any of this +types base types, then the propertys type MUST be a type derived from the type +specified for the property of the base type and constrains this property to be +of the specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + + + +
    + +

    Structural properties are represented +as members of the object representing a structured type. The member name is the +property name, the member value is an object.

    + +

    The property object MAY contain the +member $Kind with a string value of Property. This member SHOULD be omitted to reduce +document size.

    + +

    It MAY contain the member $Type, $Collection, +$Nullable, +$MaxLength, +$Unicode, +$Precision, +$Scale, +$SRID, +and $DefaultValue. +

    + +

    It also MAY contain annotations.

    + +
    + +

    Example 15: complex type with two properties Dimension and Length

    + +
    + +

    "Measurement": {

    + +

    "$Kind": +"ComplexType",

    + +

    "Dimension": {

    + +

    "$MaxLength": 50,

    + +

    "$DefaultValue": +"Unspecified"

    + +

    },

    + +

    "Length": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Precision": 18,

    + +

    "$Scale": 2

    + +

    }

    + +

    }

    + +
    + +

    7.1 Type

    + +

    The propertys type MUST be a primitive +type, complex type, or enumeration type in scope, or a collection of +one of these types.

    + +

    A collection-valued property MAY be annotated with the Core.Ordered +term, defined in
    +[OData-VocCore]), to specify that it +supports a stable ordering.

    + +

    A collection-valued property MAY be annotated with the Core.PositionalInsert +term, defined in [OData-VocCore]), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued properties the value +of $Type is the qualified name of the propertys +type.

    + +

    For collection-valued properties the +value of $Type is the qualified name of the +propertys item type, and the member $Collection +MUST be present with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String. This member +SHOULD be omitted for string properties to reduce document size.

    + +
    + +

    Example 16: property Units that +can have zero or more strings as its value

    + +
    + +

    "Units": {

    + +

    "$Collection": true

    + +

    }

    + +
    + +

    7.2 Type Facets

    + +

    Facets modify or constrain the acceptable values of a +property.

    + +

    For single-valued properties the facets apply to the value +of the property. For collection-valued properties the facets apply to the items +in the collection.

    + +

    7.2.1 +Nullable

    + +

    A Boolean value specifying whether the property can have the +value null.

    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +

    For single-valued properties the value +true means that the property allows the null value.

    + +

    For collection-valued properties the +property value will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +
    + +

    7.2.2 +MaxLength

    + +

    A positive integer value specifying the maximum length of a +binary, stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length (number +of code points for Unicode).

    + +

    If no maximum length is specified, clients SHOULD expect +arbitrary length.

    + +
    + +

    $MaxLength

    + +
    + +
    + +

    The value of $MaxLength +is a positive integer.

    + +

    Note: [OData-CSDLXML] +defines a symbolic value max that is only allowed +in OData 4.0 responses. This symbolic value is not allowed in CDSL JSON +documents at all. Services MAY instead specify the concrete maximum length supported +for the type by the service or omit the member entirely.

    + +
    + +

    7.2.3 +Precision

    + +

    For a decimal value: the maximum number of significant +decimal digits of the propertys value; it MUST be a positive integer.

    + +

    For a temporal value (datetime-with-timezone-offset, +duration, or time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve.

    + +

    Note: service authors SHOULD be aware that some clients are +unable to support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential for data +loss when round-tripping values of greater precision. Updating via PATCH and exclusively specifying modified properties will +reduce the risk for unintended data loss.

    + +

    Note: duration properties supporting a granularity less than +seconds (e.g. minutes, hours, days) can be annotated with term Measures.DurationGranularity, see [OData-VocMeasures].

    + +
    + +

    $Precision

    + +
    + +
    + +

    The value of $Precision +is a number.

    + +

    Absence of $Precision +means arbitrary precision.

    + +
    + +

    Example 17: Precision facet applied to the DateTimeOffset type

    + +
    + +

    "SuggestedTimes": {

    + +

    "$Type": Edm.DateTimeOffset",

    + +

    "$Collection": true,

    + +

    "$Precision": 6

    + +

    }

    + +
    + +

    7.2.4 Scale

    + +

    A non-negative integer value specifying the maximum number +of digits allowed to the right of the decimal point, or one of the symbolic +values floating or variable.

    + +

    The value floating means that the +decimal property represents a decimal floating-point number whose number of +significant digits is the value of the Precision facet. OData 4.0 responses +MUST NOT specify the value floating.

    + +

    The value variable +means that the number of digits to the right of the decimal point can vary from +zero to the value of the Precision facet.

    + +

    An integer value means that the number of digits to the +right of the decimal point may vary from zero to the value of the Scale facet, and the number of digits to the left of the +decimal point may vary from one to the value of the Precision +facet minus the value of the Scale facet. If Precision is equal to Scale, +a single zero MUST precede the decimal point.

    + +

    The value of Scale MUST be less +than or equal to the value of Precision.

    + +

    Note: if the underlying data store allows negative scale, services +may use a Precision +with the absolute value of the negative scale added to the actual number of +significant decimal digits, and client-provided values may have to be rounded +before being stored.

    + +
    + +

    $Scale

    + +
    + +
    + +

    The value of $Scale +is a number or a string with one of the symbolic values floating +or variable.

    + +

    Services +SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner.

    + +

    Absence of $Scale +means variable.

    + +
    + +

    Example 18: Precision=3 and Scale=2. +
    +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3

    + +
    + +

    "Amount32": {

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 3,

    + +

    "$Scale": 2

    + +

    }

    + +
    + +

    Example 19: Precision=2 +equals Scale.
    +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2

    + +
    + +

    "Amount22": {

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 2,

    + +

    "$Scale": 2

    + +

    }

    + +
    + +

    Example 20: Precision=3 +and a variable Scale.
    +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed values: 12.34, +1234 and 123.4 due to the limited precision.

    + +
    + +

    "Amount3v": {

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 3

    + +

    }

    + +
    + +

    Example 21: Precision=7 +and a floating Scale.
    +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: 1e-102 +and 1e97 due to the limited precision.

    + +
    + +

    "Amount7f": +{

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 7,

    + +

    "$Scale": +"floating"

    + +

    }

    + +
    + +

    7.2.5 Unicode

    + +

    For a string property the Unicode +facet indicates whether the property might contain and accept string values +with Unicode characters (code points) beyond the ASCII character set. The value +false indicates that the property will only contain +and accept string values with characters limited to the ASCII character set.

    + +

    If no value is specified, the Unicode +facet defaults to true.

    + +
    + +

    $Unicode

    + +
    + +
    + +

    The value of $Unicode +is one of the Boolean literals true or false. Absence of the member means true. +

    + +
    + +

    7.2.6 SRID

    + +

    For a geometry or geography property the SRID facet identifies which spatial reference system is +applied to values of the property on type instances.

    + +

    The value of the SRID facet MUST +be a non-negative integer or the special value variable. +If no value is specified, the facet defaults to 0 +for Geometry types or 4326 +for Geography types.

    + +

    The valid values of the SRID +facet and their meanings are as defined by the European Petroleum Survey Group [EPSG].

    + +
    + +

    $SRID

    + +
    + +
    + +

    The value of $SRID +is a string containing a number or the symbolic value variable. +

    + +
    + +

    7.2.7 +Default Value

    + +

    A primitive or enumeration property MAY define a default +value that is used if the property is not explicitly represented in an +annotation or the body of a request or response.

    + +

    If no value is specified, the client SHOULD NOT assume a +default value.

    + + + +
    + +

    The value of $DefaultValue +is the type-specific JSON representation of the default value of the property, +see [OData-JSON]. For properties of +type Edm.Decimal and Edm.Int64 +the representation depends on the media type parameter IEEE754Compatible.

    + +
    + + + +

    A navigation property allows navigation to related entities. +It MUST specify a unique name as well as a type.

    + +

    The navigation propertys name MUST be a simple identifier. It +is used when referencing, serializing or deserializing the navigation property. +It MUST be unique within the set of structural and navigation properties of the +declaring structured type, and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the same name +is defined in any of this types base types, then the navigation propertys +type MUST be a type derived from the type specified for the navigation property +of the base type, and constrains this navigation property to be of the +specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + + + +
    + +

    Navigation properties are represented +as members of the object representing a structured type. The member name is the +property name, the member value is an object.

    + +

    The navigation property object MUST +contain the member $Kind with a string value of NavigationProperty.

    + +

    It MUST contain the member $Type, +and it MAY contain the members $Collection, $Nullable, +$Partner, +$ContainsTarget, +$ReferentialConstraint, +and $OnDelete. +

    + +

    It also MAY contain annotations.

    + +
    + +

    Example 22: the Product entity +type has a navigation property to a Category, which +has a navigation link back to one or more products

    + +
    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "Category": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Category",

    + +

    "$Partner": +"Products",

    + +

    +"$ReferentialConstraint": {

    + +

    "CategoryID": +"ID"

    + +

    }

    + +

    },

    + +

    "Supplier": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Supplier"

    + +

    }

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "Products": {

    + +

    "$Kind": "NavigationProperty",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$Partner": +"Category",

    + +

    "$OnDelete": +"Cascade",

    + +

    "$OnDelete@Core.Description": +"Delete all related entities"

    + +

    }

    + +

    }

    + +
    + +

    8.1 Navigation +Property Type

    + +

    The navigation propertys type MUST be an entity type in scope, the abstract type Edm.EntityType, +or a collection of one of these types.

    + +

    If the type is a collection, an arbitrary number of entities +can be related. Otherwise there is at most one related entity.

    + +

    The related entities MUST be of the specified entity type or +one of its subtypes.

    + +

    For a collection-valued containment navigation property the +specified entity type MUST have a key defined.

    + +

    A collection-valued navigation property MAY be annotated +with the Core.Ordered +term, defined in [OData-VocCore]), to +specify that it supports a stable ordering.

    + +

    A collection-valued navigation property MAY be annotated +with the Core.PositionalInsert +term, defined in [OData-VocCore]), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued navigation +properties the value of $Type is the qualified name +of the navigation propertys type.

    + +

    For collection-valued navigation +properties the value of $Type is the qualified name +of the navigation propertys item type, and the member $Collection +MUST be present with the literal value true.

    + +
    + +

    8.2 Nullable +Navigation Property

    + +

    A Boolean value specifying whether the declaring type MAY +have no related entity. If false, instances of the declaring structured type +MUST always have a related entity.

    + +

    Nullable MUST NOT be specified for a collection-valued +navigation property, a collection is allowed to have zero items.

    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    8.3 Partner Navigation Property

    + +

    A navigation property of an entity +type MAY specify a partner navigation property. Navigation properties of +complex types MUST NOT specify a partner.

    + +

    If specified, the partner navigation property is identified +by a path relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that type or +a derived type. The path MAY traverse complex types, including derived complex +types, but MUST NOT traverse any navigation properties. The type of the partner +navigation property MUST be the declaring entity type of the current navigation +property or one of its parent entity types.

    + +

    If the partner navigation property +is single-valued, it MUST lead back to the source entity from all related +entities. If the partner navigation property is collection-valued, the source +entity MUST be part of that collection.

    + +

    If no partner navigation property +is specified, no assumptions can be made as to whether one of the navigation +properties on the target type will lead back to the source entity.

    + +

    If a partner navigation property +is specified, this partner navigation property MUST either specify the current +navigation property as its partner to define a bi-directional +relationship or it MUST NOT specify a partner navigation property. The latter +can occur if the partner navigation property is defined on a complex type, or +if the current navigation property is defined on a type derived from the type +of the partner navigation property.

    + +
    + +

    $Partner

    + +
    + +
    + +

    The value of $Partner +is a string containing the path to the partner navigation property.

    + +
    + +

    8.4 Containment Navigation Property

    + +

    A navigation property MAY indicate that instances of its +declaring structured type contain the targets of the navigation property, in +which case the navigation property is called a containment navigation +property.

    + +

    Containment navigation properties define an implicit entity +set for each instance of its declaring structured type. This implicit entity +set is identified by the read URL of the navigation property for that structured +type instance.

    + +

    Instances of the structured type that declares the +navigation property, either directly or indirectly via a property of complex +type, contain the entities referenced by the containment navigation property. +The canonical URL for contained entities is the canonical URL of the containing +instance, followed by the path segment of the navigation property and the key +of the contained entity, see [OData‑URL].

    + +

    Entity types used in collection-valued containment +navigation properties MUST have a key defined.

    + +

    For items of an ordered collection of complex types (those +annotated with the Core.Ordered +term defined in [OData-VocCore]), the +canonical URL of the item is the canonical URL of the collection appended with +a segment containing the zero-based ordinal of the item. Items within in an +unordered collection of complex types do not have a canonical URL. Services +that support unordered collections of complex types declaring a containment +navigation property, either directly or indirectly via a property of complex +type, MUST specify the URL for the navigation link within a payload +representing that item, according to format-specific rules.

    + +

    OData +4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued property.

    + +

    An entity cannot be referenced by more than one containment +relationship, and cannot both belong to an entity set declared within the +entity container and be referenced by a containment relationship.

    + +

    Containment navigation properties MUST NOT be specified as +the last path segment in the path of a navigation +property binding.

    + +

    When a containment navigation property navigates between +entity types in the same inheritance hierarchy, the containment is called recursive. +

    + +

    Containment navigation properties MAY specify a partner +navigation property. If the containment is recursive, the relationship defines +a tree, thus the partner navigation property MUST be nullable (for the root of the tree) +and single-valued (for the parent of a non-root entity). If the containment is +not recursive, the partner navigation property MUST NOT be nullable.

    + +

    An entity type inheritance chain MUST NOT contain more than +one navigation property with a partner navigation property that is a +containment navigation property.

    + +

    Note: without a partner navigation property, there is no +reliable way for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity can also +be reached via a non-containment navigation path.

    + + + +
    + +

    The value of $ContainsTarget +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    8.5 Referential Constraint

    + +

    A single-valued navigation property MAY define one or more +referential constraints. A referential constraint asserts that the dependent +property (the property defined on the structured type declaring the +navigation property) MUST have the same value as the principal property +(the referenced property declared on the entity type that is the target of the +navigation).

    + +

    The type of the dependent property MUST match the type of +the principal property, or both types MUST be complex types.

    + +

    If the principle property references an entity, then the +dependent property must reference the same entity.

    + +

    If the principle propertys value is a complex type +instance, then the dependent propertys value must be a complex type instance +with the same properties, each with the same values.

    + +

    If the navigation property on which the referential +constraint is defined is nullable, or the principal property is nullable, then +the dependent property MUST also be nullable. If both the navigation property +and the principal property are not nullable, then the dependent property MUST +NOT be nullable.

    + + + +
    + +

    The value of $ReferentialConstraint +is an object with one member per referential constraint. The member name is the +path to the dependent property, this path is relative to the structured type +declaring the navigation property. The member value is a string containing the +path to the principal property, this path is relative to the entity type that +is the target of the navigation property.

    + +

    It also MAY contain annotations. These are prefixed with the path of the +dependent property of the annotated referential constraint.

    + +
    + +

    Example 23: the category must +exist for a product in that category to exist. The CategoryID +of the product is identical to the ID of the +category, and the CategoryKind property of the +product is identical to the Kind property of the +category.

    + +
    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "CategoryID": {},

    + +

    "CategoryKind": {},

    + +

    "Category": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Category",

    + +

    "$Partner": +"Products",

    + +

    +"$ReferentialConstraint": {

    + +

    "CategoryID": +"ID",

    + +

    "CategoryKind": +"Kind"

    + +

    "CategoryKind@Core.Description": +"Referential Constraint to non-key property"

    + +

    }

    + +

    }

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "Kind": {

    + +

    "$Nullable": true

    + +

    },

    + +

    + +

    }

    + +
    + +

    8.6 On-Delete Action

    + +

    A navigation property MAY define an on-delete action that +describes the action the service will take on related entities when the entity +on which the navigation property is defined is deleted.

    + +

    The action can have one of the following values:

    + +
      +
    • Cascade, meaning the related + entities will be deleted if the source entity is deleted,
    • +
    • None, meaning a DELETE request on a source entity with related + entities will fail,
    • +
    • SetNull, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to null,
    • +
    • SetDefault, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to their default value.
    • +
    + +

    If no on-delete action is specified, the action taken by the +service is not predictable by the client and could vary per entity.

    + +
    + +

    $OnDelete

    + +
    + +
    + +

    The value of $OnDelete +is a string with one of the values Cascade, None, SetNull, or SetDefault.

    + +

    Annotations +for $OnDelete are prefixed with $OnDelete.

    + +
    + +

    Example 24: deletion of a +category implies deletion of the related products in that category

    + +
    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    + +

    "Products": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$Partner": +"Category",

    + +

    "$OnDelete": +"Cascade",

    + +

    "$OnDelete@Core.Description": +"Delete all products in this category"

    + +

    }

    + +

    }

    + +
    + + + +

    Complex types are keyless nominal +structured types. The lack of a key means +that instances of complex types cannot be referenced, created, updated or +deleted independently of an entity type. Complex types allow entity models to +group properties into common structures.

    + +

    The complex types name is a simple +identifier that MUST be unique within its schema.

    + +

    A complex type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, complex, +or enumeration types. A navigation property +is a named reference to an entity type or a collection of entity types.

    + +

    All properties MUST have a unique name within a complex +type. Properties MUST NOT have the same name as the declaring complex type. +They MAY have the same name as one of the direct or indirect base types or +derived types.

    + + + +
    + +

    A complex type is represented as a +member of the schema object whose name is the unqualified name of the complex +type and whose value is an object.

    + +

    The complex type object MUST contain +the member $Kind with a string value of ComplexType. It MAY contain the members $BaseType, +$Abstract, +and $OpenType. +It also MAY contain members representing structural +properties and navigation properties +as well as annotations.

    + +
    + +

    Example 25: a complex type used by two entity types

    + +
    + +

    "Dimensions": {

    + +

    "$Kind": +"ComplexType",

    + +

    "Height": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    },

    + +

    "Weight": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    },

    + +

    "Length": {

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0

    + +

    }

    + +

    },

    + +

    "Product": {

    + +

    + +

    "ProductDimensions": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Dimensions"

    + +

    },

    + +

    "ShippingDimensions": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Dimensions"

    + +

    }

    + +

    },

    + +

    "ShipmentBox": {

    + +

    + +

    "Dimensions": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Dimensions"

    + +

    }

    + +

    }

    + +
    + +

    9.1 Derived Complex Type

    + +

    A complex type can inherit from another complex type by +specifying it as its base type.

    + +

    A complex type inherits the structural and navigation +properties of its base type.

    + +

    A complex type MUST NOT introduce an inheritance cycle by +specifying a base type.

    + +

    The rules for annotations of derived complex types are +described in section 14.2.

    + +
    + +

    $BaseType

    + +
    + +
    + +

    The value of $BaseType +is the qualified name of the base type.

    + +
    + +

    9.2 Abstract Complex Type

    + +

    A complex type MAY indicate that it is abstract and cannot +have instances.

    + +
    + +

    $Abstract

    + +
    + +
    + +

    The value of $Abstract +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    9.3 Open Complex Type

    + +

    A complex type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    A complex type derived from an open complex type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see [OData‑Protocol].

    + +
    + +

    $OpenType

    + +
    + +
    + +

    The value of $OpenType +is one of the Boolean literals true or false. Absence of the member means false. +

    + +
    + + + +

    Enumeration types are nominal +types that represent a non-empty series of related values. Enumeration types +expose these related values as members of the enumeration.

    + +

    The enumeration types name is a simple identifier that MUST be unique within +its schema.

    + +

    Although enumeration types have an underlying numeric value, +the preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the AllowedValues annotation defined +in [OData-VocCore].

    + +

    Enumeration types marked as flags allow values that consist +of more than one enumeration member at a time.

    + + + +
    + +

    An enumeration type is represented as +a member of the schema object whose name is the unqualified name of the +enumeration type and whose value is an object.

    + +

    The enumeration type object MUST +contain the member $Kind with a string value of EnumType.

    + +

    It MAY contain the members $UnderlyingType +and $IsFlags.

    + +

    The enumeration type object MUST +contain members representing the +enumeration type members.

    + +

    The enumeration type object MAY +contain annotations.

    + +
    + +

    Example 26: a simple flags-enabled enumeration

    + +
    + +

    "FileAccess": {

    + +

    "$Kind": +"EnumType",

    + +

    "$UnderlyingType": +"Edm.Int32",

    + +

    "$IsFlags": true,

    + +

    "Read": 1,

    + +

    "Write": 2,

    + +

    "Create": 4,

    + +

    "Delete": 8

    + +

    }

    + +
    + +

    10.1 +Underlying Integer Type

    + +

    An enumeration type MAY specify one of Edm.Byte, +Edm.SByte, Edm.Int16, Edm.Int32, or Edm.Int64 as +its underlying type.

    + +

    If not explicitly specified, Edm.Int32 +is used as the underlying type.

    + + + +
    + +

    The value of $UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    10.2 +Flags Enumeration Type

    + +

    An enumeration type MAY indicate that the enumeration type +allows multiple members to be selected simultaneously.

    + +

    If not explicitly specified, only one enumeration type +member MAY be selected simultaneously.

    + +
    + +

    $IsFlags

    + +
    + +
    + +

    The value of $IsFlags +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    Example 27: pattern values can +be combined, and some combined values have explicit names

    + +
    + +

    "Pattern": {

    + +

    "$Kind": +"EnumType",

    + +

    "$UnderlyingType": +"Edm.Int32",

    + +

    "$IsFlags": true,

    + +

    "Plain": 0,

    + +

    "Red": 1,

    + +

    "Blue": 2,

    + +

    "Yellow": 4,

    + +

    "Solid": 8,

    + +

    "Striped": 16,

    + +

    "SolidRed": 9,

    + +

    "SolidBlue": 10,

    + +

    "SolidYellow": 12,

    + +

    "RedBlueStriped": 19,

    + +

    "RedYellowStriped": 21,

    + +

    "BlueYellowStriped": 22

    + +

    }

    + +
    + +

    10.3 Enumeration Type Member

    + +

    Enumeration type values consist of discrete members.

    + +

    Each member is identified by its name, a simple identifier that MUST be unique within +the enumeration type. Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    Each member MUST specify an associated numeric value that +MUST be a valid value for the underlying type of the enumeration type.

    + +

    Enumeration types can have multiple members with the same value. Members with the same numeric +value compare as equal, and members with the same numeric value can be used +interchangeably.

    + +

    Enumeration +members are sorted by their numeric value.

    + +

    For flag enumeration types the combined numeric value of +simultaneously selected members is the bitwise OR of the discrete numeric +member values.

    + + + +
    + +

    Enumeration type members are +represented as JSON object members, where the object member name is the +enumeration member name and the object member value is the enumeration member +value.

    + +

    For members of flags enumeration types a combined +enumeration member value is equivalent to the bitwise OR of the discrete values.

    + +

    Annotations for enumeration members +are prefixed with the enumeration member name.

    + +
    + +

    Example 28: FirstClass has a value of 0, TwoDay a value of 1, and Overnight +a value of 2.

    + +
    + +

    "ShippingMethod": {

    + +

    "$Kind": +"EnumType",

    + +

    "FirstClass": 0,

    + +

    "FirstClass@Core.Description": +"Shipped with highest priority",

    + +

    "TwoDay": 1,

    + +

    "TwoDay@Core.Description": +"Shipped within two days",

    + +

    "Overnight": 2,

    + +

    "Overnight@Core.Description": +"Shipped overnight",

    + +

    "@Core.Description": "Method +of shipping"

    + +

    }

    + +
    + + + +

    A type definition defines a specialization of one of the primitive types or of the built-in abstract type Edm.PrimitiveType.

    + +

    The type definitions name is a simple identifier that MUST be unique within +its schema.

    + +

    Type definitions can be used wherever a primitive type is +used (other than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions defined +using the same underlying type.

    + +

    It is up to the definition of a term to specify whether and +how annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden.

    + + + +
    + +

    A type definition is represented as a +member of the schema object whose name is the unqualified name of the type +definition and whose value is an object.

    + +

    The type definition object MUST +contain the member $Kind with a string value of TypeDefinition and the member $UnderlyingType. +It MAY contain the members $MaxLength, $Unicode, $Precision, $Scale, and $SRID, and it MAY contain annotations.

    + +
    + +

    Example 29:

    + +
    + +

    "Length": {

    + +

    "$Kind": "TypeDefinition",

    + +

    "$UnderlyingType": "Edm.Int32",

    + +

    "@Measures.Unit": "Centimeters"

    + +

    },

    + +

    "Weight": {

    + +

    "$Kind": "TypeDefinition",

    + +

    "$UnderlyingType": "Edm.Int32",

    + +

    "@Measures.Unit": "Kilograms"

    + +

    },

    + +

    "Size": {

    + +

    "$Kind": "ComplexType",

    + +

    "Height": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Length"

    + +

    },

    + +

    "Weight": {

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Weight"

    + +

    }

    + +

    }

    + +
    + +

    11.1 +Underlying Primitive Type

    + +

    The underlying type of a type definition MUST be a primitive +type that MUST NOT be another type definition.

    + + + +
    + +

    The value of $UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    The type definition MAY specify facets applicable to the +underlying type. Possible facets are: $MaxLength, $Unicode, +$Precision, $Scale, or $SRID.

    + +

    Additional facets appropriate for the underlying type MAY be +specified when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified.

    + +

    For a type definition with underlying type Edm.PrimitiveType +no facets are applicable, neither in the definition itself nor when the type +definition is used, and these should be ignored by the client.

    + +

    Where type definitions are used, the type definition is +returned in place of the primitive type wherever the type is specified in a +response.

    + + + +

    12.1 Action

    + +

    Actions are service-defined operations that MAY have +observable side effects and MAY return a single instance or a collection of +instances of any type.

    + +

    The actions name is a simple +identifier that MUST be unique within its schema.

    + +

    Actions cannot be composed with additional path segments.

    + +

    An action MAY specify a return +type that MUST be a primitive, entity or complex type, or a collection of +primitive, entity or complex types in scope.

    + +

    An action MAY define parameters +used during the execution of the action.

    + +

    12.2 +Action Overloads

    + +

    Bound +actions support overloading (multiple actions having the same name within the +same schema) by binding parameter type. The combination of action name and the +binding parameter type MUST be unique within a schema.

    + +

    Unbound +actions do not support overloads. The names of all unbound actions MUST be +unique within a schema.

    + +

    An unbound action MAY have the same name as a bound action.

    + + + +
    + +

    An action is represented as a member +of the schema object whose name is the unqualified name of the action and whose +value is an array. The array contains one object per action overload.

    + +

    The action overload object MUST +contain the member $Kind with a string value of Action.

    + +

    It MAY contain the members $IsBound, +$EntitySetPath, +$Parameter, +and $ReturnType, +and it MAY contain annotations.

    + +
    + +

    12.3 Function

    + +

    Functions are service-defined operations that MUST NOT have +observable side effects and MUST return a single instance or a collection of +instances of any type.

    + +

    The functions name is a simple +identifier that MUST be unique within its schema.

    + +

    Functions MAY be composable.

    + +

    The function MUST specify a return +type which MUST be a primitive, entity or complex type, or a collection of +primitive, entity or complex types in scope.

    + +

    A function MAY define parameters +used during the execution of the function.

    + +

    12.4 +Function Overloads

    + +

    Bound +functions support overloading (multiple functions having the same name within +the same schema) subject to the following rules:

    + +

             +The combination of function name, binding parameter type, and +unordered set of non-binding parameter names MUST be unique within a schema.

    + +

             +The combination of function name, binding parameter type, and +ordered set of parameter types MUST be unique within a schema.

    + +

             +All bound functions with the same function name and binding +parameter type within a schema MUST specify the same return type.

    + +

    Unbound +functions support overloading subject to the following rules:

    + +

             +The combination of function name and unordered set of parameter +names MUST be unique within a schema.

    + +

             +The combination of function name and ordered set of parameter +types MUST be unique within a schema.

    + +

             +All unbound functions with the same function name within a schema +MUST specify the same return type.

    + +

    An unbound +function MAY have the same name as a bound function.

    + +

    Note that type definitions +can be used to disambiguate overloads for both bound and unbound functions, +even if they specify the same underlying type.

    + + + +
    + +

    A function is represented as a member +of the schema object whose name is the unqualified name of the function and +whose value is an array. The array contains one object per function overload.

    + +

    The function overload object MUST +contain the member $Kind with a string value of Function.

    + +

    It MUST contain the member $ReturnType, +and it MAY contain the members $IsBound, +$EntitySetPath, +and $Parameter, and it MAY contain annotations.

    + +
    + +

    12.5 Bound or Unbound Action or +Function Overloads

    + +

    An action or function overload MAY indicate that it is +bound. If not explicitly indicated, it is unbound.

    + +

    Bound actions or functions are invoked on resources matching +the type of the binding parameter. The binding parameter can be of any type, +and it MAY be nullable.

    + +

    Unbound actions are invoked from the entity container through +an action import.

    + +

    Unbound functions are invoked as static functions within a +filter or orderby expression, or from the entity container through a function import.

    + +
    + +

    $IsBound

    + +
    + +
    + +

    The value of $IsBound +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    12.6 +Entity Set Path

    + +

    Bound actions and functions that return an entity or a +collection of entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter value.

    + +

    The entity set path consists of a series of segments joined +together with forward slashes.

    + +

    The first segment of the entity set path MUST be the name of +the binding parameter. The remaining segments of the entity set path MUST +represent navigation segments or type casts.

    + +

    A navigation segment names the simple identifier of the navigation property to be traversed. A +type-cast segment names the qualified name of +the entity type that should be returned from the type cast.

    + + + +
    + +

    The value of $EntitySetPath +is a string containing the entity set path.

    + +
    + +

    12.7 +Composable Function

    + +

    A function MAY indicate that it is composable. If not +explicitly indicated, it is not composable.

    + +

    A composable function can be invoked with additional path +segments or key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for the type +returned by the composable function.

    + + + +
    + +

    The value of $IsComposable +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + +

    12.8 +Return Type

    + +

    The return type of an action or function overload MAY be any +type in scope, or a collection of any type in scope.

    + +

    The facets Nullable, MaxLength, Precision, Scale, and SRID can be used as appropriate to +specify value restrictions of the return type, as well as the Unicode +facet for 4.01 and greater payloads.

    + +

    For a single-valued return type the facets apply to the +returned value. For a collection-valued return type the facets apply to the +items in the returned collection.

    + +
    + +

    $ReturnType

    + +
    + +
    + +

    The value of $ReturnType +is an object. It MAY contain the members $Type, +$Collection, $Nullable, $MaxLength, $Unicode, $Precision, $Scale, and $SRID.

    + +

    It also MAY contain annotations.

    + +
    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued return types the +value of $Type is the qualified name of the +returned type.

    + +

    For collection-valued return types the +value of $Type is the qualified name of the +returned item type, and the member $Collection MUST +be present with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String.

    + +
    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +

    If the return +type is a collection of entity types, the $Nullable +member has no meaning and MUST NOT be specified.

    + +

    For other collection-valued return +types the result will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +

    For single-valued return types the +value true means that the action or function MAY +return a single null value. The value false means that the action or function will never return +a null value and instead will fail with an error +response if it cannot compute a result.

    + +
    + +

    12.9 Parameter

    + +

    An action or function overload MAY specify parameters.

    + +

    A bound action or function overload MUST specify at least +one parameter; the first parameter is its binding parameter. The order of parameters +MUST NOT change unless the schema version changes.

    + +

    Each parameter MUST have a name that is a simple identifier. The parameter name MUST be +unique within the action or function overload.

    + +

    The parameter MUST specify a type. It MAY be any type in +scope, or a collection of any type in scope.

    + +

    The facets MaxLength, Precision, Scale, or SRID can be used as appropriate to +specify value restrictions of the parameter, as well as the Unicode +facet for 4.01 and greater payloads.

    + +

    For single-valued parameters the facets apply to the +parameter value. If the parameter value is a collection, the facets apply to +the items in the collection.

    + +
    + +

    $Parameter

    + +
    + +
    + +

    The value of $Parameter +is an array. The array contains one object per parameter.

    + +
    + + + +
    + +

    A parameter object MUST contain the +member $Name, and it MAY contain +the members $Type, $Collection, $Nullable, $MaxLength, $Unicode, $Precision, $Scale, and $SRID.

    + +

    Parameter objects MAY also contain annotations.

    + +
    + +
    + +

    $Name

    + +
    + +
    + +

    The value of $Name +is a string containing the parameter name.

    + +
    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued parameters the value +of $Type is the qualified name of the accepted +type.

    + +

    For collection-valued parameters the +value of $Type is the qualified name of the +accepted item type, and the member $Collection MUST +be present with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String.

    + +
    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.

    + +

    For single-valued parameters the value +true means that the parameter accepts a null value.

    + +

    For collection-valued parameters the +parameter value will always be a collection that MAY be empty. In this case $Nullable applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +
    + +

    Example 30: a function returning the top-selling products +for a given year. In this case the year must be specified as a parameter of the +function with the edm:Parameter element.

    + +
    + +

    "TopSellingProducts": [

    + +

    {

    + +

    "$Kind": "Function",

    + +

    "$Parameter": [

    + +

    {

    + +

    "$Name": "Year",

    + +

    "$Nullable": true,

    + +

    "$Type": "Edm.Decimal",

    + +

    "$Precision": 4,

    + +

    "$Scale": 0

    + +

    }

    + +

    ],

    + +

    "$ReturnType": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product"

    + +

    }

    + +

    }

    + +

    ]

    + +
    + + + +

    Each metadata document used to describe an OData service +MUST define exactly one entity container.

    + +

    The entity containers name is a simple identifier that MUST be unique within +its schema.

    + +

    Entity containers define the entity sets, singletons, +function and action imports exposed by the service.

    + +

    Entity set, singleton, action import, and function import +names MUST be unique within an entity container.

    + +

    An entity +set allows access to entity type instances. Simple entity models +frequently have one entity set per entity type.

    + +

    Example 31: one entity set per entity type

    + +
    + +

    "Products": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product"

    + +

    },

    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category"

    + +

    }

    + +
    + +

    Other entity models may +expose multiple entity sets per type.

    + +

    Example 32: three entity sets referring to the two entity +types

    + +
    + +

    "StandardCustomers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Customer",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Orders": "Orders"

    + +

    }

    + +

    },

    + +

    "PreferredCustomers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Customer",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Orders": "Orders"

    + +

    }

    + +

    },

    + +

    "Orders": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Order"

    + +

    }

    + +
    + +

    There are separate entity sets for standard customers and +preferred customers, but only one entity set for orders. The entity sets for standard +customers and preferred customers both have navigation property bindings to the +orders entity set, but the orders entity set does not have a navigation +property binding for the Customer navigation property, since it could lead to +either set of customers.

    + +

    An entity set can expose instances of the specified entity +type as well as any entity type inherited from the specified entity type.

    + +

    A singleton allows +addressing a single entity directly from the entity container without having to +know its key, and without requiring an entity set.

    + +

    A function import or an action import is used to expose a function +or action defined in an entity model as a top level resource.

    + + + +
    + +

    An entity container is represented as +a member of the schema object whose name is the unqualified name of the entity +container and whose value is an object.

    + +

    The entity container object MUST +contain the member $Kind with a string value of EntityContainer.

    + +

    The entity container object MAY +contain the member $Extends, members representing entity sets, singletons, +action imports, and function imports, as well as annotations.

    + +
    + +

    Example 33: An entity container aggregates entity sets, +singletons, action imports, and function imports.

    + +
    + +

    "DemoService": {

    + +

    "$Kind": +"EntityContainer",

    + +

    "Products": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Category": "Categories",

    + +

    "Supplier": +"Suppliers"

    + +

    },

    + +

    "@UI.DisplayName": +"Product Catalog"

    + +

    },

    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products"

    + +

    }

    + +

    },

    + +

    "Suppliers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Supplier",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Products": "Products"

    + +

    },

    + +

    "@UI.DisplayName": +"Supplier Directory"

    + +

    },

    + +

    "MainSupplier": {

    + +

    "$Type": "self.Supplier"

    + +

    },

    + +

    "LeaveRequestApproval": {

    + +

    "$Action": "self.Approval"

    + +

    },

    + +

    "ProductsByRating": {

    + +

    "$EntitySet": +"Products",

    + +

    "$Function": "self.ProductsByRating"

    + +

    }

    + +

    }

    + +
    + +

    13.1 +Extending an Entity Container

    + +

    An entity container MAY specify that it extends another +entity container in scope. All children of the base entity container are +added to the extending entity container.

    + +

    If the extending entity container defines an entity set +with the same name as defined in any of its base containers, then the entity +sets type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the base container. The same holds +for singletons. Action imports and function imports cannot be redefined, nor +can the extending container define a child with the same name as a child of a +different kind in a base container.

    + +

    Note: services should not introduce cycles by extending +entity containers. Clients should be prepared to process cycles introduced by +extending entity containers.

    + +
    + +

    $Extends

    + +
    + +
    + +

    The value of $Extends +is the qualified name of the entity container to be extended.

    + +
    + +

    Example 34: the entity +container Extending will contain all child elements +that it defines itself, plus all child elements of the Base +entity container located in SomeOtherSchema

    + +
    + +

    "Extending": {

    + +

    "$Kind": +"EntityContainer",

    + +

    "$Extends": "Some.Other.Schema.Base",

    + +

    + +

    }

    + +
    + +

    13.2 Entity +Set

    + +

    Entity sets are top-level collection-valued resources.

    + +

    An entity set is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An entity set MUST specify a type that MUST be an entity +type in scope.

    + +

    An entity set MUST contain only instances of its specified +entity type or its subtypes. The entity type MAY be abstract but MUST have a key +defined.

    + +

    An entity set MAY indicate whether it is included in the +service document. If not explicitly indicated, it is included.

    + +

    Entity sets that cannot be queried without specifying +additional query options SHOULD NOT be included in the service document.

    + + + +
    + +

    An entity set is represented as a +member of the entity container object whose name is the name of the entity set +and whose value is an object.

    + +

    The entity set object MUST contain the +members $Collection and $Type.

    + +

    It MAY contain the members $IncludeInServiceDocument and $NavigationPropertyBinding +as well as annotations.

    + +
    + +
    + +

    $Collection

    + +
    + +
    + +

    The value of $Collection +is the Booelan value true.

    + +
    + +
    + +

    $Type

    + +
    + +
    + +

    The value of $Type +is the qualified name of an entity type.

    + +
    + + + +
    + +

    The value of $IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the member means true.

    + +
    + +

    13.3 +Singleton

    + +

    Singletons are top-level single-valued resources.

    + +

    A singleton is identified by its name, a simple identifier that MUST be unique within its +entity container.

    + +

    A singleton MUST specify a type that MUST be an entity type +in scope.

    + +

    A singleton MUST reference an instance its entity type.

    + + + +
    + +

    A singleton is represented as a member +of the entity container object whose name is the name of the singleton and +whose value is an object.

    + +

    The singleton object MUST contain the +member $Type and it MAY contain the member $Nullable.

    + +

    It MAY contain the member $NavigationPropertyBinding +as well as annotations.

    + +
    + +
    + +

    $Type

    + +
    + +
    + +

    The value of $Type +is the qualified name of an entity type.

    + +
    + +
    + +

    $Nullable

    + +
    + +
    + +

    The value of $Nullable +is one of the Boolean literals true or false. Absence of the member means false.In +OData 4.0 responses this member MUST NOT be specified.

    + +
    + +

    13.4 +Navigation Property Binding

    + +

    If the entity type of an entity set or singleton declares +navigation properties, a navigation property binding allows describing which +entity set or singleton will contain the related entities.

    + +

    An entity set or a singleton SHOULD specify a navigation property +binding for each navigation property of +its entity type, including navigation properties defined on complex typed +properties or derived types.

    + +

    If omitted, clients MUST assume that the target entity set +or singleton can vary per related entity.

    + +

    13.4.1 +Navigation Property Path +Binding

    + +

    A navigation property binding MUST specify a path to a +navigation property of the entity sets or singleton's declared entity type, or +a navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation property is +defined on a subtype, the path MUST contain the qualified +name of the subtype, followed by a forward slash, followed by the +navigation property name. If the navigation property is defined on a complex +type used in the definition of the entity sets entity type, the path MUST +contain a forward-slash separated list of complex property names and qualified +type names that describe the path leading to the navigation property.

    + +

    The path can traverse one or more containment navigation +properties, but the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment.

    + +

    If the path traverses collection-valued complex properties +or collection-valued containment navigation properties, the binding applies to +all items of these collections.

    + +

    If the path contains a recursive sub-path (i.e. a path +leading back to the same structured type, the binding applies recursively to +any positive number of cycles through that sub-path.

    + +

    OData 4.01 services MAY have a type-cast segment as the last +path segment, allowing to bind instances of different sub-types to different +targets.

    + +

    The same navigation property path MUST NOT be specified in +more than one navigation property binding; navigation property bindings are +only used when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths that +differ only in a type-cast segment, allowing to bind instances of different +sub-types to different targets. If paths differ only in type-cast segments, the +most specific path applies.

    + +

    13.4.2 +Binding Target

    + +

    A navigation property binding MUST specify a target via a simple identifier or target +path. It specifies the entity set, +singleton, or containment navigation property that contains the related +entities.

    + +

    If the target is a simple +identifier, it MUST resolve to an entity set or singleton defined in the +same entity container.

    + +

    If the target is a target path, +it MUST resolve to an entity set, singleton, or direct or indirect containment +navigation property of a singleton in scope. The path can traverse +single-valued containment navigation properties or single-valued complex +properties before ending in a containment navigation property, and there MUST +NOT be any non-containment navigation properties prior to the final segment.

    + + + +
    + +

    The value of $NavigationPropertyBinding +is an object. It consists of members whose name is the navigation property +binding path and whose value is a string containing the navigation property +binding target. If the target is in the same entity container, the target MUST +NOT be prefixed with the qualified entity container name.

    + +
    + +

    Example 35: for an entity set in the same container as the +enclosing entity set Categories

    + +
    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"SomeSet"

    + +

    }

    + +

    }

    + +
    + +

    Example 36: for an entity set in any container in scope

    + +
    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Products": +"SomeModel.SomeContainer/SomeSet"

    + +

    }

    + +

    }

    + +
    + +

    Example 37: binding Supplier on Products +contained within Categories binding applies to all suppliers of +all products of all categories

    + +
    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    +"$NavigationPropertyBinding": {

    + +

    "Products/Supplier": +"Suppliers"

    + +

    }

    + +

    }

    + +
    + +

    13.5 Action Import

    + +

    Action imports sets are top-level resources that are never +included in the service document.

    + +

    An action import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An action import MUST specify the name of an unbound action +in scope.

    + +

    If the imported action returns an entity or a collection of +entities, a simple identifier or target path value MAY be specified to identify the +entity set that contains the returned entities. If a simple identifier is specified, it MUST +resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an +entity set in scope.

    + + + +
    + +

    An action import is represented as a +member of the entity container object whose name is the name of the action +import and whose value is an object.

    + +

    The action import object MUST contain +the member $Action.

    + +

    It MAY contain the member $EntitySet.

    + +

    It MAY also contain annotations.

    + +
    + +
    + +

    $Action

    + +
    + +
    + +

    The value of $Action +is a string containing the qualified name of an unbound action.

    + +
    + +
    + +

    $EntitySet

    + +
    + +
    + +

    The value of $EntitySet +is a string containing either the unqualified name of an entity set in the same +entity container or a path to an entity set in a different entity container.

    + +
    + +

    13.6 +Function Import

    + +

    Function imports sets are top-level resources.

    + +

    A function import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    A function import MUST specify the name of an unbound +function in scope. All unbound +overloads of the imported function can be invoked from the entity +container.

    + +

    If the imported function returns an entity or a collection +of entities, a simple identifier or target path value MAY be specified to identify the +entity set that contains the returned entities. If a simple identifier is specified, it MUST +resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an +entity set in scope.

    + +

    A function import for a parameterless function MAY indicate +whether it is included in the service document. If not explicitly indicated, it +is not included.

    + + + +
    + +

    A function import is represented as a +member of the entity container object whose name is the name of the function +import and whose value is an object.

    + +

    The function import object MUST +contain the member $Function.

    + +

    It MAY contain the members $EntitySet and $IncludeInServiceDocument.

    + +

    It MAY also contain annotations.

    + +
    + +
    + +

    $Function

    + +
    + +
    + +

    The value of $Function +is a string containing the qualified name of an unbound function.

    + +
    + +
    + +

    $EntitySet

    + +
    + +
    + +

    The value of $EntitySet +is a string containing either the unqualified name of an entity set in the same +entity container or a path to an entity set in a different entity container.

    + +
    + + + +
    + +

    The value of $IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the member means false.

    + +
    + + + +

    Vocabularies and annotations provide the ability to annotate +metadata as well as instance data, and define a powerful extensibility point +for OData. An annotation applies a term to a +model element and defines how to calculate a value for the applied term.

    + +

    Metadata annotations are terms applied to model +elements. Behaviors or constraints described by a metadata annotation must be +consistent with the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity type, +property, function, action, or parameter. For example, a metadata annotation +may define ranges of valid values for a particular property. Metadata +annotations are applied in CSDL documents describing or referencing an entity +model.

    + +

    Instance annotations are terms applied to a +particular instance within an OData payload, such as described in [OData‑JSON]. An instance annotation can be +used to define additional information associated with a particular result, +entity, property, or error. For example, whether a property is read-only for a +particular instance. Where the same annotation is defined at both the metadata +and instance level, the instance-level annotation overrides the annotation +specified at the metadata level. Annotations that apply across instances should +be specified as metadata annotations.

    + +

    A vocabulary is a schema containing a set of terms +where each term is a named metadata extension. Anyone +can define a vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary [OData-VocCore].

    + +

    A term can be used to:

    + +

             +Extend model elements and type instances with additional +information.

    + +

             +Map instances of annotated structured types to an interface +defined by the term type; i.e. annotations allow viewing instances of a +structured type as instances of a differently structured type specified by the +applied term.

    + +

    A service SHOULD NOT require a client to interpret +annotations. Clients SHOULD ignore invalid or unknown terms and silently treat unexpected +or invalid values (including invalid type, invalid literal expression, invalid +targets, etc.) as an unknown value for the term. Unknown or invalid annotations +should never result in an error, as long as the payload remains well-formed.

    + +

    Example 38: the Product entity type is extended with a DisplayName by a metadata annotation +that binds the term DisplayName to the value of the property Name. The Product +entity type also includes an annotation that allows its instances to be viewed +as instances of the type specified by the term SearchResult

    + +
    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "Description": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "@UI.DisplayName": {

    + +

    "$Path": +"Name"

    + +

    },

    + +

    +"@SearchVocabulary.SearchResult": {

    + +

    "Title": {

    + +

    "$Path": +"Name"

    + +

    },

    + +

    "Abstract": {

    + +

    "$Path": +"Description"

    + +

    },

    + +

    "Url": {

    + +

    "$Apply": [

    + +

    "Products(",

    + +

    {

    + +

    "$Path": +"ID"

    + +

    },

    + +

    ")"

    + +

    ],

    + +

    "$Function": +"odata.concat"

    + +

    }

    + +

    }

    + +

    }

    + +
    + +

    14.1 Term

    + +

    A term allows annotating a model element or OData resource +representation with additional data.

    + +

    The terms name is a simple +identifier that MUST be unique within its schema.

    + +

    The terms type MUST be a type in scope, or a collection of a +type in scope.

    + +
    + +

    Term Object

    + +
    + +
    + +

    A term is represented as a member of +the schema object whose name is the unqualified name of the term and whose +value is an object.

    + +

    The term object MUST contain the +member $Kind with a string value of Term.

    + +

    It MAY contain the members $Type, $Collection, +$AppliesTo, +$Nullable, +$MaxLength, +$Precision, +$Scale, +$SRID, +and $DefaultValue, as well as $Unicode +for 4.01 and greater payloads.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Type and $Collection

    + +
    + +
    + +

    For single-valued terms the value of $Type is the qualified name of the terms type.

    + +

    For collection-valued terms the value +of $Type is the qualified name of the terms item +type, and the member $Collection MUST be present +with the literal value true.

    + +

    Absence of the $Type +member means the type is Edm.String.

    + +
    + + + +
    + +

    The value of $DefaultValue +is the type-specific JSON representation of the default value of the term, see [OData-JSON].

    + +

    Note: the $DefaultValue +member is purely for documentation and isomorphy to [OData-CSDLXML]. +Annotations in CSDL JSON documents MUST always specify an explicit value.

    + +
    + +

    14.1.1 +Specialized Term

    + +

    A term MAY specialize another term in scope by specifying it +as its base term.

    + +

    When applying a specialized term, the base term MUST also be +applied with the same qualifier, and so on until a term without a base term is +reached.

    + +
    + +

    $BaseTerm

    + +
    + +
    + +

    The value of $BaseTerm +is the qualified name of the base term.

    + +
    + +

    14.1.2 Applicability

    + +

    The applicability of a term MAY be restricted to a list of +model elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be extended in +future versions of the vocabulary. As the intended usage may evolve over time, +clients SHOULD be prepared for any term to be applied to any model element and +SHOULD be prepared to handle unknown values within the list of model +constructs. Applicability is expressed using the following symbolic values:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Symbolic Value

    +
    +

    Model Element

    +
    +

    Action

    +
    +

    Action

    +
    +

    ActionImport

    +
    +

    Action Import

    +
    +

    Annotation

    +
    +

    Annotation

    +
    +

    Apply

    +
    +

    Application of a client-side function in an annotation

    +
    +

    Cast

    +
    +

    Type Cast annotation expression

    +
    +

    Collection

    +
    +

    Entity Set or collection-valued Property or Navigation + Property

    +
    +

    ComplexType

    +
    +

    Complex Type

    +
    +

    EntityContainer

    +
    +

    Entity Container

    +
    +

    EntitySet

    +
    +

    Entity Set

    +
    +

    EntityType

    +
    +

    Entity Type

    +
    +

    EnumType

    +
    +

    Enumeration Type

    +
    +

    Function

    +
    +

    Function

    +
    +

    FunctionImport

    +
    +

    Function Import

    +
    +

    If

    +
    +

    Conditional annotation expression

    +
    +

    Include

    +
    +

    Reference to an Included Schema

    +
    +

    IsOf

    +
    +

    Type Check annotation expression

    +
    +

    LabeledElement

    +
    +

    Labeled Element expression

    +
    +

    Member

    +
    +

    Enumeration Member

    +
    +

    NavigationProperty

    +
    +

    Navigation Property

    +
    +

    Null

    +
    +

    Null annotation expression

    +
    +

    OnDelete

    +
    +

    On-Delete Action of a navigation property

    +
    +

    Parameter

    +
    +

    Action of Function Parameter

    +
    +

    Property

    +
    +

    Property of a structured type

    +
    +

    PropertyValue

    +
    +

    Property value of a Record annotation expression

    +
    +

    Record

    +
    +

    Record annotation expression

    +
    +

    Reference

    +
    +

    Reference to another CSDL document

    +
    +

    ReferentialConstraint

    +
    +

    Referential Constraint of a navigation property

    +
    +

    ReturnType

    +
    +

    Return Type of an Action or Function

    +
    +

    Schema

    +
    +

    Schema

    +
    +

    Singleton

    +
    +

    Singleton

    +
    +

    Term

    +
    +

    Term

    +
    +

    TypeDefinition

    +
    +

    Type Definition

    +
    +

    UrlRef

    +
    +

    UrlRef annotation expression

    +
    + +
    + +

    $AppliesTo

    + +
    + +
    + +

    The value of $AppliesTo +is an array whose items are strings containing symbolic values from the table +above that identify model elements the term is intended to be applied to.

    + +
    + +

    Example 39: the IsURL term can +be applied to properties and terms that are of type Edm.String +(the Core.Tag type and the two Core terms +are defined in [OData‑VocCore])

    + +
    + +

    "IsURL": {

    + +

    "$Kind": "Term",

    + +

    "$Type": "Core.Tag",

    + +

    "$DefaultValue": true,

    + +

    "$AppliesTo": [

    + +

    "Property"

    + +

    ],

    + +

    "@Core.Description": "Properties and terms +annotated with this term MUST contain a valid URL",

    + +

    "@Core.RequiresType": "Edm.String"

    + +

    }

    + +
    + +

    14.2 Annotation

    + +

    An annotation applies a term to a model element and defines how to calculate a +value for the term application. Both term and model element MUST be in scope. +Section 14.1.2 specifies which model elements MAY be annotated with a term.

    + +

    The value of an annotation is specified as an annotation +expression, which is either a constant +expression representing a constant value, or a dynamic expression. The most common construct for assigning an +annotation value is a path expression that refers to a property of the same or a related +structured type.

    + + + +
    + +

    An annotation is represented as a +member whose name consists of an at (@) character, +followed by the qualified name of a term, optionally followed by a hash (#) and a qualifier.

    + +

    The value of the annotation MUST be a constant expression or dynamic expression.

    + +

    The annotation can be a member of the +object representing the model element it annotates, or a second-level member of +the $Annotations member of a schema object.

    + +

    An annotation can itself be annotated. +Annotations on annotations are represented as a member whose name consists of +the annotation name (including the optional qualifier), followed by an at (@) character, followed by the qualified name of a term, optionally followed by a hash (#) and a qualifier.

    + +
    + +

    Example 40: term Measures.ISOCurrency, +once applied with a constant value, once with a path value

    + +
    + +

    "AmountInReportingCurrency": +{

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0,

    + +

    "@Measures.ISOCurrency": +"USD",

    + +

    "@Measures.ISOCurrency@Core.Description": +"The parent companys currency"

    + +

    },

    + +

    "AmountInTransactionCurrency": +{

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "$Scale": 0,

    + +

    "@Measures.ISOCurrency": {

    + +

    "$Path": +"Currency"

    + +

    }

    + +

    },

    + +

    "Currency": {

    + +

    "$Nullable": true,

    + +

    "$MaxLength": 3

    + +

    }

    + +
    + +

    If an entity type or complex type is annotated with a term +that itself has a structured type, an instance of the annotated type may be +viewed as an instance of the term, and the qualified term name may be used as +a term-cast segment in path expressions.

    + +

    Structured types inherit annotations from their direct or +indirect base types. If both the type and one of its base types is annotated +with the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or collection-valued +annotation values are not merged. Similarly, properties of a structured type +inherit annotations from identically named properties of a base type.

    + +

    It is up to the definition of a term to specify whether and +how annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a "Label" +annotation for a UI can propagate from a type definition to all properties +using that type definition and may be overridden at each property with a more +specific label, whereas an annotation marking a type definition as containing a +phone number will propagate to all using properties but may not be overridden.

    + +

    14.2.1 Qualifier

    + +

    A term can be applied multiple times to the same model +element by providing a qualifier to distinguish the annotations. The qualifier +is a simple identifier.

    + +

    The combination of target model +element, term, and qualifier uniquely identifies an annotation.

    + +

    Example 41: annotation should only be applied to tablet +devices

    + +
    + +

    "@UI.DisplayName#Tablet": {

    + +

    "$Path": +"FirstName"

    + +

    }

    + +
    + +

    14.2.2 Target

    + +

    The target of an annotation is the model element the term is +applied to.

    + +

    The target of an annotation MAY be specified indirectly by +nesting the annotation within the model element. Whether and how this is +possible is described per model element in this specification.

    + +

    The target of an annotation MAY also be specified directly; +this allows defining an annotation in a different schema than the targeted +model element.

    + +

    This external targeting is only possible for model elements that are uniquely identified within +their parent, and all their ancestor elements are uniquely identified within +their parent:

    + + + +

    These are the +direct children of a schema with a unique name (i.e. except actions and +functions whose overloads to not possess a natural identifier), and all direct +children of an entity container.

    + +

    External targeting is possible for +actions, functions, their parameters, and their return type, either in a way that applies to all overloads of the +action or function or all parameters of that name across all overloads, or in a way that identifies a single overload.

    + +

    External +targeting is also possible for properties and navigation properties of +singletons or entities in a particular entity set. These annotations override +annotations on the properties or navigation properties targeted via the +declaring structured type.

    + +

    The allowed path +expressions are:

    + +

             +qualified +name of schema child

    + +

             +qualified +name of schema child followed +by a forward slash and name of child element

    + +

             +qualified +name of structured type followed +by zero or more property, navigation property, or type-cast segments, each +segment starting with a forward slash

    + +

             +qualified +name of an entity +container followed by a segment containing a singleton or entity set name and +zero or more property, navigation property, or type-cast segments

    + +

             +qualified +name of an action +followed by parentheses containing the qualified name of the binding parameter type of a bound action +overload to identify that bound overload, or by empty parentheses to identify +the unbound overload

    + +

             +qualified +name of a function +followed by parentheses containing the comma-separated list of qualified names of the parameter types of a bound +or unbound function overload in the order of their definition in the function +overload

    + +

             +qualified +name of an action or +function, optionally followed by parentheses as described in the two previous +bullet points to identify a single overload, followed by a forward slash and +either a parameter name or $ReturnType

    + +

             +qualified +name of an entity +container followed by a segment containing an action or function import name, +optionally followed by a forward slash and either a parameter name or $ReturnType

    + +
      +
    • One of the + preceding, followed by a forward slash, an at (@), the qualified name of a term, and optionally a hash (#) and the + qualifier of an annotation
    • +
    + +

    All qualified names used in a target path MUST be in scope.

    + +

    Example 42: Target expressions

    + +
    + +

    MySchema.MyEntityType

    + +

    MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityType/MyNavigationProperty

    + +

    MySchema.MyComplexType

    + +

    MySchema.MyComplexType/MyProperty

    + +

    MySchema.MyComplexType/MyNavigationProperty

    + +

    MySchema.MyEnumType

    + +

    MySchema.MyEnumType/MyMember

    + +

    MySchema.MyTypeDefinition

    + +

    MySchema.MyTerm

    + +

    MySchema.MyEntityContainer

    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MyActionImport

    + +

    MySchema.MyEntityContainer/MyFunctionImport

    + +

    MySchema.MyAction

    + +

    MySchema.MyAction(MySchema.MyBindingType)

    + +

    MySchema.MyAction()

    + +

    MySchema.MyFunction

    + +

    MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType)

    + +

    MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType)

    + +

    MySchema.MyFunction/MyParameter

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty

    + +
    + +

    14.3 +Constant Expression

    + +

    Constant expressions allow assigning a constant value to an +applied term.

    + +

    14.3.1 Binary

    + +
    + +

    Binary expressions are represented as +a string containing the base64url-encoded binary value.

    + +
    + +

    Example 43: base64url-encoded binary value (OData)

    + +
    + +

    "@UI.Thumbnail": +"T0RhdGE"

    + +
    + +

    14.3.2 Boolean

    + +
    + +

    Boolean expressions are represented as +the literals true or false.

    + +
    + +

    Example 44:

    + +
    + +

    "@UI.ReadOnly": true

    + +
    + +

    14.3.3 Date

    + +
    + +

    Date expressions are represented as a +string containing the date value. The value MUST conform to type xs:date, see [XML‑Schema‑2], +section 3.3.9. The value +MUST also conform to rule dateValue in [OData‑ABNF], i.e. it MUST NOT contain a +time-zone offset.

    + +
    + +

    Example 45:

    + +
    + +

    "@vCard.birthDay": +"2000-01-01"

    + +
    + +

    14.3.4 +DateTimeOffset

    + +
    + +

    Datetimestamp expressions are +represented as a string containing the timestamp value. The value MUST conform +to type xs:dateTimeStamp, see [XML‑Schema‑2], section 3.4.28. +The value MUST also conform to rule dateTimeOffsetValue +in [OData‑ABNF], i.e. it MUST NOT contain an +end-of-day fragment (24:00:00).

    + +
    + +

    Example 46:

    + +
    + +

    "@UI.LastUpdated": +"2000-01-01T16:00:00.000Z"

    + +
    + +

    14.3.5 Decimal

    + +
    + +

    Decimal expressions are represented as +either a number or a string. The special values INF, +-INF, or NaN are +represented as strings. Numeric values are represented as numbers or strings +depending on the media type parameter IEEE754Compatible.

    + +
    + +

    Example 47: default representation as a number

    + +
    + +

    "@UI.Width": 3.14

    + +
    + +

    Example 48: safe +representation as a string

    + +
    + +

    "@UI.Width": +"3.14"

    + +
    + +

    14.3.6 Duration

    + +
    + +

    Duration expressions are represented +as a string containing the duration value. The value MUST conform to type xs:dayTimeDuration, see [XML‑Schema‑2], +section 3.4.27.

    + +
    + +

    Example 49:

    + +
    + +

    "@task.duration": +"P7D"

    + +
    + +

    14.3.7 +Enumeration Member

    + +
    + +

    Enumeration member expressions are +represented as a string containing the numeric or symbolic enumeration value.

    + +
    + +

    Example 50: single value Red +with numeric value and symbolic value

    + +
    + +

    "@self.HasPattern": "1"

    + +
    + +

     

    + +
    + +

    "@self.HasPattern": "Red"

    + +
    + +

    Example 51: combined value Red,Striped +with numeric value 1 + 16 and symbolic value

    + +
    + +

    "@self.HasPattern": "17"

    + +
    + +

     

    + +
    + +

    "@self.HasPattern": "Red,Striped"

    + +
    + +

    14.3.8 Floating-Point Number

    + +
    + +

    Floating-point expressions are +represented as a number or as a string containing one of the special values INF, -INF, or NaN.

    + +
    + +

    Example 52:

    + +
    + +

    "@UI.FloatWidth": 3.14

    + +
    + +

     

    + +
    + +

    "@UI.FloatWidth": +"INF"

    + +
    + +

    14.3.9 Guid

    + +
    + +

    Guid expressions are represented as a +string containing the uuid value. The value MUST conform to the rule guidValue in [OData‑ABNF].

    + +
    + +

    Example 53:

    + +
    + +

    "@UI.Id": "21EC2020-3AEA-1069-A2DD-08002B30309D"

    + +
    + +

    14.3.10 Integer

    + +
    + +

    Integer expressions are represented as +either a number or a string, depending on the media type parameter IEEE754Compatible.

    + +
    + +

    Example 54: default representation as a number

    + +
    + +

    "@An.Int": 42

    + +
    + +

    Example 55: safe +representation as a string

    + +
    + +

    "@A.Very.Long.Int": +"9007199254740992"

    + +
    + +

    14.3.11 String

    + +
    + +

    String expressions are represented as +a JSON string.

    + +
    + +

    Example 56:

    + +
    + +

    "@UI.DisplayName": +"Product Catalog"

    + +
    + +

    14.3.12 +Time of Day

    + +
    + +

    Time-of-day expressions are +represented as a string containing the time-of-day value. The value MUST +conform to the rule timeOfDayValue in [OData‑ABNF].

    + +
    + +

    Example 57:

    + +
    + +

    "@UI.EndTime": "21:45:00"

    + +
    + +

    14.4 +Dynamic Expression

    + +

    Dynamic expressions allow assigning a calculated value to an +applied term.

    + +

    14.4.1 Path Expressions

    + +

    Path expressions allow +assigning a value to an applied term or term component. There are two kinds of +path expressions:

    + +

             +A +model path is used within Annotation +Path, Model Element Path, Navigation Property Path, and Property Path expressions to traverse the model of +a service and resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the built-in types Edm.AnnotationPath, Edm.NavigationPropertyPath, +Edm.PropertyPath, and their base types Edm.AnyPropertyPath and Edm.ModelElementPath.

    + +

             +An instance path is used within a Value +Path expression to traverse a graph of type instances and resolves to the +value identified by the path. It allows assigning values to terms or term +properties of built-in types other than the Edm.*Path +types, or of any model-defined type.

    + +

    14.4.1.1 Path Syntax

    + +

    Model paths and instance paths share a common syntax which +is derived from the path expression syntax of URLs, see [OData‑URL].

    + +

    A path MUST be composed of zero or more path segments joined +together by forward slashes (/).

    + +

    Paths starting with a forward slash (/) +are absolute paths, and the first path segment MUST be the qualified name of a +model element, e.g. an entity container. The remaining path after the second +forward slash is interpreted relative to that model element.

    + +

    Example 58: absolute path to an entity set

    + +
    + +

    /My.Schema.MyEntityContainer/MyEntitySet

    + +
    + +

    Paths not starting with a forward slash are interpreted +relative to the annotation target, following the rules specified in section Path Evaluation.

    + +

    Example 59: relative path to a property

    + +
    + +

    Address/City

    + +
    + +

    If a path segment is a qualified +name, it represents a type cast, and the +segment MUST be the name of a type in scope. If the type or instance identified +by the preceding path part cannot be cast to the specified type, the path +expression evaluates to the null value.

    + +

    Example 60: type-cast segment

    + +
    + +

    /self.Manager/

    + +
    + +

    If a path segment starts with an at (@) +character, it represents a term cast. The at +(@) character MUST be followed by a qualified name that +MAY be followed by a hash (#) character and a simple identifier. The qualified name preceding +the hash character MUST resolve to a term that is in scope, the simple identifier following +the hash sign is interpreted as a qualifier for +the term. If the model element or instance identified by the preceding path +part has not been annotated with that term (and if present, with that +qualifier), the term cast evaluates to the null value. Four special terms are implicitly +annotated for media entities and stream properties:

    + +
      +
    • odata.mediaEditLink
    • +
    • odata.mediaReadLink
    • +
    • odata.mediaContentType
    • +
    • odata.mediaEtag
    • +
    + +

    Example 61: term-cast segments

    + +
    + +

    /@Capabilities.SortRestrictions/

    + +
    + +

    If a path segment is a simple +identifier, it MUST be the name of a child model element of the model +element identified by the preceding path part, or a structural or navigation +property of the instance identified by the preceding path part. A sequence of +navigation segments can traverse multiple CSDL documents. The document +containing the path expression only needs to reference the next traversed +document to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document.

    + +

    A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path.

    + +

    Example 62: property segments in model path

    + +
    + +

    /Orders/Items/Product/

    + +
    + +

    An instance path MUST NOT contain +more than one segment representing a collection-valued construct, e.g. an +entity set or a collection-valued navigation property that is not followed by a +key predicate, or a collection-valued structural +property that is not followed by an index segment. The result of the +expression is the collection of instances resulting from applying any remaining +path segments that operate on a single-valued expression to each instance in +the collection-valued segment.

    + +

    An instance path MAY +terminate in a $count segment if the previous +segment is collection-valued, in which case the path evaluates to the number of +items in the collection identified by the preceding segment.

    + +

    Example 63: property segments in instance path

    + +
    + +

    /Addresses/Street

    + +

    /Addresses/$count

    + +
    + +

    A model path MAY contain path segments starting with a +navigation property, then followed by an at (@) +character, then followed by the qualified name of a term in scope, and optionally followed by a +hash (#) character and a simple identifier which is interpreted as a qualifier for the term. If the navigation property +has not been annotated with that term (and if present, with that qualifier), +the path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity type +specified by the navigation property are addressed via a term-cast +segment.

    + +

    Example 64: model path addressing an annotation on a +navigation property

    + +
    + +

    /Items@Capabilities.InsertRestrictions/Insertable

    + +
    + +

    An instance path MAY contain path segments starting with an +entity set or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see [OData‑URL]. +The key values are either primitive literals or instance paths. If the key +value is a relative instance path, it is interpreted according to the same rule +below as the instance path it is part of, not relative to the instance +identified by the preceding path part.

    + +

    Example 65: instance path with entity set and key predicate

    + +
    + +

    /self.container/SettingsCollection('FeatureXxx')/IsAvailable +

    + +

    /self.container/Products(ID=ProductID)/Name

    + +
    + +

    An instance path MAY contain an +index segment immediately following a path segment representing an ordered +collection-valued structural property. The index is zero-based and MUST be an +integer literal. Negative integers count from the end of the collection, with +-1 representing the last item in the collection. Remaining path segments are +evaluated relative to the identified item of the collection.

    + +

    Example 66: instance path with collection-valued structural +property and index segment

    + +
    + +

    Addresses/1

    + +

    Addresses/-1/Street

    + +
    + +

    14.4.1.2 Path Evaluation

    + +

    Annotations MAY be embedded within their target, or +specified separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as targeting +in the remainder of this section.

    + +

    For annotations embedded within or targeting an entity +container, the path is evaluated starting at the entity container, i.e. an +empty path resolves to the entity container, and non-empty paths MUST start +with a segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules for +paths targeting the corresponding child element.

    + +

    For annotations embedded within or targeting an entity set +or a singleton, the path is evaluated starting at the entity set or singleton, +i.e. an empty path resolves to the entity set or singleton, and non-empty paths +MUST follow the rules for annotations targeting the declared entity type of the +entity set or singleton.

    + +

    For annotations embedded within or targeting an entity type +or complex type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be a +structural or navigation property of the type, a type +cast, or a term cast.

    + +

    For annotations embedded within a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the directly enclosing type. This allows e.g. specifying the value of an annotation +on one property to be calculated from values of other properties of the same +type. An empty path resolves to the enclosing type, and non-empty paths MUST +follow the rules for annotations targeting the directly enclosing type.

    + +

    For annotations targeting a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the outermost entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the first +segment of a non-empty path MUST be a structural or navigation property of the +outermost type, a type cast, or a term cast.

    + +

    For annotations embedded within or targeting an action, +action import, function, function import, parameter, or return type, the first +segment of the path MUST be a parameter name or $ReturnType.

    + +

    14.4.1.3 Annotation Path

    + +

    The annotation path expression provides a value for terms or +term properties that specify the built-in types Edm.AnnotationPath or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

             +A +non-null path MUST resolve to an annotation.

    + +

    A term or term property of type Edm.AnnotationPath +can be annotated with term Validation.AllowedTerms +(see [OData-VocValidation]) if its intended +value is an annotation path that ends in a term cast with one of the listed +terms.

    + +

    The value of the annotation path expression is the path +itself, not the value of the annotation identified by the path. This is useful +for terms that reuse or refer to other terms.

    + +
    + +

    Annotation path expressions are +represented as a string containing a path.

    + +
    + +

    Example 67:

    + +
    + +

    "@UI.ReferenceFacet": +"Product/Supplier/@UI.LineItem",

    + +

    "@UI.CollectionFacet#Contacts": +[

    + +

    +"Supplier/@Communication.Contact",

    + +

    +"Customer/@Communication.Contact"

    + +

    ]

    + +
    + +

    14.4.1.4 +Model Element Path

    + +

    The model element path expression provides a value for terms +or term properties that specify the built-in type Edm.ModelElementPath. Its argument is a model path.

    + +

    The value of the model element path expression is the path +itself, not the instance(s) identified by the path.

    + +
    + +

    Model element path expressions are +represented as a string containing a path.

    + +
    + +

    Example 68:

    + +
    + +

    "@org.example.MyFavoriteModelElement": +"/self.someAction"

    + +
    + +

    14.4.1.5 Navigation Property Path

    + +

    The navigation property path +expression provides a value for terms or term properties that specify the built-in types Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

             +A non-null path MUST resolve to a model element whose type is an +entity type, or a collection of entity types, e.g. a navigation property.

    + +

    The value of the navigation property path expression is the +path itself, not the entitiy or collection of entities identified by the path.

    + +
    + +

    Navigation property path expressions +are represented as a string containing a path.

    + +
    + +

    Example 69:

    + +
    + +

    "@UI.HyperLink": +"Supplier",

    + +

     

    + +

    "@Capabilities.UpdateRestrictions": +{

    + +

    +"NonUpdatableNavigationProperties": [

    + +

    "Supplier",

    + +

    "Category"

    + +

    ]

    + +

    }

    + +
    + +

    14.4.1.6 +Property Path

    + +

    The property path expression provides a value for terms or +term properties that specify one of the built-in types Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

             +A non-null path MUST resolve to a model element whose type is a primitive or complex type, an +enumeration type, a type definition, or a collection of one of these +types.

    + +

    The value of the property path expression is the path +itself, not the value of the structural property or the value of the term cast identified +by the path.

    + +
    + +

    Property path expressions are +represented as a string containing a path.

    + +
    + +

    Example 70:

    + +
    + +

    "@UI.RefreshOnChangeOf": +"ChangedAt",

    + +

     

    + +

    "@Capabilities.UpdateRestrictions": +{

    + +

    "NonUpdatableProperties": +[

    + +

    "CreatedAt",

    + +

    "ChangedAt"

    + +

    ]

    + +

    }

    + +
    + +

    14.4.1.7 +Value Path

    + +

    The value path expression allows assigning a value by +traversing an object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation properties of +structured types, and structural properties of structured types. Its argument +is an instance path.

    + +

    The value of the path expression is the instance or +collection of instances identified by the path.

    + +
    + +

    $Path

    + +
    + +
    + +

    Path expressions are represented as an +object with a single member $Path whose value is a +string containing a path.

    + +
    + +

    Example 71:

    + +
    + +

    "@UI.DisplayName": {

    + +

    "$Path": +"FirstName"

    + +

    },

    + +

     

    + +

    "@UI.DisplayName#second": {

    + +

    "$Path": +"@vCard.Address#work/FullName"

    + +

    }

    + +
    + +

    14.4.2 Comparison and Logical Operators

    + +

    Annotations MAY use the following logical and comparison +expressions which evaluate to a Boolean value. These expressions MAY be +combined and they MAY be used anywhere instead of a Boolean expression.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Logical Operators

    +
    +

    And

    +
    +

    Logical + and

    +
    +

    Or

    +
    +

    Logical + or

    +
    +

    Not

    +
    +

    Logical + negation

    +
    +

    Comparison Operators

    +
    +

    Eq

    +
    +

    Equal

    +
    +

    Ne

    +
    +

    Not + equal

    +
    +

    Gt

    +
    +

    Greater + than

    +
    +

    Ge

    +
    +

    Greater + than or equal

    +
    +

    Lt

    +
    +

    Less than

    +
    +

    Le

    +
    +

    Less + than or equal

    +
    +

    Has

    +
    +

    Has + enumeration flag(s) set

    +
    +

    In

    +
    +

    Is + in collection

    +
    + +

    The And and Or operators require two operand expressions that +evaluate to Boolean values. The Not operator +requires a single operand expression that evaluates to a Boolean value. For +details on null handling for comparison operators see [OData‑URL].

    + +

    The other comparison operators require two operand +expressions that evaluate to comparable values.

    + +
    + +

    $And and $Or

    + +
    + +
    + +

    The And +and Or logical expressions are represented as an +object with a single member whose value is an array with two annotation +expressions. The member name is one of $And, or $Or.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Not

    + +
    + +
    + +

    Negation expressions are represented +as an object with a single member $Not whose value +is an annotation expression.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Eq, $Ne, +$Gt, $Ge, $Lt, +$Le, $Has, and $In

    + +
    + +
    + +

    All comparison expressions are +represented as an object with a single member whose value is an array with two +annotation expressions. The member name is one of $Eq, +$Ne, $Gt, $Ge, $Lt, $Le, $Has, or $In.

    + +

    They MAY contain annotations.

    + +
    + +

    Example 72:

    + +
    + +

    {

    + +

    "$And": [

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    },

    + +

    {

    + +

    "$Path": +"IsMarried"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Or": [

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    },

    + +

    {

    + +

    "$Path": +"IsMarried"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Not": {

    + +

    "$Path": +"IsMale"

    + +

    }

    + +

    },

    + +

    {

    + +

    "$Eq": [

    + +

    null,

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Ne": [

    + +

    null,

    + +

    {

    + +

    "$Path": +"IsMale"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Gt": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    20

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Ge": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    10

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Lt": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    20

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Le": [

    + +

    {

    + +

    "$Path": +"Price"

    + +

    },

    + +

    100

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Has": [

    + +

    {

    + +

    "$Path": +"Fabric"

    + +

    },

    + +

    "Red"

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$In": [

    + +

    {

    + +

    "$Path": +"Size"

    + +

    },

    + +

    [

    + +

    "XS",

    + +

    "S"

    + +

    ]

    + +

    ]

    + +

    }

    + +
    + +

    14.4.3 +Arithmetic Operators

    + +

    Annotations MAY use the following arithmetic expressions +which evaluate to a numeric value. These expressions MAY be combined, and they MAY +be used anywhere instead of a numeric expression of the appropriate type. The +semantics and evaluation rules for each arithmetic expression is identical to +the corresponding arithmetic operator defined in [OData‑URL].

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Add

    +
    +

    Addition

    +
    +

    Sub

    +
    +

    Subtraction

    +
    +

    Neg

    +
    +

    Negation

    +
    +

    Mul

    +
    +

    Multiplication

    +
    +

    Div

    +
    +

    Division + (with integer result for integer operands)

    +
    +

    DivBy

    +
    +

    Division + (with fractional result also for integer operands)

    +
    +

    Mod

    +
    +

    Modulo

    +
    + +

    The Neg operator requires a +single operand expression that evaluates to a numeric value. The other arithmetic +operators require two operand expressions that evaluate to numeric values.

    + +
    + +

    $Neg

    + +
    + +
    + +

    Negation expressions are represented +as an object with a single member $Neg whose value +is an annotation expression.

    + +

    It MAY contain annotations.

    + +
    + +
    + +

    $Add, $Sub, +$Mul, $Div, $DivBy, +and $Mod

    + +
    + +
    + +

    These arithmetic expressions are +represented as an object with as single member whose value is an array with two +annotation expressions. The member name is one of $Add, +$Sub, $Neg, $Mul, $Div, $DivBy, or $Mod.

    + +

    They MAY contain annotations.

    + +
    + +

    Example 73:

    + +
    + +

    {

    + +

    "$Add": [

    + +

    {

    + +

    "$Path": +"StartDate"

    + +

    },

    + +

    {

    + +

    "$Path": +"Duration"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Sub": [

    + +

    {

    + +

    "$Path": +"Revenue"

    + +

    },

    + +

    {

    + +

    "$Path": "Cost"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Neg": {

    + +

    "$Path": +"Height"

    + +

    }

    + +

    },

    + +

    {

    + +

    "$Mul": [

    + +

    {

    + +

    "$Path": +"NetPrice"

    + +

    },

    + +

    {

    + +

    "$Path": +"TaxRate"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Div": [

    + +

    {

    + +

    "$Path": +"Quantity"

    + +

    },

    + +

    {

    + +

    "$Path": "QuantityPerParcel"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$DivBy": [

    + +

    {

    + +

    "$Path": +"Quantity"

    + +

    },

    + +

    {

    + +

    "$Path": +"QuantityPerParcel"

    + +

    }

    + +

    ]

    + +

    },

    + +

    {

    + +

    "$Mod": [

    + +

    {

    + +

    "$Path": +"Quantity"

    + +

    },

    + +

    {

    + +

    "$Path": +"QuantityPerParcel"

    + +

    }

    + +

    ]

    + +

    }

    + +
    + +

    14.4.4 Apply Client-Side Functions

    + +

    The apply expression enables a value to be obtained by +applying a client-side function. The apply expression MAY have operand +expressions. The operand expressions are used as parameters to the client-side +function.

    + +
    + +

    $Apply

    + +
    + +
    + +

    Apply expressions are represented as +an object with a member $Apply whose value is an +array of annotation expressions, and a member $Function +whose value is a string containing the qualified +name of the client-side function to be applied.

    + +

    It MAY contain +annotations.

    + +
    + +

    OData defines the following functions. Services MAY support +additional functions that MUST be qualified with a namespace other than odata. Function names qualified with odata are reserved for this specification and its future +versions.

    + +

    14.4.4.1 Canonical Functions

    + +

    All canonical functions defined in [OData‑URL] +can be used as client-side functions, qualified with the namespace odata. The semantics of these client-side functions is +identical to their counterpart function defined in [OData‑URL].

    + +

    For example, the odata.concat +client-side function takes two or more expressions as arguments. Each argument +MUST evaluate to a primitive or enumeration type. It returns a value of type Edm.String that is the concatenation of the literal representations +of the results of the argument expressions. Values of primitive types other +than Edm.String are represented according to the +appropriate alternative in the primitiveValue rule +of [OData‑ABNF], i.e. Edm.Binary +as binaryValue, Edm.Boolean +as booleanValue etc.

    + +

    Example 74:

    + +
    + +

    "@UI.DisplayName": {

    + +

    "$Apply": [

    + +

    "Product: ",

    + +

    {

    + +

    "$Path": +"ProductName"

    + +

    },

    + +

    " (",

    + +

    {

    + +

    "$Path": +"Available/Quantity"

    + +

    },

    + +

    " ",

    + +

    {

    + +

    "$Path": +"Available/Unit"

    + +

    },

    + +

    " available)"

    + +

    ],

    + +

    "$Function": +"odata.concat"

    + +

    }

    + +
    + +

    ProductName is of type String, Quantity in complex +type Available is of type Decimal, +and Unit in Available +is of type enumeration, so the result of the Path +expression is represented as the member name of the enumeration value.

    + +

    14.4.4.2 +Function odata.fillUriTemplate

    + +

    The odata.fillUriTemplate +client-side function takes two or more expressions as arguments and returns a +value of type Edm.String.

    + +

    The first argument MUST be of type Edm.String +and specifies a URI template according to [RFC6570], +the other arguments MUST be labeled element +expressions. Each labeled element expression +specifies the template parameter name as its name and evaluates to the template +parameter value.

    + +

    [RFC6570] defines three +kinds of template parameters: simple values, lists of values, and key-value +maps.

    + +

    Simple values are represented as labeled element expressions that evaluate to a +single primitive value. The literal representation of this value according to [OData‑ABNF] is used to fill the +corresponding template parameter.

    + +

    Lists of values are represented as labeled element expressions that evaluate to a +collection of primitive values.

    + +

    Key-value maps are represented as labeled element expressions that evaluate to a +collection of complex types with two properties that are used in lexicographic +order. The first property is used as key, the second property as value.

    + +

    Example 75: assuming there are no special characters in +values of the Name property of the Actor entity

    + +
    + +

    {

    + +

    "$Apply": [

    + +

    "http://host/someAPI/Actors/{actorName}/CV",

    + +

    {

    + +

    "$LabeledElement": {

    + +

    "$Path": "Actor/Name"

    + +

    },

    + +

    "$Name": "self.actorName"

    + +

    }

    + +

    ],

    + +

    "$Function": "odata.fillUriTemplate"

    + +

    }

    + +
    + +

    14.4.4.3 +Function odata.matchesPattern

    + +

    The odata.matchesPattern +client-side function takes two string expressions as arguments and returns a +Boolean value.

    + +

    The function returns true if the second expression evaluates +to an [ECMAScript] (JavaScript) regular +expression and the result of the first argument expression matches that regular +expression, using syntax and semantics of [ECMAScript] +regular expressions.

    + +

    Example 76: all non-empty FirstName +values not containing the letters b, c, or d evaluate to true

    + +
    + +

    {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": "FirstName"

    + +

    },

    + +

    "^[^b-d]+$"

    + +

    ],

    + +

    "$Function": "odata.matchesPattern"

    + +

    }

    + +
    + +

    14.4.4.4 Function odata.uriEncode

    + +

    The odata.uriEncode client-side +function takes one argument of primitive type and returns the URL-encoded OData +literal that can be used as a key value in OData URLs or in the query part of +OData URLs.

    + +

    Note: string literals are surrounded by single quotes as +required by the paren-style key syntax.

    + +

    Example 77:

    + +
    + +

    {

    + +

    "$Apply": [

    + +

    "http://host/service/Genres({genreName})",

    + +

    {

    + +

    "$LabeledElement": {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": "NameOfMovieGenre"

    + +

    }

    + +

    ],

    + +

    "$Function": "odata.uriEncode"

    + +

    },

    + +

    "$Name": "self.genreName"

    + +

    }

    + +

    ],

    + +

    "$Function": "odata.fillUriTemplate"

    + +

    }

    + +
    + +

    14.4.5 Cast

    + +

    The cast expression casts the value obtained from its single +child expression to the specified type. The cast expression follows the same +rules as the cast canonical function defined in [OData‑URL].

    + +
    + +

    $Cast

    + +
    + +
    + +

    Cast expressions are represented as an +object with a member $Cast whose value is an +annotation expression, a member $Type whose value +is a string containing the qualified type name, and optionally a member $Collection with a value of true.

    + +

    It MAY contain annotations.

    + +

    If the specified type is a primitive +type or a collection of primitive types, the facet members $MaxLength, +$Unicode, $Precision, +$Scale, +and $SRID +MAY be specified if applicable to the specified primitive type. If the facet +members are not specified, their values are considered unspecified.

    + +
    + +

    Example 78:

    + +
    + +

    "@UI.Threshold": {

    + +

    "$Cast": {

    + +

    "$Path": +"Average"

    + +

    },

    + +

    "$Type": +"Edm.Decimal"

    + +

    }

    + +
    + +

    14.4.6 +Collection

    + +

    The collection expression enables a value to be obtained +from zero or more item expressions. The value calculated by the collection +expression is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type compatible.

    + +
    + +

    Collection expressions are represented +as arrays with one array item per item expression within the collection +expression.

    + +
    + +

    Example 79:

    + +
    + +

    "@seo.SeoTerms": [

    + +

    "Product",

    + +

    "Supplier",

    + +

    "Customer"

    + +

    ]

    + +
    + +

    14.4.7 +If-Then-Else

    + +

    The if-then-else expression enables a value to be obtained +by evaluating a condition expression. It MUST contain exactly three +child expressions. There is one exception to this rule: if and only if the if-then-else +expression is an item of a collection expression, the third child expression +MAY be omitted, reducing it to an if-then expression. This can be used to +conditionally add an element to a collection.

    + +

    The first child expression is the condition and MUST +evaluate to a Boolean result, e.g. the comparison and logical operators +can be used.

    + +

    The second and third child expressions are evaluated +conditionally. The result MUST be type compatible with the type expected by the +surrounding expression.

    + +

    If the first expression evaluates to true, +the second expression MUST be evaluated and its value MUST be returned as the +result of the if-then-else expression. If the first expression evaluates to false and a third child element is present, it MUST be +evaluated and its value MUST be returned as the result of the if-then-else +expression. If no third expression is present, nothing is added to the +surrounding collection.

    + +
    + +

    $If

    + +
    + +
    + +

    Conditional expressions are +represented as an object with a member $If whose +value is an array of two or three annotation expressions.

    + +

    It MAY contain annotations.

    + +
    + +

    Example 80: the condition is a value +path expression referencing the Boolean property IsFemale +,whose value then determines the value of the $If +expression

    + +
    + +

    "@person.Gender": {

    + +

    "$If": [

    + +

    {

    + +

    "$Path": +"IsFemale"

    + +

    },

    + +

    "Female",

    + +

    "Male"

    + +

    ]

    + +

    }

    + +
    + +

    14.4.8 Is-Of

    + +

    The is-of +expression checks whether the value obtained from its single child expression +is compatible with the specified type. It returns true +if the child expression returns a type that is compatible with the specified +type, and false otherwise.

    + +
    + +

    $IsOf

    + +
    + +
    + +

    Is-of expressions are represented as +an object with a member $IsOf whose value is an +annotation expression, a member $Type whose value +is a string containing an qualified type name, and optionally a member $Collection with a value of true.

    + +

    It MAY contain annotations.

    + +

    If the specified type is a primitive +type or a collection of primitive types, the facet members $MaxLength, +$Unicode, $Precision, +$Scale, +and $SRID +MAY be specified if applicable to the specified primitive type. If the facet +members are not specified, their values are considered unspecified.

    + +
    + +

    Example 81:

    + +
    + +

    "@Self.IsPreferredCustomer": +{

    + +

    "$IsOf": {

    + +

    "$Path": +"Customer"

    + +

    },

    + +

    "$Type": "self.PreferredCustomer"

    + +

    }

    + +
    + +

    14.4.9 +Labeled Element

    + +

    The labeled element expression assigns a name to its single +child expression. The value of the child expression can then be reused +elsewhere with a labeled element +reference expression.

    + +

    A labeled element expression MUST contain exactly one child +expression. The value of the child expression is also the value of the labeled +element expression.

    + +

    A labeled element expression MUST provide a simple identifier value as its name that MUST +be unique within the schema containing the expression.

    + + + +
    + +

    Labeled element expressions are +represented as an object with a member $LabeledElement +whose value is an annotation expression, and a member $Name +whose value is a string containing the labeled elements name.

    + +

    It MAY contain annotations.

    + +
    + +

    Example 82:

    + +
    + +

    "@UI.DisplayName": {

    + +

    "$LabeledElement": {

    + +

    "$Path": +"FirstName"

    + +

    },

    + +

    "$Name": +"CustomerFirstName"

    + +

    }

    + +
    + +

    14.4.10 +Labeled Element Reference

    + +

    The labeled element reference expression MUST specify the qualified name of a labeled +element expression in scope and returns the value of the identified labeled +element expression as its value.

    + + + +
    + +

    Labeled element reference expressions +are represented as an object with a member $LabeledElementReference +whose value is a string containing an qualified name.

    + +
    + +

    Example 83:

    + +
    + +

    "@UI.DisplayName": {

    + +

    +"$LabeledElementReference": "self.CustomerFirstName"

    + +

    }

    + +
    + +

    14.4.11 Null

    + +

    The null expression indicates the absence of a value. The null +expression MAY be annotated.

    + +
    + +

    Null expressions that do not contain +annotations are represented as the literal null.

    + +
    + +

    Example 84:

    + +
    + +

    "@UI.DisplayName": null,

    + +
    + +
    + +

    $Null

    + +
    + +
    + +

    Null expression containing annotations are represented as an object with a +member $Null whose value is the literal null.

    + +
    + +

    Example 85:

    + +
    + +

    "@UI.Address": {

    + +

    "$Null": null,

    + +

    "@self.Reason": +"Private"

    + +

    }

    + +
    + +

    14.4.12 Record

    + +

    The record expression enables a new entity type or complex +type instance to be constructed.

    + +

    A record expression MAY specify the structured type of its +result, which MUST be an entity type or complex type in scope. If not +explicitly specified, the type is derived from the expressions context.

    + +

    A record expression contains zero or more property value +expressions. For each single-valued structural or navigation property of the +record expressions type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if the +record expression is the value of an annotation for a term that has a base term whose type is structured and directly +or indirectly inherits from the type of its base term. In this case, property +values that already have been specified in the annotation for the base term or +its base term etc. need not be specified again.

    + +

    For collection-valued properties the absence of a property +value expression is equivalent to specifying an empty collection as its value.

    + +
    + +

    Record expressions are represented as +objects with one member per property value expression. The member name is the +property name, and the member value is the property value expression.

    + +

    The type of a record expression is +represented as the @type control information, see [OData‑JSON].

    + +

    It MAY contain annotations for itself and its members. +Annotations for record members are prefixed with the member name.

    + +
    + +

    Example 86: this annotation morphs the entity type from +example 8 into a structured type with two structural properties GivenName and Surname and two +navigation properties DirectSupervisor and CostCenter. The first three properties simply rename +properties of the annotated entity type, the fourth adds a calculated +navigation property that is pointing to a different service

    + +
    + +

    "@person.Employee": {

    + +

    "@type": +"https://example.org/vocabs/person#org.example.person.Manager",

    + +

    "@Core.Description": +"Annotation on record",

    + +

    "GivenName": {

    + +

    "$Path": +"FirstName"

    + +

    },

    + +

    "GivenName@Core.Description": +"Annotation on record member",

    + +

    "Surname": {

    + +

    "$Path": +"LastName"

    + +

    },

    + +

    "DirectSupervisor": {

    + +

    "$Path": +"Manager"

    + +

    },

    + +

    "CostCenter": {

    + +

    "$UrlRef": {

    + +

    "$Apply": [

    + +

    +"http://host/anotherservice/CostCenters('{ccid}')",

    + +

    {

    + +

    "$LabeledElement": +{

    + +

    "$Path": +"CostCenterID"

    + +

    },

    + +

    "$Name": +"ccid"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.fillUriTemplate"

    + +

    }

    + +

    }

    + +

    }

    + +
    + +

    14.4.13 +URL Reference

    + +

    The URL reference expression enables a value to be obtained +by sending a GET request.

    + +

    The URL reference expression MUST contain exactly one +expression of type Edm.String. Its value is treated +as a URL that MAY be relative or absolute; relative URLs are relative to the +URL of the document containing the URL reference expression, or relative to a +base URL specified in a format-specific way.

    + +

    The response body of the GET +request MUST be returned as the result of the URL reference expression. +The result of the +URL reference expression MUST be type compatible with the type +expected by the surrounding expression.

    + +
    + +

    $UrlRef

    + +
    + +
    + +

    URL reference expressions are +represented as an object with a single member $UrlRef +whose value is an annotation expression.

    + +

    It MAY contain annotations.

    + +
    + +

    Example 87:

    + +
    + +

    "@org.example.person.Supplier": +{

    + +

    "$UrlRef": {

    + +

    "$Apply": [

    + +

    +"http://host/service/Suppliers({suppID})",

    + +

    {

    + +

    "$LabeledElement": {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": +"SupplierId"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.uriEncode"

    + +

    },

    + +

    "$Name": +"suppID"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.fillUriTemplate"

    + +

    }

    + +

    },

    + +

     

    + +

    "@Core.LongDescription#element": +{

    + +

    "$UrlRef": "http://host/wiki/HowToUse"

    + +

    }

    + +
    + + + +

    15.1 +Namespace

    + +

    A namespace is a dot-separated sequence of simple identifiers with a maximum length of +511 Unicode characters (code points).

    + +

    15.2 +Simple Identifier

    + +

    A simple identifier is a Unicode +character sequence with the following restrictions:

    + +
      +
    • It consists of at least one and at most 128 Unicode + characters (code points).
    • +
    • The first character MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L) or Letter + number (Nl).
    • +
    • The remaining characters MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L), Letter + number (Nl), Decimal number (Nd), Non-spacing mark (Mn), Combining + spacing mark (Mc), Connector punctuation (Pc), and Other, format + (Cf).
    • +
    + +

    Non-normatively speaking it starts with a letter or +underscore, followed by at most 127 letters, underscores or digits.

    + +

    15.3 +Qualified Name

    + +

    For model elements that are direct children of a schema: the +namespace or alias of the schema that defines the model element, followed by a +dot and the name of the model element, see rule qualifiedTypeName +in [OData‑ABNF].

    + +

    For built-in primitive types: +the name of the type, prefixed with Edm followed by +a dot.

    + +

    15.4 +Target Path

    + +

    Target paths are +used to refer to other model elements.

    + +

    The allowed path +expressions are:

    + +

             +The qualified name of an entity container, followed by a +forward slash and the name of a container child element

    + +

             +The target path of a +container child followed by a forward slash and one or more forward-slash +separated property, navigation property, or type-cast segments

    + +

    Example 88: Target expressions

    + +
    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp

    + +
    + + + +

    Following are two basic examples of valid EDM models as +represented in CSDL JSON. These examples demonstrate many of the topics covered +above.

    + +

    16.1 +Products and Categories Example

    + +

    Example 89:

    + +
    + +

    {

    + +

    "$Version": +"4.0",

    + +

    "$EntityContainer": +"ODataDemo.DemoService",

    + +

    "$Reference": {

    + +

    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "Org.OData.Core.V1",

    + +

    "$Alias": +"Core",

    + +

    "@Core.DefaultNamespace": +true

    + +

    }

    + +

    ]

    + +

    },

    + +

    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.json": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "Org.OData.Measures.V1",

    + +

    "$Alias": +"Measures"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    "ODataDemo": {

    + +

    "$Alias": +"self",

    + +

    +"@Core.DefaultNamespace": true,

    + +

    "Product": {

    + +

    "$Kind": +"EntityType",

    + +

    "$HasStream": true,

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "Description": {

    + +

    "$Nullable": true,

    + +

    "@Core.IsLanguageDependent": +true

    + +

    },

    + +

    "ReleaseDate": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Date"

    + +

    },

    + +

    "DiscontinuedDate": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Date"

    + +

    },

    + +

    "Rating": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Price": {

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Decimal",

    + +

    "@Measures.ISOCurrency": +{

    + +

    "$Path": +"Currency"

    + +

    }

    + +

    },

    + +

    "Currency": {

    + +

    "$Nullable": true,

    + +

    "$MaxLength": 3

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Type": "self.Category",

    + +

    "$Partner": +"Products"

    + +

    },

    + +

    "Supplier": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Supplier",

    + +

    "$Partner": +"Products"

    + +

    }

    + +

    },

    + +

    "Category": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Name": {

    + +

    "@Core.IsLanguageDependent": +true

    + +

    },

    + +

    "Products": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Partner": +"Category",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$OnDelete": +"Cascade"

    + +

    }

    + +

    },

    + +

    "Supplier": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "ID"

    + +

    ],

    + +

    "ID": {},

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "Address": {

    + +

    "$Type": "self.Address"

    + +

    },

    + +

    "Concurrency": {

    + +

    "$Type": +"Edm.Int32"

    + +

    },

    + +

    "Products": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Partner": +"Supplier",

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product"

    + +

    }

    + +

    },

    + +

    "Country": {

    + +

    "$Kind": +"EntityType",

    + +

    "$Key": [

    + +

    "Code"

    + +

    ],

    + +

    "Code": {

    + +

    "$MaxLength": 2

    + +

    },

    + +

    "Name": {

    + +

    "$Nullable": true

    + +

    }

    + +

    },

    + +

    "Address": {

    + +

    "$Kind": +"ComplexType",

    + +

    "Street": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "City": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "State": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "ZipCode": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "CountryName": {

    + +

    "$Nullable": true

    + +

    },

    + +

    "Country": {

    + +

    "$Kind": +"NavigationProperty",

    + +

    "$Nullable": true,

    + +

    "$Type": "self.Country",

    + +

    "$ReferentialConstraint": +{

    + +

    "CountryName": +"Name"

    + +

    }

    + +

    }

    + +

    },

    + +

    "ProductsByRating": [

    + +

    {

    + +

    "$Kind": +"Function",

    + +

    "$Parameter": [

    + +

    {

    + +

    "$Name": +"Rating",

    + +

    "$Nullable": true,

    + +

    "$Type": +"Edm.Int32"

    + +

    }

    + +

    ],

    + +

    "$ReturnType": {

    + +

    "$Collection": +true,

    + +

    "$Type": "self.Product"

    + +

    }

    + +

    }

    + +

    ],

    + +

    "DemoService": {

    + +

    "$Kind": +"EntityContainer",

    + +

    "Products": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Product",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Category": +"Categories"

    + +

    }

    + +

    },

    + +

    "Categories": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Category",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products"

    + +

    },

    + +

    "@Core.Description": +"Product Categories"

    + +

    },

    + +

    "Suppliers": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Supplier",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products",

    + +

    "Address/Country": +"Countries"

    + +

    },

    + +

    "@Core.OptimisticConcurrency": +[

    + +

    "Concurrency"

    + +

    ]

    + +

    },

    + +

    "Countries": {

    + +

    "$Collection": true,

    + +

    "$Type": "self.Country"

    + +

    },

    + +

    "MainSupplier": {

    + +

    "$Type": "self.Supplier",

    + +

    "$NavigationPropertyBinding": +{

    + +

    "Products": +"Products"

    + +

    },

    + +

    "@Core.Description": +"Primary Supplier"

    + +

    },

    + +

    "ProductsByRating": {

    + +

    "$EntitySet": +"Products",

    + +

    "$Function": "self.ProductsByRating"

    + +

    }

    + +

    }

    + +

    }

    + +

    }

    + +
    + +

    16.2 +Annotations for +Products and Categories Example

    + +

    Example 90:

    + +
    + +

    {

    + +

    "$Version": +"4.01",

    + +

    "$Reference": {

    + +

    "http://host/service/$metadata": +{

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "ODataDemo",

    + +

    "$Alias": +"target"

    + +

    }

    + +

    ]

    + +

    },

    + +

    +"http://somewhere/Vocabulary/V1": {

    + +

    "$Include": [

    + +

    {

    + +

    "$Namespace": "Some.Vocabulary.V1",

    + +

    "$Alias": +"Vocabulary1"

    + +

    }

    + +

    ]

    + +

    }

    + +

    },

    + +

    "External.Annotations": {

    + +

    "$Annotations": {

    + +

    "target.Supplier": {

    + +

    "@Vocabulary1.EMail": +null,

    + +

    +"@Vocabulary1.AccountID": {

    + +

    "$Path": "ID"

    + +

    },

    + +

    +"@Vocabulary1.Title": "Supplier Info",

    + +

    +"@Vocabulary1.DisplayName": {

    + +

    "$Apply": [

    + +

    {

    + +

    "$Path": +"Name"

    + +

    },

    + +

    " in ",

    + +

    {

    + +

    "$Path": +"Address/CountryName"

    + +

    }

    + +

    ],

    + +

    "$Function": +"odata.concat"

    + +

    }

    + +

    },

    + +

    "target.Product": {

    + +

    "@Vocabulary1.Tags": +[

    + +

    "MasterData"

    + +

    ]

    + +

    }

    + +

    }

    + +

    }

    + +

    }

    + +
    + + + +

    Conforming services MUST follow all rules of this +specification document for the types, sets, functions, actions, containers and +annotations they expose.

    + +

    In addition, conforming services MUST NOT return 4.01 CSDL +constructs for requests made with OData-MaxVersion:4.0.

    + +

    Specifically, they

    + +

    1.     +MUST NOT include properties in derived types that overwrite a property +defined in the base type

    + +

    2.     +MUST NOT include Edm.Untyped +

    + +

    3.     +MUST NOT use path syntax added with 4.01

    + +

    4.     +MUST NOT use Edm.ModelElementPath +and Edm.AnyPropertyPath

    + +

    5.     +MUST NOT specify referential +constraints to +complex types and navigation properties

    + +

    6.     +MUST NOT include a non-abstract entity type with no inherited or defined +entity key

    + +

    7.     +MUST NOT include the Core.DefaultNamespace annotation +on included schemas

    + +

    8.     +MUST NOT return the Unicode facet for terms, parameters, and return +types

    + +

    9.     +MUST NOT include collections of Edm.ComplexType +or Edm.Untyped

    + +

    10.  +MUST NOT specify a key as a property of a related entity

    + +

    11.  +SHOULD NOT include new/unknown values for $AppliesTo

    + +

    12.  +MAY include new CSDL annotations

    + +

    In addition, OData 4.01 services:

    + +

    13.  SHOULD NOT have identifiers +within a uniqueness scope (e.g. a schema, a structural type, or an entity +container) that differ only by case

    + +

    Conforming clients MUST be prepared to consume a model that +uses any or all constructs defined in this specification, including custom +annotations, and MUST ignore constructs not defined in this version of the +specification.

    + + + +

    The work of the OpenUI5 team on the OData V4 Metadata JSON +Format, see [OpenUI5], is +gratefully acknowledged, especially the contributions of

    + +

             +Thomas Chadzelek (SAP SE)

    + +

             +Jens Ittel (SAP SE)

    + +

             +Patric Ksinsik (SAP SE)

    + +

    The contributions of the OASIS OData Technical Committee +members, enumerated in [ODataProtocol], are +gratefully acknowledged.

    + + + +
    + +
    +
    + +
    + +

    Document Object 16

    + +

    $Version. 16

    + +

    $EntityContainer. 16

    + +

    $Reference. 16

    + +

    Reference Object 16

    + +

    $Include. 17

    + +

    $Namespace. 17

    + +

    $Alias. 17

    + +

    $IncludeAnnotations. 18

    + +

    $TermNamespace. 19

    + +

    $Qualifier. 19

    + +

    $TargetNamespace. 19

    + +

    Schema Object 20

    + +

    $Alias. 20

    + +

    $Annotations. 21

    + +

    Entity Type Object 22

    + +

    $BaseType. 22

    + +

    $Abstract. 23

    + +

    $OpenType. 23

    + +

    $HasStream. 23

    + +

    $Key. 25

    + +

    Property Object 27

    + +

    $Type +and $Collection. 28

    + +

    $Nullable. 28

    + +

    $MaxLength. 28

    + +

    $Precision. 29

    + +

    $Scale. 29

    + +

    $Unicode. 30

    + +

    $SRID. 30

    + +

    $DefaultValue. 31

    + +

    Navigation Property Object 32

    + +

    $Type +and $Collection. 33

    + +

    $Nullable. 33

    + +

    $Partner. 34

    + +

    $ContainsTarget. 34

    + +

    $ReferentialConstraint. 35

    + +

    $OnDelete. 36

    + +

    Complex Type Object 37

    + +

    $BaseType. 38

    + +

    $Abstract. 38

    + +

    $OpenType. 38

    + +

    Enumeration Type Object 39

    + +

    $UnderlyingType. 39

    + +

    $IsFlags. 39

    + +

    Enumeration Member Object 40

    + +

    Type Definition Object 41

    + +

    $UnderlyingType. 41

    + +

    Action Overload Object 43

    + +

    Function Overload Object 44

    + +

    $IsBound. 44

    + +

    $EntitySetPath. 44

    + +

    $IsComposable. 45

    + +

    $ReturnType. 45

    + +

    $Type +and $Collection. 45

    + +

    $Nullable. 45

    + +

    $Parameter. 46

    + +

    Parameter Object 46

    + +

    $Name. 46

    + +

    $Type +and $Collection. 46

    + +

    $Nullable. 46

    + +

    Entity Container Object 47

    + +

    $Extends. 48

    + +

    Entity Set Object 49

    + +

    $Collection. 49

    + +

    $Type. 49

    + +

    $IncludeInServiceDocument. 49

    + +

    Singleton Object 49

    + +

    $Type. 50

    + +

    $Nullable. 50

    + +

    $NavigationPropertyBinding. 51

    + +

    Action Import Object 51

    + +

    $Action. 51

    + +

    $EntitySet. 52

    + +

    Function Import Object 52

    + +

    $Function. 52

    + +

    $EntitySet. 52

    + +

    $IncludeInServiceDocument. 52

    + +

    Term Object 54

    + +

    $Type +and $Collection. 54

    + +

    $DefaultValue. 54

    + +

    $BaseTerm. 54

    + +

    $AppliesTo. 56

    + +

    Annotation Member 56

    + +

    $Path. 65

    + +

    $And +and $Or. 66

    + +

    $Not. 66

    + +

    $Eq, +$Ne, $Gt, $Ge, $Lt, $Le, +$Has, and $In. 66

    + +

    $Neg. 68

    + +

    $Add, +$Sub, $Mul, $Div, +$DivBy, and $Mod. 69

    + +

    $Apply. 70

    + +

    $Cast. 72

    + +

    $If. 73

    + +

    $IsOf. 73

    + +

    $LabeledElement. 74

    + +

    $LabeledElementReference. 74

    + +

    $Null. 75

    + +

    $UrlRef. 76

    + +

     

    + +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Revision

    +
    +

    Date

    +
    +

    Editor

    +
    +

    Changes Made

    +
    +

    Working Draft 01

    +
    +

    2016-11-16

    +
    +

    Ralf Handl

    +
    +

    Initial version

    +
    +

    Committee Specification Draft 01

    +
    +

    2017-06-08

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Integrated 4.01 features

    +
    +

    Committee Specification Draft 02

    +
    +

    2017-09-22

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +

    Changed defaults of $Nullable, + $Scale, and $Precision

    +
    +

    Committee Specification Draft 03

    +
    +

    2017-11-10

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +

    Stable order of action and function parameters

    +
    +

    Committee Specification 01

    +
    +

    2017-12-19

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-Material Changes

    +
    +

    Committee Specification Draft 04

    +
    +

    2019-06-21

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    External targeting for annotations on action/function + overloads, parameters, and return types

    +

    Key and index segments for path expressions in annotations

    +

    Nullable singletons

    +

    Simplified syntax of entity container children and + constant annotation expressions

    +
    +

    Committee Specification Draft 05

    +
    +

    2019-09-26

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Redefining entity sets and singletons when extending + entity containers

    +
    +

    Committee Specification 02

    +
    +

    2019-11-05

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    +

    Candidate OASIS Standard 02

    +
    +

    2020-04-09

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    + +

     

    + +
    + + + + diff --git a/odata-csdl/temp/odata-csdl-json-v4.01-os.md b/odata-csdl/temp/odata-csdl-json-v4.01-os.md new file mode 100644 index 000000000..32ab30e88 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-json-v4.01-os.md @@ -0,0 +1,6228 @@ +# ##sec Introduction + +OData services are described in terms of an [Entity +Model](#EntityModel). The Common Schema Definition Language (CSDL) +defines a representation of the entity model exposed by an OData service +using the JavaScript Object Notation (JSON)[, see[ +]{.apple-converted-space}]{style="color:black"}**\[**[**RFC8259**](#rfc8259)**\]**. + +This format is based on the OpenUI5 OData V4 Metadata JSON Format, see +**\[**[**OpenUI5**](#OpenUI5)**\]**, with some extensions and +modifications made necessary to fully cover OData CSDL Version 4.01. + +## ##subsec IPR Policy + +This specification is provided under the [RF on RAND +Terms](https://www.oasis-open.org/policies-guidelines/ipr#RF-on-RAND-Mode) +Mode of the [OASIS IPR +Policy](https://www.oasis-open.org/policies-guidelines/ipr), the mode +chosen when the Technical Committee was established. For information on +whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing +terms, please refer to the Intellectual Property Rights section of the +TC's web page (). + +## ##subsec Terminology + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", +"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this +document are to be interpreted as described in +**\[**[**RFC2119**](#rfc2119)**\]**. + +## ##subsec Normative References + +[\[ECMAScript\]]{.Refterm}[[         +]{style="font-weight:normal"}]{.Refterm}*ECMAScript 2016 Language +Specification, 7^th^ Edition,* June 2016. Standard ECMA-262. +. + +[\[EPSG\]                   ]{.Refterm}European Petroleum Survey Group +(EPSG). . + +[\[OData-ABNF\]]{.Refterm}         *OData ABNF Construction Rules +Version 4.01*.\ +See link in "Additional artifacts" section on cover +page[.]{style="color: +#222222"} + +**[\[OData-CSDL-Schema]{lang="DE" +style="color:windowtext"}**[**[\]]{lang="DE" +style="color:windowtext"}**]{.Hyperlink1}[       ]{lang="DE" +style="color:windowtext"}*[OData CSDL JSON Schema.]{lang="DE"}*[\ +]{lang="DE"}See link in "Additional artifacts" section on cover page. + +**\[OData-CSDLXML**[**\]**]{.Hyperlink1}  OData Common Schema Definition +Language (CSDL) XML Representation Version 4.01.\ +See link in "Related work" section on cover page. + +**\[OData-JSON**[**\]**]{.Hyperlink1}         *OData JSON Format Version +4.01.*\ +See link in "Related work" section on cover page. + +[\[OData-Protocol\]]{.Refterm}     *OData Version 4.01 Part 1: +Protocol*.\ +See link in "Related work" section on cover +page[.]{style="color:#222222"} + +OData-URL           *OData Version 4.01 Part 2: URL Conventions*.\ +See link in "Related work" section on cover page. + +OData-VocCore     *OData Vocabularies Version 4.0: Core Vocabulary.*\ +See link in "Related work" section on cover page. + +OData-VocMeasures         *OData Vocabularies Version 4.0: Measures +Vocabulary.*\ +See link in "Related work" section on cover page. + +OData-VocValidation        *OData Vocabularies Version 4.0: Validation +Vocabulary.*\ +See link in "Related work" section on cover page. + +[\[RFC2119\]]{.Refterm}               Bradner, S., "Key words for use in +RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. +. + +RFC6570               Gregorio, J., Fielding, R., Hadley, M., +Nottingham, M., and D. Orchard, "URI Template", RFC 6570, March 2012. +. + +[\[RFC7493\]]{.Refterm}[[               +]{style="font-weight:normal"}]{.Refterm}[[Bray, T., Ed., \"The I-JSON +Message Format\", RFC7493, March 2015.]{style="font-weight:normal"} +]{.Refterm}. + +[\[RFC8259\]]{.Refterm}               Bray, T., Ed., "The JavaScript +Object Notation (JSON) Data Interchange Format", RFC 8259, December +2017. . + +[\[XML-Schema-2\]]{.Refterm}     W3C XML Schema Definition Language +(XSD) 1.1 Part 2: DatatypesW3C XML Schema Definition Language (XSD) 1.1 +Part 2: Datatypes, D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. +Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April +2012, .\ +Latest version available at . + +## ##subsec Non-Normative References + +[\[OpenUI5\]]{.Refterm}[[               +]{style="font-weight:normal"}]{.Refterm}[OpenUI5 Version[ +]{.apple-converted-space}[1.40.10 -- +]{.sapuitv}]{style="background:white"}[[OData V4 Metadata JSON Format, +]{style="font-weight:normal"}]{.Refterm}[[ +]{style="font-weight:normal"}]{.Refterm} + +## ##subsec Typographical Conventions + +Keywords defined by this specification use this `monospaced` font. + +`Normative source code uses this paragraph style.` + +Some sections of this specification are illustrated with non-normative +examples. + +::: example +Example ##ex: text describing an example uses this paragraph style +``` +Non-normative examples use this paragraph style. +``` +::: + +All examples in this document are non-normative and informative only. + +Representation-specific text is indented and marked with vertical lines. + +::: csdlHeadline +Representation-Specific Headline +::: + +::: csdl +Normative representation-specific text +::: + +All other text is normative unless otherwise labeled. + +# ##sec JSON Representation + +OData CSDL JSON is a full representation of the OData Common Schema +Definition Language in the JavaScript Object Notation (JSON) defined in +**\[**[**RFC8259**](#rfc8259)**\]**. It additionally follows the rules +for "Internet JSON" (I-JSON) defined in +**\[**[**RFC7493**](#rfc7493)**\]** for e.g. objects, numbers, date +values, and duration values. + +It is an alternative to the CSDL XML representation defined in +**\[**[**OData-CSDLXML**](#ODataCSDL)**\]** and neither adds nor removes +features. + +## ##subsec Requesting the JSON Representation + +The OData CSDL JSON representation can be requested using the `$format` +query option in the request URL with the media type `application/json`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `json` which MUST NOT be followed by media type parameters. + +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/json`, optionally followed by +media type parameters. + +If specified, `$format` overrides any value specified in the `Accept` +header. + +The response MUST contain the `Content-Type` header with a value of +`application/json`, optionally followed by media type parameters. + +Possible media type parameters are: +- [`IEEE754Compatible`](#ControllingtheRepresentationofNumber) +- [`metadata`](#ControllingtheAmountofControlInforma) + +The names and values of these parameters are case-insensitive. + +### ##subsubsec Controlling the Representation of Numbers + +The `IEEE754Compatible=true` parameter indicates that the service MUST +serialize `Edm.Int64` and `Edm.Decimal` numbers as strings. This is in +conformance with [RFC7493](#rfc7493). If not specified, or specified as +`IEEE754Compatible=false`, all numbers MUST be serialized as JSON +numbers. + +This enables support for JavaScript numbers that are defined to be +64-bit binary format IEEE 754 values [**\[ECMAScript\]**](#ECMAScript) +(see [section +4.3.1.9](http://www.ecma-international.org/ecma-262/5.1/#sec-4.3.19)) +resulting in integers losing precision past 15 digits, and decimals +losing precision due to the conversion from base 10 to base 2. + +Responses that format `Edm.Int64` and `Edm.Decimal` values as strings +MUST specify this parameter in the media type returned in the +`Content-Type` header. + +### ##subsubsec Controlling the Amount of Control Information + +The representation of constant annotation values in CSDL JSON documents +closely follows the representation of data defined in +[OData‑JSON](#ODataJSON). + +A client application can use the `metadata` format parameter in the +`Accept` header when requesting a CSDL JSON document to influence how +much control information will be included in the response. + +Other `Accept` header parameters are orthogonal to the `metadata` +parameter and are therefore not mentioned in this section. + +#### ##subsubsubsec `metadata=minimal` + +The `metadata=minimal` format parameter indicates that the service +SHOULD remove computable control information from the payload wherever +possible. + +This means that the `@type` control information is only included if the +type of the containing object or targeted property cannot be +heuristically determined, e.g. for +- Terms or term properties with an abstract declared type, +- Terms or term properties with a declared type that has derived +types, or +- Dynamic properties of open types. + +See [OData‑JSON](#ODataJSON) for the exact rules. + +#### ##subsubsubsec `metadata=full` + +The `metadata=full` format parameter indicates that the service MUST +include all control information explicitly in the payload. + +This means that the `@type` control information is included in +annotation values except for primitive values whose type can be +heuristically determined from the representation of the value, see +[OData‑JSON](#ODataJSON) for the exact rules. + +#### ##subsubsubsec `metadata=none` + +The `metadata=none` format parameter indicates that the service SHOULD +omit all control information. + +## ##subsec Design Considerations + +CSDL JSON documents are designed for easy and efficient lookup of model +constructs by their name without having to know or guess what kind of +model element it is. Thus, all primary model elements (entity types, +complex types, type definitions, enumeration types, terms, actions, +functions, and the entity container) are direct members of their schema, +using the schema-unique name as the member name. Similarly, child +elements of primary model elements (properties, navigation properties, +enumeration type members, entity sets, singletons, action imports, and +function imports) are direct members of the objects describing their +parent model element, using their locally unique name as the member +name. + +To avoid name collisions, all fixed member names are prefixed with a +dollar (`$`) sign and otherwise have the same name and capitalization as +their counterparts in the CSDL XML representation +**\[**[**OData-CSDLXML**](#ODataCSDL)**\]** (with one exception: the +counterpart of the `EntitySet` element's `EntityType` attribute is +[`$Type`](#EntitySet), to harmonize it with all other type references). + +Additional fixed members introduced by this specification and without +counterpart in **\[**[**OData-CSDLXML**](#ODataCSDL)**\]** are also +prefixed with a dollar (`$`) sign and use upper-camel-case names. One of +these is `$Kind` which represents the kind of model element. Its value +is the upper-camel-case local name of the XML element representing this +kind of model element in **\[**[**OData-CSDLXML**](#ODataCSDL)**\]**, +e.g. `EntityType` or `NavigationProperty`. + +While the XML representation of CSDL allows referencing model elements +with alias-qualified names as well as with namespace-qualified names, +this JSON representation requires the use of alias-qualified names if an +alias is specified for an included or document-defined schema. Aliases +are usually shorter than namespaces, so this reduces text size of the +JSON document. Text size matters even if the actual HTTP messages are +sent in compressed form because the decompressed form needs to be +reconstructed, and clients not using a streaming JSON parser have to +materialize the full JSON document before parsing. + +To further reduce size the member `$Kind` is optional for [structural +properties](#StructuralProperty) as these are more common than +[navigation properties](#NavigationProperty), and the member +[`$Type`](#Type) is optional for string properties, parameters, and +return types, as this type is more common than other primitive types. + +In general, all members that have a default value SHOULD be omitted if +they have the default value. + +## ##subsec JSON Schema Definition + +The structure of CSDL JSON documents can be verified with the JSON +Schema **\[**[**OData-CSDL-Schema**](#CSDLschema)**\]** provided as an +additional artifact of this prose specification. This schema only +defines the shape of a well-formed CSDL JSON document but is not +descriptive enough to define what a correct CSDL JSON document MUST be +in every imaginable use case. This specification document defines +additional rules that correct CSDL JSON documents MUST fulfill. In case +of doubt on what makes a CSDL JSON document correct the rules defined in +this specification document take precedence. + +# ##sec Entity Model + +An OData service exposes a single entity model. This model may be +distributed over several [schemas](#Schema), and these schemas may be +distributed over several documents. + +A service is defined by a single CSDL document which can be accessed by +sending a `GET` request to `/$metadata`. This document is +called the metadata document. It MAY [reference](#Reference) other CSDL +documents. + +The metadata document contains a single [entity +container](#EntityContainer) that defines the resources exposed by this +service. This entity container MAY [extend](#ExtendinganEntityContainer) +an entity container defined in a [referenced document](#Reference). + +The *model* of the service consists of all CSDL constructs used in its +entity containers. + +The *scope* of a CSDL document is the document itself and all schemas +[included](#IncludedSchema) from directly [referenced +documents](#Reference). All entity types, complex types and other named +model elements *in scope* (that is, defined in the document itself or a +schema of a directly referenced document) can be accessed from a +referencing document by their qualified names. This includes the +[built-in primitive](#PrimitiveTypes) and [abstract +types](#BuiltInAbstractTypes). + +Referencing another document may alter the model defined by the +referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, +then an [entity set](#EntitySet) of the service defined by the +referencing document may return entities of the derived type. This is +identical to the behavior if the derived type had been defined directly +in the referencing document. + +Note: referencing documents is not recursive. Only named model elements +defined in directly referenced documents can be used within the schema. +However, those elements may in turn include or reference model elements +defined in schemas referenced by their defining schema. + +## ##subsec Nominal Types + +A nominal type has a name that MUST be a [simple +identifier](#SimpleIdentifier). Nominal types are referenced using their +[qualified name](#QualifiedName). The qualified type name MUST be unique +within a model as it facilitates references to the element from other +parts of the model. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +## ##subsec Structured Types + +Structured types are composed of other model elements. Structured types +are common in entity models as the means of representing entities and +structured properties in an OData service. [Entity types](#EntityType) +and [complex types](#ComplexType) are both structured types. + +Structured Types are composed of zero or more [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty). + +[Open entity types](#OpenEntityType) and [open complex +types](#OpenComplexType) allow properties to be added dynamically to +instances of the open type. + +## ##subsec Primitive Types + +Structured types are composed of other structured types and primitive +types. OData defines the following primitive types: + + **Type** **Meaning** + -------------------------------- ---------------------------------------------------------------- + `Edm.Binary` Binary data + `Edm.Boolean` Binary-valued logic + `Edm.Byte` Unsigned 8-bit integer + `Edm.Date` Date without a time-zone offset + `Edm.DateTimeOffset` Date and time with a time-zone offset, no leap seconds + `Edm.Decimal` Numeric values with decimal representation + `Edm.Double` IEEE 754 binary64 floating-point number (15-17 decimal digits) + `Edm.Duration` Signed duration in days, hours, minutes, and (sub)seconds + `Edm.Guid` 16-byte (128-bit) unique identifier + `Edm.Int16 ` Signed 16-bit integer + `Edm.Int32` Signed 32-bit integer + `Edm.Int64` Signed 64-bit integer + `Edm.SByte` Signed 8-bit integer + `Edm.Single` IEEE 754 binary32 floating-point number (6-9 decimal digits) + `Edm.Stream` Binary data stream + `Edm.String` Sequence of characters + `Edm.TimeOfDay` Clock time 00:00-23:59:59.999999999999 + `Edm.Geography` Abstract base type for all Geography types + `Edm.GeographyPoint` A point in a round-earth coordinate system + `Edm.GeographyLineString` Line string in a round-earth coordinate system + `Edm.GeographyPolygon` Polygon in a round-earth coordinate system + `Edm.GeographyMultiPoint` Collection of points in a round-earth coordinate system + `Edm.GeographyMultiLineString` Collection of line strings in a round-earth coordinate system + `Edm.GeographyMultiPolygon` Collection of polygons in a round-earth coordinate system + `Edm.GeographyCollection` Collection of arbitrary Geography values + `Edm.Geometry` Abstract base type for all Geometry types + `Edm.GeometryPoint` Point in a flat-earth coordinate system + `Edm.GeometryLineString` Line string in a flat-earth coordinate system + `Edm.GeometryPolygon` Polygon in a flat-earth coordinate system + `Edm.GeometryMultiPoint` Collection of points in a flat-earth coordinate system + `Edm.GeometryMultiLineString` Collection of line strings in a flat-earth coordinate system + `Edm.GeometryMultiPolygon` Collection of polygons in a flat-earth coordinate system + `Edm.GeometryCollection` Collection of arbitrary Geometry values + +`Edm.Date` and `Edm.DateTimeOffset` follow +[**\[XML‑Schema‑2\]**](#BMXMLSchema2) and use the proleptic Gregorian +calendar, allowing the year `0000` (equivalent to 1 BCE) and negative +years (year `-0001` being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying +persistency layer, e.g. SQL only supports years `0001` to `9999`. + +`Edm.Decimal with a `[`Scale`](#Scale)` value of floating`, +`Edm.Double`, and `Edm.Single` allow the special numeric values `‑INF`, +`INF`, and `NaN`. + +`Edm.Stream` is a primitive type that can be used as a property of an +[entity type](#EntityType) or [complex type](#ComplexType), the +underlying type for a [type definition](#TypeDefinition), or the binding +parameter or return type of an [action](#Action) or +[function](#Function). `Edm.Stream`, or a type definition whose +underlying type is `Edm.Stream`, cannot be used in collections or for +non-binding parameters to functions or actions. + +Some of these types allow [facets](#TypeFacets), defined in section +"[Type Facets](#TypeFacets)". + +See rule `primitiveLiteral` in [OData‑ABNF](#ODataABNF) for the +representation of primitive type values in URLs and +[OData‑JSON](#ODataJSON) for the representation in requests and +responses. + +## ##subsec Built-In Abstract Types + +The following built-in abstract types can be used within a model: +- `Edm.PrimitiveType` +- `Edm.ComplexType` +- `Edm.EntityType` +- `Edm.Untyped` + +Conceptually, these are the abstract base types for primitive types +(including type definitions and enumeration types), complex types, +entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except: +- `Edm.EntityType` + +- - cannot be used as the type of a singleton in an entity container + because it doesn't define a structure, which defeats the purpose + of a singleton. + - cannot be used as the type of an entity set because all entities + in an entity set must have the same key fields to uniquely + identify them within the set. + - cannot be the base type of an entity type or complex type. +- `Edm.ComplexType` + +- - cannot be the base type of an entity type or complex type. +- `Edm.PrimitiveType` + +- - cannot be used as the type of a key property of an entity type + or as the underlying type of an enumeration type. + - cannot be used as the underlying type of a type definition in a + CSDL document with a version of `4.0`. + - can be used as the underlying type of a type definition in a + CSDL document with a version of `4.01` or greater. +- `Edm.Untyped` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + - cannot be used as the type of a key property of an entity type. + - cannot be the base type of an entity type or complex type. + - cannot be used as the underlying type of a type definition or + enumeration type. +- `Collection(Edm.PrimitiveType)` + +- - cannot be used as the type of a property or term. + - cannot be used as the type of a parameter or the return type of + an action or function. +- `Collection(Edm.Untyped)` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + +## ##subsec Built-In Types for defining Vocabulary Terms + +[Vocabulary terms](#VocabularyandAnnotation) can, in addition, use +- `Edm.AnnotationPath` +- `Edm.PropertyPath` +- `Edm.NavigationPropertyPath` +- `Edm.AnyPropertyPath `(`Edm.PropertyPath `or +`Edm.NavigationPropertyPath`) +- `Edm.ModelElementPath `(any +model element, including +`Edm.AnnotationPath`,` Edm.NavigationPropertyPath`, and +`Edm.PropertyPath`) + +as the type of a primitive term, or the type of a property of a complex +type (recursively) that is exclusively used as the type of a term. See +section "[Path Expressions](#PathExpressions)" for details. + +## ##subsec Annotations + +Many parts of the model can be decorated with additional information +using [annotations](#Annotation). Annotations are identified by their +term name and an optional qualifier that allows applying the same term +multiple times to the same model element. + +A model element MUST NOT specify more than one annotation for a given +combination of term and qualifier. + +# ##sec CSDL JSON Document + +::: csdlHeadline +Document Object +::: + +::: csdl +A CSDL JSON document consists of a single JSON object. This document +object MUST contain the member `$Version`. + +The document object MAY contain the member [`$Reference`](#Reference) to +reference other CSDL documents. + +It also MAY contain members for [schemas](#Schema). + +If the CSDL JSON document is the metadata document of an OData service, +the document object MUST contain the member `$EntityContainer`. +::: + +::: csdlHeadline +`$Version` +::: + +::: csdl +The value of `$Version` is a string containing either `4.0` or `4.01`. +::: + +::: csdlHeadline +`$EntityContainer` +::: + +::: csdl +The value of `$EntityContainer` is value is the namespace-qualified name +of the entity container of that service. This is the only place where a +model element MUST be referenced with its namespace-qualified name and +use of the alias-qualified name is not allowed. +::: + +::: example +Example ##ex: +``` +{ +  "$Version": "4.01", +  "$EntityContainer": "org.example.DemoService", +  … +} +``` +::: + +## ##subsec Reference + +A reference to an external CSDL document allows to bring part of the +referenced document's content into the scope of the referencing +document. + +A reference MUST specify a URI that uniquely identifies the referenced +document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be +absolute or relative URI; relative URLs are relative to the URL of the +document containing the reference, or relative to a base URL specified +in a format-specific way. + +A reference MAY be annotated. + +The +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation, defined in [OData-VocCore](#ODataVocCore), MAY be used to +indicate a particular version of the referenced document. If the +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation is present, the `$schemaversion` system query option, defined +[OData‑Protocol](#ODataProtocol), SHOULD be used when retrieving the +referenced schema document. + +::: csdlHeadline +`$Reference` +::: + +::: csdl +The value of `$Reference` is an object that contains one member per +referenced CSDL document. The name of the pair is a URI for the +referenced document. The URI MAY be relative to the document containing +the `$Reference`. The value of each member is a reference object. +::: + +::: csdlHeadline +Reference Object +::: + +::: csdl +The reference object MAY contain the members +[`$Include`](#IncludedSchema) and +[`$IncludeAnnotations`](#IncludedAnnotations) as well as +[annotations](#Annotation). +::: + +::: example +Example ##ex: references to other CSDL documents +``` +{ +  … +  "$Reference": { +    "http://vocabs.odata.org/capabilities/v1": { +      … +    }, +    "http://vocabs.odata.org/core/v1": { +      … +    }, +    "http://example.org/display/v1": { +      … +    } +  }, +  … +} +``` +::: + +## ##subsec Included Schema + +A reference MAY include zero or more schemas from the referenced +document. + +The included schemas are identified via their [namespace](#Namespace). +The same namespace MUST NOT be included more than once, even if it is +declared in more than one referenced document. + +When including a schema, a [simple identifier](#SimpleIdentifier) value +MAY be specified as an alias for the schema that is used in qualified +names instead of the namespace. For example, an alias of `display` might +be assigned to the namespace `org.example.vocabularies.display`. An +alias-qualified name is resolved to a fully qualified name by examining +aliases for included schemas and schemas defined within the document. + +::: csdl +If an included schema specifies an alias, the alias MUST be used in +qualified names throughout the document to identify model elements of +the included schema. A mixed use of namespace-qualified names and +alias-qualified names is not allowed. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +An alias is only valid within the document in which it is declared; a +referencing document may define its own aliases for included schemas. + +::: csdlHeadline +`$Include` +::: + +::: csdl +The value of `$Include` is an array. Array items are objects that MUST +contain the member `$Namespace` and MAY contain the member `$Alias`. + +The item objects MAY contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Namespace` +::: + +::: csdl +The value of `$Namespace` is a string containing the namespace of the +included schema. +::: + +::: csdlHeadline +`$Alias` +::: + +::: csdl +The value of `$Alias` is a string containing the alias for the included +schema. +::: + +::: example +Example ##ex: references to entity models containing definitions of +vocabulary terms +``` +{ +  … +  "$Reference": { +    "http://vocabs.odata.org/capabilities/v1": { +      "$Include": [ +        { +          "$Namespace": "Org.OData.Capabilities.V1", +          "$Alias": "Capabilities" +        } +      ] +    }, +    "http://vocabs.odata.org/core/v1": { +      "$Include": [ +        { +          "$Namespace": "Org.OData.Core.V1", +          "$Alias": "Core", +          "@Core.DefaultNamespace": true +        } +      ] +    }, +    "http://example.org/display/v1": { +      "$Include": [ +        { +          "$Namespace": "org.example.display", +          "$Alias": "UI" +        } +      ] +    } +  }, +  … +} +``` +::: + +## ##subsec Included Annotations + +In addition to including whole schemas with all model constructs defined +within that schema, annotations can be included with more flexibility. + +Annotations are selectively included by specifying the +[namespace](#Namespace) of the annotations' term. Consumers can opt not +to inspect the referenced document if none of the term namespaces is of +interest for the consumer. + +In addition, the [qualifier](#Qualifier) of annotations to be included +MAY be specified. For instance, a service author might want to supply a +different set of annotations for various device form factors. If a +qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of +the target namespace, if present) SHOULD be included. If no qualifier is +specified, all annotations within the referenced document from the +specified term namespace (taking into account the target namespace, if +present) SHOULD be included. + +The qualifier also provides consumers insight about what qualifiers are +present in the referenced document. If the consumer is not interested in +that particular qualifier, the consumer can opt not to inspect the +referenced document. + +In addition, the namespace of the annotations' [target](#Target) MAY be +specified. If a target namespace is specified, only those annotations +which apply a term form the specified term namespace to a model element +of the target namespace (with the specified qualifier, if present) +SHOULD be included. If no target namespace is specified, all annotations +within the referenced document from the specified term namespace (taking +into account the qualifier, if present) SHOULD be included. + +The target namespace also provides consumers insight about what +namespaces are present in the referenced document. If the consumer is +not interested in that particular target namespace, the consumer can opt +not to inspect the referenced document. + +::: csdlHeadline +`$IncludeAnnotations` +::: + +::: csdl +The value of `$IncludeAnnotations` is an array. Array items are objects +that MUST contain the member `$TermNamespace` and MAY contain the +members `$Qualifier` and `$TargetNamespace`. +::: + +::: csdlHeadline +`$TermNamespace` +::: + +::: csdl +The value of `$TermNamespace` is a namespace. +::: + +::: csdlHeadline +`$Qualifier` +::: + +::: csdl +The value of `$Qualifier` is a simple identifier. +::: + +::: csdlHeadline +`$TargetNamespace` +::: + +::: csdl +The value of `$TargetNamespace` is a namespace. +::: + +::: example +Example ##ex: reference documents that contain annotations +``` +{ +  … +  "$Reference": { +    "http://odata.org/ann/b": { +      "$IncludeAnnotations": [ +        { +          "$TermNamespace": "org.example.validation" +        }, +        { +          "$TermNamespace": "org.example.display", +          "$Qualifier": "Tablet" +        }, +        { +          "$TermNamespace": "org.example.hcm", +          "$TargetNamespace": "com.example.Sales" +        }, +        { +          "$TermNamespace": "org.example.hcm", +          "$Qualifier": "Tablet", +          "$TargetNamespace": "com.example.Person" +        } +      ] +    } +  }, +  … +} +``` +::: + +The following annotations from `http://odata.org/ann/b` are included: +- Annotations that use a +term from the `org.example.validation` namespace, and +- Annotations that use a +term from the `org.example.display` namespace and specify a `Tablet` +qualifier and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Sales` namespace and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Person` namespace and specify a `Tablet` qualifier. + +# ##sec Schema + +One or more schemas describe the entity model exposed by an OData +service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms. + +A schema is identified by a [namespace](#Namespace). Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally +unique. A schema cannot span more than one document. + +The schema's namespace is combined with the name of elements in the +schema to create unique [qualified names](#QualifiedName), so +identifiers that are used to name types MUST be unique within a +namespace to prevent ambiguity. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +The namespace MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: csdlHeadline +Schema Object +::: + +::: csdl +A schema is represented as a member of the document object whose name is +the schema namespace. Its value is an object that MAY contain the +members [`$Alias`](#Alias) and +[`$Annotations`](#AnnotationswithExternalTargeting). + +The schema object MAY contain members representing [entity +types](#EntityType), [complex types](#ComplexType), [enumeration +types](#EnumerationType), [type definitions](#TypeDefinition), +[actions](#Action), [functions](#Function), [terms](#Term), and an +[entity container](#EntityContainer). + +The schema object MAY also contain [annotations](#Annotation) that apply +to the schema itself. +::: + +## ##subsec Alias + +A schema MAY specify an alias which MUST be a [simple +identifier](#SimpleIdentifier). + +::: csdl +If a schema specifies an alias, the alias MUST be used instead of the +namespace within qualified names throughout the document to identify +model elements of that schema. A mixed use of namespace-qualified names +and alias-qualified names is not allowed. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the +containing document and are not restricted to the schema that defines +them. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: csdlHeadline +`$Alias` +::: + +::: csdl +The value of `$Alias` is a string containing the alias for the schema. +::: + +::: example +Example ##ex: document defining a schema `org.example` with an alias and a +description for the schema +``` +{ +  … +  "org.example": { +    "$Alias": "self", +    "@Core.Description": "Example schema", +    … +  }, +  … +} +``` +::: + +## ##subsec Annotations with External Targeting + +::: csdlHeadline +`$Annotations` +::: + +::: csdl +The value of `$Annotations` is an object with one member per [annotation +target](#Target). The member name is a path identifying the [annotation +target](#Target), the member value is an object containing +[annotations](#Annotation) for that target. +::: + +::: example +Example ##ex: annotations targeting the `Person` type with qualifier +`Tablet` +``` +"org.example": { +  "$Alias": "self", +  "$Annotations": { +    "self.Person": { +      "@Core.Description#Tablet": "Dummy", +      … +    } +  } +}, +``` +::: + +# ##sec Entity Type + +Entity types are [nominal](#NominalTypes) [structured +types](#StructuredTypes) with a key that consists of one or more +references to [structural properties](#StructuralProperty). An entity +type is the template for an entity: any uniquely identifiable record +such as a customer or order. + +The entity type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +An entity type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to another entity type or collection of entity types. + +All properties MUST have a unique name within an entity type. Properties +MUST NOT have the same name as the declaring entity type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: csdlHeadline +Entity Type Object +::: + +::: csdl +An entity type is represented as a member of the schema object whose +name is the unqualified name of the entity type and whose value is an +object. + +The entity type object MUST contain the member `$Kind` with a string +value of `EntityType`. + +It MAY contain the members [`$BaseType`](#DerivedEntityType), +[`$Abstract`](#AbstractEntityType), [`$OpenType`](#OpenEntityType), +[`$HasStream`](#MediaEntityType), and [`$Key`](#Key). + +It also MAY contain members representing [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty) as well as [annotations](#Annotation). +::: + +::: example +Example ##ex: a simple entity type +``` +"Employee": { +  "$Kind": "EntityType", +  "$Key": [ +    "ID" +  ], +  "ID": {}, +  "FirstName": {}, +  "LastName": {}, +  "Manager": { +    "$Kind": "NavigationProperty", +    "$Nullable": true, +    "$Type": "self.Manager" +  } +} +``` +::: + +## ##subsec Derived Entity Type + +An entity type can inherit from another entity type by specifying it as +its base type. + +An entity type inherits the [key](#Key) as well as structural and +navigation properties of its base type. + +An entity type MUST NOT introduce an inheritance cycle by specifying a +base type. + +::: csdlHeadline +`$BaseType` +::: + +::: csdl +The value of `$BaseType` is the qualified name of the base type. +::: + +::: example +Example ##ex: a derived entity type based on the previous example +``` +"Manager": { +  "$Kind": "EntityType", +  "$BaseType": "self.Employee", +  "AnnualBudget": { +    "$Nullable": true, +    "$Type": "Edm.Decimal", +    "$Scale": 0 +  }, +  "Employees": { +    "$Kind": "NavigationProperty", +    "$Collection": true, +    "$Type": "self.Employee" +  } +} +``` +::: + +Note: the derived type has the same name as one of the properties of its +base type. + +## ##subsec Abstract Entity Type + +An entity type MAY indicate that it is abstract and cannot have +instances. + +For OData 4.0 responses a non-abstract entity type MUST define a +[key](#Key) or derive from a [base type](#DerivedEntityType) with a +defined key. + +An abstract entity type MUST NOT inherit from a non-abstract entity +type. + +::: csdlHeadline +`$Abstract` +::: + +::: csdl +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Open Entity Type + +An entity type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +An entity type derived from an open entity type MUST indicate that it is +also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: csdlHeadline +`$OpenType` +::: + +::: csdl +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +  + +## ##subsec Media Entity Type + +An entity type that does not specify a base type MAY indicate that it is +a media entity type. *Media entities* are entities that represent a +media stream, such as a photo. Use a media entity if the out-of-band +stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal +entity with one or more properties of type `Edm.Stream` if the +structured data of the entity is the main topic of interest and the +stream data is just additional information attached to the structured +data. For more information on media entities see +[OData‑Protocol](#ODataProtocol). + +An entity type derived from a media entity type MUST indicate that it is +also a media entity type. + +Media entity types MAY specify a list of acceptable media types using an +annotation with term +[`Core.AcceptableMediaTypes`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#AcceptableMediaTypes), +see [OData-VocCore](#ODataVocCore). + +::: csdlHeadline +`$HasStream` +::: + +::: csdl +The value of `$HasStream `is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Key + +An entity is uniquely identified within an entity set by its key. A key +MAY be specified if the entity type does not specify a [base +type](#DerivedEntityType) that already has a key declared. + +In order to be specified as the type of an [entity set](#EntitySet) or a +collection-valued [containment navigation +property](#ContainmentNavigationProperty), the entity type MUST either +specify a key or inherit its key from its [base +type](#DerivedEntityType). + +In OData 4.01 responses entity types used for [singletons](#Singleton) +or single-valued [navigation properties](#NavigationProperty) do not +require a key. In OData 4.0 responses entity types used for +[singletons](#Singleton) or single-valued [navigation +properties](#NavigationProperty) MUST have a key defined. + +An entity type (whether or not it is marked as abstract) MAY define a +key only if it doesn't inherit one. + +An entity type's key refers to the set of properties whose values +uniquely identify an instance of the entity type within an entity set. +The key MUST consist of at least one property. + +Key properties MUST NOT be nullable and MUST be typed with an +[enumeration type](#EnumerationType), one of the following [primitive +types](#PrimitiveTypes), or a [type definition](#TypeDefinition) based +on one of these primitive types: + +- `Edm.Boolean ` +- `Edm.Byte ` +- `Edm.Date ` +- `Edm.DateTimeOffset ` +- `Edm.Decimal ` +- `Edm.Duration ` +- `Edm.Guid ` +- `Edm.Int16 ` +- `Edm.Int32 ` +- `Edm.Int64 ` +- `Edm.SByte ` +- `Edm.String ` +- `Edm.TimeOfDay` + +Key property values MAY be language-dependent, but their values MUST be +unique across all languages and the entity ids (defined in +[OData‑Protocol](#ODataProtocol)) MUST be language independent. + +A key property MUST be a non-nullable primitive property of the entity +type itself, including non-nullable primitive properties of non-nullable +single-valued complex properties, recursively. + +In OData 4.01 the key properties of a directly related entity type MAY +also be part of the key if the navigation property is single-valued and +not nullable. This includes navigation properties of non-nullable +single-valued complex properties (recursively) of the entity type. If a +key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key. + +If the key property is a property of a complex property (recursively) or +of a directly related entity type, the key MUST specify an alias for +that property that MUST be a [simple identifier](#SimpleIdentifier) and +MUST be unique within the set of aliases, structural and navigation +properties of the declaring entity type and any of its base types. + +An alias MUST NOT be defined if the key property is a primitive property +of the entity type itself. + +For key properties that are a property of a complex or navigation +property, the alias MUST be used in the key predicate of URLs instead of +the path to the property because the required percent-encoding of the +forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be +used in the query part of URLs, where paths to properties don't require +special encoding and are a standard constituent of expressions anyway. + +::: csdlHeadline +`$Key` +::: + +::: csdl +The value of `$Key` is an array with one item per key property. + +Key properties without a key alias are represented as strings containing +the property name. + +Key properties with a key alias are represented as objects with one +member whose name is the key alias and whose value is a string +containing the path to the property. +::: + +::: example +Example ##ex: entity type with a simple key +``` +"Category": { +  "$Kind": "EntityType", +  "$Key": [ +    "ID" +  ], +  "ID": { +    "$Type": "Edm.Int32" +  }, +  "Name": { +    "$Nullable": true, +    "@Core.IsLanguageDependent": true +  } +} +``` +::: + +::: example +Example ##ex: entity type with a simple key referencing a property of a +[complex type](#ComplexType) +``` +"Category": { +  "$Kind": "EntityType", +  "$Key": [ +    { +      "EntityInfoID": "Info/ID" +    } +  ], +  "Info": { +    "$Type": "self.EntityInfo" +  }, +  "Name": { +    "$Nullable": true +  } +}, +"EntityInfo": { +  "$Kind": "ComplexType", +  "ID": { +    "$Type": "Edm.Int32" +  }, +  "Created": { +    "$Type": "Edm.DateTimeOffset", +    "$Precision": 0 +  } +} +``` +::: + +::: example +Example ##ex: entity type with a composite key +``` +"OrderLine": { +  "$Kind": "EntityType", +  "$Key": [ +    "OrderID", +    "LineNumber" +  ], +  "OrderID": { +    "$Type": "Edm.Int32" +  }, +  "LineNumber": { +    "$Type": "Edm.Int32" +  } +} +``` +::: + +Example 13 (based on example 11): requests to an entity set `Categories` +of type `Category` must use the alias +``` +GET http://host/service/Categories(EntityInfoID=1) +``` + +Example 14 (based on example 11): in a query part the value assigned to +the name attribute must be used +``` +GET http://example.org/OData.svc/Categories?\$filter=Info/ID le 100 +``` + +# ##sec Structural Property + +A structural property is a property of a structured type that has one of +the following types: +- [Primitive type](#PrimitiveTypes) +- [Complex type](#ComplexType) +- [Enumeration type](#EnumerationType) +- A collection of one of the above + +A structural property MUST specify a unique name as well as a +[type](#Type). + +The property's name MUST be a [simple identifier](#SimpleIdentifier). It +is used when referencing, serializing or deserializing the property. It +MUST be unique within the set of structural and navigation properties of +the declaring [structured type](#StructuredTypes), and MUST NOT match +the name of any navigation property in any of its base types. If a +structural property with the same name is defined in any of this type's +base types, then the property's type MUST be a type derived from the +type specified for the property of the base type and constrains this +property to be of the specified subtype for instances of this structured +type. The name MUST NOT match the name of any structural or navigation +property of any of this type's base types for OData 4.0 responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: csdlHeadline +Property Object +::: + +::: csdl +Structural properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The property object MAY contain the member `$Kind` with a string value +of `Property`. This member SHOULD be omitted to reduce document size. + +It MAY contain the member [`$Type`](#Type), [`$Collection`](#Type), +[`$Nullable`](#Nullable), [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +[`$SRID`](#SRID), and [`$DefaultValue`](#DefaultValue). + +It also MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: complex type with two properties `Dimension` and `Length` +``` +"Measurement": { +  "$Kind": "ComplexType", +  "Dimension": { +    "$MaxLength": 50, +    "$DefaultValue": "Unspecified" +  }, +  "Length": { +    "$Type": "Edm.Decimal", +    "$Precision": 18, +    "$Scale": 2 +  } +} +``` +::: + +## ##subsec Type + +The property's type MUST be a [primitive type](#PrimitiveTypes), +[complex type](#ComplexType), or [enumeration type](#EnumerationType) in +scope, or a collection of one of these types. + +A collection-valued property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in\ +[OData-VocCore](#ODataVocCore)**)**, to specify that it supports a +stable ordering. + +A collection-valued property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: csdlHeadline +`$Type` and `$Collection` +::: + +::: csdl +For single-valued properties the value of `$Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `$Type` is the qualified +name of the property's item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. This +member SHOULD be omitted for string properties to reduce document size. +::: + +::: example +Example ##ex: property `Units` that can have zero or more strings as its +value +``` +"Units": { +  "$Collection": true +} +``` +::: + +## ##subsec Type Facets + +Facets modify or constrain the acceptable values of a property. + +For single-valued properties the facets apply to the value of the +property. For collection-valued properties the facets apply to the items +in the collection. + +### ##subsubsec Nullable + +A Boolean value specifying whether the property can have the value +`null`. + +::: csdlHeadline +`$Nullable` +::: + +::: csdl +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + +### ##subsubsec MaxLength + +A positive integer value specifying the maximum length of a binary, +stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length +(number of code points for Unicode). + +If no maximum length is specified, clients SHOULD expect arbitrary +length. + +::: csdlHeadline +`$MaxLength` +::: + +::: csdl +The value of `$MaxLength` is a positive integer. + +Note: **\[**[**OData-CSDLXML**](#ODataCSDL)**\]** defines a symbolic +value `max` that is only allowed in OData 4.0 responses. This symbolic +value is not allowed in CDSL JSON documents at all. Services MAY instead +specify the concrete maximum length supported for the type by the +service or omit the member entirely. +::: + +### ##subsubsec Precision + +For a decimal value: the maximum number of significant decimal digits of +the property's value; it MUST be a positive integer. + +For a temporal value (datetime-with-timezone-offset, duration, or +time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve. + +Note: service authors SHOULD be aware that some clients are unable to +support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential +for data loss when round-tripping values of greater precision. Updating +via `PATCH` and exclusively specifying modified properties will reduce +the risk for unintended data loss. + +Note: duration properties supporting a granularity less than seconds +(e.g. minutes, hours, days) can be annotated with term +[`Measures.DurationGranularity`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Measures.V1.md#DurationGranularity), +see [OData-VocMeasures](#ODataVocMeasures). + +::: csdlHeadline +`$Precision` +::: + +::: csdl +The value of `$Precision` is a number. + +Absence of `$Precision` means arbitrary precision. +::: + +::: example +Example ##ex: `Precision` facet applied to the `DateTimeOffset` type +``` +"SuggestedTimes": { +  "$Type": Edm.DateTimeOffset", +  "$Collection": true, +  "$Precision": 6 +} +``` +::: + +### ##subsubsec Scale + +A non-negative integer value specifying the maximum number of digits +allowed to the right of the decimal point, or one of the symbolic values +`floating` or `variable`. + +The value `floating` means that the decimal property represents a +decimal floating-point number whose number of significant digits is the +value of the [`Precision`](#Precision) facet. OData 4.0 responses MUST +NOT specify the value `floating`. + +The value `variable` means that the number of digits to the right of the +decimal point can vary from zero to the value of the +[`Precision`](#Precision) facet. + +An integer value means that the number of digits to the right of the +decimal point may vary from zero to the value of the `Scale` facet, and +the number of digits to the left of the decimal point may vary from one +to the value of the `Precision` facet minus the value of the `Scale` +facet. If `Precision` is equal to `Scale`, a single zero MUST precede +the decimal point. + +The value of `Scale` MUST be less than or equal to the value of +[`Precision`](#Precision). + +Note: if the underlying data store allows negative scale, services may +use a [`Precision`](#Precision) with the absolute value of the negative +scale added to the actual number of significant decimal digits, and +client-provided values may have to be rounded before being stored. + +::: csdlHeadline +`$Scale` +::: + +::: csdl +The value of `$Scale` is a number or a string with one of the symbolic +values `floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +Absence of `$Scale` means `variable`. +::: + +::: example +Example ##ex: [`Precision`](#Precision)`=3` and `Scale=2`.\ +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 +``` +"Amount32": { +  "$Nullable": true, +  "$Type": "Edm.Decimal", +  "$Precision": 3, +  "$Scale": 2 +} +``` +::: + +::: example +Example ##ex: `Precision=2` equals `Scale`.\ +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 +``` +"Amount22": { +  "$Nullable": true, +  "$Type": "Edm.Decimal", +  "$Precision": 2, +  "$Scale": 2 +} +``` +::: + +::: example +Example ##ex: `Precision=3` and a variable `Scale`.\ +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. +``` +"Amount3v": { +  "$Nullable": true, +  "$Type": "Edm.Decimal", +  "$Precision": 3 +} +``` +::: + +::: example +Example ##ex: `Precision=7` and a floating `Scale`.\ +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. +``` +`"Amount7f": {` +::: + +`  "$Nullable": true, +  "$Type": "Edm.Decimal", +  "$Precision": 7, +  "$Scale": "floating" +} +``` + +### ##subsubsec Unicode + +For a string property the `Unicode` facet indicates whether the property +might contain and accept string values with Unicode characters (code +points) beyond the ASCII character set. The value `false` indicates that +the property will only contain and accept string values with characters +limited to the ASCII character set. + +If no value is specified, the `Unicode` facet defaults to `true`. + +::: csdlHeadline +`$Unicode` +::: + +::: csdl +The value of `$Unicode` is one of the Boolean literals `true` or +`false`. Absence of the member means `true`. +::: + +### ##subsubsec SRID + +For a geometry or geography property the `SRID` facet identifies which +spatial reference system is applied to values of the property on type +instances. + +The value of the `SRID` facet MUST be a non-negative integer or the +special value `variable`. If no value is specified, the facet defaults +to `0` for `Geometry` types or `4326` for `Geography` types. + +The valid values of the `SRID` facet and their meanings are as defined +by the European Petroleum Survey Group [**\[EPSG\]**](#BMEPSG)**.** + +::: csdlHeadline +`$SRID` +::: + +::: csdl +The value of `$SRID` is a string containing a number or the symbolic +value `variable`. +::: + +### ##subsubsec [Default Value](#DefaultValue) + +A primitive or enumeration property MAY define a default value that is +used if the property is not explicitly represented in an annotation or +the body of a request or response. + +If no value is specified, the client SHOULD NOT assume a default value. + +::: csdlHeadline +`$DefaultValue` +::: + +::: csdl +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the property, see +**\[**[**OData-JSON**](#ODataJSON)**\]**. For properties of type +`Edm.Decimal` and `Edm.Int64` the representation depends on the media +type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumber). +::: + +# ##sec Navigation Property + +A navigation property allows navigation to related entities. It MUST +specify a unique name as well as a type. + +The navigation property's name MUST be a [simple +identifier](#SimpleIdentifier). It is used when referencing, serializing +or deserializing the navigation property. It MUST be unique within the +set of structural and navigation properties of the declaring [structured +type](#StructuredTypes), and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the +same name is defined in any of this type's base types, then the +navigation property's type MUST be a type derived from the type +specified for the navigation property of the base type, and constrains +this navigation property to be of the specified subtype for instances of +this structured type. The name MUST NOT match the name of any structural +or navigation property of any of this type's base types for OData 4.0 +responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: csdlHeadline +Navigation Property Object +::: + +::: csdl +Navigation properties are represented as members of the object +representing a structured type. The member name is the property name, +the member value is an object. + +The navigation property object MUST contain the member `$Kind` with a +string value of `NavigationProperty`. + +It MUST contain the member [`$Type`](#NavigationPropertyType), and it +MAY contain the members [`$Collection`](#NavigationPropertyType), +[`$Nullable`](#NullableNavigationProperty), +[`$Partner`](#PartnerNavigationProperty), +[`$ContainsTarget`](#ContainmentNavigationProperty), +[`$ReferentialConstraint`](#ReferentialConstraint), and +[`$OnDelete`](#OnDeleteAction). + +It also MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: the `Product` entity type has a navigation property to a +`Category`, which has a navigation link back to one or more products +``` +"Product": { +  "$Kind": "EntityType", +  … +  "Category": { +    "$Kind": "NavigationProperty", +    "$Type": "self.Category", +    "$Partner": "Products", +    "$ReferentialConstraint": { +      "CategoryID": "ID" +    } +  }, +  "Supplier": { +    "$Kind": "NavigationProperty", +    "$Type": "self.Supplier" +  } +}, +"Category": { +  "$Kind": "EntityType", +  … +  "Products": { +    "$Kind": "NavigationProperty", +    "$Collection": true, +    "$Type": "self.Product", +    "$Partner": "Category", +    "$OnDelete": "Cascade", +    "$OnDelete@Core.Description": "Delete all related entities" +  } +} +``` +::: + +## ##subsec Navigation Property Type + +The navigation property's type MUST be an [entity type](#EntityType) in +scope, the [abstract type](#BuiltInAbstractTypes) `Edm.EntityType`, or a +collection of one of these types. + +If the type is a collection, an arbitrary number of entities can be +related. Otherwise there is at most one related entity. + +The related entities MUST be of the specified entity type or one of its +subtypes. + +For a collection-valued containment navigation property the specified +entity type MUST have a [key](#Key) defined. + +A collection-valued navigation property MAY be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-VocCore](#ODataVocCore)**)**, to specify that it +supports a stable ordering. + +A collection-valued navigation property MAY be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-VocCore](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: csdlHeadline +`$Type` and `$Collection` +::: + +::: csdl +For single-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `$Type` is the +qualified name of the navigation property's item type, and the member +`$Collection` MUST be present with the literal value `true`. +::: + +## ##subsec Nullable Navigation Property + +A Boolean value specifying whether the declaring type MAY have no +related entity. If false, instances of the declaring structured type +MUST always have a related entity. + +Nullable MUST NOT be specified for a collection-valued navigation +property, a collection is allowed to have zero items. + +::: csdlHeadline +`$Nullable` +::: + +::: csdl +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Partner Navigation Property + +A navigation property of an [entity type](#EntityType) MAY specify a +partner navigation property. Navigation properties of complex types MUST +NOT specify a partner. + +If specified, the partner navigation property is identified by a path +relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that +type or a derived type. The path MAY traverse complex types, including +derived complex types, but MUST NOT traverse any navigation properties. +The type of the partner navigation property MUST be the declaring entity +type of the current navigation property or one of its parent entity +types. + +If the partner navigation property is single-valued, it MUST lead back +to the source entity from all related entities. If the partner +navigation property is collection-valued, the source entity MUST be part +of that collection. + +If no partner navigation property is specified, no assumptions can be +made as to whether one of the navigation properties on the target type +will lead back to the source entity. + +If a partner navigation property is specified, this partner navigation +property MUST either specify the current navigation property as its +partner to define a bi-directional relationship or it MUST NOT specify a +partner navigation property. The latter can occur if the partner +navigation property is defined on a complex type, or if the current +navigation property is defined on a type derived from the type of the +partner navigation property. + +::: csdlHeadline +`$Partner` +::: + +::: csdl +The value of `$Partner` is a string containing the path to the partner +navigation property. +::: + +## ##subsec Containment Navigation Property + +A navigation property MAY indicate that instances of its declaring +structured type contain the targets of the navigation property, in which +case the navigation property is called a *containment navigation +property*. + +Containment navigation properties define an implicit entity set for each +instance of its declaring structured type. This implicit entity set is +identified by the read URL of the navigation property for that +structured type instance. + +Instances of the structured type that declares the navigation property, +either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The +canonical URL for contained entities is the canonical URL of the +containing instance, followed by the path segment of the navigation +property and the key of the contained entity, see +[OData‑URL](#ODataURL). + +Entity types used in collection-valued containment navigation properties +MUST have a [key](#Key) defined. + +For items of an ordered collection of complex types (those annotated +with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term defined in [OData-VocCore](#ODataVocCore)**)**, the canonical URL +of the item is the canonical URL of the collection appended with a +segment containing the zero-based ordinal of the item. Items within in +an unordered collection of complex types do not have a canonical URL. +Services that support unordered collections of complex types declaring a +containment navigation property, either directly or indirectly via a +property of complex type, MUST specify the URL for the navigation link +within a payload representing that item, according to format-specific +rules. + +OData 4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued +property. + +An entity cannot be referenced by more than one containment +relationship, and cannot both belong to an entity set declared within +the entity container and be referenced by a containment relationship. + +Containment navigation properties MUST NOT be specified as the last path +segment in the path of a [navigation property +binding](#NavigationPropertyBinding). + +When a containment navigation property navigates between entity types in +the same inheritance hierarchy, the containment is called *recursive*. + +Containment navigation properties MAY specify a partner navigation +property. If the containment is recursive, the relationship defines a +tree, thus the partner navigation property MUST be +[nullable](#NullableNavigationProperty) (for the root of the tree) and +single-valued (for the parent of a non-root entity). If the containment +is not recursive, the partner navigation property MUST NOT be nullable. + +An entity type inheritance chain MUST NOT contain more than one +navigation property with a partner navigation property that is a +containment navigation property. + +Note: without a partner navigation property, there is no reliable way +for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity +can also be reached via a non-containment navigation path. + +::: csdlHeadline +`$ContainsTarget` +::: + +::: csdl +The value of `$ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Referential Constraint + +A single-valued navigation property MAY define one or more referential +constraints. A referential constraint asserts that the *dependent +property* (the property defined on the structured type declaring the +navigation property) MUST have the same value as the *principal +property* (the referenced property declared on the entity type that is +the target of the navigation). + +The type of the dependent property MUST match the type of the principal +property, or both types MUST be complex types. + +If the principle property references an entity, then the dependent +property must reference the same entity. + +If the principle property's value is a complex type instance, then the +dependent property's value must be a complex type instance with the same +properties, each with the same values. + +If the navigation property on which the referential constraint is +defined is nullable, or the principal property is nullable, then the +dependent property MUST also be nullable. If both the navigation +property and the principal property are not nullable, then the dependent +property MUST NOT be nullable. + +::: csdlHeadline +`$ReferentialConstraint` +::: + +::: csdl +The value of `$ReferentialConstraint` is an object with one member per +referential constraint. The member name is the path to the dependent +property, this path is relative to the structured type declaring the +navigation property. The member value is a string containing the path to +the principal property, this path is relative to the entity type that is +the target of the navigation property. + +It also MAY contain [annotations](#Annotation). These are prefixed with +the path of the dependent property of the annotated referential +constraint. +::: + +::: example +Example ##ex: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. +``` +"Product": { +  "$Kind": "EntityType", +  … +  "CategoryID": {}, +  "CategoryKind": {}, +  "Category": { +    "$Kind": "NavigationProperty", +    "$Type": "self.Category", +    "$Partner": "Products", +    "$ReferentialConstraint": { +      "CategoryID": "ID", +      "CategoryKind": "Kind" +      "CategoryKind@Core.Description": "Referential Constraint to non-key property" +    } +  } +}, +"Category": { +  "$Kind": "EntityType", +  "$Key": [ +    "ID" +  ], +  "ID": {}, +  "Kind": { +    "$Nullable": true +  }, +  … +} +``` +::: + +## ##subsec On-Delete Action + +A navigation property MAY define an on-delete action that describes the +action the service will take on related entities when the entity on +which the navigation property is defined is deleted. + +The action can have one of the following values: + +- `Cascade`, meaning the related entities will be deleted if the + source entity is deleted, +- `None`, meaning a `DELETE` request on a source entity with related + entities will fail, +- `SetNull`, meaning all properties of related entities that are tied + to properties of the source entity via a referential constraint and + that do not participate in other referential constraints will be set + to null, +- `SetDefault`, meaning all properties of related entities that are + tied to properties of the source entity via a referential constraint + and that do not participate in other referential constraints will be + set to their default value. + +If no on-delete action is specified, the action taken by the service is +not predictable by the client and could vary per entity. + +::: csdlHeadline +`$OnDelete` +::: + +::: csdl +The value of `$OnDelete` is a string with one of the values `Cascade`, +`None`, `SetNull`, or `SetDefault`. + +[Annotations](#Annotation) for `$OnDelete` are prefixed with +`$OnDelete`. +::: + +::: example +Example ##ex: deletion of a category implies deletion of the related +products in that category +``` +"Category": { +  "$Kind": "EntityType", +  … +  "Products": { +    "$Kind": "NavigationProperty", +    "$Collection": true, +    "$Type": "self.Product", +    "$Partner": "Category", +    "$OnDelete": "Cascade", +    "$OnDelete@Core.Description": "Delete all products in this category" +  } +} +``` +::: + +# ##sec Complex Type + +Complex types are keyless [nominal](#NominalTypes) [structured +types](#StructuredTypes). The lack of a key means that instances of +complex types cannot be referenced, created, updated or deleted +independently of an entity type. Complex types allow entity models to +group properties into common structures. + +The complex type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +A complex type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to an entity type or a collection of entity types. + +All properties MUST have a unique name within a complex type. Properties +MUST NOT have the same name as the declaring complex type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: csdlHeadline +Complex Type Object +::: + +::: csdl +A complex type is represented as a member of the schema object whose +name is the unqualified name of the complex type and whose value is an +object. + +The complex type object MUST contain the member `$Kind` with a string +value of `ComplexType`. It MAY contain the members +[`$BaseType`](#DerivedComplexType), [`$Abstract`](#AbstractComplexType), +and [`$OpenType`](#OpenComplexType). It also MAY contain members +representing [structural properties](#StructuralProperty) and +[navigation properties](#NavigationProperty) as well as +[annotations](#Annotation). +::: + +::: example +Example ##ex: a complex type used by two entity types +``` +"Dimensions": { +  "$Kind": "ComplexType", +  "Height": { +    "$Type": "Edm.Decimal", +    "$Scale": 0 +  }, +  "Weight": { +    "$Type": "Edm.Decimal", +    "$Scale": 0 +  }, +  "Length": { +    "$Type": "Edm.Decimal", +    "$Scale": 0 +  } +}, +"Product": { +  … +  "ProductDimensions": { +    "$Nullable": true, +    "$Type": "self.Dimensions" +  }, +  "ShippingDimensions": { +    "$Nullable": true, +    "$Type": "self.Dimensions" +  } +}, +"ShipmentBox": { +  … +  "Dimensions": { +    "$Nullable": true, +    "$Type": "self.Dimensions" +  } +} +``` +::: + +## ##subsec Derived Complex Type + +A complex type can inherit from another complex type by specifying it as +its base type. + +A complex type inherits the structural and navigation properties of its +base type. + +A complex type MUST NOT introduce an inheritance cycle by specifying a +base type. + +The rules for annotations of derived complex types are described in +section 14.2. + +::: csdlHeadline +`$BaseType` +::: + +::: csdl +The value of `$BaseType` is the qualified name of the base type. +::: + +## ##subsec Abstract Complex Type + +A complex type MAY indicate that it is abstract and cannot have +instances. + +::: csdlHeadline +`$Abstract` +::: + +::: csdl +The value of `$Abstract` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Open Complex Type + +A complex type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +A complex type derived from an open complex type MUST indicate that it +is also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: csdlHeadline +`$OpenType` +::: + +::: csdl +The value of `$OpenType` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +# ##sec Enumeration Type + +Enumeration types are [nominal](#NominalTypes) types that represent a +non-empty series of related values. Enumeration types expose these +related values as members of the enumeration. + +The enumeration type's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Although enumeration types have an underlying numeric value, the +preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the `AllowedValues` annotation defined in +[OData-VocCore](#ODataVocCore). + +Enumeration types marked as flags allow values that consist of more than +one enumeration member at a time. + +::: csdlHeadline +Enumeration Type Object +::: + +::: csdl +An enumeration type is represented as a member of the schema object +whose name is the unqualified name of the enumeration type and whose +value is an object. + +The enumeration type object MUST contain the member `$Kind` with a +string value of `EnumType`. + +It MAY contain the members [`$UnderlyingType`](#UnderlyingIntegerType) +and [`$IsFlags`](#FlagsEnumerationType). + +The enumeration type object MUST contain members representing [the +enumeration type members](#EnumerationTypeMember). + +The enumeration type object MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: a simple flags-enabled enumeration +``` +"FileAccess": { +  "$Kind": "EnumType", +  "$UnderlyingType": "Edm.Int32", +  "$IsFlags": true, +  "Read": 1, +  "Write": 2, +  "Create": 4, +  "Delete": 8 +} +``` +::: + +## ##subsec Underlying Integer Type + +An enumeration type MAY specify one of `Edm.Byte`, `Edm.SByte`, +`Edm.Int16`, `Edm.Int32`, or `Edm.Int64` as its underlying type. + +If not explicitly specified, `Edm.Int32` is used as the underlying type. + +::: csdlHeadline +`$UnderlyingType` +::: + +::: csdl +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + +## ##subsec Flags Enumeration Type + +An enumeration type MAY indicate that the enumeration type allows +multiple members to be selected simultaneously. + +If not explicitly specified, only one enumeration type member MAY be +selected simultaneously. + +::: csdlHeadline +`$IsFlags` +::: + +::: csdl +The value of `$IsFlags` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +::: example +Example ##ex: pattern values can be combined, and some combined values +have explicit names +``` +"Pattern": { +  "$Kind": "EnumType", +  "$UnderlyingType": "Edm.Int32", +  "$IsFlags": true, +  "Plain": 0, +  "Red": 1, +  "Blue": 2, +  "Yellow": 4, +  "Solid": 8, +  "Striped": 16, +  "SolidRed": 9, +  "SolidBlue": 10, +  "SolidYellow": 12, +  "RedBlueStriped": 19, +  "RedYellowStriped": 21, +  "BlueYellowStriped": 22 +} +``` +::: + +## ##subsec Enumeration Type Member + +Enumeration type values consist of discrete members. + +Each member is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within the +enumeration type. Names are case-sensitive, but service authors SHOULD +NOT choose names that differ only in case. + +Each member MUST specify an associated numeric value that MUST be a +valid value for the underlying type of the enumeration type. + +Enumeration types can have multiple members with the same value. Members +with the same numeric value compare as equal, and members with the same +numeric value can be used interchangeably. + +Enumeration members are sorted by their numeric value. + +For flag enumeration types the combined numeric value of simultaneously +selected members is the bitwise OR of the discrete numeric member +values. + +::: csdlHeadline +Enumeration Member Object +::: + +::: csdl +Enumeration type members are represented as JSON object members, where +the object member name is the enumeration member name and the object +member value is the enumeration member value. + +For members of [flags enumeration types](#FlagsEnumerationType) a +combined enumeration member value is equivalent to the bitwise OR of the +discrete values. + +Annotations for enumeration members are prefixed with the enumeration +member name. +::: + +::: example +Example ##ex: `FirstClass` has a value of `0`, `TwoDay` a value of 1, and +`Overnight` a value of 2. +``` +"ShippingMethod": { +  "$Kind": "EnumType", +  "FirstClass": 0, +  "FirstClass@Core.Description": "Shipped with highest priority", +  "TwoDay": 1, +  "TwoDay@Core.Description": "Shipped within two days", +  "Overnight": 2, +  "Overnight@Core.Description": "Shipped overnight", +  "@Core.Description": "Method of shipping" +} +``` +::: + +# ##sec Type Definition + +A type definition defines a specialization of one of the [primitive +types](#PrimitiveTypes) or of the built-in abstract type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes). + +The type definition's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Type definitions can be used wherever a primitive type is used (other +than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions +defined using the same underlying type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden. + +::: csdlHeadline +Type Definition Object +::: + +::: csdl +A type definition is represented as a member of the schema object whose +name is the unqualified name of the type definition and whose value is +an object. + +The type definition object MUST contain the member `$Kind` with a string +value of `TypeDefinition` and the member +[`$UnderlyingType`](#UnderlyingPrimitiveType). It MAY contain the +members [`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID), +and it MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: +``` +\"Length\": { +::: + +  \"\$Kind\": \"TypeDefinition\", + +  \"\$UnderlyingType\": \"Edm.Int32\", + +  \"@Measures.Unit\": \"Centimeters\" + +}, + +\"Weight\": { + +  \"\$Kind\": \"TypeDefinition\", + +  \"\$UnderlyingType\": \"Edm.Int32\", + +  \"@Measures.Unit\": \"Kilograms\" + +}, + +\"Size\": { + +  \"\$Kind\": \"ComplexType\", + +  \"Height\": { + +`    "$Nullable": true,` + +    \"\$Type\": \"self.Length\" + +  }, + +  \"Weight\": { + +`    "$Nullable": true,` + +    \"\$Type\": \"self.Weight\" + +  } + +} +``` + +## ##subsec Underlying Primitive Type + +The underlying type of a type definition MUST be a primitive type that +MUST NOT be another type definition. + +::: csdlHeadline +`$UnderlyingType` +::: + +::: csdl +The value of `$UnderlyingType` is the qualified name of the underlying +type. +::: + +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`$MaxLength`](#MaxLength), +`$`[`Unicode`](#Unicode), `$`[`Precision`](#Precision), +`$`[`Scale`](#Scale), or `$`[`SRID`](#SRID). + +Additional facets appropriate for the underlying type MAY be specified +when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified. + +For a type definition with underlying type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes) no facets are applicable, +neither in the definition itself nor when the type definition is used, +and these should be ignored by the client. + +Where type definitions are used, the type definition is returned in +place of the primitive type wherever the type is specified in a +response. + +# ##sec Action and Function + +## ##subsec Action + +Actions are service-defined operations that MAY have observable side +effects and MAY return a single instance or a collection of instances of +any type. + +The action's name is a [simple identifier](#SimpleIdentifier) that MUST +be unique within its schema. + +Actions cannot be composed with additional path segments. + +An action MAY specify a [return type](#ReturnType) that MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +An action MAY define [parameters](#Parameter) used during the execution +of the action. + +## ##subsec Action Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) actions support +overloading (multiple actions having the same name within the same +schema) by binding parameter type. The combination of action name and +the binding parameter type MUST be unique within a schema. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) actions do not support +overloads. The names of all unbound actions MUST be unique within a +schema. + +An unbound action MAY have the same name as a bound action. + +::: csdlHeadline +Action Overload Object +::: + +::: csdl +An action is represented as a member of the schema object whose name is +the unqualified name of the action and whose value is an array. The +array contains one object per action overload. + +The action overload object MUST contain the member `$Kind` with a string +value of `Action`. + +It MAY contain the members +[`$IsBound`](#BoundorUnboundActionorFunctionOverlo), +[`$EntitySetPath`](#EntitySetPath), [`$Parameter`](#Parameter), and +[`$ReturnType`](#ReturnType), and it MAY contain +[annotations](#Annotation). +::: + +## ##subsec Function + +Functions are service-defined operations that MUST NOT have observable +side effects and MUST return a single instance or a collection of +instances of any type. + +The function's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +Functions MAY be [composable](#ComposableFunction). + +The function MUST specify a [return type](#ReturnType) which MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +A function MAY define [parameters](#Parameter) used during the execution +of the function. + +## ##subsec Function Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading (multiple functions having the same name within the same +schema) subject to the following rules: +- The combination of function name, +binding parameter type, and unordered set of non-binding parameter names +MUST be unique within a schema. +- The combination of function name, +binding parameter type, and ordered set of parameter types MUST be +unique within a schema. +- All bound functions with the same +function name and binding parameter type within a schema MUST specify +the same return type. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading subject to the following rules: +- The combination of function name and +unordered set of parameter names MUST be unique within a schema. +- The combination of function name and +ordered set of parameter types MUST be unique within a schema. +- All unbound functions with the same +function name within a schema MUST specify the same return type. + +An unbound function MAY have the same name as a bound function. + +Note that [type definitions](#TypeDefinition) can be used to +disambiguate overloads for both bound and unbound functions, even if +they specify the same underlying type. + +::: csdlHeadline +Function Overload Object +::: + +::: csdl +A function is represented as a member of the schema object whose name is +the unqualified name of the function and whose value is an array. The +array contains one object per function overload. + +The function overload object MUST contain the member `$Kind` with a +string value of `Function`. + +It MUST contain the member [`$ReturnType`](#ReturnType), and it MAY +contain the members [`$IsBound`](#BoundorUnboundActionorFunctionOverlo), +[`$EntitySetPath`](#EntitySetPath), and` `[`$Parameter`](#Parameter), +and it MAY contain [annotations](#Annotation). +::: + +## ##subsec Bound or Unbound Action or Function Overloads + +An action or function overload MAY indicate that it is bound. If not +explicitly indicated, it is unbound. + +Bound actions or functions are invoked on resources matching the type of +the binding parameter. The binding parameter can be of any type, and it +MAY be [nullable](#Nullable). + +Unbound actions are invoked from the entity container through an [action +import](#ActionImport). + +Unbound functions are invoked as static functions within a filter or +orderby expression, or from the entity container through a [function +import](#FunctionImport). + +::: csdlHeadline +`$IsBound` +::: + +::: csdl +The value of `$IsBound` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Entity Set Path + +Bound actions and functions that return an entity or a collection of +entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter +value. + +The entity set path consists of a series of segments joined together +with forward slashes. + +The first segment of the entity set path MUST be the name of the binding +parameter. The remaining segments of the entity set path MUST represent +navigation segments or type casts. + +A navigation segment names the [simple identifier](#SimpleIdentifier) of +the [navigation property](#NavigationProperty) to be traversed. A +type-cast segment names the [qualified name](#QualifiedName) of the +entity type that should be returned from the type cast. + +::: csdlHeadline +`$EntitySetPath` +::: + +::: csdl +The value of `$EntitySetPath` is a string containing the entity set +path. +::: + +## ##subsec Composable Function + +A function MAY indicate that it is composable. If not explicitly +indicated, it is not composable. + +A composable function can be invoked with additional path segments or +key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for +the type returned by the composable function. + +::: csdlHeadline +`$IsComposable` +::: + +::: csdl +The value of `$IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. +::: + +## ##subsec Return Type + +The return type of an action or function overload MAY be any type in +scope, or a collection of any type in scope. + +The facets [`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID) can be +used as appropriate to specify value restrictions of the return type, as +well as the [`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For a single-valued return type the facets apply to the returned value. +For a collection-valued return type the facets apply to the items in the +returned collection. + +::: csdlHeadline +`$ReturnType` +::: + +::: csdl +The value of `$ReturnType` is an object. It MAY contain the members +`$Type`, `$Collection`, `$Nullable`, [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID). + +It also MAY contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Type` and `$Collection` +::: + +::: csdl +For single-valued return types the value of `$Type` is the qualified +name of the returned type. + +For collection-valued return types the value of `$Type` is the qualified +name of the returned item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. +::: + +::: csdlHeadline +`$Nullable` +::: + +::: csdl +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +If the return type is a collection of entity types, the `$Nullable` +member has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + +## ##subsec Parameter + +An action or function overload MAY specify parameters. + +A bound action or function overload MUST specify at least one parameter; +the first parameter is its binding parameter. The order of parameters +MUST NOT change unless the schema version changes. + +Each parameter MUST have a name that is a [simple +identifier](#SimpleIdentifier). The parameter name MUST be unique within +the action or function overload. + +The parameter MUST specify a type. It MAY be any type in scope, or a +collection of any type in scope. + +The facets [`MaxLength`](#MaxLength), [`Precision`](#Precision), +[`Scale`](#Scale), or [`SRID`](#SRID) can be used as appropriate to +specify value restrictions of the parameter, as well as the +[`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +For single-valued parameters the facets apply to the parameter value. If +the parameter value is a collection, the facets apply to the items in +the collection. + +::: csdlHeadline +`$Parameter` +::: + +::: csdl +The value of `$Parameter` is an array. The array contains one object per +parameter. +::: + +::: csdlHeadline +Parameter Object +::: + +::: csdl +A parameter object MUST contain the member `$Name`, and it MAY contain +the members `$Type`, `$Collection`, `$Nullable`, +[`$MaxLength`](#MaxLength), [`$Unicode`](#Unicode), +[`$Precision`](#Precision), [`$Scale`](#Scale), and [`$SRID`](#SRID). + +Parameter objects MAY also contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Name` +::: + +::: csdl +The value of `$Name` is a string containing the parameter name. +::: + +::: csdlHeadline +`$Type` and `$Collection` +::: + +::: csdl +For single-valued parameters the value of `$Type` is the qualified name +of the accepted type. + +For collection-valued parameters the value of `$Type` is the qualified +name of the accepted item type, and the member `$Collection` MUST be +present with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. +::: + +::: csdlHeadline +`$Nullable` +::: + +::: csdl +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`. + +For single-valued parameters the value `true` means that the parameter +accepts a `null` value. + +For collection-valued parameters the parameter value will always be a +collection that MAY be empty. In this case `$Nullable` applies to items +of the collection and specifies whether the collection MAY contain +`null` values. +::: + +::: example +Example ##ex: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `edm:Parameter` element. +``` +\"TopSellingProducts\": \[ +::: + +  { + +    \"\$Kind\": \"Function\", + +    \"\$Parameter\": \[ + +      { + +        \"\$Name\": \"Year\", + +        \"\$Nullable\": true, + +        \"\$Type\": \"Edm.Decimal\", + +        \"\$Precision\": 4, + +        \"\$Scale\": 0 + +      } + +    \], + +    \"\$ReturnType\": { + +      \"\$Collection\": true, + +      \"\$Type\": \"self.Product\" + +    } + +  } + +\] +``` + +# ##sec Entity Container + +Each metadata document used to describe an OData service MUST define +exactly one entity container. + +The entity container's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Entity containers define the entity sets, singletons, function and +action imports exposed by the service. + +Entity set, singleton, action import, and function import names MUST be +unique within an entity container. + +An [*entity set*](#EntitySet) allows access to entity type instances. +Simple entity models frequently have one entity set per entity type. + +::: example +Example ##ex: one entity set per entity type +``` +"Products": { +  "$Collection": true, +  "$Type": "self.Product" +}, +"Categories": { +  "$Collection": true, +  "$Type": "self.Category" +} +``` +::: + +Other entity models may expose multiple entity sets per type. + +::: example +Example ##ex: three entity sets referring to the two entity types +``` +"StandardCustomers": { +  "$Collection": true, +  "$Type": "self.Customer", +  "$NavigationPropertyBinding": { +    "Orders": "Orders" +  } +}, +"PreferredCustomers": { +  "$Collection": true, +  "$Type": "self.Customer", +  "$NavigationPropertyBinding": { +    "Orders": "Orders" +  } +}, +"Orders": { +  "$Collection": true, +  "$Type": "self.Order" +} +``` +::: + +There are separate entity sets for standard customers and preferred +customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have [navigation +property bindings](#NavigationPropertyBinding) to the orders entity set, +but the orders entity set does not have a navigation property binding +for the Customer navigation property, since it could lead to either set +of customers. + +An entity set can expose instances of the specified entity type as well +as any entity type inherited from the specified entity type. + +A [*singleton*](#Singleton) allows addressing a single entity directly +from the entity container without having to know its key, and without +requiring an entity set. + +A [*function import*](#FunctionImport) or an [*action +import*](#ActionImport) is used to expose a function or action defined +in an entity model as a top level resource. + +::: csdlHeadline +Entity Container Object +::: + +::: csdl +An entity container is represented as a member of the schema object +whose name is the unqualified name of the entity container and whose +value is an object. + +The entity container object MUST contain the member `$Kind` with a +string value of `EntityContainer`. + +The entity container object MAY contain the member +[`$Extends`](#ExtendinganEntityContainer), members representing [entity +sets](#EntitySet), [singletons](#Singleton), [action +imports](#ActionImport), and [function imports](#FunctionImport), as +well as [annotations](#Annotation). +::: + +::: example +Example ##ex: An entity container aggregates entity sets, singletons, +action imports, and function imports. +``` +"DemoService": { +  "$Kind": "EntityContainer", +  "Products": { +    "$Collection": true, +    "$Type": "self.Product", +    "$NavigationPropertyBinding": { +      "Category": "Categories", +      "Supplier": "Suppliers" +    }, +    "@UI.DisplayName": "Product Catalog" +  }, +  "Categories": { +    "$Collection": true, +    "$Type": "self.Category", +    "$NavigationPropertyBinding": { +      "Products": "Products" +    } +  }, +  "Suppliers": { +    "$Collection": true, +    "$Type": "self.Supplier", +    "$NavigationPropertyBinding": { +      "Products": "Products" +    }, +    "@UI.DisplayName": "Supplier Directory" +  }, +  "MainSupplier": { +    "$Type": "self.Supplier" +  }, +  "LeaveRequestApproval": { +    "$Action": "self.Approval" +  }, +  "ProductsByRating": { +    "$EntitySet": "Products", +    "$Function": "self.ProductsByRating" +  } +} +``` +::: + +## ##subsec Extending an Entity Container + +An entity container MAY specify that it extends another entity container +in scope. All children of the "base" entity container are added to the +"extending" entity container. + +If the "extending" entity container defines an entity set with the same +name as defined in any of its "base" containers, then the entity set's +type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the "base" container. The same +holds for singletons. Action imports and function imports cannot be +redefined, nor can the "extending" container define a child with the +same name as a child of a different kind in a "base" container. + +Note: services should not introduce cycles by extending entity +containers. Clients should be prepared to process cycles introduced by +extending entity containers. + +::: csdlHeadline +`$Extends` +::: + +::: csdl +The value of `$Extends` is the qualified name of the entity container to +be extended. +::: + +::: example +Example ##ex: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` +``` +\"Extending\": { +::: + +`  "$Kind": "EntityContainer",` + +  \"\$Extends\": \"Some.Other.Schema.Base\", + +   `…` + +} +``` + +## ##subsec Entity Set + +Entity sets are top-level collection-valued resources. + +An entity set is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An entity set MUST specify a type that MUST be an entity type in scope. + +An entity set MUST contain only instances of its specified entity type +or its subtypes. The entity type MAY be [abstract](#AbstractEntityType) +but MUST have a [key](#Key) defined. + +An entity set MAY indicate whether it is included in the service +document. If not explicitly indicated, it is included. + +Entity sets that cannot be queried without specifying additional query +options SHOULD NOT be included in the service document. + +::: csdlHeadline +Entity Set Object +::: + +::: csdl +An entity set is represented as a member of the entity container object +whose name is the name of the entity set and whose value is an object. + +The entity set object MUST contain the members `$Collection` and +`$Type`. + +It MAY contain the members `$IncludeInServiceDocument` and +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). +::: + +::: csdlHeadline +`$Collection` +::: + +::: csdl +The value of `$Collection` is the Booelan value `true`. +::: + +::: csdlHeadline +`$Type` +::: + +::: csdl +The value of `$Type` is the qualified name of an entity type. +::: + +::: csdlHeadline +`$IncludeInServiceDocument` +::: + +::: csdl +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `true`. +::: + +## ##subsec Singleton + +Singletons are top-level single-valued resources. + +A singleton is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A singleton MUST specify a type that MUST be an entity type in scope. + +A singleton MUST reference an instance its entity type. + +::: csdlHeadline +Singleton Object +::: + +::: csdl +A singleton is represented as a member of the entity container object +whose name is the name of the singleton and whose value is an object. + +The singleton object MUST contain the member `$Type` and it MAY contain +the member `$Nullable`. + +It MAY contain the member +[`$NavigationPropertyBinding`](#NavigationPropertyBinding) as well as +[annotations](#Annotation). +::: + +::: csdlHeadline +`$Type` +::: + +::: csdl +The value of `$Type` is the qualified name of an entity type. +::: + +::: csdlHeadline +`$Nullable` +::: + +::: csdl +The value of `$Nullable` is one of the Boolean literals `true` or +`false`. Absence of the member means `false`.In OData 4.0 responses this +member MUST NOT be specified. +::: + +## ##subsec Navigation Property Binding + +If the entity type of an entity set or singleton declares navigation +properties, a navigation property binding allows describing which entity +set or singleton will contain the related entities. + +An [entity set](#EntitySet) or a [singleton](#Singleton) SHOULD specify +a navigation property binding for each [navigation +property](#NavigationProperty) of its entity type, including navigation +properties defined on complex typed properties or derived types. + +If omitted, clients MUST assume that the target entity set or singleton +can vary per related entity. + +### ##subsubsec Navigation Property Path Binding + +A navigation property binding MUST specify a path to a navigation +property of the entity set's or singleton\'s declared entity type, or a +navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation +property is defined on a subtype, the path MUST contain the [qualified +name](#QualifiedName) of the subtype, followed by a forward slash, +followed by the navigation property name. If the navigation property is +defined on a complex type used in the definition of the entity set's +entity type, the path MUST contain a forward-slash separated list of +complex property names and qualified type names that describe the path +leading to the navigation property. + +The path can traverse one or more containment navigation properties, but +the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment. + +If the path traverses collection-valued complex properties or +collection-valued containment navigation properties, the binding applies +to all items of these collections. + +If the path contains a recursive sub-path (i.e. a path leading back to +the same structured type, the binding applies recursively to any +positive number of cycles through that sub-path. + +OData 4.01 services MAY have a type-cast segment as the last path +segment, allowing to bind instances of different sub-types to different +targets. + +The same navigation property path MUST NOT be specified in more than one +navigation property binding; navigation property bindings are only used +when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths +that differ only in a type-cast segment, allowing to bind instances of +different sub-types to different targets. If paths differ only in +type-cast segments, the most specific path applies. + +### ##subsubsec Binding Target + +A navigation property binding MUST specify a target via a [simple +identifier](#SimpleIdentifier) or [target path](#TargetPath). It +specifies the entity set, singleton, or containment navigation property +that contains the related entities. + +If the target is a [simple identifier](#SimpleIdentifier), it MUST +resolve to an entity set or singleton defined in the same entity +container. + +If the target is a [target path](#TargetPath), it MUST resolve to an +entity set, singleton, or direct or indirect containment navigation +property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties +before ending in a containment navigation property, and there MUST NOT +be any non-containment navigation properties prior to the final segment. + +::: csdlHeadline +`$NavigationPropertyBinding` +::: + +::: csdl +The value of `$NavigationPropertyBinding` is an object. It consists of +members whose name is the navigation property binding path and whose +value is a string containing the navigation property binding target. If +the target is in the same entity container, the target MUST NOT be +prefixed with the qualified entity container name. +::: + +::: example +Example ##ex: for an entity set in the same container as the enclosing +entity set `Categories` +``` +"Categories": { +  "$Collection": true, +  "$Type": "self.Category", +  "$NavigationPropertyBinding": { +    "Products": "SomeSet" +  } +} +``` +::: + +::: example +Example ##ex: for an entity set in any container in scope +``` +"Categories": { +  "$Collection": true, +  "$Type": "self.Category", +  "$NavigationPropertyBinding": { +    "Products": "SomeModel.SomeContainer/SomeSet" +  } +} +``` +::: + +::: example +Example ##ex: binding `Supplier` on `Products` contained within +`Categories – binding applies to all suppliers of all products of all categories` +``` +"Categories": { +  "$Collection": true, +  "$Type": "self.Category", +  "$NavigationPropertyBinding": { +    "Products/Supplier": "Suppliers" +  } +} +``` +::: + +## ##subsec Action Import + +Action imports sets are top-level resources that are never included in +the service document. + +An action import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An action import MUST specify the name of an unbound action in scope. + +If the imported action returns an entity or a collection of entities, a +[simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +::: csdlHeadline +Action Import Object +::: + +::: csdl +An action import is represented as a member of the entity container +object whose name is the name of the action import and whose value is an +object. + +The action import object MUST contain the member `$Action`. + +It MAY contain the member `$EntitySet`. + +It MAY also contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Action` +::: + +::: csdl +The value of `$Action` is a string containing the qualified name of an +unbound action. +::: + +::: csdlHeadline +`$EntitySet` +::: + +::: csdl +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. +::: + +## ##subsec Function Import + +Function imports sets are top-level resources. + +A function import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A function import MUST specify the name of an unbound function in scope. +All [unbound overloads](#BoundorUnboundActionorFunctionOverlo) of the +imported function can be invoked from the entity container. + +If the imported function returns an entity or a collection of entities, +a [simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +A function import for a parameterless function MAY indicate whether it +is included in the service document. If not explicitly indicated, it is +not included. + +::: csdlHeadline +Function Import Object +::: + +::: csdl +A function import is represented as a member of the entity container +object whose name is the name of the function import and whose value is +an object. + +The function import object MUST contain the member `$Function`. + +It MAY contain the members `$EntitySet` and `$IncludeInServiceDocument`. + +It MAY also contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Function` +::: + +::: csdl +The value of `$Function` is a string containing the qualified name of an +unbound function. +::: + +::: csdlHeadline +`$EntitySet` +::: + +::: csdl +The value of `$EntitySet` is a string containing either the unqualified +name of an entity set in the same entity container or a path to an +entity set in a different entity container. +::: + +::: csdlHeadline +`$IncludeInServiceDocument` +::: + +::: csdl +The value of `$IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the member means `false`. +::: + +# ##sec Vocabulary and Annotation + +Vocabularies and annotations provide the ability to annotate metadata as +well as instance data, and define a powerful extensibility point for +OData. An [*annotation*](#Annotation) applies a [*term*](#Term) to a +model element and defines how to calculate a value for the applied term. + +*Metadata annotations* are terms applied to model elements. Behaviors or +constraints described by a metadata annotation must be consistent with +the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity +type, property, function, action, or parameter. For example, a metadata +annotation may define ranges of valid values for a particular property. +Metadata annotations are applied in CSDL documents describing or +referencing an entity model. + +*Instance annotations* are terms applied to a particular instance within +an OData payload, such as described in [OData‑JSON](#ODataJSON). An +instance annotation can be used to define additional information +associated with a particular result, entity, property, or error. For +example, whether a property is read-only for a particular instance. +Where the same annotation is defined at both the metadata and instance +level, the instance-level annotation overrides the annotation specified +at the metadata level. Annotations that apply across instances should be +specified as metadata annotations. + +A *vocabulary* is a schema containing a set of terms where each +[term](#Term) is a named metadata extension. Anyone can define a +vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary +[OData-VocCore](#ODataVocCore). + +A [term](#Term) can be used to: +- Extend model elements and type instances +with additional information. +- Map instances of annotated structured +types to an interface defined by the term type; i.e. annotations allow +viewing instances of a structured type as instances of a differently +structured type specified by the applied term. + +A service SHOULD NOT require a client to interpret annotations. Clients +SHOULD ignore invalid or unknown terms and silently treat unexpected or +invalid values (including invalid type, invalid literal expression, +invalid targets, etc.) as an unknown value for the term. Unknown or +invalid annotations should never result in an error, as long as the +payload remains well-formed. + +::: example +Example ##ex: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` +``` +"Product": { +  "$Kind": "EntityType", +  "$Key": [ +    "ID" +  ], +  "ID": { +    "$Type": "Edm.Int32" +  }, +  "Name": { +    "$Nullable": true +  }, +  "Description": { +    "$Nullable": true +  }, +  "@UI.DisplayName": { +    "$Path": "Name" +  }, +  "@SearchVocabulary.SearchResult": { +    "Title": { +      "$Path": "Name" +    }, +    "Abstract": { +      "$Path": "Description" +    }, +    "Url": { +      "$Apply": [ +        "Products(", +        { +          "$Path": "ID" +        }, +        ")" +      ], +      "$Function": "odata.concat" +    } +  } +} +``` +::: + +## ##subsec Term + +A term allows annotating a model element or OData resource +representation with additional data. + +The term's name is a [simple identifier](#SimpleIdentifier) that MUST be +unique within its schema. + +The term's type MUST be a type in scope, or a collection of a type in +scope. + +::: csdlHeadline +Term Object +::: + +::: csdl +A term is represented as a member of the schema object whose name is the +unqualified name of the term and whose value is an object. + +The term object MUST contain the member `$Kind` with a string value of +`Term`. + +It MAY contain the members `$Type`, `$Collection`, +[`$AppliesTo`](#Applicability), [`$Nullable`](#Nullable), +[`$MaxLength`](#MaxLength), [`$Precision`](#Precision), +[`$Scale`](#Scale), [`$SRID`](#SRID), and `$DefaultValue`, as well as +[`$Unicode`](#Unicode) for 4.01 and greater payloads. + +It MAY contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Type` and `$Collection` +::: + +::: csdl +For single-valued terms the value of `$Type` is the qualified name of +the term's type. + +For collection-valued terms the value of `$Type` is the qualified name +of the term's item type, and the member `$Collection` MUST be present +with the literal value `true`. + +Absence of the `$Type` member means the type is `Edm.String`. +::: + +::: csdlHeadline +`$DefaultValue` +::: + +::: csdl +The value of `$DefaultValue` is the type-specific JSON representation of +the default value of the term, see +**\[**[**OData-JSON**](#ODataJSON)**\]**. + +Note: the `$DefaultValue` member is purely for documentation and +isomorphy to **\[**[**OData-CSDLXML**](#ODataCSDL)**\]**. Annotations in +CSDL JSON documents MUST always specify an explicit value. +::: + +### ##subsubsec Specialized Term + +A term MAY specialize another term in scope by specifying it as its base +term. + +When applying a specialized term, the base term MUST also be applied +with the same qualifier, and so on until a term without a base term is +reached. + +::: csdlHeadline +`$BaseTerm` +::: + +::: csdl +The value of `$BaseTerm` is the qualified name of the base term. +::: + +### ##subsubsec Applicability + +The applicability of a term MAY be restricted to a list of model +elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be +extended in future versions of the vocabulary. As the intended usage may +evolve over time, clients SHOULD be prepared for any term to be applied +to any model element and SHOULD be prepared to handle unknown values +within the list of model constructs. Applicability is expressed using +the following symbolic values: + + **Symbolic Value** **Model Element** + ------------------------- ----------------------------------------------------------------- + `Action` Action + `ActionImport` Action Import + `Annotation` Annotation + `Apply` Application of a client-side function in an annotation + `Cast` Type Cast annotation expression + `Collection` Entity Set or collection-valued Property or Navigation Property + `ComplexType` Complex Type + `EntityContainer` Entity Container + `EntitySet` Entity Set + `EntityType` Entity Type + `EnumType` Enumeration Type + `Function` Function + `FunctionImport` Function Import + `If` Conditional annotation expression + `Include` Reference to an Included Schema + `IsOf` Type Check annotation expression + `LabeledElement` Labeled Element expression + `Member` Enumeration Member + `NavigationProperty` Navigation Property + `Null` Null annotation expression + `OnDelete` On-Delete Action of a navigation property + `Parameter` Action of Function Parameter + `Property` Property of a structured type + `PropertyValue` Property value of a Record annotation expression + `Record` Record annotation expression + `Reference` Reference to another CSDL document + `ReferentialConstraint` Referential Constraint of a navigation property + `ReturnType` Return Type of an Action or Function + `Schema` Schema + `Singleton` Singleton + `Term` Term + `TypeDefinition` Type Definition + `UrlRef` UrlRef annotation expression + +::: csdlHeadline +`$AppliesTo` +::: + +::: csdl +The value of `$AppliesTo` is an array whose items are strings containing +symbolic values from the table above that identify model elements the +term is intended to be applied to. +::: + +::: example +Example ##ex: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData‑VocCore](#ODataVocCore)) +``` +\"IsURL\": { +::: + +  \"\$Kind\": \"Term\", + +  \"\$Type\": \"Core.Tag\", + +  \"\$DefaultValue\": true, + +  \"\$AppliesTo\": \[ + +    \"Property\" + +  \], + +  \"@Core.Description\": \"Properties and terms annotated with this term +MUST contain a valid URL\", + +  \"@Core.RequiresType\": \"Edm.String\" + +`} +``` + +## ##subsec Annotation + +An annotation applies a [term](#Term) to a model element and defines how +to calculate a value for the term application. Both term and model +element MUST be in scope. Section 14.1.2 specifies which model elements +MAY be annotated with a term. + +The value of an annotation is specified as an *annotation expression*, +which is either a [constant expression](#ConstantExpression) +representing a constant value, or a [dynamic +expression](#DynamicExpression). The most common construct for assigning +an annotation value is a [path expression](#ValuePath) that refers to a +property of the same or a related structured type. + +::: csdlHeadline +Annotation Member +::: + +::: csdl +An annotation is represented as a member whose name consists of an at +(`@`) character, followed by the qualified name of a term, optionally +followed by a hash (`#`) and a [qualifier](#Qualifier). + +The value of the annotation MUST be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +The annotation can be a member of the object representing the model +element it annotates, or a second-level member of the +[`$Annotations`](#AnnotationswithExternalTargeting) member of a schema +object. + +An annotation can itself be annotated. Annotations on annotations are +represented as a member whose name consists of the annotation name +(including the optional qualifier), followed by an at (`@`) character, +followed by the qualified name of a term, optionally followed by a hash +(`#`) and a [qualifier](#Qualifier). +::: + +::: example +Example ##ex: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value +``` +"AmountInReportingCurrency": { +  "$Nullable": true, +  "$Type": "Edm.Decimal", +  "$Scale": 0, +  "@Measures.ISOCurrency": "USD", +  "@Measures.ISOCurrency@Core.Description": "The parent company’s currency" +}, +"AmountInTransactionCurrency": { +  "$Nullable": true, +  "$Type": "Edm.Decimal", +  "$Scale": 0, +  "@Measures.ISOCurrency": { +    "$Path": "Currency" +  } +}, +"Currency": { +  "$Nullable": true, +  "$MaxLength": 3 +} +``` +::: + +If an entity type or complex type is annotated with a term that itself +has a structured type, an instance of the annotated type may be viewed +as an "instance" of the term, and the qualified term name may be used as +a [term-cast segment](#ref_TermCast) in path expressions. + +Structured types "inherit" annotations from their direct or indirect +base types. If both the type and one of its base types is annotated with +the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or +collection-valued annotation values are not merged. Similarly, +properties of a structured type inherit annotations from identically +named properties of a base type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a \"Label\" +annotation for a UI can propagate from a type definition to all +properties using that type definition and may be overridden at each +property with a more specific label, whereas an annotation marking a +type definition as containing a phone number will propagate to all using +properties but may not be overridden. + +### ##subsubsec Qualifier + +A term can be applied multiple times to the same model element by +providing a qualifier to distinguish the annotations. The qualifier is a +[simple identifier](#SimpleIdentifier). + +The combination of target model element, term, and qualifier uniquely +identifies an annotation. + +::: example +Example ##ex: annotation should only be applied to tablet devices +``` +"@UI.DisplayName#Tablet": { +  "$Path": "FirstName" +} +``` +::: + +### ##subsubsec Target + +The target of an annotation is the model element the term is applied to. + +The target of an annotation MAY be specified indirectly by "nesting" the +annotation within the model element. Whether and how this is possible is +described per model element in this specification. + +The target of an annotation MAY also be specified directly; this allows +defining an annotation in a different schema than the targeted model +element. + +This external targeting is only possible for model elements that are +uniquely identified within their parent, and all their ancestor elements +are uniquely identified within their parent: + +- [Action](#Action)[ (]{style="color:black; + background:white"}single or all overloads) +- [Action Import](#ActionImport) +- [Complex Type](#ComplexType) +- [Entity Container](#EntityContainer) +- [Entity Set](#EntitySet) +- [Entity Type](#EntityType) +- [Enumeration Type](#EnumerationType) +- [Enumeration Type Member](#EnumerationTypeMember) +- [Function](#Function)[ (single or all + overloads)]{style="color:black;background:white"} +- [Function Import](#FunctionImport) +- [Navigation Property](#NavigationProperty) (via type, entity set, or + singleton) +- [Parameter](#Parameter)[ of an action or function (single overloads + or all overloads defining the + parameter)]{style="color:black;background:white"} +- [Property](#StructuralProperty) (via type, entity set, or singleton) +- [Return Type](#ReturnType)[ of an action or function (single or all + overloads)]{style="color:black;background:white"} +- [Singleton](#Singleton) +- [Type Definition](#TypeDefinition) + +These are the direct children of a schema with a unique name (i.e. +except actions and functions whose overloads to not possess a natural +identifier), and all direct children of an entity container. + +External targeting is possible for actions, functions, their parameters, +and their return type, either in a way that applies to all overloads of +the action or function or all parameters of that name across all +overloads, or in a way that identifies a single overload. + +External targeting is also possible for properties and navigation +properties of singletons or entities in a particular entity set. These +annotations override annotations on the properties or navigation +properties targeted via the declaring structured type. + +The allowed path expressions are: +- [qualified name](#QualifiedName) +of schema child +- [qualified +name](#QualifiedName) of schema child followed by a forward slash and +name of child element +- [qualified +name](#QualifiedName) of structured type followed by zero or more +property, navigation property, or type-cast segments, each segment +starting with a forward slash +- [qualified name](#QualifiedName) +of an entity container followed by a segment containing a singleton or +entity set name and zero or more property, navigation property, or +type-cast segments +- [qualified +name](#QualifiedName) of an action followed by parentheses containing +the [qualified name](#QualifiedName)[ of the binding parameter *type* of +a bound action overload to identify that bound overload, or by empty +parentheses to identify the unbound overload]{style="color:black; +background:white"} +- [qualified name](#QualifiedName) of a +function followed by parentheses containing the comma-separated list of +[qualified names](#QualifiedName)[ of the parameter *types* of a bound +or unbound function overload in the order of their definition in the +function overload]{style="color:black;background:white"} +- [qualified +name](#QualifiedName) of an action or function, optionally followed by +parentheses as described in the two previous bullet points to identify a +single overload, followed by a forward slash and either a parameter name +or `$ReturnType` +- [qualified +name](#QualifiedName) of an entity container followed by a segment +containing an action or function import name, optionally followed by a +forward slash and either a parameter name or `$ReturnType` + +- One of the preceding, followed by a forward slash, an at (`@`), the + [qualified name](#QualifiedName)[ of a term, and optionally a hash + (]{style="color:black;background:white"}`#`) and the qualifier of an + annotation + +All [qualified names](#QualifiedName) used in a target path MUST be in +scope. + +::: example +Example ##ex: Target expressions +``` +MySchema.MyEntityType +::: + +MySchema.MyEntityType/MyProperty + +MySchema.MyEntityType/MyNavigationProperty + +MySchema.MyComplexType + +MySchema.MyComplexType/MyProperty + +MySchema.MyComplexType/MyNavigationProperty + +MySchema.MyEnumType + +MySchema.MyEnumType/MyMember + +MySchema.MyTypeDefinition + +MySchema.MyTerm + +MySchema.MyEntityContainer + +MySchema.MyEntityContainer/MyEntitySet + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MyActionImport + +MySchema.MyEntityContainer/MyFunctionImport + +MySchema.MyAction + +MySchema.MyAction(MySchema.MyBindingType) + +MySchema.MyAction() + +MySchema.MyFunction + +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType) + +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType) + +MySchema.MyFunction/MyParameter + +MySchema.MyEntityContainer/MyEntitySet/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty +``` + +## ##subsec Constant Expression + +Constant expressions allow assigning a constant value to an applied +term. + +### ##subsubsec Binary + +::: csdl +Binary expressions are represented as a string containing the +base64url-encoded binary value. +::: + +::: example +Example ##ex: base64url-encoded binary value (OData) +``` +"@UI.Thumbnail": "T0RhdGE" +``` +::: + +### ##subsubsec Boolean + +::: csdl +Boolean expressions are represented as the literals `true` or `false`. +::: + +::: example +Example ##ex: +``` +"@UI.ReadOnly": true +``` +::: + +### ##subsubsec Date + +::: csdl +Date expressions are represented as a string containing the date value. +The value MUST conform to type `xs:date`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData‑ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. +::: + +::: example +Example ##ex: +``` +"@vCard.birthDay": "2000-01-01" +``` +::: + +### ##subsubsec DateTimeOffset + +::: csdl +Datetimestamp expressions are represented as a string containing the +timestamp value. The value MUST conform to type `xs:dateTimeStamp`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData‑ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). +::: + +::: example +Example ##ex: +``` +"@UI.LastUpdated": "2000-01-01T16:00:00.000Z" +``` +::: + +### ##subsubsec Decimal + +::: csdl +Decimal expressions are represented as either a number or a string. The +special values `INF`, `-INF`, or `NaN` are represented as strings. +Numeric values are represented as numbers or strings depending on the +media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumber). +::: + +::: example +Example ##ex: default representation as a number +``` +"@UI.Width": 3.14 +``` +::: + +::: example +Example ##ex: "safe" representation as a string +``` +"@UI.Width": "3.14" +``` +::: + +### ##subsubsec Duration + +::: csdl +Duration expressions are represented as a string containing the duration +value. The value MUST conform to type `xs:dayTimeDuration`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). +::: + +::: example +Example ##ex: +``` +"@task.duration": "P7D" +``` +::: + +### ##subsubsec Enumeration Member + +::: csdl +Enumeration member expressions are represented as a string containing +the numeric or symbolic enumeration value. +::: + +::: example +Example ##ex: single value `Red` with numeric value and symbolic value +``` +"@self.HasPattern": "1" +``` +::: + +` ` +``` +"@self.HasPattern": "Red" +``` + +::: example +Example ##ex: combined value `Red,Striped` with numeric value 1 + 16 and +symbolic value +``` +"@self.HasPattern": "17" +``` +::: + +` ` +``` +"@self.HasPattern": "Red,Striped" +``` + +### ##subsubsec Floating-Point Number + +::: csdl +Floating-point expressions are represented as a number or as a string +containing one of the special values `INF`, `-INF`, or `NaN`. +::: + +::: example +Example ##ex: +``` +"@UI.FloatWidth": 3.14 +``` +::: + +` ` +``` +"@UI.FloatWidth": "INF" +``` + +### ##subsubsec Guid + +::: csdl +Guid expressions are represented as a string containing the uuid value. +The value MUST conform to the rule `guidValue` in +[OData‑ABNF](#ODataABNF). +::: + +::: example +Example ##ex: +``` +"@UI.Id": "21EC2020-3AEA-1069-A2DD-08002B30309D" +``` +::: + +### ##subsubsec Integer + +::: csdl +Integer expressions are represented as either a number or a string, +depending on the media type parameter +[`IEEE754Compatible`](#ControllingtheRepresentationofNumber). +::: + +::: example +Example ##ex: default representation as a number +``` +"@An.Int": 42 +``` +::: + +::: example +Example ##ex: "safe" representation as a string +``` +"@A.Very.Long.Int": "9007199254740992" +``` +::: + +### ##subsubsec String + +::: csdl +String expressions are represented as a JSON string. +::: + +::: example +Example ##ex: +``` +"@UI.DisplayName": "Product Catalog" +``` +::: + +### ##subsubsec Time of Day + +::: csdl +Time-of-day expressions are represented as a string containing the +time-of-day value. The value MUST conform to the rule `timeOfDayValue` +in [OData‑ABNF](#ODataABNF). +::: + +::: example +Example ##ex: +``` +"@UI.EndTime": "21:45:00" +``` +::: + +## ##subsec Dynamic Expression + +Dynamic expressions allow assigning a calculated value to an applied +term. + +### ##subsubsec Path Expressions + +Path expressions allow assigning a value to an applied term or term +component. There are two kinds of path expressions: +- [[A *model path* is used within +]{style="font-family:\"Arial\",sans-serif"}]{.Datatype}[Annotation +Path](#AnnotationPath), [Model Element Path](#ModelElementPath), +[Navigation Property Path](#NavigationPropertyPath), and [Property +Path](#PropertyPath) expressions to traverse the model of a service and +resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) `Edm.AnnotationPath`, +`Edm.NavigationPropertyPath`, `Edm.PropertyPath`, and their base types +`Edm.AnyPropertyPath` and `Edm.ModelElementPath`. +- An *instance path* is used within a +[Value Path](#ValuePath) expression to traverse a graph of type +instances and resolves to the value identified by the path. It allows +assigning values to terms or term properties of built-in types other +than the `Edm.*Path` types, or of any model-defined type. + +#### ##subsubsubsec Path Syntax + +Model paths and instance paths share a common syntax which is derived +from the path expression syntax of URLs, see [OData‑URL](#ODataURL). + +A path MUST be composed of zero or more path segments joined together by +forward slashes (`/`). + +Paths starting with a forward slash (`/`) are absolute paths, and the +first path segment MUST be the qualified name of a model element, e.g. +an entity container. The remaining path after the second forward slash +is interpreted relative to that model element. + +::: example +Example ##ex: absolute path to an entity set +``` +/My.Schema.MyEntityContainer/MyEntitySet +``` +::: + +Paths not starting with a forward slash are interpreted relative to the +annotation target, following the rules specified in section "[Path +Evaluation](#PathEvaluation)". + +::: example +Example ##ex: relative path to a property +``` +Address/City +``` +::: + +If a path segment is a [qualified name](#QualifiedName), it represents a +[*type cast*]{#ref_TypeCast}, and the segment MUST be the name of a type +in scope. If the type or instance identified by the preceding path part +cannot be cast to the specified type, the path expression evaluates to +the null value. + +::: example +Example ##ex: type-cast segment +``` +.../self.Manager/... +``` +::: + +If a path segment starts with an at (`@`) character, it represents a +[*term cast*]{#ref_TermCast}. The at (`@`) character MUST be followed by +a [qualified name](#QualifiedName) that MAY be followed by a hash (`#`) +character and a [simple identifier](#SimpleIdentifier). The [qualified +name](#QualifiedName) preceding the hash character MUST resolve to a +term that is in scope, the [simple identifier](#SimpleIdentifier) +following the hash sign is interpreted as a [qualifier](#Qualifier) for +the term. If the model element or instance identified by the preceding +path part has not been annotated with that term (and if present, with +that qualifier), the term cast evaluates to the null value. Four special +terms are implicitly "annotated" for media entities and stream +properties: + +- `odata.mediaEditLink` +- `odata.mediaReadLink` +- `odata.mediaContentType` +- `odata.mediaEtag` + +::: example +Example ##ex: term-cast segments +``` +.../@Capabilities.SortRestrictions/... +``` +::: + +If a path segment is a [simple identifier](#SimpleIdentifier), it MUST +be the name of a child model element of the model element identified by +the preceding path part, or a structural or navigation property of the +instance identified by the preceding path part. A sequence of navigation +segments can traverse multiple CSDL documents. The document containing +the path expression only needs to reference the next traversed document +to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document. + +A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path. + +::: example +Example ##ex: property segments in model path +``` +.../Orders/Items/Product/... +``` +::: + +An instance path MUST NOT contain more than one segment representing a +collection-valued construct, e.g. an entity set or a collection-valued +navigation property that is not followed by a key predicate, or a +collection-valued structural property that is not followed by an index +segment. The result of the expression is the collection of instances +resulting from applying any remaining path segments that operate on a +single-valued expression to each instance in the collection-valued +segment. + +An instance path MAY terminate in a `$count` segment if the previous +segment is collection-valued, in which case the path evaluates to the +number of items in the collection identified by the preceding segment. + +::: example +Example ##ex: property segments in instance path +``` +.../Addresses/Street +::: + +.../Addresses/\$count +``` + +A model path MAY contain path segments starting with a navigation +property, then followed by an at (`@`) character, then followed by the +[qualified name](#QualifiedName) of a term in scope, and optionally +followed by a hash (`#`) character and a [simple +identifier](#SimpleIdentifier) which is interpreted as a +[qualifier](#Qualifier) for the term. If the navigation property has not +been annotated with that term (and if present, with that qualifier), the +path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity +type specified by the navigation property are addressed via a [term-cast +segment](#ref_TermCast). + +::: example +Example ##ex: model path addressing an annotation on a navigation property +``` +.../Items@Capabilities.InsertRestrictions/Insertable +``` +::: + +An instance path MAY contain path segments starting with an entity set +or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see +[OData‑URL](#ODataURL). The key values are either primitive literals or +instance paths. If the key value is a relative instance path, it is +interpreted according to the same rule below as the instance path it is +part of, *not* relative to the instance identified by the preceding path +part. + +::: example +Example ##ex: instance path with entity set and key predicate +``` +/self.container/SettingsCollection(\'FeatureXxx\')/IsAvailable +::: + +/self.container/Products(ID=ProductID)/Name +``` + +An instance path MAY contain an index segment immediately following a +path segment representing an ordered collection-valued structural +property. The index is zero-based and MUST be an integer literal. +Negative integers count from the end of the collection, with -1 +representing the last item in the collection. Remaining path segments +are evaluated relative to the identified item of the collection. + +::: example +Example ##ex: instance path with collection-valued structural property and +index segment +``` +Addresses/1 +::: + +Addresses/-1/Street +``` + +#### ##subsubsubsec Path Evaluation + +Annotations MAY be embedded within their target, or specified +separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as +*targeting* in the remainder of this section. + +For annotations embedded within or targeting an entity container, the +path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a +segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules +for paths targeting the corresponding child element. + +For annotations embedded within or targeting an entity set or a +singleton, the path is evaluated starting at the entity set or +singleton, i.e. an empty path resolves to the entity set or singleton, +and non-empty paths MUST follow the rules for annotations targeting the +declared entity type of the entity set or singleton. + +For annotations embedded within or targeting an entity type or complex +type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be +a structural or navigation property of the type, a [type +cast](#ref_TypeCast), or a [term cast](#ref_TermCast). + +For annotations embedded within a structural or navigation property of +an entity type or complex type, the path is evaluated starting at the +directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other +properties of the same type. An empty path resolves to the enclosing +type, and non-empty paths MUST follow the rules for annotations +targeting the directly enclosing type. + +For annotations targeting a structural or navigation property of an +entity type or complex type, the path is evaluated starting at the +*outermost* entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the +first segment of a non-empty path MUST be a structural or navigation +property of the outermost type, a [type cast](#ref_TypeCast), or a [term +cast](#ref_TermCast). + +For annotations embedded within or targeting an action, action import, +function, function import, parameter, or return type, the first segment +of the path MUST be a parameter name or `$ReturnType`. + +#### ##subsubsubsec Annotation Path + +The annotation path expression provides a value for terms or term +properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.AnnotationPath or Edm.ModelElementPath`. Its argument is a [model +path](#PathExpressions) with the following restriction: +- `A non-null path MUST resolve to an annotation. ` + +A term or term property of type `Edm.AnnotationPath` can be annotated +with term `Validation.AllowedTerms` (see +[OData-VocValidation](#ODataVocValidation)) if its intended value is an +annotation path that ends in a term cast with one of the listed terms. + +The value of the annotation path expression is the path itself, not the +value of the annotation identified by the path. This is useful for terms +that reuse or refer to other terms. + +::: csdl +Annotation path expressions are represented as a string containing a +path. +::: + +::: example +Example ##ex: +``` +"@UI.ReferenceFacet": "Product/Supplier/@UI.LineItem", +"@UI.CollectionFacet#Contacts": [ +  "Supplier/@Communication.Contact", +  "Customer/@Communication.Contact" +] +``` +::: + +#### ##subsubsubsec Model Element Path + +The model element path expression provides a value for terms or term +properties that specify the [built-in +type](#BuiltInTypesfordefiningVocabularyTer)` Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions). + +The value of the model element path expression is the path itself, not +the instance(s) identified by the path. + +::: csdl +Model element path expressions are represented as a string containing a +path. +::: + +::: example +Example ##ex: +``` +"@org.example.MyFavoriteModelElement": "/self.someAction" +``` +::: + +#### ##subsubsubsec Navigation Property Path + +The navigation property path expression provides a value for terms or +term properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. +Its argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is an entity type, or a collection of entity types, +e.g. a navigation property. + +The value of the navigation property path expression is the path itself, +not the entitiy or collection of entities identified by the path. + +::: csdl +Navigation property path expressions are represented as a string +containing a path. +::: + +::: example +Example ##ex: +``` +"@UI.HyperLink": "Supplier", +  +"@Capabilities.UpdateRestrictions": { +  "NonUpdatableNavigationProperties": [ +    "Supplier", +    "Category" +  ] +} +``` +::: + +#### ##subsubsubsec Property Path + +The property path expression provides a value for terms or term +properties that specify one of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is a primitive or complex type, an enumeration type, +a type definition, or a collection of one of these types. + +The value of the property path expression is the path itself, not the +value of the structural property or the value of the term cast +identified by the path. + +::: csdl +Property path expressions are represented as a string containing a path. +::: + +::: example +Example ##ex: +``` +"@UI.RefreshOnChangeOf": "ChangedAt", +  +"@Capabilities.UpdateRestrictions": { +  "NonUpdatableProperties": [ +    "CreatedAt", +    "ChangedAt" +  ] +} +``` +::: + +#### ##subsubsubsec Value Path + +The value path expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation +properties of structured types, and structural properties of structured +types. Its argument is an [instance path](#PathExpressions). + +The value of the path expression is the instance or collection of +instances identified by the path. + +::: csdlHeadline +`$Path` +::: + +::: csdl +Path expressions are represented as an object with a single member +`$Path` whose value is a string containing a path. +::: + +::: example +Example ##ex: +``` +"@UI.DisplayName": { +  "$Path": "FirstName" +}, +  +"@UI.DisplayName#second": { +  "$Path": "@vCard.Address#work/FullName" +} +``` +::: + +### ##subsubsec Comparison and Logical Operators + +Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and +they MAY be used anywhere instead of a Boolean expression. + + **Operator** **Description** + -------------------------- ------------------------------- + **Logical Operators** + `And` `Logical and` + `Or` `Logical or` + `Not` `Logical negation` + **Comparison Operators** + `Eq` `Equal` + `Ne` `Not equal` + `Gt` `Greater than` + `Ge` `Greater than or equal` + `Lt` Less than + `Le` `Less than or equal` + `Has` `Has enumeration flag(s) set` + `In` `Is in collection` + +The `And` and `Or` operators require two operand expressions that +evaluate to Boolean values. The `Not` operator requires a single operand +expression that evaluates to a Boolean value. For details on null +handling for comparison operators see [OData‑URL](#ODataURL). + +The other comparison operators require two operand expressions that +evaluate to comparable values. + +::: csdlHeadline +`$And and ``$Or` +::: + +::: csdl +The `And` and `Or` logical expressions are represented as an object with +a single member whose value is an array with two annotation expressions. +The member name is one of `$And`, or `$Or`. + +It MAY contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Not` +::: + +::: csdl +Negation expressions are represented as an object with a single member +`$Not` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Eq, ``$Ne, $Gt, $Ge, $Lt, $Le, $Has, and $In` +::: + +::: csdl +All comparison expressions are represented as an object with a single +member whose value is an array with two annotation expressions. The +member name is one of `$Eq`, `$Ne`, `$Gt`, `$Ge`, `$Lt`, `$Le`, `$Has`, +or `$In`. + +They MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: +``` +{ +  "$And": [ +    { +      "$Path": "IsMale" +    }, +    { +      "$Path": "IsMarried" +    } +  ] +}, +{ +  "$Or": [ +    { +      "$Path": "IsMale" +    }, +    { +      "$Path": "IsMarried" +    } +  ] +}, +{ +  "$Not": { +    "$Path": "IsMale" +  } +}, +{ +  "$Eq": [ +    null, +    { +      "$Path": "IsMale" +    } +  ] +}, +{ +  "$Ne": [ +    null, +    { +      "$Path": "IsMale" +    } +  ] +}, +{ +  "$Gt": [ +    { +      "$Path": "Price" +    }, +    20 +  ] +}, +{ +  "$Ge": [ +    { +      "$Path": "Price" +    }, +    10 +  ] +}, +{ +  "$Lt": [ +    { +      "$Path": "Price" +    }, +    20 +  ] +}, +{ +  "$Le": [ +    { +      "$Path": "Price" +    }, +    100 +  ] +}, +{ +  "$Has": [ +    { +      "$Path": "Fabric" +    }, +    "Red" +  ] +}, +{ +  "$In": [ +    { +      "$Path": "Size" +    }, +    [ +      "XS", +      "S" +    ] +  ] +} +``` +::: + +### ##subsubsec Arithmetic Operators + +Annotations MAY use the following arithmetic expressions which evaluate +to a numeric value. These expressions MAY be combined, and they MAY be +used anywhere instead of a numeric expression of the appropriate type. +The semantics and evaluation rules for each arithmetic expression is +identical to the corresponding arithmetic operator defined in +[OData‑URL](#ODataURL). + + **Operator** **Description** + -------------- --------------------------------------------------------------- + `Add` `Addition` + `Sub` `Subtraction` + `Neg` `Negation` + `Mul` `Multiplication` + `Div` `Division (with integer result for integer operands)` + `DivBy` `Division (with fractional result also for integer operands)` + `Mod` `Modulo` + +The `Neg` operator requires a single operand expression that evaluates +to a numeric value. The other arithmetic operators require two operand +expressions that evaluate to numeric values. + +::: csdlHeadline +`$Neg` +::: + +::: csdl +Negation expressions are represented as an object with a single member +`$Neg` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +::: csdlHeadline +`$Add, ``$Sub, $Mul, $Div, $DivBy, and $Mod` +::: + +::: csdl +These arithmetic expressions are represented as an object with as single +member whose value is an array with two annotation expressions. The +member name is one of `$Add`, `$Sub`, `$Neg`, `$Mul`, `$Div`, `$DivBy`, +or `$Mod`. + +They MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: +``` +{ +  "$Add": [ +    { +      "$Path": "StartDate" +    }, +    { +      "$Path": "Duration" +    } +  ] +}, +{ +  "$Sub": [ +    { +      "$Path": "Revenue" +    }, +    { +      "$Path": "Cost" +    } +  ] +}, +{ +  "$Neg": { +    "$Path": "Height" +  } +}, +{ +  "$Mul": [ +    { +      "$Path": "NetPrice" +    }, +    { +      "$Path": "TaxRate" +    } +  ] +}, +{ +  "$Div": [ +    { +      "$Path": "Quantity" +    }, +    { +      "$Path": "QuantityPerParcel" +    } +  ] +}, +{ +  "$DivBy": [ +    { +      "$Path": "Quantity" +    }, +    { +      "$Path": "QuantityPerParcel" +    } +  ] +}, +{ +  "$Mod": [ +    { +      "$Path": "Quantity" +    }, +    { +      "$Path": "QuantityPerParcel" +    } +  ] +} +``` +::: + +### ##subsubsec Apply Client-Side Functions + +The apply expression enables a value to be obtained by applying a +client-side function. The apply expression MAY have operand expressions. +The operand expressions are used as parameters to the client-side +function. + +::: csdlHeadline +`$Apply` +::: + +::: csdl +Apply expressions are represented as an object with a member `$Apply` +whose value is an array of annotation expressions, and a member +`$Function` whose value is a string containing the [qualified +name](#QualifiedName) of the client-side function to be applied. + +It MAY contain [annotations](#Annotation). +::: + +OData defines the following functions. Services MAY support additional +functions that MUST be qualified with a namespace other than `odata`. +Function names qualified with `odata` are reserved for this +specification and its future versions. + +#### ##subsubsubsec Canonical Functions + +All canonical functions defined in [OData‑URL](#ODataURL) can be used as +client-side functions, qualified with the namespace `odata`. The +semantics of these client-side functions is identical to their +counterpart function defined in [OData‑URL](#ODataURL). + +For example, the `odata.concat` client-side function takes two or more +expressions as arguments. Each argument MUST evaluate to a primitive or +enumeration type. It returns a value of type `Edm.String` that is the +concatenation of the literal representations of the results of the +argument expressions. Values of primitive types other than `Edm.String` +are represented according to the appropriate alternative in the +`primitiveValue` rule of [OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as +`binaryValue`, `Edm.Boolean` as `booleanValue` etc. + +::: example +Example ##ex: +``` +"@UI.DisplayName": { +  "$Apply": [ +    "Product: ", +    { +      "$Path": "ProductName" +    }, +    " (", +    { +      "$Path": "Available/Quantity" +    }, +    " ", +    { +      "$Path": "Available/Unit" +    }, +    " available)" +  ], +  "$Function": "odata.concat" +} +``` +::: + +`ProductName` is of type `String`, `Quantity` in complex type +`Available` is of type `Decimal`, and `Unit` in `Available` is of type +enumeration, so the result of the `Path` expression is represented as +the member name of the enumeration value. + +#### ##subsubsubsec Function `odata.fillUriTemplate` + +The `odata.fillUriTemplate` client-side function takes two or more +expressions as arguments and returns a value of type `Edm.String.` + +The first argument MUST be of type `Edm.String` and specifies a URI +template according to [RFC6570](#rfc6570), the other arguments MUST be +[labeled element expressions](#LabeledElement). Each [labeled element +expression](#LabeledElement) specifies the template parameter name as +its name and evaluates to the template parameter value. + +[RFC6570](#rfc6570) defines three kinds of template parameters: simple +values, lists of values, and key-value maps. + +Simple values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a single primitive value. +The literal representation of this value according to +[OData‑ABNF](#ODataABNF) is used to fill the corresponding template +parameter. + +Lists of values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of primitive +values. + +Key-value maps are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of complex +types with two properties that are used in lexicographic order. The +first property is used as key, the second property as value. + +::: example +Example ##ex: assuming there are no special characters in values of the +`Name property of the Actor` entity +``` +{ +::: + +  \"\$Apply\": \[ + +    \"http://host/someAPI/Actors/{actorName}/CV\", + +    { + +      \"\$LabeledElement\": { + +        \"\$Path\": \"Actor/Name\" + +      }, + +      \"\$Name\": \"self.actorName\" + +    } + +  \], + +  \"\$Function\": \"odata.fillUriTemplate\" + +} +``` + +#### ##subsubsubsec [Function `odata.matchesPattern`](#FunctionodatamatchesPattern) + +The `odata.matchesPattern` client-side function takes two string +expressions as arguments and returns a Boolean value`.` + +The function returns true if the second expression evaluates to an +[**\[ECMAScript\]**](#ECMAScript) (JavaScript) regular expression and +the result of the first argument expression matches that regular +expression, using syntax and semantics of +[**\[ECMAScript\]**](#ECMAScript) regular expressions. + +::: example +Example ##ex: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` +``` +{ +::: + +  \"\$Apply\": \[ + +    { + +      \"\$Path\": \"FirstName\" + +    }, + +    \"\^\[\^b-d\]+\$\" + +  \], + +  \"\$Function\": \"odata.matchesPattern\" + +} +``` + +#### ##subsubsubsec Function `odata.uriEncode` + +The `odata.uriEncode `client-side function takes one argument of +primitive type and returns the URL-encoded OData literal that can be +used as a key value in OData URLs or in the query part of OData URLs. + +Note: string literals are surrounded by single quotes as required by the +paren-style key syntax. + +::: example +Example ##ex: +``` +{ +::: + +  \"\$Apply\": \[ + +    \"http://host/service/Genres({genreName})\", + +    { + +      \"\$LabeledElement\": { + +        \"\$Apply\": \[ + +          { + +            \"\$Path\": \"NameOfMovieGenre\" + +          } + +        \], + +        \"\$Function\": \"odata.uriEncode\" + +      }, + +      \"\$Name\": \"self.genreName\" + +    } + +  \], + +  \"\$Function\": \"odata.fillUriTemplate\" + +} +``` + +### ##subsubsec Cast + +The cast expression casts the value obtained from its single child +expression to the specified type. The cast expression follows the same +rules as the `cast` canonical function defined in +[OData‑URL](#ODataURL). + +::: csdlHeadline +`$Cast` +::: + +::: csdl +Cast expressions are represented as an object with a member `$Cast` +whose value is an annotation expression, a member `$Type` whose value is +a string containing the qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +::: example +Example ##ex: +``` +"@UI.Threshold": { +  "$Cast": { +    "$Path": "Average" +  }, +  "$Type": "Edm.Decimal" +} +``` +::: + +### ##subsubsec Collection + +The collection expression enables a value to be obtained from zero or +more item expressions. The value calculated by the collection expression +is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type +compatible. + +::: csdl +Collection expressions are represented as arrays with one array item per +item expression within the collection expression. +::: + +::: example +Example ##ex: +``` +"@seo.SeoTerms": [ +  "Product", +  "Supplier", +  "Customer" +] +``` +::: + +### ##subsubsec If-Then-Else + +The if-then-else expression enables a value to be obtained by evaluating +a *condition expression*. It MUST contain exactly three child +expressions. There is one exception to this rule: if and only if the +if-then-else expression is an item of a collection expression, the third +child expression MAY be omitted, reducing it to an if-then expression. +This can be used to conditionally add an element to a collection. + +The first child expression is the condition and MUST evaluate to a +Boolean result, e.g. the [comparison and logical +operators](#ComparisonandLogicalOperators) can be used. + +The second and third child expressions are evaluated conditionally. The +result MUST be type compatible with the type expected by the surrounding +expression. + +If the first expression evaluates to `true`, the second expression MUST +be evaluated and its value MUST be returned as the result of the +if-then-else expression. If the first expression evaluates to `false` +and a third child element is present, it MUST be evaluated and its value +MUST be returned as the result of the if-then-else expression. If no +third expression is present, nothing is added to the surrounding +collection. + +::: csdlHeadline +`$If` +::: + +::: csdl +Conditional expressions are represented as an object with a member `$If` +whose value is an array of two or three annotation expressions. + +It MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale` ,whose value then determines +the value of the `$If` expression +``` +"@person.Gender": { +  "$If": [ +    { +      "$Path": "IsFemale" +    }, +    "Female", +    "Male" +  ] +} +``` +::: + +### ##subsubsec Is-Of + +The i`s-of` expression checks whether the value obtained from its single +child expression is compatible with the specified type. It returns +`true` if the child expression returns a type that is compatible with +the specified type, and `false` otherwise. + +::: csdlHeadline +`$IsOf` +::: + +::: csdl +Is-of expressions are represented as an object with a member `$IsOf` +whose value is an annotation expression, a member `$Type` whose value is +a string containing an qualified type name, and optionally a member +`$Collection` with a value of `true`. + +It MAY contain [annotations](#Annotation). + +If the specified type is a primitive type or a collection of primitive +types, the facet members [`$MaxLength`](#MaxLength), +[`$Unicode`](#Unicode), [`$Precision`](#Precision), [`$Scale`](#Scale), +and [`$SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet members are not specified, their values are +considered unspecified. +::: + +::: example +Example ##ex: +``` +"@Self.IsPreferredCustomer": { +  "$IsOf": { +    "$Path": "Customer" +  }, +  "$Type": "self.PreferredCustomer" +} +``` +::: + +### ##subsubsec Labeled Element + +The labeled element expression assigns a name to its single child +expression. The value of the child expression can then be reused +elsewhere with a [labeled element reference +expression](#LabeledElementReference). + +A labeled element expression MUST contain exactly one child expression. +The value of the child expression is also the value of the labeled +element expression. + +A labeled element expression MUST provide a [simple +identifier](#SimpleIdentifier) value as its name that MUST be unique +within the schema containing the expression. + +::: csdlHeadline +`$LabeledElement` +::: + +::: csdl +Labeled element expressions are represented as an object with a member +`$LabeledElement` whose value is an annotation expression, and a member +`$Name` whose value is a string containing the labeled element's name. + +It MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: +``` +"@UI.DisplayName": { +  "$LabeledElement": { +    "$Path": "FirstName" +  }, +  "$Name": "CustomerFirstName" +} +``` +::: + +### ##subsubsec Labeled Element Reference + +The labeled element reference expression MUST specify the [qualified +name](#QualifiedName) of a [labeled element expression](#LabeledElement) +in scope and returns the value of the identified labeled element +expression as its value. + +::: csdlHeadline +`$LabeledElementReference` +::: + +::: csdl +Labeled element reference expressions are represented as an object with +a member `$LabeledElementReference` whose value is a string containing +an qualified name. +::: + +::: example +Example ##ex: +``` +"@UI.DisplayName": { +  "$LabeledElementReference": "self.CustomerFirstName" +} +``` +::: + +### ##subsubsec Null + +The null expression indicates the absence of a value. The null +expression MAY be annotated. + +::: csdl +Null expressions that do not contain annotations are represented as the +literal `null`. +::: + +::: example +Example ##ex: +``` +"@UI.DisplayName": null, +``` +::: + +::: csdlHeadline +`$Null` +::: + +::: csdl +Null expression containing [annotations](#Annotations) are represented +as an object with a member `$Null` whose value is the literal `null`. +::: + +::: example +Example ##ex: +``` +"@UI.Address": { +  "$Null": null, +  "@self.Reason": "Private" +} +``` +::: + +### ##subsubsec Record + +The record expression enables a new entity type or complex type instance +to be constructed. + +A record expression MAY specify the structured type of its result, which +MUST be an entity type or complex type in scope. If not explicitly +specified, the type is derived from the expression's context. + +A record expression contains zero or more property value expressions. +For each single-valued structural or navigation property of the record +expression's type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if +the record expression is the value of an annotation for a term that has +a [base term](#SpecializedTerm) whose type is structured and directly or +indirectly inherits from the type of its base term. In this case, +property values that already have been specified in the annotation for +the base term or its base term etc. need not be specified again. + +For collection-valued properties the absence of a property value +expression is equivalent to specifying an empty collection as its value. + +::: csdl +Record expressions are represented as objects with one member per +property value expression. The member name is the property name, and the +member value is the property value expression. + +The type of a record expression is represented as the `@type` control +information, see  [OData‑JSON](#ODataJSON). + +It MAY contain [annotations](#Annotation) for itself and its members. +Annotations for record members are prefixed with the member name. +::: + +::: example +Example ##ex: this annotation "morphs" the entity type from example 8 into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service +``` +"@person.Employee": { +  "@type": "https://example.org/vocabs/person#org.example.person.Manager", +  "@Core.Description": "Annotation on record", +  "GivenName": { +    "$Path": "FirstName" +  }, +  "GivenName@Core.Description": "Annotation on record member", +  "Surname": { +    "$Path": "LastName" +  }, +  "DirectSupervisor": { +    "$Path": "Manager" +  }, +  "CostCenter": { +    "$UrlRef": { +      "$Apply": [ +        "http://host/anotherservice/CostCenters('{ccid}')", +        { +          "$LabeledElement": { +            "$Path": "CostCenterID" +          }, +          "$Name": "ccid" +        } +      ], +      "$Function": "odata.fillUriTemplate" +    } +  } +} +``` +::: + +### ##subsubsec URL Reference + +The URL reference expression enables a value to be obtained by sending a +`GET` request. + +The URL reference expression MUST contain exactly one expression of type +`Edm.String`. Its value is treated as a URL that MAY be relative or +absolute; relative URLs are relative to the URL of the document +containing the URL reference expression, or relative to a base URL +specified in a format-specific way. + +The response body of the `GET` request MUST be returned as the result of +the` `URL reference expression. The result of the` `URL reference +expression MUST be type compatible with the type expected by the +surrounding expression. + +::: csdlHeadline +`$UrlRef` +::: + +::: csdl +URL reference expressions are represented as an object with a single +member `$UrlRef` whose value is an annotation expression. + +It MAY contain [annotations](#Annotation). +::: + +::: example +Example ##ex: +``` +"@org.example.person.Supplier": { +  "$UrlRef": { +    "$Apply": [ +      "http://host/service/Suppliers({suppID})", +      { +        "$LabeledElement": { +          "$Apply": [ +            { +              "$Path": "SupplierId" +            } +          ], +          "$Function": "odata.uriEncode" +        }, +        "$Name": "suppID" +      } +    ], +    "$Function": "odata.fillUriTemplate" +  } +}, +  +"@Core.LongDescription#element": { +  "$UrlRef": "http://host/wiki/HowToUse" +} +``` +::: + +# ##sec Identifier and Path Values + +## ##subsec Namespace + +A namespace is a dot-separated sequence of [simple +identifier](#SimpleIdentifier)s with a maximum length of 511 Unicode +characters (code points). + +## ##subsec Simple Identifier + +A simple identifier is a Unicode character sequence with the following +restrictions: + +- It consists of at least one and at most 128 Unicode characters (code + points). +- The first character MUST be the underscore character (U+005F) or any + character in the Unicode category "Letter (L)" or "Letter number + (Nl)". +- The remaining characters MUST be the underscore character (U+005F) + or any character in the Unicode category "Letter (L)", "Letter + number (Nl)", "Decimal number (Nd)", "Non-spacing mark (Mn)", + "Combining spacing mark (Mc)", "Connector punctuation (Pc)", and + "Other, format (Cf)". + +Non-normatively speaking it starts with a letter or underscore, followed +by at most 127 letters, underscores or digits. + +## ##subsec Qualified Name + +For model elements that are direct children of a schema: the namespace +or alias of the schema that defines the model element, followed by a dot +and the name of the model element, see rule `qualifiedTypeName` in +[OData‑ABNF](#ODataABNF). + +For built-in [primitive types](#PrimitiveTypes): the name of the type, +prefixed with `Edm` followed by a dot. + +## ##subsec Target Path + +Target paths are used to refer to other model elements. + +The allowed path expressions are: +- The [qualified +name](#QualifiedName) of an entity container, followed by a forward +slash and the name of a container child element +- The target +path of a container child followed by a forward slash and one or more +forward-slash separated property, navigation property, or type-cast +segments + +::: example +Example ##ex: Target expressions +``` +MySchema.MyEntityContainer/MyEntitySet +::: + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty + +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp +``` + +# ##sec [CSDL Examples](#CSDLExamples) + +Following are two basic examples of valid EDM models as represented in +CSDL JSON. These examples demonstrate many of the topics covered above. + +## ##subsec [Products and Categories Example](#ProductsandCategoriesExample) + +::: example +Example ##ex: +``` +{ +  "$Version": "4.0", +  "$EntityContainer": "ODataDemo.DemoService", +  "$Reference": { +    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": { +      "$Include": [ +        { +          "$Namespace": "Org.OData.Core.V1", +          "$Alias": "Core", +          "@Core.DefaultNamespace": true +        } +      ] +    }, +    "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.json": { +      "$Include": [ +        { +          "$Namespace": "Org.OData.Measures.V1", +          "$Alias": "Measures" +        } +      ] +    } +  }, +  "ODataDemo": { +    "$Alias": "self", +    "@Core.DefaultNamespace": true, +    "Product": { +      "$Kind": "EntityType", +      "$HasStream": true, +      "$Key": [ +        "ID" +      ], +      "ID": {}, +      "Description": { +        "$Nullable": true, +        "@Core.IsLanguageDependent": true +      }, +      "ReleaseDate": { +        "$Nullable": true, +        "$Type": "Edm.Date" +      }, +      "DiscontinuedDate": { +        "$Nullable": true, +        "$Type": "Edm.Date" +      }, +      "Rating": { +        "$Nullable": true, +        "$Type": "Edm.Int32" +      }, +      "Price": { +        "$Nullable": true, +        "$Type": "Edm.Decimal", +        "@Measures.ISOCurrency": { +          "$Path": "Currency" +        } +      }, +      "Currency": { +        "$Nullable": true, +        "$MaxLength": 3 +      }, +      "Category": { +        "$Kind": "NavigationProperty", +        "$Type": "self.Category", +        "$Partner": "Products" +      }, +      "Supplier": { +        "$Kind": "NavigationProperty", +        "$Nullable": true, +        "$Type": "self.Supplier", +        "$Partner": "Products" +      } +    }, +    "Category": { +      "$Kind": "EntityType", +      "$Key": [ +        "ID" +      ], +      "ID": { +        "$Type": "Edm.Int32" +      }, +      "Name": { +        "@Core.IsLanguageDependent": true +      }, +      "Products": { +        "$Kind": "NavigationProperty", +        "$Partner": "Category", +        "$Collection": true, +        "$Type": "self.Product", +        "$OnDelete": "Cascade" +      } +    }, +    "Supplier": { +      "$Kind": "EntityType", +      "$Key": [ +        "ID" +      ], +      "ID": {}, +      "Name": { +        "$Nullable": true +      }, +      "Address": { +        "$Type": "self.Address" +      }, +      "Concurrency": { +        "$Type": "Edm.Int32" +      }, +      "Products": { +        "$Kind": "NavigationProperty", +        "$Partner": "Supplier", +        "$Collection": true, +        "$Type": "self.Product" +      } +    }, +    "Country": { +      "$Kind": "EntityType", +      "$Key": [ +        "Code" +      ], +      "Code": { +        "$MaxLength": 2 +      }, +      "Name": { +        "$Nullable": true +      } +    }, +    "Address": { +      "$Kind": "ComplexType", +      "Street": { +        "$Nullable": true +      }, +      "City": { +        "$Nullable": true +      }, +      "State": { +        "$Nullable": true +      }, +      "ZipCode": { +        "$Nullable": true +      }, +      "CountryName": { +        "$Nullable": true +      }, +      "Country": { +        "$Kind": "NavigationProperty", +        "$Nullable": true, +        "$Type": "self.Country", +        "$ReferentialConstraint": { +          "CountryName": "Name" +        } +      } +    }, +    "ProductsByRating": [ +      { +        "$Kind": "Function", +        "$Parameter": [ +          { +            "$Name": "Rating", +            "$Nullable": true, +            "$Type": "Edm.Int32" +          } +        ], +        "$ReturnType": { +          "$Collection": true, +          "$Type": "self.Product" +        } +      } +    ], +    "DemoService": { +      "$Kind": "EntityContainer", +      "Products": { +        "$Collection": true, +        "$Type": "self.Product", +        "$NavigationPropertyBinding": { +          "Category": "Categories" +        } +      }, +      "Categories": { +        "$Collection": true, +        "$Type": "self.Category", +        "$NavigationPropertyBinding": { +          "Products": "Products" +        }, +        "@Core.Description": "Product Categories" +      }, +      "Suppliers": { +        "$Collection": true, +        "$Type": "self.Supplier", +        "$NavigationPropertyBinding": { +          "Products": "Products", +          "Address/Country": "Countries" +        }, +        "@Core.OptimisticConcurrency": [ +          "Concurrency" +        ] +      }, +      "Countries": { +        "$Collection": true, +        "$Type": "self.Country" +      }, +      "MainSupplier": { +        "$Type": "self.Supplier", +        "$NavigationPropertyBinding": { +          "Products": "Products" +        }, +        "@Core.Description": "Primary Supplier" +      }, +      "ProductsByRating": { +        "$EntitySet": "Products", +        "$Function": "self.ProductsByRating" +      } +    } +  } +} +``` +::: + +## [Annotations for Products and Categories Example](#AnnotationsforProductsandCategoriesE) {#annotations-for-products-and-categories-example style="margin-left:28.9pt;text-indent:-28.9pt"} + +::: example +Example ##ex: +``` +{ +  "$Version": "4.01", +  "$Reference": { +    "http://host/service/$metadata": { +      "$Include": [ +        { +          "$Namespace": "ODataDemo", +          "$Alias": "target" +        } +      ] +    }, +    "http://somewhere/Vocabulary/V1": { +      "$Include": [ +        { +          "$Namespace": "Some.Vocabulary.V1", +          "$Alias": "Vocabulary1" +        } +      ] +    } +  }, +  "External.Annotations": { +    "$Annotations": { +      "target.Supplier": { +        "@Vocabulary1.EMail": null, +        "@Vocabulary1.AccountID": { +          "$Path": "ID" +        }, +        "@Vocabulary1.Title": "Supplier Info", +        "@Vocabulary1.DisplayName": { +          "$Apply": [ +            { +              "$Path": "Name" +            }, +            " in ", +            { +              "$Path": "Address/CountryName" +            } +          ], +          "$Function": "odata.concat" +        } +      }, +      "target.Product": { +        "@Vocabulary1.Tags": [ +          "MasterData" +        ] +      } +    } +  } +} +``` +::: + +# ##sec Conformance + +Conforming services MUST follow all rules of this specification document +for the types, sets, functions, actions, containers and annotations they +expose. + +In addition, conforming services MUST NOT return 4.01 CSDL constructs +for requests made with `OData-MaxVersion:4.0`. + +Specifically, they + +1\. MUST NOT include properties in derived types that overwrite a +property defined in the base type + +2\. MUST NOT include `Edm.Untyped` + +3\. MUST NOT use [path syntax](#PathSyntax) added with 4.01 + +4\. MUST NOT use `Edm.ModelElementPath` and `Edm.AnyPropertyPath` + +5\. MUST NOT specify [referential constraints](#ReferentialConstraint) +to complex types and navigation properties + +6\. MUST NOT include a non-abstract entity type with no inherited or +defined [entity key](#Key) + +7\. MUST NOT include the +[`Core.DefaultNamespace`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#DefaultNamespace) +annotation on [included schemas](#IncludedSchema) + +8\. MUST NOT return the Unicode facet for terms, parameters, and return +types + +9\. MUST NOT include collections of `Edm.ComplexType` or `Edm.Untyped` + +10\. MUST NOT specify a key as a property of a related entity + +11\. SHOULD NOT include new/unknown values for +[`$AppliesTo`](#Applicability) + +12\. MAY include new CSDL annotations + +In addition, OData 4.01 services: + +13\. SHOULD NOT have identifiers within a uniqueness scope (e.g. a +schema, a structural type, or an entity container) that differ only by +case + +Conforming clients MUST be prepared to consume a model that uses any or +all constructs defined in this specification, including custom +annotations, and MUST ignore constructs not defined in this version of +the specification. + +Appendix A. [Acknowledgments](#Acknowledgments) + +The work of the OpenUI5 team on the OData V4 Metadata JSON Format, see +**\[**[**OpenUI5**](#OpenUI5)**\]**, is gratefully acknowledged, +especially the contributions of +- Thomas Chadzelek (SAP SE) +- Jens Ittel (SAP SE) +- Patric Ksinsik (SAP SE) + +The contributions of the OASIS OData Technical Committee members, +enumerated in [ODataProtocol](#ODataProtocol), are gratefully +acknowledged. + +Appendix B. [Table of JSON Objects and +Members](#TableofJSONObjectsandMembers) + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection2 +[Document Object[ ]{style="color: +windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317364) + +[`$Version`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317365) + +[`$EntityContainer`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317366) + +[`$Reference`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317367) + +[Reference Object[ +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37317368) + +[`$Include`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37317369) + +[`$Namespace`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37317370) + +[`$Alias`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37317371) + +[`$IncludeAnnotations`[. +]{style="color:windowtext;display:none"}[18]{style="color:windowtext;display:none"}](#_Toc37317372) + +[`$TermNamespace`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37317373) + +[`$Qualifier`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37317374) + +[`$TargetNamespace`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37317375) + +[Schema Object[ ]{style="color:windowtext; +display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37317376) + +[`$Alias`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37317377) + +[`$Annotations`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37317378) + +[Entity Type Object[ +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37317379) + +[`$BaseType`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37317380) + +[`$Abstract`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37317381) + +[`$OpenType`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37317382) + +[`$HasStream`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37317383) + +[`$Key`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37317384) + +[Property Object[ ]{style="color: +windowtext;display:none"}[27]{style="color:windowtext;display:none"}](#_Toc37317385) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37317386) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37317387) + +[`$MaxLength`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37317388) + +[`$Precision`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37317389) + +[`$Scale`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37317390) + +[`$Unicode`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37317391) + +[`$SRID`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37317392) + +[`$DefaultValue`[. +]{style="color:windowtext;display:none"}[31]{style="color:windowtext;display:none"}](#_Toc37317393) + +[Navigation Property Object[ +]{style="color:windowtext;display:none"}[32]{style="color:windowtext;display:none"}](#_Toc37317394) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37317395) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37317396) + +[`$Partner`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37317397) + +[`$ContainsTarget`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37317398) + +[`$ReferentialConstraint`[. +]{style="color:windowtext;display:none"}[35]{style="color:windowtext;display:none"}](#_Toc37317399) + +[`$OnDelete`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37317400) + +[Complex Type Object[ +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37317401) + +[`$BaseType`[. +]{style="color:windowtext;display:none"}[38]{style="color:windowtext;display:none"}](#_Toc37317402) + +[`$Abstract`[. +]{style="color:windowtext;display:none"}[38]{style="color:windowtext;display:none"}](#_Toc37317403) + +[`$OpenType`[. +]{style="color:windowtext;display:none"}[38]{style="color:windowtext;display:none"}](#_Toc37317404) + +[Enumeration Type Object[ +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37317405) + +[`$UnderlyingType`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37317406) + +[`$IsFlags`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37317407) + +[Enumeration Member Object[ +]{style="color:windowtext;display:none"}[40]{style="color:windowtext;display:none"}](#_Toc37317408) + +[Type Definition Object[ +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37317409) + +[`$UnderlyingType`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37317410) + +[Action Overload Object[ +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37317411) + +[Function Overload Object[ +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37317412) + +[`$IsBound`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37317413) + +[`$EntitySetPath`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37317414) + +[`$IsComposable`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317415) + +[`$ReturnType`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317416) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317417) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37317418) + +[`$Parameter`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317419) + +[Parameter Object[ +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317420) + +[`$Name`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317421) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317422) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37317423) + +[Entity Container Object[ +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37317424) + +[`$Extends`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37317425) + +[Entity Set Object[ +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317426) + +[`$Collection`[. +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317427) + +[`$Type`[. +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317428) + +[`$IncludeInServiceDocument`[. +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317429) + +[Singleton Object[ +]{style="color:windowtext;display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37317430) + +[`$Type`[. +]{style="color:windowtext;display:none"}[50]{style="color:windowtext;display:none"}](#_Toc37317431) + +[`$Nullable`[. +]{style="color:windowtext;display:none"}[50]{style="color:windowtext;display:none"}](#_Toc37317432) + +[`$NavigationPropertyBinding`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37317433) + +[Action Import Object[ +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37317434) + +[`$Action`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37317435) + +[`$EntitySet`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317436) + +[Function Import Object[ +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317437) + +[`$Function`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317438) + +[`$EntitySet`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317439) + +[`$IncludeInServiceDocument`[. +]{style="color:windowtext;display:none"}[52]{style="color:windowtext;display:none"}](#_Toc37317440) + +[Term Object[ ]{style="color:windowtext; +display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317441) + +[`$Type` and `$Collection`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317442) + +[`$DefaultValue`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317443) + +[`$BaseTerm`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37317444) + +[`$AppliesTo`[. +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37317445) + +[Annotation Member[ +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37317446) + +[`$Path`[. +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37317447) + +[`$And` and `$Or`[. ]{style="color:windowtext; +display:none"}[66]{style="color:windowtext;display:none"}](#_Toc37317448) + +[`$Not`[. +]{style="color:windowtext;display:none"}[66]{style="color:windowtext;display:none"}](#_Toc37317449) + +[`$Eq`, `$Ne`, `$Gt`, `$Ge`, `$Lt`, `$Le`, `$Has`, and `$In`[. +]{style="color:windowtext; +display:none"}[66]{style="color:windowtext;display:none"}](#_Toc37317450) + +[`$Neg`[. +]{style="color:windowtext;display:none"}[68]{style="color:windowtext;display:none"}](#_Toc37317451) + +[`$Add`, `$Sub`, `$Mul`, `$Div`, `$DivBy`, and `$Mod`[. +]{style="color:windowtext; +display:none"}[69]{style="color:windowtext;display:none"}](#_Toc37317452) + +[`$Apply`[. +]{style="color:windowtext;display:none"}[70]{style="color:windowtext;display:none"}](#_Toc37317453) + +[`$Cast`[. +]{style="color:windowtext;display:none"}[72]{style="color:windowtext;display:none"}](#_Toc37317454) + +[`$If`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37317455) + +[`$IsOf`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37317456) + +[`$LabeledElement`[. +]{style="color:windowtext;display:none"}[74]{style="color:windowtext;display:none"}](#_Toc37317457) + +[`$LabeledElementReference`[. +]{style="color:windowtext;display:none"}[74]{style="color:windowtext;display:none"}](#_Toc37317458) + +[`$Null`[. +]{style="color:windowtext;display:none"}[75]{style="color:windowtext;display:none"}](#_Toc37317459) + +[`$UrlRef`[. +]{style="color:windowtext;display:none"}[76]{style="color:windowtext;display:none"}](#_Toc37317460) + +  +::: + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection3 +Appendix C. [Revision History](#RevisionHistory) + ++-----------------+-----------------+-----------------+-----------------+ +| **Revision** | **Date** | **Editor** | **Changes | +| | | | Made** | ++-----------------+-----------------+-----------------+-----------------+ +| Working Draft | 2016-11-16 | Ralf Handl | Initial version | +| 01 | | | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-06-08 | Michael Pizzo | Integrated 4.01 | +| Specification | | | features | +| Draft 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-09-22 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 02 | | Ralf Handl | | +| | | | Changed | +| | | | defaults of | +| | | | `$Nullable`, | +| | | | `$Scale`, and | +| | | | `$Precision` | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-11-10 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 03 | | Ralf Handl | | +| | | | Stable order of | +| | | | action and | +| | | | function | +| | | | parameters | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-12-19 | Michael Pizzo | Non-Material | +| Specification | | | Changes | +| 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-06-21 | Michael Pizzo | External | +| Specification | | | targeting for | +| Draft 04 | | Ralf Handl | annotations on | +| | | | action/function | +| | | | overloads, | +| | | | parameters, and | +| | | | return types | +| | | | | +| | | | Key and index | +| | | | segments for | +| | | | path | +| | | | expressions in | +| | | | annotations | +| | | | | +| | | | Nullable | +| | | | singletons | +| | | | | +| | | | Simplified | +| | | | syntax of | +| | | | entity | +| | | | container | +| | | | children and | +| | | | constant | +| | | | annotation | +| | | | expressions | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-09-26 | Michael Pizzo | Redefining | +| Specification | | | entity sets and | +| Draft 05 | | Ralf Handl | singletons when | +| | | | extending | +| | | | entity | +| | | | containers | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-11-05 | Michael Pizzo | Non-material | +| Specification | | | changes | +| 02 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Candidate OASIS | 2020-04-09 | Michael Pizzo | Non-material | +| Standard 02 | | | changes | +| | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ + +  +::: diff --git a/odata-csdl/temp/odata-csdl-xml-v4.01-os-clean.html b/odata-csdl/temp/odata-csdl-xml-v4.01-os-clean.html new file mode 100644 index 000000000..69c2b1367 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-xml-v4.01-os-clean.html @@ -0,0 +1,9937 @@ + + + + + + +OData Common Schema Definition Language (CSDL) XML Representation +Version 4.01 + + + + + +

    ##sec Introduction

    + + + +

    OData services are described in terms of an Entity Model. The Common Schema Definition Language +(CSDL) defines a representation of the entity data model exposed by an OData +service using the Extensible Markup Language (XML) 1.1 (Second Edition) [XML‑1.1] with further building blocks from the +W3C XML Schema Definition Language (XSD) 1.1 as described in [XML‑Schema‑1] and [XML‑Schema‑2].

    + +

    ##subsec IPR Policy

    + +

    This specification is provided under the RF on +RAND Terms Mode of the OASIS IPR Policy, +the mode chosen when the Technical Committee was established. For information +on whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing terms, +please refer to the Intellectual Property Rights section of the TCs web page (https://www.oasis-open.org/committees/odata/ipr.php).

    + +

    ##subsec Terminology

    + +

    The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL +NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this +document are to be interpreted as described in RFC2119.

    + +

    ##subsec Normative References

    + +

    [ECMAScript] ECMAScript +2016 Language Specification, 7th Edition, June 2016. Standard +ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm. +

    + +

    [EPSG] European +Petroleum Survey Group (EPSG). http://www.epsg.org/. +

    + +

    [OData-ABNF] OData +ABNF Construction Rules Version 4.01.
    +See link in Additional artifacts section on cover page.

    + +

    [OData-EDM] OData EDM XML Schema.
    +
    See link in Additional artifacts section on cover page.

    + +

    [OData-EDMX] OData EDMX XML Schema.
    +
    See link in Additional artifacts section on cover page.

    + +

    OData-CSDLJSON OData Common Schema Definition +Language (CSDL) JSON Representation Version 4.01. See link in Related +work section on cover page.

    + +

    [OData-JSON] OData JSON Format Version 4.01. +
    +See link in Related work section on cover page.

    + +

    [OData-Protocol] OData +Version 4.01 Part 1: Protocol.
    +See link in Additional artifacts section on cover page.

    + +

    OData-URL OData +Version 4.01 Part 2: URL Conventions.
    +See link in Additional artifacts section on cover page.

    + +

    OData-VocCore OData Vocabularies +Version 4.0: Core Vocabulary.
    +See link in Related work section on cover page.

    + +

    OData-VocMeasures OData +Vocabularies Version 4.0: Measures Vocabulary.
    +See link in Related work section on cover page.

    + +

    OData-VocValidation OData +Vocabularies Version 4.0: Validation Vocabulary.
    +See link in Related work section on cover page.

    + +

    [RFC2119] Bradner, +S., Key words for use in RFCs to Indicate Requirement Levels, BCP 14, RFC +2119, March 1997. https://tools.ietf.org/html/rfc2119.

    + +

    RFC6570 Gregorio, J., +Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, URI Template, RFC +6570, March 2012. http://tools.ietf.org/html/rfc6570. +

    + +

    [XML-1.1] Extensible +Markup Language (XML) 1.1 (Second Edition), F. Yergeau, E. Maler, J. Cowan, T. +Bray, C. M. Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August +2006,
    +http://www.w3.org/TR/2006/REC-xml11-20060816. +
    +Latest version available at http://www.w3.org/TR/xml11/.

    + +

    [XML-Base] XML Base +(Second Edition), J. Marsh, R. Tobin, Editors, W3C Recommendation, 28 January +2009,
    +http://www.w3.org/TR/2009/REC-xmlbase-20090128/. +
    +Latest version available at http://www.w3.org/TR/xmlbase/. +

    + +

    [XML-Schema-1] W3C +XML Schema Definition Language (XSD) 1.1 Part 1: Structures, D. Beech, M. +Maloney, C. M. Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, +Editors, W3C Recommendation, 5 April 2012, http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/.
    +Latest version available at http://www.w3.org/TR/xmlschema11-1/. +

    + +

    [XML-Schema-2] W3C +XML Schema Definition Language (XSD) 1.1 Part 2: DatatypesW3C XML Schema +Definition Language (XSD) 1.1 Part 2: Datatypes, D. Peterson, S. Gao, C. M. +Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C +Recommendation, 5 April 2012, http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/.
    +Latest version available at http://www.w3.org/TR/xmlschema11-2/.

    + +

    ##subsec Typographical Conventions

    + +

    Keywords defined by this specification use this monospaced font.

    + +

    Normative source code uses this paragraph style.

    + +

    Some sections of this specification are illustrated with +non-normative examples.

    + +

    Example 1: text describing an example uses this paragraph +style

    + +
    + +

    Non-normative examples use this paragraph style.

    + +
    + +

    All examples in this document are non-normative and +informative only.

    + +

    Representation-specific text is indented and marked with +vertical lines.

    + +
    + +

    Representation-Specific +Headline

    + +
    + +
    + +

    Normative representation-specific text

    + +
    + +

    All other text is normative unless otherwise labeled.

    + + + +

    ##sec XML Representation

    + + + +

    OData CSDL XML is a full representation of the OData Common +Schema Definition Language in the Extensible Markup Language (XML) 1.1 (Second +Edition) [XML‑1.1] with further building +blocks from the W3C XML Schema Definition Language (XSD) 1.1 as described in [XML‑Schema‑1] and [XML‑Schema‑2].

    + +

    It is an alternative to the CSDL JSON representation defined +in [OData-CSDLJSON] and neither +adds nor removes features.

    + +

    ##subsec Requesting the XML Representation

    + +

    The OData CSDL XML representation can be requested using the +$format query option in the request URL with the media +type application/xml, optionally followed by media +type parameters, or the case-insensitive abbreviation xml +which MUST NOT be followed by media type parameters.

    + +

    Alternatively, this representation can be requested using +the Accept header with the media type application/xml, optionally followed by media type +parameters.

    + +

    If specified, $format overrides +any value specified in the Accept header.

    + +

    The response MUST contain the Content-Type +header with a value of application/xml, optionally +followed by media type parameters.

    + +

    This specification does not define additional parameters for +the media type application/xml.

    + +

    ##subsec XML +Namespaces

    + +

    In addition to the default XML namespace, the elements and +attributes used to describe the entity model of an OData service are defined in +one of the following namespaces.

    + +

    ##subsubsec Namespace EDMX

    + +

    Elements and attributes associated with the top-level +wrapper that contains the CSDL used to define the entity model for an OData +Service are qualified with the Entity Data Model for Data Services Packaging +namespace:

    + +

    http://docs.oasis-open.org/odata/ns/edmx

    + +

    Prior versions of OData used the following namespace for +EDMX:

    + +

    EDMX version 1.0: http://schemas.microsoft.com/ado/2007/06/edmx

    + +

    They are non-normative for this specification.

    + +

    In this specification the namespace prefix edmx is used to represent the Entity Data Model for Data +Services Packaging namespace, however the prefix name is not prescriptive.

    + +

    ##subsubsec Namespace EDM

    + +

    Elements and attributes that define the entity model exposed +by the OData Service are qualified with the Entity Data Model namespace:

    + +

    http://docs.oasis-open.org/odata/ns/edm

    + +

    Prior versions of CSDL used the following namespaces for +EDM:

    + +

    CSDL version 1.0: http://schemas.microsoft.com/ado/2006/04/edm

    + +

    CSDL version 1.1: http://schemas.microsoft.com/ado/2007/05/edm

    + +

    CSDL version 1.2: http://schemas.microsoft.com/ado/2008/01/edm

    + +

    CSDL version 2.0: http://schemas.microsoft.com/ado/2008/09/edm

    + +

    CSDL version 3.0: http://schemas.microsoft.com/ado/2009/11/edm

    + +

    They are non-normative for this specification.

    + +

    In this specification the namespace prefix edm is used to represent the Entity Data Model namespace, +however the prefix name is not prescriptive.

    + +

    ##subsec XML Schema Definitions

    + +

    This specification contains normative XML schemas for the +EDMX and EDM namespaces; see OData‑EDMX +and OData‑EDM.

    + +

    These XML schemas only define the shape of a well-formed +CSDL XML document and are not descriptive enough to define what a correct CSDL +XML document MUST be in every imaginable use case. This specification document +defines additional rules that correct CSDL XML documents MUST fulfill. In case +of doubt on what makes a CSDL XML document correct the rules defined in this +specification document take precedence.

    + +

    ##subsec XML Document Order

    + +

    Client libraries MUST retain +the document order of XML elements for CSDL XML documents because for some +elements the order of child elements is significant. This includes, but is not +limited to, members of enumeration types +and items within a collection expression.

    + +

    OData does not impose any ordering constraints on XML +attributes within XML elements.

    + + + +

    ##sec Entity Model

    + + + +

    An OData service exposes a single entity model. This model +may be distributed over several schemas, and these +schemas may be distributed over several physical locations.

    + +

    A service is defined by a single CSDL document which can be +accessed by sending a GET request to <serviceRoot>/$metadata. This document is called +the metadata document. It may reference other CSDL documents.

    + +

    The metadata document contains a single entity container that defines the resources +exposed by this service. This entity container MAY extend an entity container defined +in a referenced document.

    + +

    The model of the service consists of all CSDL +constructs used in its entity containers.

    + +

    The scope of a CSDL document is the document itself +and all schemas included from directly referenced documents. All entity types, complex types +and other named elements in scope (that is, defined in the document +itself or a schema of a directly referenced document) can be accessed from a +referencing document by their qualified names. This includes the built-in primitive and abstract types.

    + +

    Referencing another document may alter the model defined by +the referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, then an entity set of the service defined by the referencing +document may return entities of the derived type. This is identical to the +behavior if the derived type had been defined directly in the referencing +document.

    + +

    Note: referencing documents is not recursive. Only named +elements defined in directly referenced documents can be used within the +schema. However, those elements may in turn include elements defined in schemas +referenced by their defining schema.

    + +

    ##subsec Nominal +Types

    + +

    A nominal type has a name that MUST be a simple identifier. Nominal types are +referenced using their qualified name. The +qualified type name MUST be unique within a model as it facilitates references +to the element from other parts of the model.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    ##subsec Structured Types

    + +

    Structured types are composed of other model elements. +Structured types are common in entity models as the means of representing +entities and structured properties in an OData service. Entity types and complex +types are both structured types.

    + +

    Structured +Types are composed of zero or more structural +properties and navigation properties.

    + +

    Open entity types and open complex types allow properties to be added +dynamically to instances of the open type.

    + +

    ##subsec Primitive Types

    + +

    Structured types are composed of other structured types and +primitive types. OData defines the following primitive types:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Type

    +
    +

    Meaning

    +
    +

    Edm.Binary

    +
    +

    Binary data

    +
    +

    Edm.Boolean

    +
    +

    Binary-valued logic

    +
    +

    Edm.Byte

    +
    +

    Unsigned 8-bit integer

    +
    +

    Edm.Date

    +
    +

    Date without a time-zone offset

    +
    +

    Edm.DateTimeOffset

    +
    +

    Date and time with a time-zone offset, no leap seconds

    +
    +

    Edm.Decimal

    +
    +

    Numeric values with decimal representation

    +
    +

    Edm.Double

    +
    +

    IEEE 754 binary64 floating-point number (15-17 decimal + digits)

    +
    +

    Edm.Duration

    +
    +

    Signed duration in days, hours, minutes, and (sub)seconds

    +
    +

    Edm.Guid

    +
    +

    16-byte (128-bit) unique identifier

    +
    +

    Edm.Int16

    +
    +

    Signed 16-bit integer

    +
    +

    Edm.Int32

    +
    +

    Signed 32-bit integer

    +
    +

    Edm.Int64

    +
    +

    Signed 64-bit integer

    +
    +

    Edm.SByte

    +
    +

    Signed 8-bit integer

    +
    +

    Edm.Single

    +
    +

    IEEE 754 binary32 floating-point number (6-9 decimal + digits)

    +
    +

    Edm.Stream

    +
    +

    Binary data stream

    +
    +

    Edm.String

    +
    +

    Sequence of characters

    +
    +

    Edm.TimeOfDay

    +
    +

    Clock time 00:00-23:59:59.999999999999

    +
    +

    Edm.Geography

    +
    +

    Abstract base type for all Geography types

    +
    +

    Edm.GeographyPoint

    +
    +

    A point in a round-earth coordinate system

    +
    +

    Edm.GeographyLineString

    +
    +

    Line string in a round-earth coordinate system

    +
    +

    Edm.GeographyPolygon

    +
    +

    Polygon in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiPoint

    +
    +

    Collection of points in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiLineString

    +
    +

    Collection of line strings in a round-earth coordinate + system

    +
    +

    Edm.GeographyMultiPolygon

    +
    +

    Collection of polygons in a round-earth coordinate system

    +
    +

    Edm.GeographyCollection

    +
    +

    Collection of arbitrary Geography values

    +
    +

    Edm.Geometry

    +
    +

    Abstract base type for all Geometry types

    +
    +

    Edm.GeometryPoint

    +
    +

    Point in a flat-earth coordinate system

    +
    +

    Edm.GeometryLineString

    +
    +

    Line string in a flat-earth coordinate system

    +
    +

    Edm.GeometryPolygon

    +
    +

    Polygon in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiPoint

    +
    +

    Collection of points in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiLineString

    +
    +

    Collection of line strings in a flat-earth coordinate + system

    +
    +

    Edm.GeometryMultiPolygon

    +
    +

    Collection of polygons in a flat-earth coordinate system

    +
    +

    Edm.GeometryCollection

    +
    +

    Collection of arbitrary Geometry values

    +
    + +

    Edm.Date and Edm.DateTimeOffset follow [XML‑Schema‑2] +and use the proleptic Gregorian calendar, allowing the year 0000 (equivalent to 1 BCE) and negative years (year -0001 being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying persistency +layer, e.g. SQL only supports years 0001 to 9999.

    + +

    Edm.Decimal with a Scale value of floating, Edm.Double, and Edm.Single allow the special numeric values -INF, INF, and NaN.

    + +

    Edm.Stream is a primitive type +that can be used as a property of an entity type +or complex type, the underlying type for a type definition, or the binding parameter or +return type of an action or function. +Edm.Stream, or a type definition whose underlying +type is Edm.Stream, cannot be used in collections +or for non-binding parameters to functions or actions.

    + +

    Some of these types allow facets, +defined in section Type Facets.

    + +

    See rule primitiveLiteral in OData‑ABNF for the representation of primitive +type values in URLs and OData‑JSON for the +representation in requests and responses.

    + +

    ##subsec Built-In Abstract Types

    + +

    The following built-in abstract types can be used within a +model:

    + +

    Edm.PrimitiveType 

    + +

    Edm.ComplexType

    + +

    Edm.EntityType

    + +

    Edm.Untyped

    + +

    Conceptually, these are the abstract base types for +primitive types (including type definitions and enumeration types), complex +types, entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except:

    + +

    Edm.EntityType

    + +
      +
        +
      • cannot be used as the type of a singleton in an entity container + because it doesnt define a structure, which defeats the purpose of a + singleton.
      • +
      • cannot be used as the type of an entity set because all + entities in an entity set must have the same key fields to uniquely + identify them within the set.
      • +
      • cannot be the base type of an entity type or complex type. 
      • +
      +
    + +

    Edm.ComplexType

    + +
      +
        +
      • cannot be the base type of an entity type or complex type. 
      • +
      +
    + +

    Edm.PrimitiveType

    + +
      +
        +
      • cannot be used as the type of a key property of an entity + type or as the underlying type of an enumeration type.
      • +
      • cannot be used as the underlying type of a type definition + in a CSDL document with a version of 4.0.
      • +
      • can be used as the underlying type of a type definition + in a CSDL document with a version of 4.01 or + greater.
      • +
      +
    + +

    Edm.Untyped

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      • cannot be used as the type of a key property of an entity + type.
      • +
      • cannot be the base type of an entity type or complex type. 
      • +
      • cannot be used as the underlying type of a type + definition or enumeration type.
      • +
      +
    + +

    Collection(Edm.PrimitiveType)

    + +
      +
        +
      • cannot be used as the type of a property or term.
      • +
      • cannot be used as the type of a parameter or the return + type of an action or function.
      • +
      +
    + +

    Collection(Edm.Untyped)

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      +
    + +

    ##subsec Built-In Types for defining +Vocabulary Terms

    + +

    Vocabulary terms can, in addition, use

    + +

    Edm.AnnotationPath

    + +

    Edm.PropertyPath

    + +

    Edm.NavigationPropertyPath 

    + +

    Edm.AnyPropertyPath (Edm.PropertyPath or Edm.NavigationPropertyPath)

    + +

    Edm.ModelElementPath (any +model element, including Edm.AnnotationPath, Edm.NavigationPropertyPath, and Edm.PropertyPath)

    + +

    as the type of a primitive term, or the type of a property +of a complex type (recursively) that is exclusively used as the type of a term. +See section Path Expressions for details.

    + +

    ##subsec Annotations

    + +

    Many parts of the model can be decorated with additional +information using annotations. Annotations are +identified by their term name and an optional qualifier that allows applying +the same term multiple times to the same model element.

    + +

    A model element MUST NOT specify more than one annotation +for a given combination of term and qualifier.

    + + + +

    ##sec CSDL XML Document

    + + + +
    + +

    Element +edmx:Edmx

    + +
    + +
    + +

    The edmx:Edmx +element is the root element of a CSDL XML document. It MUST contain the Version attribute and it MUST contain exactly one edmx:DataServices element.

    + +

    It MAY contain edmx:Reference elements to +reference other CSDL documents.

    + +
    + +
    + +

    Attribute +Version

    + +
    + +
    + +

    The Version +attribute specifies the OData protocol version of the service. For OData 4.0 +responses the value of this attribute MUST be 4.0. +For OData 4.01 responses the value of this attribute MUST be 4.01. Services MUST return an OData 4.0 response if the +request was made with an OData-MaxVersion header +with a value of 4.0.

    + +
    + +
    + +

    Element edmx:DataServices

    + +
    + +
    + +

    The edmx:DataServices +element MUST contain one or more edm:Schema elements which define the schemas exposed +by the OData service.

    + +
    + +

    Example 2:

    + +
    + +

    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"

    + +

    Version="4.01">
    +<edmx:DataServices>
    +
    + </edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    ##subsec Reference

    + +

    A reference to an external CSDL document allows to bring +part of the referenced documents content into the scope of the referencing +document.

    + +

    A reference MUST specify a URI that uniquely identifies the +referenced document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be absolute +or relative URI; relative URLs are relative to the URL of the document +containing the reference, or relative to a base URL specified in a +format-specific way.

    + +

    A reference MAY be annotated.

    + +

    The Core.SchemaVersion annotation, +defined in OData-VocCore, MAY be used to +indicate a particular version of the referenced schema. If the Core.SchemaVersion annotation is +present, the $schemaversion system query option, +defined OData‑Protocol, SHOULD +be used when retrieving the referenced schema document.

    + +
    + +

    Element edmx:Reference

    + +
    + +
    + +

    The edmx:Reference +element specifies external CSDL documents referenced by the referencing +document. The child elements edmx:Include and edmx:IncludeAnnotations +specify which parts of the referenced document are available for use in the +referencing document.

    + +

    The edmx:Reference +element MUST contain +the Uri attribute, and it MUST contain at least one +edmx:Include +or edmx:IncludeAnnotations +child element.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Uri

    + +
    + +
    + +

    The value of Uri +is an absolute or relative URI; relative URIs are relative to the xml:base attribute, see [XML‑Base].

    + +
    + +

    Example +3: references to other CSDL documents

    + +
    + +

    <?xml version="1.0" +encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    + Version="4.0">
    +<edmx:Reference Uri="http://vocabs.odata.org/capabilities/v1">

    + +

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://vocabs.odata.org/core/v1">

    + +

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://example.org/display/v1">
    +

    + +

    </edmx:Reference>
    +<edmx:DataServices></edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    ##subsec Included +Schema

    + +

    A reference MAY include zero or more schemas from the +referenced document.

    + +

    The included schemas are identified via their namespace. The same +namespace MUST NOT be included more than once, even if it is declared in more +than one referenced document.

    + +

    When including a schema, a simple +identifier value MAY be specified as an alias for the schema that is used +in qualified names instead of the namespace. For example, an alias of display might be assigned to the namespace org.example.vocabularies.display. An alias-qualified name +is resolved to a fully qualified name by examining aliases for included schemas +and schemas defined within the document.

    + +
    + +

    If an included schema specifies an +alias, the alias MAY be used instead of the namespace within qualified names to +identify model elements of the included schema. An alias only provides a more +convenient notation, allowing a short string to be substituted for a long +namespace. Every model element that can be identified via an alias-qualified +name can alternatively be identified via its full namespace-qualified name.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document.

    + +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +

    An alias is only valid within the document in which it is +declared; a referencing document may define its own aliases for included +schemas.

    + +
    + +

    Element edmx:Include

    + +
    + +
    + +

    The edmx:Include +element specifies a schema to include from the referenced CSDL document. It +MUST provide the Namespace attribute and it MAY +provide the Alias attribute.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Namespace

    + +
    + +
    + +

    The value of Namespace +is the namespace of a schema defined in the referenced CSDL document.

    + +
    + +
    + +

    Attribute Alias

    + +
    + +
    + +

    The value of Alias +is a simple identifier that can be used in +qualified names instead of the namespace.

    + +
    + +

    Example 4: references to entity models containing +definitions of vocabulary terms

    + +
    + +

    <?xml version="1.0" +encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    + Version="4.0">
    +<edmx:Reference Uri="http://vocabs.odata.org/capabilities/v1">

    + +

    <edmx:Include +Namespace="Org.OData.Capabilities.V1" />

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://vocabs.odata.org/core/v1">

    + +

    <edmx:Include +Namespace="Org.OData.Core.V1" Alias="Core">

    + +

    <Annotation +Term="Core.DefaultNamespace" />

    + +

    </edmx:Include>

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://example.org/display/v1">
    + <edmx:Include Alias="UI" +Namespace="org.example.display" />

    + +

    </edmx:Reference>
    +<edmx:DataServices></edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    ##subsec Included +Annotations

    + +

    In addition to including whole schemas with all model +constructs defined within that schema, annotations can be included with more +flexibility.

    + +

    Annotations are selectively included by specifying the namespace of the +annotations term. Consumers can opt not to inspect the referenced document if +none of the term namespaces is of interest for the consumer.

    + +

    In addition, the qualifier of +annotations to be included MAY be specified. For instance, a service author +might want to supply a different set of annotations for various device form +factors. If a qualifier is specified, only those annotations from the specified +term namespace with the specified qualifier (applied to a model element of the +target namespace, if present) SHOULD be included. If no qualifier is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the target namespace, if present) SHOULD be +included.

    + +

    The qualifier also provides consumers insight about what +qualifiers are present in the referenced document. If the consumer is not +interested in that particular qualifier, the consumer can opt not to inspect +the referenced document.

    + +

    In addition, the namespace of the annotations target MAY be specified. If a target namespace is +specified, only those annotations which apply a term form the specified term +namespace to a model element of the target namespace (with the specified +qualifier, if present) SHOULD be included. If no target namespace is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the qualifier, if present) SHOULD be included.

    + +

    The target namespace also provides consumers insight about +what namespaces are present in the referenced document. If the consumer is not +interested in that particular target namespace, the consumer can opt not to +inspect the referenced document.

    + +
    + +

    Element edmx:IncludeAnnotations

    + +
    + +
    + +

    The edmx:IncludeAnnotations +element specifies the annotations to include from the referenced CSDL document. +If no edmx:IncludeAnnotations element is specified, +a client MAY ignore all annotations in the referenced document that are not +explicitly used in an edm:Path +expression of the referencing document.

    + +

    The edmx:IncludeAnnotations +element MUST provide the TermNamespace attribute, +and it MAY provide the Qualifier and TargetNamespace attribute.

    + +
    + +
    + +

    Attribute TermNamespace

    + +
    + +
    + +

    The value of TermNamespace +is a namespace.

    + +
    + +
    + +

    Attribute Qualifier

    + +
    + +
    + +

    The value of Qualifier +is a simple identifier.

    + +
    + +
    + +

    Attribute TargetNamespace +

    + +
    + +
    + +

    The value of TargetNamespace +is a namespace.

    + +
    + +

    Example 5: reference documents that contain annotations

    + +
    + +

    <?xml version="1.0" +encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx=
    "http://docs.oasis-open.org/odata/ns/edmx"

    + +

    Version="4.0">
    + <edmx:Reference Uri="http://odata.org/ann/b">
    + <edmx:IncludeAnnotations +TermNamespace="org.example.validation" />
    + <edmx:IncludeAnnotations TermNamespace="org.example.display"

    + +

    Qualifier="Tablet" +/>
    + <edmx:IncludeAnnotations TermNamespace="org.example.hcm"
    + TargetNamespace="com.example.Sales" />
    + <edmx:IncludeAnnotations TermNamespace="org.example.hcm"

    + +

    Qualifier="Tablet"
    + TargetNamespace="com.example.Person" />
    +</edmx:Reference>
    +<edmx:DataServices></edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    The following annotations from http://odata.org/ann/b +are included:

    + +

    Annotations that use a term from the org.example.validation +namespace, and

    + +

    Annotations that use a term from the org.example.display +namespace and specify a Tablet +qualifier and

    + +

    Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Sales +namespace and

    + +

    Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Person +namespace and specify a Tablet +qualifier.

    + + + +

    ##sec Schema

    + + + +

    One or more schemas describe the entity model exposed by an +OData service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms.

    + +

    A schema +is identified by a namespace. Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally unique. A +schema cannot span more than one document.

    + +

    The schemas namespace is combined with the name of elements +in the entity model to create unique qualified +names, so identifiers that are used to name +types MUST be unique within a namespace to prevent ambiguity.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    The namespace +MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +
    + +

    Element edm:Schema

    + +
    + +
    + +

    The edm:Schema element +defines a schema. It MUST contain the Namespace +attribute and it MAY contain the Alias attribute.

    + +

    It MAY contain elements edm:Action, edm:Annotations, edm:Annotation, edm:ComplexType, edm:EntityContainer, edm:EntityType, edm:EnumType, edm:Function, edm:Term, or edm:TypeDefinition.

    + +
    + +
    + +

    Attribute Namespace

    + +
    + +
    + +

    The value of Namespace +is the namespace of the schema

    + +
    + +

    ##subsec Alias

    + +

    A schema MAY specify an alias which MUST be a simple identifier.

    + +
    + +

    If a schema specifies an alias, the +alias MAY be used instead of the namespace within qualified names to identify +model elements of that schema. An alias only provides a more convenient +notation, allowing a short string to be substituted for a long namespace. Every +model element that can be identified via an alias-qualified name can +alternatively be identified via its full namespace-qualified name.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the containing +document and are not restricted to the schema that defines them.

    + +

    The alias MUST NOT be one of the reserved +values Edm, odata, System, or Transient.

    + +
    + +

    Attribute Alias

    + +
    + +
    + +

    The value of Alias +is a simple identifier.

    + +
    + +

    Example 6: schema org.example +with an alias and a description for the schema

    + +
    + +

    <Schema +Namespace="org.example" Alias="self">

    + +

    <Annotation Term="Core.Description" +String="Example schema" />

    + +

    + +

    </Schema>

    + +
    + +

    ##subsec Annotations +with External Targeting

    + +
    + +

    Element edm:Annotations

    + +
    + +
    + +

    The edm:Annotations +element is used to apply a group of annotations to a single model element. It MUST contain the Target attribute and it MAY contain the Qualifier attribute.

    + +

    It MUST +contain at least one edm:Annotation element.

    + +
    + +
    + +

    Attribute Target

    + +
    + +
    + +

    The value of Target +is a path expression identifying the annotation target. +It MUST resolve to a model element in scope.

    + +
    + +
    + +

    Attribute Qualifier

    + +
    + +
    + +

    The value of Qualifier +is a simple identifier.

    + +
    + +

    Example 7: annotations should only be applied to tablet +devices

    + +
    + +

    <Annotations Target="org.example.Person" +Qualifier="Tablet">
    + <Annotation Term="Core.Description" String="Dummy" +/>

    + +


    +</Annotations>

    + +
    + + + +

    ##sec Entity Type

    + + + +

    Entity types are nominal structured types with a key that consists of +one or more references to structural +properties. An entity type is the template for an entity: any uniquely +identifiable record such as a customer or order.

    + +

    The entity types name is a simple +identifier that MUST be unique within its +schema.

    + +

    An entity type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, +complex, or enumeration types. A navigation +property is a named reference to another entity type or collection of +entity types.

    + +

    All properties MUST have a unique name within an entity +type. Properties MUST NOT have the same name as the declaring entity type. They +MAY have the same name as one of the direct or indirect base types or derived +types.

    + +
    + +

    Element edm:EntityType

    + +
    + +
    + +

    The edm:EntityType +element MUST contain the Name attribute, and it MAY +contain the BaseType, +Abstract, +OpenType, +and HasStream +attributes.

    + +

    It MAY contain edm:Property +and edm:NavigationProperty +elements describing the properties of the entity type.

    + +

    It MAY contain one edm:Key element.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the entity types name.

    + +
    + +

    Example 8: a simple entity type

    + +
    + +

    <EntityType Name="Employee">
    +<Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.String" +Nullable="false" />
    + <Property Name="FirstName" Type="Edm.String" +Nullable="false" />
    + <Property Name="LastName" Type="Edm.String" +Nullable="false" />
    + <NavigationProperty Name="Manager" Type="self.Manager" +/>
    +</EntityType>

    + +
    + +

    ##subsec Derived +Entity Type

    + +

    An entity type can inherit from another entity type by +specifying it as its base type.

    + +

    An entity type inherits the key as +well as structural and navigation properties of its base type.

    + +

    An entity type MUST NOT introduce an inheritance cycle via +the base type attribute.

    + +
    + +

    Attribute BaseType

    + +
    + +
    + +

    The value of BaseType +is the qualified name of the base type.

    + +
    + +

    Example 9: a derived entity type based on the previous +example

    + +
    + +

    <EntityType Name="Manager" +BaseType="self.Employee">
    + <Property Name="AnnualBudget" Type="Edm.Decimal" />
    + <NavigationProperty Name="Employees" Type="Collection(self.Employee)" +/>
    +</EntityType>

    + +
    + +

    Note: the derived type has the same name +as one of the properties of its base type.

    + +

    ##subsec Abstract Entity Type

    + +

    An entity type MAY indicate that it is abstract and cannot +have instances.

    + +

    For OData 4.0 responses a +non-abstract entity type MUST define a key or derive +from a base type with a defined key.

    + +

    An abstract entity type MUST NOT inherit from a non-abstract +entity type.

    + +
    + +

    Attribute +Abstract

    + +
    + +
    + +

    The value of Abstract +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    ##subsec Open +Entity Type

    + +

    An entity type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    An entity type derived from an open entity type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see OData‑Protocol.

    + +
    + +

    Attribute OpenType

    + +
    + +
    + +

    The value of OpenType +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    ##subsec Media +Entity Type

    + +

    An entity type that does not specify a base type MAY specify +that it is a media entity type. Media entities are entities that +represent a media stream, such as a photo. Use a media entity if the +out-of-band stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal entity +with one or more properties of type Edm.Stream if +the structured data of the entity is the main topic of interest and the stream +data is just additional information attached to the structured data. For more +information on media entities see OData‑Protocol.

    + +

    An entity type derived from a media entity type MUST +indicate that it is also a media entity type.

    + +

    Media entity types MAY specify a list of acceptable media +types using an annotation with term Core.AcceptableMediaTypes, see OData‑VocCore.

    + +
    + +

    Attribute HasStream

    + +
    + +
    + +

    The value of HasStream +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    ##subsec Key

    + +

    An entity is uniquely identified within an entity set by its +key. A key MAY be specified if the entity type does not specify a base type that already has a key declared.

    + +

    In order to be specified as the type of an entity set or a collection-valued containment navigation property, +the entity type MUST either specify a key or inherit its key from its base type.

    + +

    In OData +4.01 responses entity types used for singletons +or single-valued navigation properties do +not require a key. In OData 4.0 responses entity types used +for singletons or single-valued navigation properties MUST have a key +defined.

    + +

    An entity type (whether or not it is marked as abstract) MAY +define a key only if it doesnt inherit one.

    + +

    An entity types key refers to the set of properties that +uniquely identify an instance of the entity type within an entity set. The key +MUST consist of at least one property.

    + +

    Key properties MUST NOT be nullable and MUST be typed with +an enumeration type, +one of the following primitive types, or a type definition based on one of these primitive +types:

    + +
      +
    • Edm.Boolean
    • +
    • Edm.Byte
    • +
    • Edm.Date
    • +
    • Edm.DateTimeOffset
    • +
    • Edm.Decimal
    • +
    • Edm.Duration
    • +
    • Edm.Guid
    • +
    • Edm.Int16
    • +
    • Edm.Int32
    • +
    • Edm.Int64
    • +
    • Edm.SByte
    • +
    • Edm.String
    • +
    • Edm.TimeOfDay
    • +
    + +

    Key property values MAY be language-dependent, but their +values MUST be unique across all languages and the entity ids (defined in OData‑Protocol) MUST be language +independent.

    + +

    A key property MUST be a non-nullable primitive property of +the entity type itself, including non-nullable primitive properties of +non-nullable single-valued complex properties, recursively.

    + +

    In OData 4.01 the key properties of a directly related +entity type MAY also be part of the key if the navigation property is +single-valued and not nullable. This includes navigation properties of +non-nullable single-valued complex properties (recursively) of the entity type. +If a key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key.

    + +

    If the key property is a property of a complex property +(recursively) or of a directly related entity type, the key MUST specify an +alias for that property that MUST be a simple +identifier and MUST be unique within the set of aliases, structural and +navigation properties of the containing entity type and any of its base types.

    + +

    An alias MUST NOT be defined if the key property is a primitive +property of the entity type itself.

    + +

    For key properties that are a property of a complex or +navigation property, the alias MUST be used in the key predicate of URLs +instead of the path to the property because the required percent-encoding of +the forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be used in +the query part of URLs, where paths to properties dont require special +encoding and are a standard constituent of expressions anyway.

    + +
    + +

    Element edm:Key

    + +
    + +
    + +

    The edm:Key +element MUST contain at least one edm:PropertyRef +element.

    + +
    + +
    + +

    Element edm:PropertyRef

    + +
    + +
    + +

    The edm:PropertyRef +element MUST contain the Name attribute and MAY +contain the Alias attribute.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is a path expression leading to a primitive property. The names of the +properties in the path are joined together by forward slashes.

    + +
    + +
    + +

    Attribute Alias +

    + +
    + +
    + +

    The value of Alias +is a simple identifier.

    + +
    + +

    Example 10: entity type with a simple key

    + +
    + +

    <EntityType +Name="Category">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.Int32" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" />
    +</EntityType>

    + +
    + +

    Example 11: +entity type with a simple key referencing a property of a complex type

    + +
    + +

    <EntityType Name="Category">
    + <Key>
    + <PropertyRef Name="Info/ID" Alias="EntityInfoID" +/>
    +</Key>
    + <Property Name="Info" Type="Sales.EntityInfo" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" />
    +</EntityType>

    + +

     

    + +

    <ComplexType +Name="EntityInfo">

    + +

    <Property Name="ID" +Type="Edm.Int32" Nullable="false" />
    + <Property Name="Created" Type="Edm.DateTimeOffset" +/>
    +</ComplexType>

    + +
    + +

    Example 12: entity type with a composite key

    + +
    + +

    <EntityType +Name="OrderLine">
    + <Key>
    + <PropertyRef Name="OrderID" />
    + <PropertyRef Name="LineNumber" />
    +</Key>
    +<Property Name="OrderID" Type="Edm.Int32" +Nullable="false" />
    +<Property Name="LineNumber" Type="Edm.Int32" +Nullable="false" />
    +</EntityType>

    + +
    + +

    Example 13 (based on example 11): +requests to an entity set Categories +of type Category must use the +alias

    + +
    + +

    GET http://host/service/Categories(EntityInfoID=1)

    + +
    + +

    Example 14 (based on example 11): +in a query part the value assigned to the name attribute must be used

    + +
    + +

    GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100

    + +
    + + + +

    ##sec Structural Property

    + + + +

    A structural property is a property (of a structural type) +that has one of the following types:

    + +

    Primitive type

    + +

    Complex type

    + +

    Enumeration type

    + +

    A collection of one of the above

    + +

    A structural property MUST specify a +unique name as well as a type.

    + +

    The propertys name MUST be a simple identifier used when referencing, +serializing or deserializing the property. It MUST be unique within the set of +structural and navigation properties of the declaring structured type, +and MUST NOT match the name of any navigation property in any of its base +types. If a structural property with the same name is defined in any of this +types base types, then the propertys type MUST be a type derived from the +type specified for the property of the base type and constrains this property +to be of the specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are +case-sensitive, but service authors SHOULD NOT choose names that differ only in +case.

    + +
    + +

    Element edm:Property

    + +
    + +
    + +

    The edm:Property +element MUST contain the Name and the Type attribute, and it MAY contain the facet attributes Nullable, +MaxLength, +Unicode, +Precision, +Scale, SRID, and DefaultValue.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the propertys name.

    + +
    + +

    Example 15: complex type with two properties

    + +
    + +

    <ComplexType +Name="Measurement">
    +<Property Name="Dimension" Type="Edm.String" +Nullable="false" MaxLength="50"

    + +

    DefaultValue="Unspecified" +/>
    +<Property Name="Length" Type="Edm.Decimal" +Nullable="false" Precision="18"

    + +

    Scale="2" />
    +</ComplexType>

    + +
    + +

    ##subsec Type

    + +

    The propertys type MUST be a primitive +type, complex type, or enumeration type in scope, or a collection of +one of these types.

    + +

    A collection-valued property may be annotated with the Core.Ordered +term, defined in OData-CoreVoc), to +specify that it supports a stable ordering.

    + +

    A collection-valued property may be annotated with the Core.PositionalInsert +term, defined in OData-CoreVoc), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued properties the value +of Type is the qualified name of the propertys +type.

    + +

    For collection-valued properties the +value of Type is the character sequence Collection( followed by the qualified name of the +propertys item type, followed by a closing parenthesis ).

    + +
    + +

    Example 16: property Units +that can have zero or more strings as its value

    + +
    + +

    <Property Name="Units" +Type="Collection(Edm.String)" />

    + +
    + +

    ##subsec Type Facets

    + +

    Facets modify or constrain the acceptable values of a +property.

    + +

    For single-valued properties facets apply to the type of the +property. For collection-valued properties the facets apply to the type of the +items in the collection.

    + +

    ##subsubsec Nullable

    + +

    A Boolean value specifying whether the property can have the +value null.

    + +
    + +

    Attribute Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false.

    + +

    For single-valued properties the value +true means that the property allows the null value.

    + +

    For collection-valued properties the +property value will always be a collection that MAY be empty. In this case the Nullable attribute applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +

    If no value is specified for a +single-valued property, the Nullable attribute +defaults to true.

    + +

    In OData 4.01 responses a +collection-valued property MUST specify a value for the Nullable +attribute.

    + +

    If no value is specified for a +collection-valued property, the client cannot assume any default value. Clients +SHOULD be prepared for this situation even in OData 4.01 responses.

    + +
    + +

    ##subsubsec MaxLength

    + +

    A positive integer value specifying the maximum length of a +binary, stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length (number +of code points for Unicode).

    + +

    If no maximum length is specified, clients +SHOULD expect arbitrary length.

    + +
    + +

    Attribute MaxLength

    + +
    + +
    + +

    The value of MaxLength +is a positive integer or the symbolic value max as a shorthand for the maximum length +supported for the type by the service.

    + +

    Note: the symbolic value max is only allowed in OData 4.0 responses; it is deprecated +in OData 4.01. While clients MUST be prepared for this symbolic value, OData +4.01 and greater services MUST NOT return the symbolic value max and MAY instead specify the concrete maximum length +supported for the type by the service or omit the attribute entirely.

    + +
    + +

    ##subsubsec Precision

    + +

    For a decimal value: the maximum number of significant +decimal digits of the propertys value; it MUST be a positive integer.

    + +

    For a temporal value (datetime-with-timezone-offset, +duration, or time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve.

    + +

    Note: service authors SHOULD be aware that some clients are +unable to support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential for data +loss when round-tripping values of greater precision. Updating via PATCH and exclusively specifying modified properties will +reduce the risk for unintended data loss.

    + +

    Note: +duration properties supporting a granularity less than seconds (e.g. minutes, +hours, days) can be annotated with term Measures.DurationGranularity, see OData-VocMeasures.

    + +
    + +

    Attribute Precision

    + +
    + +
    + +

    The value of Precision +is a number.

    + +

    If not specified for a decimal +property, the decimal property has arbitrary precision.

    + +

    If not specified for a temporal +property, the temporal property has a precision of zero.

    + +
    + +

    Example 17: Precision facet applied to the DateTimeOffset type

    + +
    + +

    <Property +Name="SuggestedTimes" Type="Collection(Edm.DateTimeOffset)"

    + +

    Precision="6" +/>

    + +
    + +

    ##subsubsec Scale

    + +

    A non-negative integer value specifying the maximum number +of digits allowed to the right of the decimal point, or one of the symbolic +values floating or variable.

    + +

    The value floating means that the +decimal property represents a decimal floating-point number whose number of +significant digits is the value of the Precision facet. OData 4.0 responses +MUST NOT specify the value floating.

    + +

    The value variable +means that the number of digits to the right of the decimal point may vary from +zero to the value of the Precision facet.

    + +

    An integer value means that the number of digits to the +right of the decimal point may vary from zero to the value of the Scale attribute, and the number of digits to the left of +the decimal point may vary from one to the value of the Precision +facet minus the value of the Scale facet. If Precision is equal to Scale, +a single zero MUST precede the decimal point.

    + +

    The value of Scale MUST be less +than or equal to the value of Precision.

    + +

    Note: if the underlying data store allows negative scale, services +may use a Precision +with the absolute value of the negative scale added to the actual number of +significant decimal digits, and client-provided values may have to be rounded +before being stored.

    + +
    + +

    Attribute Scale

    + +
    + +
    + +

    The value of Scale +is a number or one of the symbolic values floating +or variable.

    + +

    Services SHOULD use lower-case values; +clients SHOULD accept values in a case-insensitive manner.

    + +

    If not specified, the Scale facet defaults to zero.

    + +
    + +

    Example 18: Precision=3 and Scale=2.
    +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3

    + +
    + +

    <Property Name="Amount32" +Type="Edm.Decimal" Precision="3" Scale="2" />

    + +
    + +

    Example 19: Precision=2 +equals Scale.
    +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2

    + +
    + +

    <Property Name="Amount22" +Type="Edm.Decimal" Precision="2" Scale="2" />

    + +
    + +

    Example 20: Precision=3 and a +variable Scale.
    +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed values: 12.34, +1234 and 123.4 due to the limited precision.

    + +
    + +

    <Property Name="Amount3v" +Type="Edm.Decimal" Precision="3" Scale="variable" +/>

    + +
    + +

    Example +21: Precision=7 and a floating Scale.
    +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: 1e-102 +and 1e97 due to the limited precision.

    + +
    + +

    <Property Name="Amount7f" +Type="Edm.Decimal" Precision="7" Scale="floating" +/>

    + +
    + +

    ##subsubsec Unicode

    + +

    For a string property the Unicode +facet indicates whether the property might contain and accept string values +with Unicode characters (code points) beyond the ASCII character set. The value +false indicates that the property will only contain +and accept string values with characters limited to the ASCII character set.

    + +

    If no value is specified, the Unicode +facet defaults to true.

    + +
    + +

    Attribute +Unicode

    + +
    + +
    + +

    The value of Unicode +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +
    + +

    ##subsubsec SRID

    + +

    For a geometry or geography property the SRID facet identifies which spatial reference system is +applied to values of the property on type instances.

    + +

    The value of the SRID facet MUST +be a non-negative integer or the special value variable. +If no value is specified, the attribute defaults to 0 +for Geometry types or 4326 +for Geography types.

    + +

    The valid values of the SRID +facet and their meanings are as defined by the European Petroleum Survey Group [EPSG].

    + +
    + +

    Attribute SRID

    + +
    + +
    + +

    The value of $SRID +is a number or the symbolic value variable.

    + +
    + +

    ##subsubsec Default +Value

    + +

    A primitive or enumeration property MAY define a default +value that is used if the property is not explicitly represented in an +annotation or the body of a POST or PUT request.

    + +

    If no value is specified, the client SHOULD NOT assume a +default value.

    + +
    + +

    Attribute DefaultValue

    + +
    + +
    + +

    Default values of type Edm.String MUST be represented according to the XML +escaping rules for character data in attribute values. Values of other +primitive types MUST be represented according to the appropriate alternative in +the primitiveValue rule defined in OData‑ABNF, +i.e. Edm.Binary as binaryValue, +Edm.Boolean as booleanValue +etc.

    + +
    + + + +

    ##sec Navigation Property

    + + + +

    A navigation property allows +navigation to related entities. It MUST specify a unique name as well as a +type.

    + +

    The navigation propertys name MUST be a simple identifier. It +is used when referencing, serializing or deserializing the navigation property. +It MUST be unique within the set of structural and navigation properties of the +declaring structured type, and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the same name +is defined in any of this types base types, then the navigation propertys +type MUST be a type derived from the type specified for the navigation property +of the base type, and constrains this navigation property to be of the +specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +
    + +

    Element edm:NavigationProperty

    + +
    + +
    + +

    The edm:NavigationProperty element MUST contain the Name and Type attributes, and +it MAY contain the attributes Nullable, Partner, +and ContainsTarget.

    + +

    It MAY contain child elements edm:ReferentialConstraint +and at most one child element edm:OnDelete.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the navigation propertys name.

    + +
    + +

    Example 22: the Product entity type has a navigation +property to a Category, which has a navigation link back to one or more +products

    + +
    + +

    <EntityType +Name="Product">
    +
    + <NavigationProperty Name="Category" Type="self.Category" +Nullable="false"

    + +

    +Partner="Products" />
    + <NavigationProperty Name="Supplier" Type="self.Supplier" +/>
    +</EntityType>

    + +

     

    + +

    <EntityType +Name="Category">
    +
    + <NavigationProperty Name="Products" Type="Collection(self.Product)" +

    + +

    +Partner="Category" />
    +</EntityType>

    + +
    + +

    ##subsec Navigation +Property Type

    + +

    The navigation propertys type MUST be an entity type in scope, the abstract type Edm.EntityType, +or a collection of one of these types.

    + +

    If the type is a collection, an arbitrary number of entities +can be related. Otherwise there is at most one related entity.

    + +

    The related entities MUST be of the specified entity type or +one of its subtypes.

    + +

    For a collection-valued containment navigation property the +specified entity type MUST have a key defined.

    + +

    A collection-valued navigation property may be annotated +with the Core.Ordered +term, defined in OData-CoreVoc), to +specify that it supports a stable ordering.

    + +

    A collection-valued navigation property may be annotated +with the Core.PositionalInsert +term, defined in OData-CoreVoc), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued navigation +properties the value of Type is the qualified name +of the navigation propertys type.

    + +

    For collection-valued navigation +properties the value of Type is the character +sequence Collection( followed by the qualified name +of the navigation propertys item type, followed by a closing parenthesis ).

    + +
    + +

    ##subsec Nullable Navigation Property

    + +

    A Boolean value specifying whether the declaring type MAY +have no related entity. If false, instances of the declaring structured type +MUST always have a related entity.

    + +

    Nullable MUST NOT be specified for a collection-valued +navigation property, a collection is allowed to have zero items.

    + +
    + +

    Attribute +Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +
    + +

    ##subsec Partner Navigation Property

    + +

    A navigation property of an entity +type MAY specify a partner navigation property. Navigation properties of +complex types MUST NOT specify a partner.

    + +

    If specified, the partner navigation property is identified +by a path relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that type or +a derived type. The path MAY traverse complex types, including derived complex +types, but MUST NOT traverse any navigation properties. The type of the partner +navigation property MUST be the declaring entity type of the current navigation +property or one of its parent entity types.

    + +

    If the partner navigation property +is single-valued, it MUST lead back to the source entity from all related +entities. If the partner navigation property is collection-valued, the source +entity MUST be part of that collection.

    + +

    If no partner navigation property +is specified, no assumptions can be made as to whether one of the navigation +properties on the target type will lead back to the source entity.

    + +

    If a partner navigation property +is specified, this partner navigation property MUST either specify the current +navigation property as its partner to define a bi-directional +relationship or it MUST NOT specify a partner navigation property. The latter +can occur if the partner navigation property is defined on a complex type, or +if the current navigation property is defined on a type derived from the type +of the partner navigation property.

    + +
    + +

    Attribute Partner

    + +
    + +
    + +

    The value of Partner +is the path to the of the partner navigation property.

    + +
    + +

    ##subsec Containment Navigation Property

    + +

    A navigation property MAY indicate that instances of its +declaring structured type contain the targets of the navigation property, in +which case the navigation property is called a containment navigation +property.

    + +

    Containment navigation properties define an implicit entity +set for each instance of its declaring structured type. This implicit entity +set is identified by the read URL of the navigation property for that structured +type instance.

    + +

    Instances of the structured type that declares the navigation +property, either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The canonical +URL for contained entities is the canonical URL of the containing instance, +followed by the path segment of the navigation property and the key of the +contained entity, see OData‑URL.

    + +

    Entity types used in collection-valued containment +navigation properties MUST have a key defined.

    + +

    For items of an ordered collection of complex types (those +annotated with the Core.Ordered +term defined in OData-CoreVoc), the +canonical URL of the item is the canonical URL of the collection appended with +a segment containing the zero-based ordinal of the item. Items within in an +unordered collection of complex types do not have a canonical URL. Services +that support unordered collections of complex types declaring a containment +navigation property, either directly or indirectly via a property of complex +type, MUST specify the URL for the navigation link within a payload representing +that item, according to format-specific rules.

    + +

    OData +4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued property.

    + +

    An entity cannot be referenced by more than one containment +relationship and cannot both belong to an entity set declared within the entity +container and be referenced by a containment relationship.

    + +

    Containment navigation properties MUST NOT be specified as +the last path segment in the path of a navigation +property binding.

    + +

    When a containment navigation property navigates between +entity types in the same inheritance hierarchy, the containment is called recursive. +

    + +

    Containment navigation properties MAY specify a partner +navigation property. If the containment is recursive, the relationship defines +a tree, thus the partner navigation property MUST be Nullable (for the root of the tree) +and single-valued (for the parent of a non-root entity). If the containment is +not recursive, the partner navigation property MUST NOT be nullable.

    + +

    An entity type inheritance chain MUST NOT contain more than +one navigation property with a partner navigation property that is a +containment navigation property.

    + +

    Note: without a partner navigation property, there is no +reliable way for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity can also +be reached via a non-containment navigation path.

    + +
    + +

    Attribute ContainsTarget

    + +
    + +
    + +

    The value of ContainsTarget +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    ##subsec Referential Constraint

    + +

    A single-valued navigation property MAY define one or more +referential constraints. A referential constraint asserts that the dependent +property (the property defined on the structured type declaring the +navigation property) MUST have the same value as the principal property +(the referenced property declared on the entity type that is the target of the +navigation).

    + +

    The type of the dependent property MUST match the type of +the principal property, or both types MUST be complex types.

    + +

    If the principle property references an entity, then the +dependent property must reference the same entity.

    + +

    If the principle propertys value is a complex type +instance, then the dependent propertys value must be a complex type instance +with the same properties, each with the same values.

    + +

    If the navigation property on which the referential +constraint is defined is nullable, or the principal property is nullable, then +the dependent property MUST also be nullable. If both the navigation property +and the principal property are not nullable, then the dependent property MUST +NOT be nullable.

    + +
    + +

    Element edm:ReferentialConstraint

    + +
    + +
    + +

    The edm:ReferentialConstraint +element MUST contain the attributes Property and ReferencedProperty.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Property

    + +
    + +
    + +

    The Property +attribute specifies the property that takes part in the referential constraint +on the dependent structured type. Its value MUST be a path expression resolving +to a property of the dependent structured type itself or to a property of a complex +property (recursively) of the dependent structured type. The names of the +properties in the path are joined together by forward slashes. The path is +relative to the dependent structured type declaring the navigation property.

    + +
    + +
    + +

    Attribute ReferencedProperty

    + +
    + +
    + +

    The ReferencedProperty +attribute specifies the corresponding property of the principal entity type. +Its value MUST be a path expression resolving to a property of the principal entity +type itself or to a property of a complex property (recursively) of the principal +entity type that MUST have the same type as the property of the dependent +entity type. The path is relative to the entity type that is the target of the +navigation property.

    + +
    + +

    Example 23: the category must exist for a product in that +category to exist. The CategoryID of the product is +identical to the ID of the category, and the CategoryKind property of the product is identical to the Kind property of the category.

    + +
    + +

    <EntityType +Name="Product">
    +
    + <Property Name="CategoryID" Type="Edm.String" +Nullable="false"/>

    + +

    <Property Name="CategoryKind" +Type="Edm.String" Nullable="true" />

    + +

    <NavigationProperty +Name="Category" Type="self.Category" Nullable="false">
    + <ReferentialConstraint Property="CategoryID" ReferencedProperty="ID" +/>
    + <ReferentialConstraint Property="CategoryKind" +ReferencedProperty="Kind">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Referential +Constraint to non-key property" />

    + +

    </ReferentialConstraint>

    + +

    </NavigationProperty>

    + +

    </EntityType>

    + +

     

    + +

    <EntityType +Name="Category">

    + +

    <Key>

    + +

    <PropertyRef +Name="ID" />

    + +

    </Key>
    + <Property Name="ID" Type="Edm.String" +Nullable="false" />
    + <Property Name="Kind" Type="Edm.String" +Nullable="true" />
    +

    + +

    </EntityType>

    + +
    + +

    ##subsec On-Delete +Action

    + +

    A navigation property MAY define an on-delete action that +describes the action the service will take on related entities when the entity +on which the navigation property is defined is deleted.

    + +

    The action can have one of the following values:

    + +
      +
    • Cascade, meaning the related + entities will be deleted if the source entity is deleted,
    • +
    • None, meaning a DELETE request on a source entity with related + entities will fail,
    • +
    • SetNull, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to null,
    • +
    • SetDefault, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to their default value.
    • +
    + +

    If no on-delete action is specified, the action taken by the +service is not predictable by the client and could vary per entity.

    + +
    + +

    Element edm:OnDelete

    + +
    + +
    + +

    The edm:OnDelete +element MUST contain the Action attribute.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Action

    + +
    + +
    + +

    The value of Action +is one of the values Cascade, None, +SetNull, or SetDefault.

    + +
    + +

    Example 24: deletion of a category implies deletion of the +related products in that category

    + +
    + +

    <EntityType Name="Category">
    +
    + <NavigationProperty Name="Products" Type="Collection(self.Product)">
    + <OnDelete Action="Cascade">

    + +

    <Annotation +Term="Core.Description"
    + String="Delete all products in this category" />

    + +

    </OnDelete
    + </NavigationProperty>

    + +

    </EntityType>

    + +
    + + + +

    ##sec Complex Type

    + + + +

    Complex types are keyless nominal +structured types. The lack of a key means +that instances of complex types cannot be referenced, created, updated or +deleted independently of an entity type. Complex types allow entity models to +group properties into common structures.

    + +

    The complex types name is a simple +identifier that MUST be unique within its schema.

    + +

    A complex type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, +complex, or enumeration types. A navigation +property is a named reference to an entity type or a collection of entity +types.

    + +

    All properties MUST have a unique name within a complex +type. Properties MUST NOT have the same name as the declaring complex type. +They MAY have the same name as one of the direct or indirect base types or +derived types.

    + +
    + +

    Element edm:ComplexType

    + +
    + +
    + +

    The edm:ComplexType +element MUST contain the Name attribute, and it MAY +contain the BaseType, +Abstract, +and OpenType +attributes.

    + +

    It MAY contain edm:Property +and edm:NavigationProperty +elements describing the properties of the complex type.

    + +

    It MAY contain edm:Annotation elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the complex types name.

    + +
    + +

    Example 25: a complex type used by two entity types

    + +
    + +

    <ComplexType +Name="Dimensions">
    +<Property Name="Height" Nullable="false" +Type="Edm.Decimal" />
    +<Property Name="Weight" Nullable="false" +Type="Edm.Decimal" />
    +<Property Name="Length" Nullable="false" +Type="Edm.Decimal" />
    +</ComplexType>

    + +

     

    + +

    <EntityType +Name="Product">
    +
    + <Property Name="ProductDimensions" Type="self.Dimensions" +/>
    +<Property Name="ShippingDimensions" Type="self.Dimensions" +/>
    +</EntityType>

    + +

     

    + +

    <EntityType +Name="ShipmentBox">
    +
    + <Property Name="Dimensions" Type="self.Dimensions" +/>
    +</EntityType>

    + +
    + +

    ##subsec Derived +Complex Type

    + +

    A complex type can inherit from another complex type by +specifying it as its base type.

    + +

    A complex type inherits the structural and navigation +properties of its base type.

    + +

    A complex type MUST NOT introduce an inheritance cycle by +specifying a base type.

    + +

    The rules for annotations of derived +complex types are described in section 14.2.

    + +
    + +

    Attribute BaseType

    + +
    + +
    + +

    The value of BaseType +is the qualified name of the base type.

    + +
    + +

    ##subsec Abstract +Complex Type

    + +

    A complex type MAY indicate that it is abstract and cannot +have instances.

    + +
    + +

    Attribute +Abstract

    + +
    + +
    + +

    The value of Abstract +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    ##subsec Open +Complex Type

    + +

    A complex type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    A complex type derived from an open complex type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see OData‑Protocol.

    + +
    + +

    Attribute +OpenType

    + +
    + +
    + +

    The value of OpenType +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + + + +

    ##sec Enumeration Type

    + + + +

    Enumeration types are nominal +types that represent a non-empty series of related values. Enumeration types +expose these related values as members of the enumeration.

    + +

    The enumeration types name is a simple identifier that MUST be unique within +its schema.

    + +

    Although enumeration types have an underlying numeric value, +the preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the AllowedValues annotation defined +in [OData-VocCore].

    + +

    Enumeration types marked as flags allow values that consist +of more than one enumeration member at a time.

    + +
    + +

    Element edm:EnumType

    + +
    + +
    + +

    The edm:EnumType +element MUST contain the Name attribute, and it MAY contain the UnderlyingType +and IsFlags +attributes.

    + +

    It MUST contain one or more edm:Member +elements defining the members of the enumeration type.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the enumeration types name.

    + +
    + +

    Example 26: a simple flags-enabled +enumeration

    + +
    + +

    <EnumType +Name="FileAccess" UnderlyingType="Edm.Int32" +IsFlags="true">
    +<Member Name="Read" Value="1" />
    +<Member Name="Write" Value="2" />
    +<Member Name="Create" Value="4" />
    +<Member Name="Delete" Value="8" />
    +</EnumType>

    + +
    + +

    ##subsec Underlying Integer Type

    + +

    An enumeration type MAY specify one of Edm.Byte, +Edm.SByte, Edm.Int16, Edm.Int32, or Edm.Int64 as +its underlying type.

    + +

    If not explicitly specified, Edm.Int32 +is used as the underlying type.

    + +
    + +

    Attribute +UnderlyingType

    + +
    + +
    + +

    The value of UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    ##subsec Flags Enumeration Type

    + +

    An enumeration type MAY indicate that the enumeration type +allows multiple members to be selected simultaneously.

    + +

    If not explicitly specified, only one +enumeration type member MAY be selected simultaneously.

    + +
    + +

    Attribute IsFlags

    + +
    + +
    + +

    The value of IsFlags +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    Example 27: pattern values can be combined, and some +combined values have explicit names

    + +
    + +

    <EnumType Name="Pattern" +UnderlyingType="Edm.Int32" IsFlags="true">

    + +

    <Member Name="Plain" Value="0" +/>

    + +

    <Member Name="Red" Value="1" +/>

    + +

    <Member Name="Blue" Value="2" +/>

    + +

    <Member Name="Yellow" Value="4" +/>

    + +

    <Member Name="Solid" Value="8" +/>

    + +

    <Member Name="Striped" +Value="16" />

    + +

    <Member Name="SolidRed" +Value="9" />

    + +

    <Member +Name="SolidBlue" Value="10" />

    + +

    <Member +Name="SolidYellow" Value="12" />

    + +

    <Member +Name="RedBlueStriped" Value="19" />

    + +

    <Member +Name="RedYellowStriped" Value="21" />

    + +

    <Member +Name="BlueYellowStriped" Value="22" />

    + +

    </EnumType>

    + +
    + +

    ##subsec Enumeration Type Member

    + +

    Enumeration type values consist of discrete members.

    + +

    Each member is identified by its name, a simple identifier that MUST be unique within +the enumeration type. Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    Each member MUST specify an associated numeric value that +MUST be a valid value for the underlying type of the enumeration type.

    + +

    Enumeration types can have multiple members with the same value. Members with the same +numeric value compare as equal, and members with the same numeric value can be +used interchangeably.

    + +

    Enumeration +members are sorted by their numeric value.

    + +
    + +

    Element edm:Member

    + +
    + +
    + +

    The edm:Member +element MUST contain the Name attribute and it MAY +contain the Value attribute.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the enumeration members name.

    + +
    + +
    + +

    Attribute Value

    + +
    + +
    + +

    If the IsFlags +attribute has a value of false, either all members +MUST specify an integer value for the Value +attribute, or all members MUST NOT specify a value for the Value attribute. If no values are specified, the members +are assigned consecutive integer values in the order of their appearance, +starting with zero for the first member. Client libraries MUST preserve +elements in document order.

    + +

    If the IsFlags +attribute has a value of true, a non-negative +integer value MUST be specified for the Value +attribute. A combined value is equivalent to the bitwise OR of the discrete +values.

    + +
    + +

    Example 28: FirstClass has a +value of 0, TwoDay a +value of 1, and Overnight a value of 2.

    + +
    + +

    <EnumType +Name="ShippingMethod">
    +<Member Name="FirstClass">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Shipped +with highest priority" />

    + +

    </Member>
    + <Member Name="TwoDay">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Shipped +within two days" />
    + </Member>
    + <Member Name="Overnight">

    + +

    <Annotation Term="Core.Description"

    + +

    String="Shipped +overnight" />
    + </Member>
    +</EnumType>

    + +
    + + + +

    ##sec Type Definition

    + + + +

    A +type definition defines a specialization of one of the primitive types or of the built-in abstract type Edm.PrimitiveType.

    + +

    The type definitions name is a simple identifier that MUST be unique within +its schema.

    + +

    Type definitions can be used wherever a primitive type is +used (other than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions defined +using the same underlying type.

    + +

    It is up +to the definition of a term to specify whether and how annotations with this +term propagate to places where the annotated type definition is used, and +whether they can be overridden.

    + +
    + +

    Element edm:TypeDefinition

    + +
    + +
    + +

    The edm:TypeDefinition +element MUST contain the Name and UnderlyingType +attributes.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the type definitions name.

    + +
    + +

    Example 29:

    + +
    + +

    <TypeDefinition Name="Length" +UnderlyingType="Edm.Int32">

    + +

    <Annotation +Term="Org.OData.Measures.V1.Unit"

    + +

    String="Centimeters" />

    + +

    </TypeDefinition>

    + +

     

    + +

    <TypeDefinition Name="Weight" +UnderlyingType="Edm.Int32">

    + +

    <Annotation +Term="Org.OData.Measures.V1.Unit"

    + +

    String="Kilograms" />

    + +

    </TypeDefinition>

    + +

     

    + +

    <ComplexType Name="Size">

    + +

    <Property Name="Height" +Type="self.Length" />

    + +

    <Property Name="Weight" +Type="self.Weight" />

    + +

    </ComplexType>

    + +
    + +

    ##subsec Underlying Primitive Type

    + +

    The underlying type of a type definition MUST be a primitive type that MUST NOT be another type +definition.

    + +
    + +

    Attribute UnderlyingType

    + +
    + +
    + +

    The value of UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    The type definition MAY specify facets applicable to the +underlying type. Possible facets are: MaxLength, Unicode, Precision, Scale, or SRID.

    + +

    Additional facets appropriate for the underlying type MAY be +specified when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified.

    + +

    For a type definition with underlying type Edm.PrimitiveType +no facets are applicable, neither in the definition itself nor when the type +definition is used, and these should be ignored by the client.

    + +

    Where type definitions are used, the type definition is +returned in place of the primitive type wherever the type is specified in a +response.

    + + + +

    ##sec Action and Function

    + + + +

    ##subsec Action

    + +

    Actions are service-defined operations that MAY have +observable side effects and MAY return a single instance or a collection of +instances of any type.

    + +

    The actions name is a simple +identifier that MUST be unique within its schema.

    + +

    Actions cannot be composed with additional path segments.

    + +

    An action MAY specify a return type that MUST be a primitive, entity or +complex type, or a collection of primitive, entity or complex types in scope.

    + +

    An action MAY define parameters +used during the execution of the action.

    + +

    ##subsec Action Overloads

    + +

    Bound +actions support overloading (multiple actions having the same name within the +same schema) by binding parameter type. The combination of action name and the +binding parameter type MUST be unique within a schema.

    + +

    Unbound +actions do not support overloads. The names of all unbound actions MUST be +unique within a schema.

    + +

    An unbound action MAY have the same name as a bound action.

    + +
    + +

    Element edm:Action

    + +
    + +
    + +

    The edm:Action +element MUST contain the Name attribute and it MAY +contain the IsBound and EntitySetPath +attributes.

    + +

    It MAY contain at most one edm:ReturnType +element and MAY contain edm:Parameter +elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the actions name.

    + +
    + +

    ##subsec Function

    + +

    Functions are service-defined operations that MUST NOT have +observable side effects and MUST return a single instance or a collection of +instances of any type.

    + +

    The functions name is a simple +identifier that MUST be unique within its schema.

    + +

    Functions MAY be composable.

    + +

    The function MUST specify a return +type which MUST be a primitive, entity or complex type, or a collection of +primitive, entity or complex types in scope.

    + +

    A function MAY define parameters +to be used during the execution of the function.

    + +

    ##subsec Function +Overloads

    + +

    Bound +functions support overloading (multiple functions having the same name within +the same schema) subject to the following rules:

    + +

    The combination of function name, binding parameter type, and +unordered set of non-binding parameter names MUST be unique within a schema.

    + +

    The combination of function name, binding parameter type, and +ordered set of parameter types MUST be unique within a schema.

    + +

    All bound functions with the same function name and binding +parameter type within a schema MUST specify the same return type.

    + +

    Unbound +functions support overloading subject to the following rules:

    + +

    The combination of function name and unordered set of parameter +names MUST be unique within a schema.

    + +

    The combination of function name and ordered set of parameter +types MUST be unique within a schema.

    + +

    All unbound functions with the same function name within a schema +MUST specify the same return type.

    + +

    An unbound +function MAY have the same name as a bound function.

    + +

    Note that type definitions +can be used to disambiguate overloads for both bound and unbound functions, +even if they specify the same underlying type.

    + +
    + +

    Element edm:Function

    + +
    + +
    + +

    The edm:Function +element MUST contain the Name attribute and it MAY +contain the IsBound and EntitySetPath +attributes.

    + +

    It MUST contain one edm:ReturnType +element, and it MAY contain edm:Parameter elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the actions name.

    + +
    + +

    ##subsec Bound or Unbound Action or +Function Overloads

    + +

    An action or function overload MAY indicate that it is +bound. If not explicitly indicated, it is unbound.

    + +

    Bound actions or functions are invoked on resources matching +the type of the binding parameter. The binding parameter can be of any type, +and it MAY be Nullable.

    + +

    Unbound actions are invoked through an action import.

    + +

    Unbound functions are invoked as static functions within a +filter or orderby expression, or from the entity container through a function import.

    + +
    + +

    Attribute IsBound

    + +
    + +
    + +

    The value of IsBound +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    ##subsec Entity +Set Path

    + +

    Bound actions and functions that +return an entity or a collection of entities MAY specify an entity set path if +the entity set of the returned entities depends on the entity set of the +binding parameter value.

    + +

    The entity set path consists of a series of segments joined +together with forward slashes.

    + +

    The first segment of the entity set path MUST be the name of +the binding parameter. The remaining segments of the entity set path MUST +represent navigation segments or type casts.

    + +

    A navigation segment names the simple identifier of the navigation property to be traversed. A +type-cast segment names the qualified name of +the entity type that should be returned from the type cast.

    + +
    + +

    Attribute EntitySetPath

    + +
    + +
    + +

    The value of EntitySetPath +is the entity set path.

    + +
    + +

    ##subsec Composable Function

    + +

    A function MAY indicate that it is composable. If not +explicitly indicated, it is not composable.

    + +

    A composable function can be invoked with additional path +segments or key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for the type +returned by the composable function.

    + +
    + +

    Attribute IsComposable

    + +
    + +
    + +

    The value of IsComposable +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    ##subsec Return Type

    + +

    The return type of an action or function overload MAY be any +type in scope, or a collection of any type in scope.

    + +

    The facets Nullable, MaxLength, Precision, Scale, and SRID can be used as appropriate to +specify value restrictions of the return type, as well as the Unicode +facet for 4.01 and greater payloads.

    + +
    + +

    Element +edm:ReturnType

    + +
    + +
    + +

    The edm:ReturnType +element MUST contain the Type attribute, and it MAY +contain the attributes Nullable, MaxLength, +Unicode, +Precision, +Scale, +and SRID.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued return types the +value of Type is the qualified name of the return +type.

    + +

    For collection-valued return types the +value of Type is the character sequence Collection( followed by the qualified name of the return +item type, followed by a closing parenthesis ).

    + +
    + +
    + +

    Attribute +Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +

    If the return type is a collection of +entity types, the $Nullable member has no meaning +and MUST NOT be specified.

    + +

    For other collection-valued return +types the result will always be a collection that MAY be empty. In this case +the Nullable attribute applies to items of the +collection and specifies whether the collection MAY contain null values.

    + +

    For single-valued return types the +value true means that the action or function MAY +return a single null value. The value false means that the action or function will never return +a null value and instead will fail with an error +response if it cannot compute a result.

    + +
    + +

    ##subsec Parameter

    + +

    An action or function overload MAY specify parameters.

    + +

    A bound action or function overload MUST specify at least +one parameter; the first parameter is the binding parameter. The order of parameters MUST NOT change unless the schema +version changes.

    + +

    Each parameter MUST have a name that is a simple identifier. The parameter name MUST be +unique within the action or function overload.

    + +

    The parameter MUST specify a type. It MAY be any type in +scope, or a collection of any type in scope.

    + +

    The facets MaxLength, Precision, Scale, or SRID can be used as appropriate to +specify value restrictions of the parameter, as well as the Unicode +facet for 4.01 and greater payloads.

    + +
    + +

    Element edm:Parameter

    + +
    + +
    + +

    The edm:Parameter +element MUST contain the Name and the Type attribute, and it MAY contain the attributes Nullable, MaxLength, Unicode, Precision, Scale, and SRID.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is +the parameters name.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued parameters the value +of Type is the qualified name of the parameter.

    + +

    For collection-valued parameters the +value of Type is the character sequence Collection( followed by the qualified name of the +parameters type, followed by a closing parenthesis ).

    + +
    + +
    + +

    Attribute Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +

    The value true +means that the parameter accepts a null value.

    + +
    + +

    Example +30: a function returning the top-selling products for a given year. In this case +the year must be specified as a parameter of the function with the edm:Parameter element.

    + +
    + +

    <Function Name="TopSellingProducts">

    + +

    <Parameter Name="Year" Type="Edm.Decimal" +Precision="4" Scale="0" />

    + +

    <ReturnType Type="Collection(self.Product)" +/>

    + +

    </Function>

    + +
    + + + +

    ##sec Entity Container

    + + + +

    Each metadata document used to describe an OData service +MUST define exactly one entity container.

    + +

    The entity containers name is a simple identifier that MUST be unique within +its schema.

    + +

    Entity containers define the entity sets, singletons, +function and action imports exposed by the service.

    + +

    Entity set, singleton, action import, and function import +names MUST be unique within an entity container.

    + +

    An entity +set allows access to entity type instances. Simple entity models +frequently have one entity set per entity type.

    + +

    Example 31: one entity set per entity type

    + +
    + +

    <EntitySet Name="Products" +EntityType="self.Product" />
    +<EntitySet Name="Categories" EntityType="self.Category" +/>

    + +
    + +

    Other entity models may +expose multiple entity sets per type.

    + +

    Example 32: three entity sets referring to the two entity +types

    + +
    + +

    <EntitySet Name="StandardCustomers" +EntityType="self.Customer">
    +
    <NavigationPropertyBinding +Path="Orders" Target="Orders" />
    +</EntitySet>

    + +

    <EntitySet Name="PreferredCustomers" +EntityType="self.Customer">

    + +

    <NavigationPropertyBinding Path="Orders" +Target="Orders" />
    +</EntitySet>
    +<EntitySet Name="Orders" EntityType="self.Order" />

    + +
    + +

    There are separate entity sets for standard customers and +preferred customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have navigation property bindings to the +orders entity set, but the orders entity set does not have a navigation +property binding for the Customer navigation property, since it could lead to +either set of customers.

    + +

    An entity set can expose instances of the specified entity +type as well as any entity type inherited from the specified entity type.

    + +

    A singleton allows +addressing a single entity directly from the entity container without having to +know its key, and without requiring an entity set.

    + +

    A function import or an action import is used to expose a function +or action defined in an entity model as a top level resource.

    + +
    + +

    Element edm:EntityContainer

    + +
    + +
    + +

    The edm:EntityContainer +MUST contain one or more edm:EntitySet, edm:Singleton, edm:ActionImport, +or edm:FunctionImport +elements.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the entity containers name.

    + +
    + +

    Example 33: +An entity container aggregates entity sets, singletons, action imports, and +function imports.

    + +
    + +

    <EntityContainer +Name="DemoService">
    +<EntitySet Name="Products" EntityType="self.Product">

    + +

    <NavigationPropertyBinding +Path="Category" Target="Categories" />

    + +

    <NavigationPropertyBinding +Path="Supplier" Target="Suppliers" />

    + +

    </EntitySet>

    + +

    <EntitySet +Name="Categories" EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    </EntitySet>

    + +

    <EntitySet +Name="Suppliers" EntityType="self.Supplier">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    </EntitySet>

    + +

    <Singleton +Name="MainSupplier" Type="self.Supplier" />

    + +

    <ActionImport +Name="LeaveRequestApproval" Action="self.Approval" />
    +<FunctionImport Name="ProductsByRating" Function="self.ProductsByRating" +

    + +

    EntitySet="Products" +/>
    +</EntityContainer>

    + +
    + +

    ##subsec Extending an Entity Container

    + +

    An entity container MAY specify that it extends another +entity container in scope. All children of the base entity container are +added to the extending entity container.

    + +

    If the extending entity container defines an entity set +with the same name as defined in any of its base containers, then the entity +sets type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the base container. The same holds +for singletons. Action imports and function imports cannot be redefined, nor +can the extending container define a child with the same name as a child of a +different kind in a base container.

    + +

    Note: services should not introduce cycles by extending +entity containers. Clients should be prepared to process cycles introduced by +extending entity containers.

    + +
    + +

    Attribute Extends

    + +
    + +
    + +

    The value of Extends +is the qualified name of the entity container to be extended.

    + +
    + +

    Example 34: the entity container Extending +will contain all child elements that it defines itself, plus all child elements +of the Base entity container located in SomeOtherSchema

    + +
    + +

    <EntityContainer Name="Extending" +Extends="Some.Other.Schema.Base">

    + +

    + +

    </EntityContainer>

    + +
    + +

    ##subsec Entity Set

    + +

    Entity sets are top-level collection-valued resources.

    + +

    An entity set is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An entity set MUST specify a type that MUST be an entity +type in scope.

    + +

    An entity set MUST contain only instances of its specified +entity type or its subtypes. The entity type MAY be abstract but MUST have a key +defined.

    + +

    An entity set MAY indicate whether it is included in the +service document. If not explicitly indicated, it is included.

    + +

    Entity sets that cannot be queried without specifying +additional query options SHOULD NOT be included in the service document.

    + +
    + +

    Element edm:EntitySet

    + +
    + +
    + +

    The edm:EntitySet element MUST contain the attributes Name and EntityType, and it +MAY contain the IncludeInServiceDocument attribute.

    + +

    It MAY contain edm:NavigationPropertyBinding +elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is the entity sets name.

    + +
    + +
    + +

    Attribute EntityType

    + +
    + +
    + +

    The value of EntityType +is the qualified name of an entity type in scope.

    + +
    + +
    + +

    Attribute IncludeInServiceDocument

    + +
    + +
    + +

    The value of IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +
    + +

    ##subsec Singleton

    + +

    Singletons are top-level single-valued resources.

    + +

    A singleton is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    A singleton MUST specify a type that MUST be an entity type +in scope.

    + +

    A singleton MUST reference an instance its entity type.

    + +
    + +

    Element edm:Singleton

    + +
    + +
    + +

    The edm:Singleton element MUST include the attributes Name and Type, and it MAY +contain the Nullable attribute.

    + +

    It MAY contain edm:NavigationPropertyBinding +elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is the singletons name.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is whose value is the qualified name of an +entity type in scope.

    + +
    + +
    + +

    Attribute +Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false.

    + +

    If no value is specified, the Nullable attribute defaults to false. +

    + +

    In OData 4.0 responses this attribute +MUST NOT be specified.

    + +
    + +

    ##subsec Navigation Property Binding

    + +

    If the entity type of an entity set or singleton declares +navigation properties, a navigation property binding allows describing which +entity set or singleton will contain the related entities.

    + +

    An entity set or a singleton SHOULD contain a navigation property +binding for each navigation property of +its entity type, including navigation properties defined on complex typed +properties.

    + +

    If omitted, clients MUST assume that the target entity set +or singleton can vary per related entity.

    + +

    ##subsubsec Navigation +Property Path Binding

    + +

    A navigation property binding MUST specify a path to a +navigation property of the entity sets or singleton's declared entity type, or +a navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation property is +defined on a subtype, the path MUST contain the qualified +name of the subtype, followed by a forward slash, followed by the +navigation property name. If the navigation property is defined on a complex +type used in the definition of the entity sets entity type, the path attribute +MUST contain a forward-slash separated list of complex property names and qualified +type names that describe the path leading to the navigation property.

    + +

    The path can traverse one or more containment navigation +properties but the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment.

    + +

    If the path traverses collection-valued complex properties +or collection-valued containment navigation properties, the binding applies to +all items of these collections.

    + +

    If the path contains a recursive sub-path (i.e. a path +leading back to the same structured type, the binding applies recursively to +any positive number of cycles through that sub-path.

    + +

    OData 4.01 services MAY have a type-cast segment as the last +path segment, allowing to bind instances of different sub-types to different +targets.

    + +

    The same navigation property path MUST NOT be specified in +more than one navigation property binding; navigation property bindings are +only used when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths that +differ only in a type-cast segment, allowing to bind instances of different +sub-types to different targets. If paths differ only in type-cast segments, the +most specific path applies.

    + +

    ##subsubsec Binding Target

    + +

    A navigation property binding MUST specify a target via a simple identifier or target +path. It specifies the entity set, singleton, or containment navigation +property that contains the entities.

    + +

    If the target is a simple +identifier, it MUST resolve to an entity set or singleton defined in the +same entity container as the enclosing element.

    + +

    If the target is a target path, +it MUST resolve to an entity set, singleton, or direct or indirect containment +navigation property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties before +ending in a containment navigation property, and there MUST NOT be any +non-containment navigation properties prior to the final segment.

    + +
    + +

    Element edm:NavigationPropertyBinding

    + +
    + +
    + +

    The edm:NavigationPropertyBinding +element MUST contain the attributes Path and Target.

    + +
    + +
    + +

    Attribute Path

    + +
    + +
    + +

    The value of Path +is a path expression.

    + +
    + +
    + +

    Attribute Target

    + +
    + +
    + +

    The value of Target +is a target path.

    + +
    + +

    Example 35: for an entity set in the same container as the +enclosing entity set Categories

    + +
    + +

    <EntitySet +Name="Categories" EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products"

    + +

    +Target="SomeSet" />

    + +

    </EntitySet>

    + +
    + +

    Example 36: for an entity set in any container in scope

    + +
    + +

    <EntitySet +Name="Categories" EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products"

    + +

    Target="SomeModel.SomeContainer/SomeSet" +/>

    + +

    </EntitySet>

    + +
    + +

    Example 37: binding Supplier +on Products contained within Categories binding applies +to all suppliers of all products of all categories

    + +
    + +

    <EntitySet Name="Categories" +EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products/Supplier"

    + +

    +Target="Suppliers" />

    + +

    </EntitySet>

    + +
    + +

    ##subsec Action +Import

    + +

    Action imports sets are top-level resources that are never +included in the service document.

    + +

    An action import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An action import MUST specify the name of an unbound action +in scope.

    + +

    If the imported action +returns an entity or a collection of entities, a simple +identifier or target path value MAY be +specified to identify the entity set that contains the returned entities. If a simple identifier is specified, it MUST +resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an +entity set in scope.

    + +
    + +

    Element edm:ActionImport

    + +
    + +
    + +

    The edm:ActionImport +element MUST contain the attributes Name and Action, and it MAY contain the EntitySet +attribute.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the action imports name.

    + +
    + +
    + +

    Attribute Action

    + +
    + +
    + +

    The value of Action +is the qualified name of an unbound action.

    + +
    + +
    + +

    Attribute EntitySet

    + +
    + +
    + +

    The value of EntitySet +is either the unqualified name of an entity set in the same entity container or +a path to an entity set in a different entity container.

    + +
    + +

    ##subsec Function Import

    + +

    Function imports sets are top-level resources.

    + +

    A function import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    A function import MUST specify the name of an unbound +function in scope. All unbound overloads +of an imported function can be invoked from the entity container.

    + +

    If +the imported function returns an entity or a collection of entities, a simple identifier or target +path value MAY be specified to identify the entity set that contains the +returned entities. If a simple identifier +is specified, it MUST resolve to an entity set defined in the same entity +container. If a target path is specified, it MUST +resolve to an entity set in scope.

    + +

    A function import for a +parameterless function MAY indicate whether it is included in the service +document. If not explicitly indicated, it is not included.

    + +
    + +

    Element edm:FunctionImport

    + +
    + +
    + +

    The edm:FunctionImport +element MUST contain the attributes Name and Function, and it MAY contain the attributes EntitySet and IncludeInServiceDocument.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the function imports name.

    + +
    + +
    + +

    Attribute Function

    + +
    + +
    + +

    The value of Function +is the qualified name of an unbound function.

    + +
    + +
    + +

    Attribute EntitySet

    + +
    + +
    + +

    The value of EntitySet +is either the unqualified name of an entity set in the same entity container or +a path to an entity set in a different entity container.

    + +
    + +
    + +

    Attribute IncludeInServiceDocument

    + +
    + +
    + +

    The value of IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + + + +

    ##sec Vocabulary and Annotation

    + + + +

    Vocabularies and annotations provide the ability to annotate +metadata as well as instance data, and define a powerful extensibility point +for OData. An annotation applies a term to a +model element and defines how to calculate a value for the applied term.

    + +

    Metadata annotations are terms applied to model +elements. Behaviors or constraints described by a metadata annotation must be +consistent with the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity type, +property, function, action, or parameter. For example, a metadata annotation +may define ranges of valid values for a particular property. Metadata +annotations are applied in CSDL documents describing or referencing an entity +model.

    + +

    Instance annotations are terms applied to a +particular instance within an OData payload, such as described in OData‑JSON. An +instance annotation can be used to define additional information associated +with a particular result, entity, property, or error. For example, whether a +property is read-only for a particular instance. Where the same annotation is +defined at both the metadata and instance level, the instance-level annotation +overrides the annotation specified at the metadata level. Annotations that +apply across instances should be specified as metadata annotations.

    + +

    A vocabulary is a schema containing a set of terms +where each term is a named metadata extension. Anyone +can define a vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary OData‑VocCore.

    + +

    A term can be used to:

    + +

    Extend model elements and type instances with additional +information.

    + +

    Map instances of annotated structured types to an interface +defined by the term type; i.e. annotations allow viewing instances of a +structured type as instances of a differently structured type specified by the +applied term.

    + +

    A service SHOULD NOT require a client to interpret +annotations. Clients SHOULD ignore invalid or unknown terms and silently treat unexpected +or invalid values (including invalid type, invalid literal expression, invalid +targets, etc.) as an unknown value for the term. Unknown or invalid annotations +should never result in an error, as long as the payload remains well-formed.

    + +

    Example 38: the Product entity +type is extended with a DisplayName +by a metadata annotation that binds the term DisplayName to the value of the property Name. The Product +entity type also includes an annotation that allows its instances to be viewed +as instances of the type specified by the term SearchResult

    + +
    + +

    <EntityType +Name="Product">
    + <Key>

    + +

    <PropertyRef Name="ID" +/>

    + +

    </Key>
    + <Property Name="ID" Nullable="false" +Type="Edm.Int32" />
    + <Property Name="Name" Type="Edm.String" />
    + <Property Name="Description" Type="Edm.String" />
    +

    + +

    <Annotation Term="UI.DisplayName" +Path="Name" />
    +<Annotation Term="SearchVocabulary.SearchResult">

    + +

    <Record>
    + <PropertyValue Property="Title" Path="Name" />
    + <PropertyValue Property="Abstract" Path="Description" +/>
    + <PropertyValue Property="Url">
    + <Apply Function="odata.concat">
    + <String>Products(</String>
    + <Path>ID</Path>
    + <String>)</String>
    + </Apply>
    + </PropertyValue>

    + +

    </Record>
    +</Annotation>
    +</EntityType>

    + +
    + +

    ##subsec Term

    + +

    A term allows annotating a CSDL element or OData resource +representation with additional data.

    + +

    The terms name is a simple +identifier that MUST be unique within its schema.

    + +

    The terms type MUST be a type in scope, or a collection of a +type in scope.

    + +
    + +

    Element edm:Term

    + +
    + +
    + +

    The +edm:Term element MUST contain the attributes Name and Type. It MAY contain +the attributes BaseTerm and AppliesTo.

    + +

    It MAY specify values for the Nullable, + MaxLength, Precision, Scale, or SRID facet attributes, as well as +the Unicode +facet attribute for 4.01 and greater payloads. These facets and their +implications are described in section 7.2.

    + +

    A edm:Term +element whose Type attribute specifies a primitive +or enumeration type MAY define a value for the DefaultValue +attribute.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is the terms name.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued properties the value +of Type is the qualified name of the propertys +type.

    + +

    For collection-valued properties the value +of Type is the character sequence Collection( followed by the qualified name of the +propertys item type, followed by a closing parenthesis ).

    + +
    + +
    + +

    Attribute DefaultValue

    + +
    + +
    + +

    The value of this attribute determines +the value of the term when applied in an edm:Annotation without providing +an expression.

    + +

    Default +values of type Edm.String MUST be represented +according to the XML escaping rules for character data in attribute values. +Values of other primitive types MUST be represented according to the +appropriate alternative in the primitiveValue rule +defined in OData‑ABNF, i.e. Edm.Binary as binaryValue, Edm.Boolean as booleanValue +etc.

    + +

    If no value is specified, the DefaultValue attribute defaults to null.

    + +
    + +

    ##subsubsec Specialized +Term

    + +

    A term MAY specialize another term in scope by specifying it +as its base type.

    + +

    When applying a term with a base term, the base term MUST +also be applied with the same qualifier, and so on until a term without a base +term is reached.

    + +
    + +

    Attribute BaseTerm

    + +
    + +
    + +

    The value of BaseTerm +is the qualified name of the base term.

    + +
    + +

    ##subsubsec Applicability

    + +

    The applicability of a term MAY be restricted to a list of +model elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be extended in +future versions of the vocabulary. As the intended usage may evolve over time, +clients SHOULD be prepared for any term to be applied to any model element and +SHOULD be prepared to handle unknown values within the AppliesTo attribute. Applicability is expressed using the +following symbolic values:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Symbolic Value

    +
    +

    Model Element

    +
    +

    Action

    +
    +

    Action

    +
    +

    ActionImport

    +
    +

    Action Import

    +
    +

    Annotation

    +
    +

    Annotation

    +
    +

    Apply

    +
    +

    Application of a client-side function in an annotation

    +
    +

    Cast

    +
    +

    Type Cast annotation expression

    +
    +

    Collection

    +
    +

    Entity Set or collection-valued Property or Navigation + Property

    +
    +

    ComplexType

    +
    +

    Complex Type

    +
    +

    EntityContainer

    +
    +

    Entity Container

    +
    +

    EntitySet

    +
    +

    Entity Set

    +
    +

    EntityType

    +
    +

    Entity Type

    +
    +

    EnumType

    +
    +

    Enumeration Type

    +
    +

    Function

    +
    +

    Function

    +
    +

    FunctionImport

    +
    +

    Function Import

    +
    +

    If

    +
    +

    Conditional annotation expression

    +
    +

    Include

    +
    +

    Reference to an Included Schema

    +
    +

    IsOf

    +
    +

    Type Check annotation expression

    +
    +

    LabeledElement

    +
    +

    Labeled Element expression

    +
    +

    Member

    +
    +

    Enumeration Member

    +
    +

    NavigationProperty

    +
    +

    Navigation Property

    +
    +

    Null

    +
    +

    Null annotation expression

    +
    +

    OnDelete

    +
    +

    On-Delete Action of a navigation property

    +
    +

    Parameter

    +
    +

    Action of Function Parameter

    +
    +

    Property

    +
    +

    Property of a structured type

    +
    +

    PropertyValue

    +
    +

    Property value of a Record annotation expression

    +
    +

    Record

    +
    +

    Record annotation expression

    +
    +

    Reference

    +
    +

    Reference to another CSDL document

    +
    +

    ReferentialConstraint

    +
    +

    Referential Constraint of a navigation property

    +
    +

    ReturnType

    +
    +

    Return Type of an Action or Function

    +
    +

    Schema

    +
    +

    Schema

    +
    +

    Singleton

    +
    +

    Singleton

    +
    +

    Term

    +
    +

    Term

    +
    +

    TypeDefinition

    +
    +

    Type Definition

    +
    +

    UrlRef

    +
    +

    UrlRef annotation expression

    +
    + +
    + +

    Attribute AppliesTo

    + +
    + +
    + +

    The value of AppliesTo +is a whitespace-separated list of symbolic values from the table above that +identify model elements the term is intended to be applied to.

    + +
    + +

    Example 39: the IsURL term can +be applied to properties and terms that are of type Edm.String +(the Core.Tag type and the two Core terms +are defined in OData‑VocCore)

    + +
    + +

    <Term Name="IsURL" Type="Core.Tag" +Nullable="false" DefaultValue="true"
    + AppliesTo="Property Term">
    + <Annotation Term="Core.Description">
    + <String>
    + Properties and terms annotated with this term MUST contain a valid URL

    + +

    </String>
    + </Annotation>

    + +

    <Annotation Term="Core.RequiresType" +String="Edm.String" />

    + +

    </Term>

    + +
    + +

    ##subsec Annotation

    + +

    An +annotation applies a term to +a model element and defines how to calculate a value for the term application. +Both term and model element MUST be in scope. Section 14.1.2 specifies which +model elements MAY be annotated with a term.

    + +

    The value of an annotation is +specified as an annotation expression, which is either a constant expression representing a constant +value, or a dynamic expression. The most common construct for +assigning an annotation value is a path expression that refers to a property of the same or a related +structured type.

    + +
    + +

    Element edm:Annotation

    + +
    + +
    + +

    The edm:Annotation +element MUST contain the attribute Term, and it MAY +contain the attribute Qualifier.

    + +

    The value of the annotation MAY be a constant expression or dynamic expression.

    + +

    If no expression is specified for a +term with a primitive type, the annotation evaluates to the default value of the term definition. If no +expression is specified for a term with a complex type, the annotation +evaluates to a complex instance with default values for its properties. If no +expression is specified for a collection-valued term, the annotation evaluates +to an empty collection.

    + +

    An edm:Annotation +element can be used as a child of the model element it annotates, or as the +child of an edm:Annotations element that +targets the model element to be annotated.

    + +

    An edm:Annotation +element MAY contain edm:Annotation +elements that annotate the annotation.

    + +
    + +
    + +

    Attribute Term

    + +
    + +
    + +

    The value of Term +is the qualified name of a term in scope.

    + +
    + +

    Example 40: term Measures.ISOCurrency, +once applied with a constant value, once with a path value

    + +
    + +

    <Property Name="AmountInReportingCurrency" +Type="Edm.Decimal">
    + <Annotation Term="Measures.ISOCurrency" String="USD">

    + +

    <Annotation +Term="Core.Description"
    + String="The parent companys currency" />

    + +

    </Annotation>

    + +

    </Property>

    + +

    <Property Name="AmountInTransactionCurrency" +Type="Edm.Decimal">
    + <Annotation Term="Measures.ISOCurrency" Path="Currency" +/>

    + +

    </Property>

    + +

    <Property Name="Currency" +Type="Edm.String" MaxLength="3" />

    + +
    + +

    If an entity type or complex type is annotated with a term +that itself has a structured type, an instance of the annotated type may be +viewed as an instance of the term, and the qualified term name may be used as +a term-cast segment in path expressions.

    + +

    Structured types inherit annotations from their direct or +indirect base types. If both the type and one of its base types is annotated +with the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or collection-valued +annotation values are not merged. Similarly, properties of a structured type +inherit annotations from identically named properties of a base type.

    + +

    It is up to the definition of a term to specify whether and +how annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a "Label" +annotation for a UI can propagate from a type definition to all properties +using that type definition and may be overridden at each property with a more +specific label, whereas an annotation marking a type definition as containing a +phone number will propagate to all using properties but may not be overridden.

    + +

    ##subsubsec Qualifier

    + +

    A +term can be applied multiple times to the same model element by providing a +qualifier to distinguish the annotations. The qualifier is a simple identifier.

    + +

    The combination of target model +element, term, and qualifier uniquely identifies an annotation.

    + +
    + +

    Attribute Qualifier

    + +
    + +
    + +

    Annotation elements that are children +of an edm:Annotations element MUST NOT provide a value for +the qualifier attribute if the parent edm:Annotations +element provides a value for the qualifier attribute.

    + +
    + +

    Example 41: annotation should only be applied to tablet +devices

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName" Path="FirstName"
    + Qualifier="Tablet" />

    + +
    + +

    ##subsubsec Target

    + +

    The target of an annotation is the model element the term is +applied to.

    + +

    The target of an annotation MAY be specified indirectly by +nesting the annotation within the model element. Whether and how this is +possible is described per model element in this specification.

    + +

    The target of an annotation MAY also be specified directly; +this allows defining an annotation in a different schema than the targeted +model element.

    + +

    This external +targeting is only possible for model elements that are uniquely identified +within their parent, and all their ancestor elements are uniquely identified +within their parent:

    + + + +

    These are the +direct children of a schema with a unique name (i.e. except actions and +functions whose overloads to not possess a natural identifier), and all direct +children of an entity container.

    + +

    External targeting is possible for +actions, functions, their parameters, and their return type, either in a way +that applies to all overloads of the action or function or all parameters of +that name across all overloads, or in a way that identifies a single overload.

    + +

    External +targeting is also possible for properties and navigation properties of +singletons or entities in a particular entity set. These annotations override +annotations on the properties or navigation properties targeted via the +declaring structured type.

    + +

    The allowed path +expressions are:

    + +

    qualified +name of schema child

    + +

    qualified +name of schema child followed +by a forward slash and name of child element

    + +

    qualified +name of structured type +followed by zero or more property, navigation property, or type-cast segments, +each segment starting with a forward slash

    + +

    qualified +name of an entity +container followed by a segment containing a singleton or entity set name and +zero or more property, navigation property, or type-cast segments

    + +

    qualified +name of an action +followed by parentheses containing the binding parameter type of a bound +action overload to identify that bound overload, or by empty parentheses to +identify the unbound overload

    + +

    qualified +name of a function +followed by parentheses containing the comma-separated list of the parameter types +of a bound or unbound function overload in the order of their definition in the +function overload

    + +

    qualified +name of an action or +function, optionally followed by parentheses as described in the two previous +bullet points to identify a single overload, followed by a forward slash and +either a parameter name or $ReturnType

    + +

    qualified +name of an entity +container followed by a segment containing an action or function import name, +optionally followed by a forward slash and either a parameter name or $ReturnType

    + +
      +
    • One of the + preceding, followed by a forward slash, an at (@), the qualified name of a term, and optionally a hash (#) and the + qualifier of an annotation
    • +
    + +

    All qualified names used in a target path MUST be in scope.

    + +

    Example 42: Target expressions

    + +
    + +

    MySchema.MyEntityType

    + +

    MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityType/MyNavigationProperty

    + +

    MySchema.MyComplexType

    + +

    MySchema.MyComplexType/MyProperty

    + +

    MySchema.MyComplexType/MyNavigationProperty

    + +

    MySchema.MyEnumType

    + +

    MySchema.MyEnumType/MyMember

    + +

    MySchema.MyTypeDefinition

    + +

    MySchema.MyTerm

    + +

    MySchema.MyEntityContainer

    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MyActionImport

    + +

    MySchema.MyEntityContainer/MyFunctionImport

    + +

    MySchema.MyAction

    + +

    MySchema.MyAction(MySchema.MyBindingType)

    + +

    MySchema.MyAction(Collection(MySchema.MyBindingType))

    + +

    MySchema.MyAction()

    + +

    MySchema.MyFunction

    + +

    MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType)

    + +

    MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType)

    + +

    MySchema.MyFunction/MyParameter

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty

    + +
    + +

    ##subsec Constant Expression

    + +

    Constant expressions allow assigning a constant value to an +applied term.

    + +

    ##subsubsec Binary

    + +
    + +

    Expression edm:Binary

    + +
    + +
    + +

    The edm:Binary +expression evaluates to a primitive binary value. A binary expression MUST be +assigned a value conforming to the rule binaryValue +in OData‑ABNF.

    + +

    The binary expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 43: base64url-encoded binary value (OData)

    + +
    + +

    <Annotation +Term="org.example.display.Thumbnail" Binary="T0RhdGE" />
    +
    +<Annotation Term="org.example.display.Thumbnail">
    + <Binary>T0RhdGE</Binary>
    +</Annotation>

    + +
    + +

    ##subsubsec Boolean

    + +
    + +

    Expression edm:Bool

    + +
    + +
    + +

    The edm:Bool +expression evaluates to a primitive Boolean value. A Boolean expression MUST be +assigned a Boolean value.

    + +

    The Boolean expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 44:

    + +
    + +

    <Annotation +Term="org.example.display.ReadOnly" Bool="true" />
    +
    +<Annotation Term="org.example.display.ReadOnly">
    + <Bool>true</Bool>
    +</Annotation>

    + +
    + +

    ##subsubsec Date

    + +
    + +

    Expression edm:Date

    + +
    + +
    + +

    The edm:Date +expression evaluates to a primitive date value. A date expression MUST be +assigned a value of type xs:date, see [XML‑Schema‑2], section 3.3.9. The value +MUST also conform to rule dateValue in OData‑ABNF, i.e. it MUST NOT contain a +time-zone offset.

    + +

    The date expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 45:

    + +
    + +

    <Annotation Term="org.example.vCard.birthDay" +Date="2000-01-01" />
    +
    +<Annotation Term="org.example.vCard.birthDay">
    +<Date>2000-01-01</Date>
    +</Annotation>

    + +
    + +

    ##subsubsec DateTimeOffset

    + +
    + +

    Expression edm:DateTimeOffset

    + +
    + +
    + +

    The edm:DateTimeOffset +expression evaluates to a primitive datetimestamp value with a time-zone +offset. A datetimestamp expression MUST be assigned a value of type xs:dateTimeStamp, see [XML‑Schema‑2], +section 3.4.28. +The value MUST also conform to rule dateTimeOffsetValue +in OData‑ABNF, i.e. it MUST NOT contain an +end-of-day fragment (24:00:00).

    + +

    The datetimestamp expression MAY be +provided using element notation or attribute notation.

    + +
    + +

    Example 46:

    + +
    + +

    <Annotation +Term="org.example.display.LastUpdated"

    + +

    DateTimeOffset="2000-01-01T16:00:00.000Z" +/>
    +
    +<Annotation Term="org.example.display.LastUpdated">
    + <DateTimeOffset>2000-01-01T16:00:00.000-09:00</DateTimeOffset>
    +</Annotation>

    + +
    + +

    ##subsubsec Decimal

    + +
    + +

    Expression edm:Decimal

    + +
    + +
    + +

    The edm:Decimal +expression evaluates to a primitive decimal value. A decimal expression MUST be +assigned a value conforming to the rule decimalValue +in OData‑ABNF.

    + +

    The decimal expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 47: attribute notation

    + +
    + +

    <Annotation +Term="org.example.display.Width" Decimal="3.14" />

    + +
    + +

    Example 48: element notation

    + +
    + +

    <Annotation +Term="org.example.display.Width">
    +<Decimal>3.14</Decimal>
    +</Annotation>

    + +
    + +

    ##subsubsec Duration

    + +
    + +

    Expression edm:Duration

    + +
    + +
    + +

    The edm:Duration +expression evaluates to a primitive duration value. A duration expression MUST +be assigned a value of type xs:dayTimeDuration, see +[XML‑Schema‑2], section 3.4.27.

    + +

    The duration expression MAY be +provided using element notation or attribute notation.

    + +
    + +

    Example 49:

    + +
    + +

    <Annotation Term="org.example.task.duration" +Duration="P7D" />
    +
    +<Annotation Term="org.example.task.duration">
    + <Duration>P11DT23H59M59.999999999999S</Duration>
    +</Annotation>

    + +
    + +

    ##subsubsec Enumeration Member

    + +
    + +

    Expression edm:EnumMember

    + +
    + +
    + +

    The edm:EnumMember +expression references a member of an enumeration type. An enumeration member +expression MUST be assigned a value that consists of the qualified name of the +enumeration type, followed by a forward slash and the name of the enumeration +member. If the enumeration type specifies an IsFlags +attribute with value true, the expression MAY also +be assigned a whitespace-separated list of values. Each of these values MUST +resolve to the name of a member of the enumeration type of the specified term.

    + +

    The enumeration member expression MAY +be provided using element notation or attribute notation.

    + +
    + +

    Example 50: single value

    + +
    + +

    <Annotation Term="org.example.HasPattern"
    + EnumMember="org.example.Pattern/Red" />
    +
    +<Annotation Term="org.example.HasPattern">
    +<EnumMember>org.example.Pattern/Red</EnumMember>
    +</Annotation>

    + +
    + +

    Example 51: combined value for IsFlags +enumeration type

    + +
    + +

    <Annotation Term="org.example.HasPattern"
    + EnumMember="org.example.Pattern/Red +org.example.Pattern/Striped" />
    +
    +<Annotation Term="org.example.HasPattern">
    +<EnumMember>org.example.Pattern/Red org.example.Pattern/Striped</EnumMember>
    +</Annotation>

    + +
    + +

    ##subsubsec Floating-Point Number

    + +
    + +

    Expression edm:Float

    + +
    + +
    + +

    The edm:Float +expression evaluates to a primitive floating point (or double) value. A float expression +MUST be assigned a value conforming to the rule doubleValue +in OData‑ABNF.

    + +

    The float expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 52:

    + +
    + +

    <Annotation +Term="org.example.display.Width" Float="3.14" />
    +
    +<Annotation Term="org.example.display.Width">
    +<Float>3.14</Float>
    +</Annotation>

    + +
    + +

    ##subsubsec Guid

    + +
    + +

    Expression edm:Guid

    + +
    + +
    + +

    The edm:Guid +expression evaluates to a primitive guid value. A guid expression MUST be +assigned a value conforming to the rule guidValue +in OData‑ABNF.

    + +

    The guid expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 53:

    + +
    + +

    <Annotation +Term="org.example.display.Id"

    + +

    Guid="21EC2020-3AEA-1069-A2DD-08002B30309D" +/>
    +
    +<Annotation Term="org.example.display.Id">
    +<Guid>21EC2020-3AEA-1069-A2DD-08002B30309D</Guid>
    +</Annotation>

    + +
    + +

    ##subsubsec Integer

    + +
    + +

    Expression edm:Int

    + +
    + +
    + +

    The edm:Int +expression evaluates to a primitive integer value. An integer MUST be assigned +a value conforming to the rule int64Value in OData‑ABNF.

    + +

    The integer expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 54: attribute notation

    + +
    + +

    <Annotation +Term="org.example.display.Width" Int="42" />

    + +
    + +

    Example 55: element notation

    + +
    + +

    <Annotation +Term="org.example.display.Width">
    + <Int>42</Int>
    +</Annotation>

    + +
    + +

    ##subsubsec String

    + +
    + +

    Expression edm:String

    + +
    + +
    + +

    The edm:String +expression evaluates to a primitive string value. A string expression MUST be +assigned a value of the type xs:string, see [XML‑Schema‑2], section 3.3.1.

    + +

    The string expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 56:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName" String="Product Catalog" +/>
    +
    +<Annotation Term="org.example.display.DisplayName">
    + <String>Product Catalog</String>
    +</Annotation>

    + +
    + +

    ##subsubsec Time of Day

    + +
    + +

    Expression edm:TimeOfDay

    + +
    + +
    + +

    The edm:TimeOfDay +expression evaluates to a primitive time value. A time-of-day expression MUST +be assigned a value conforming to the rule timeOfDayValue +in OData‑ABNF.

    + +

    The time-of-day expression MAY be +provided using element notation or attribute notation.

    + +
    + +

    Example 57:

    + +
    + +

    <Annotation +Term="org.example.display.EndTime" TimeOfDay="21:45:00" +/>
    +
    +<Annotation Term="org.example.display.EndTime">
    + <TimeOfDay>21:45:00</TimeOfDay>
    +</Annotation>

    + +
    + +

    ##subsec Dynamic +Expression

    + +

    Dynamic expressions allow assigning a calculated value to an +applied term.

    + +

    ##subsubsec Path +Expressions

    + +

    Path expressions allow +assigning a value to an applied term or term component. There are two kinds of +path expressions:

    + +

    A +model path is used within Annotation +Path, Model Element Path, Navigation Property Path, and Property Path expressions to traverse the model of +a service and resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the built-in types Edm.AnnotationPath, Edm.NavigationPropertyPath, +Edm.PropertyPath, and their base types Edm.AnyPropertyPath and Edm.ModelElementPath.

    + +

    An instance path is used within a Value +Path expression to traverse a graph of type instances and resolves to the +value identified by the path. It allows assigning values to terms or term +properties of built-in types other than the Edm.*Path +types, or of any model-defined type.

    + +

    ##subsubsubsec Path Syntax

    + +

    Model paths and instance paths share a common syntax which +is derived from the path expression syntax of URLs, see OData‑URL.

    + +

    A path MUST be composed of zero or more path segments joined +together by forward slashes (/).

    + +

    Paths starting with a forward slash (/) +are absolute paths, and the first path segment MUST be the qualified name of a +model element, e.g. an entity container. The remaining path after the second +forward slash is interpreted relative to that model element.

    + +

    Example 58: absolute path to an entity set

    + +
    + +

    /self.MyEntityContainer/MyEntitySet

    + +
    + +

    Paths not starting with a forward slash are interpreted +relative to the annotation target, following the rules specified in section Path Evaluation.

    + +

    Example 59: relative path to a property

    + +
    + +

    Address/City

    + +
    + +

    If a path segment is a qualified +name, it represents a type cast, and the +segment MUST be the name of a type in scope. If the type or instance identified +by the preceding path part cannot be cast to the specified type, the path +expression evaluates to the null value.

    + +

    Example 60: type-cast segment

    + +
    + +

    /self.Manager/

    + +
    + +

    If a path segment starts with an at (@) +character, it represents a term cast. The at +(@) character MUST be followed by a qualified name that +MAY be followed by a hash (#) character and a simple identifier. The qualified name preceding +the hash character MUST resolve to a term that is in scope, the simple identifier following +the hash sign is interpreted as a qualifier for +the term. If the model element or instance identified by the preceding path +part has not been annotated with that term (and if present, with that +qualifier), the term cast evaluates to the null value. Four special terms are implicitly +annotated for media entities and stream properties:

    + +
      +
    • odata.mediaEditLink
    • +
    • odata.mediaReadLink
    • +
    • odata.mediaContentType
    • +
    • odata.mediaEtag
    • +
    + +

    Example 61: term-cast segment

    + +
    + +

    /@Capabilities.SortRestrictions/

    + +
    + +

    If a path segment is a simple +identifier, it MUST be the name of a child model element of the model +element identified by the preceding path part, or a structural or navigation +property of the instance identified by the preceding path part. A sequence of +navigation segments can traverse multiple CSDL documents. The document +containing the path expression only needs to reference the next traversed +document to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document.

    + +

    A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path.

    + +

    Example 62: property segment in model path

    + +
    + +

    /Orders/Items/Product/

    + +
    + +

    An instance path MUST NOT contain +more than one segment representing a collection-valued construct, e.g. an +entity set or a collection-valued navigation property that is not followed by a +key predicate, or a collection-valued structural property that is not followed +by an index segment. The result of the expression is the collection of +instances resulting from applying any remaining segments that operate on a +single-valued expression to each instance in the collection-valued segment.

    + +

    An instance path MAY terminate in a $count +segment if the previous segment is collection-valued, in which case the path +evaluates to the number of items in the collection identified by the preceding +segment.

    + +

    Example 63: property segments in instance path

    + +
    + +

    /Addresses/Street

    + +

    /Addresses/$count

    + +
    + +

    A model path MAY contain path segments starting with a +navigation property, then followed by an at (@) +character, then followed by the qualified name of a term in scope, and optionally followed by a +hash (#) character and a simple identifier which is interpreted as a qualifier for the term. If the navigation property +has not been annotated with that term (and if present, with that qualifier), +the path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity type +specified by the navigation property are addressed via a term-cast +segment.

    + +

    Example 64: model path addressing an annotation on a +navigation property

    + +
    + +

    /Items@Capabilities.InsertRestrictions/Insertable

    + +
    + +

    An instance path MAY contain path segments starting with an +entity set or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see OData‑URL. +The key values are either primitive literals or instance paths. If the key +value is a relative instance path, it is interpreted according to the same rule +below as the instance path it is part of, not relative to the instance +identified by the preceding path part.

    + +

    Example 65: instance path with entity set and key predicate

    + +
    + +

    /self.container/SettingsCollection('FeatureXxx')/IsAvailable +

    + +

    /self.container/Products(ID=ProductID)/Name

    + +
    + +

    An instance path MAY contain an index segment immediately +following a path segment representing an ordered collection-valued structural property. +The index is zero-based and MUST be an integer literal. Negative integers count +from the end of the collection, with -1 representing the last item in the +collection. Remaining path segments are evaluated relative to the identified +item of the collection.

    + +

    Example 66: instance path with collection-valued structural +property and index segment

    + +
    + +

    Addresses/1

    + +

    Addresses/-1/Street

    + +
    + +

    ##subsubsubsec Path +Evaluation

    + +

    Annotations MAY be embedded within their target, or +specified separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as targeting +in the remainder of this section.

    + +

    For annotations embedded within or targeting an entity container, +the path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a segment +identifying a container child (entity set, function import, action import, or +singleton). The subsequent segments follow the rules for path expressions +targeting the corresponding child element.

    + +

    For annotations embedded within or targeting an entity set +or a singleton, the path is evaluated starting at the entity set or singleton, +i.e. an empty path resolves to the entity set or singleton, and non-empty paths +MUST follow the rules for annotations targeting the declared entity type of the +entity set or singleton.

    + +

    For annotations embedded within or targeting an entity type +or complex type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be a +structural or navigation property of the type, a type +cast, or a term cast.

    + +

    For annotations embedded within a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other properties of +the same type. An empty path resolves to the enclosing type, and non-empty +paths MUST follow the rules for annotations targeting the directly enclosing +type.

    + +

    For annotations targeting a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the outermost entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the first +segment of a non-empty path MUST be a structural or navigation property of the +outermost type, a type cast, or a term cast.

    + +

    For annotations embedded within or targeting an action, +action import, function, function import, parameter, or return type, the first +segment of the path MUST be a parameter name or $ReturnType.

    + +

    ##subsubsubsec Annotation +Path

    + +

    The annotation path expression provides a value for terms or +term properties that specify the built-in types Edm.AnnotationPath or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    A +non-null path MUST resolve to an annotation.

    + +

    A term or term property of type Edm.AnnotationPath +can be annotated with term Validation.AllowedTerms +(see OData-VocValidation) if its +intended value is an annotation path that ends in a term cast with one of the +listed terms.

    + +

    The value of the annotation path expression is the path +itself, not the value of the annotation identified by the path. This is useful +for terms that reuse or refer to other terms.

    + +
    + +

    Expression edm:AnnotationPath

    + +
    + +
    + +

    The edm:AnnotationPath +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 67:

    + +
    + +

    <Annotation Term="UI.ReferenceFacet"
    + AnnotationPath="Product/Supplier/@UI.LineItem" />

    + +

     

    + +

    <Annotation Term="UI.CollectionFacet" +Qualifier="Contacts">

    + +

    <Collection>

    + +

    +<AnnotationPath>Supplier/@Communication.Contact</AnnotationPath>

    + +

    +<AnnotationPath>Customer/@Communication.Contact</AnnotationPath>

    + +

    </Collection>

    + +

    </Annotation>

    + +
    + +

    ##subsubsubsec Model Element Path

    + +

    The model element path expression provides a value for terms +or term properties that specify the built-in type Edm.ModelElementPath. Its argument is a model path.

    + +

    The value of the model element path expression is the path +itself, not the instance(s) identified by the path.

    + +
    + +

    Expression edm:ModelElementPath

    + +
    + +
    + +

    The edm:ModelElementPath +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 68:

    + +
    + +

    <Annotation Term="org.example.MyFavoriteModelElement" +

    + +

    ModelElementPath="/org.example.someAction" +/>

    + +

     

    + +

    <Annotation Term="org.example.MyFavoriteModelElement"> +

    + +

    <ModelElementPath>/org.example.someAction</ModelElementPath> +

    + +

    </Annotation>

    + +
    + +

    ##subsubsubsec Navigation Property Path

    + +

    The navigation property path expression provides a value for +terms or term properties that specify the built-in types Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    A non-null path MUST resolve to a model element whose type is an +entity type, or a collection of entity types, e.g. a navigation property.

    + +

    The value of the navigation property path expression is the +path itself, not the instance(s) identified by the path.

    + +
    + +

    Expression edm:NavigationPropertyPath

    + +
    + +
    + +

    The edm:NavigationPropertyPath +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 69:

    + +
    + +

    <Annotation Term="UI.HyperLink" +NavigationPropertyPath="Supplier" />

    + +

     

    + +

    <Annotation Term="Capabilities.UpdateRestrictions">

    + +

    <Record>
    + <PropertyValue Property="NonUpdatableNavigationProperties">

    + +

    <Collection>

    + +

    <NavigationPropertyPath>Supplier</NavigationPropertyPath>

    + +

    <NavigationPropertyPath>Category</NavigationPropertyPath>

    + +

    </Collection>

    + +

    </PropertyValue>

    + +

    </Record>

    + +

    </Annotation>

    + +
    + +

    ##subsubsubsec Property Path

    + +

    The property path expression provides a value for terms or +term properties that specify one of the built-in types Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

    A non-null path MUST resolve to a model element whose type is a primitive or complex type, an +enumeration type, a type definition, or a collection of one of these +types.

    + +

    The value of the property path expression is the path +itself, not the value of the property or the value of the term cast identified +by the path.

    + +
    + +

    Expression edm:PropertyPath

    + +
    + +
    + +

    The edm:PropertyPath +MAY be provided using either element notation or attribute notation.

    + +
    + +

    Example 70:

    + +
    + +

    <Annotation Term="UI.RefreshOnChangeOf" +PropertyPath="ChangedAt" />

    + +

     

    + +

    <Annotation Term="Capabilities.UpdateRestrictions">
    + <Record>
    + <PropertyValue Property="NonUpdatableProperties">

    + +

    <Collection>

    + +

    <PropertyPath>CreatedAt</PropertyPath>

    + +

    <PropertyPath>ChangedAt</PropertyPath>

    + +

    </Collection>

    + +

    </PropertyValue>

    + +

    </Record>

    + +

    </Annotation>

    + +
    + +

    ##subsubsubsec Value Path

    + +

    The +value path expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity containers, +entity sets, entity types, complex types, navigation properties of structured +types, and properties of structured types. Its argument is an instance path.

    + +

    The value of the path expression is the instance or +collection of instances identified by the path.

    + +
    + +

    Expression edm:Path

    + +
    + +
    + +

    The edm:Path +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 71:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName" Path="FirstName" +/>
    +
    +<Annotation Term="org.example.display.DisplayName">
    +<Path>@vCard.Address#work/FullName</Path>
    +</Annotation>

    + +
    + +

    ##subsubsec Comparison and Logical Operators

    + +

    Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and they MAY +be used anywhere instead of a Boolean expression.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Logical Operators

    +
    +

    And

    +
    +

    Logical + and

    +
    +

    Or

    +
    +

    Logical + or

    +
    +

    Not

    +
    +

    Logical + negation

    +
    +

    Comparison Operators

    +
    +

    Eq

    +
    +

    Equal

    +
    +

    Ne

    +
    +

    Not + equal

    +
    +

    Gt

    +
    +

    Greater + than

    +
    +

    Ge

    +
    +

    Greater + than or equal

    +
    +

    Lt

    +
    +

    Less than

    +
    +

    Le

    +
    +

    Less + than or equal

    +
    +

    Has

    +
    +

    Has + enumeration flag(s) set

    +
    +

    In

    +
    +

    Is + in collection

    +
    + +

    The And and Or operators require two operand expressions that +evaluate to Boolean values. The Not operator +requires a single operand expression that evaluates to a Boolean value. For +details on null handling for comparison operators see OData‑URL.

    + +

    The other comparison operators require two operand +expressions that evaluate to comparable values.

    + +
    + +

    Expressions edm:And and edm:Or

    + +
    + +
    + +

    The And +and Or logical expressions are represented as +elements edm:And and edm:Or +that MUST contain two annotation expressions.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Expression +edm:Not

    + +
    + +
    + +

    Negation expressions are represented +as an element edm:Not that MUST contain a single +annotation expression.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Expressions +edm:Eq, edm:Ne, edm:Gt, +edm:Ge, edm:Lt, edm:Le, +edm:Has, and edm:In

    + +
    + +
    + +

    All comparison expressions are +represented as an element that MUST contain two annotation expressions.

    + +

    They MAY contain edm:Annotation +elements.

    + +
    + +

    Example 72:

    + +
    + +

    <And>

    + +

    <Path>IsMale</Path>

    + +

    <Path>IsMarried</Path>

    + +

    </And>

    + +

    <Or>

    + +

    <Path>IsMale</Path>

    + +

    <Path>IsMarried</Path>

    + +

    </Or>

    + +

    <Not>

    + +

    <Path>IsMale</Path>

    + +

    </Not>

    + +

    <Eq>

    + +

    <Null />

    + +

    <Path>IsMale</Path>

    + +

    </Eq>

    + +

    <Ne>

    + +

    <Null />

    + +

    <Path>IsMale</Path>

    + +

    </Ne>

    + +

    <Gt>

    + +

    <Path>Price</Path>

    + +

    <Int>20</Int>

    + +

    </Gt>

    + +

    <Ge>

    + +

    <Path>Price</Path>

    + +

    <Int>10</Int>

    + +

    </Ge>

    + +

    <Lt>

    + +

    <Path>Price</Path>

    + +

    <Int>20</Int>

    + +

    </Lt>

    + +

    <Le>

    + +

    <Path>Price</Path>

    + +

    <Int>100</Int>

    + +

    </Le>

    + +

    <Has>

    + +

    <Path>Fabric</Path>

    + +

    +<EnumMember>org.example.Pattern/Red</EnumMember>

    + +

    </Has>

    + +

    <In>

    + +

    <Path>Size</Path>

    + +

    <Collection>

    + +

    <String>XS</String>

    + +

    <String>S</String>

    + +

    </Collection>

    + +

    </In>

    + +
    + +

    ##subsubsec Arithmetic Operators

    + +

    Annotations MAY use the following arithmetic expressions +which evaluate to a numeric value. These expressions MAY be combined, and they MAY +be used anywhere instead of a numeric expression of the appropriate type. The +semantics and evaluation rules for each arithmetic expression is identical to +the corresponding arithmetic operator defined in OData‑URL.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Add

    +
    +

    Addition

    +
    +

    Sub

    +
    +

    Subtraction

    +
    +

    Neg

    +
    +

    Negation

    +
    +

    Mul

    +
    +

    Multiplication

    +
    +

    Div

    +
    +

    Division + (with integer result for integer operands)

    +
    +

    DivBy

    +
    +

    Division + (with fractional result also for integer operands)

    +
    +

    Mod

    +
    +

    Modulo

    +
    + +

    The Neg operator requires a +single operand expression that evaluates to a numeric value. The other arithmetic +operators require two operand expressions that evaluate to numeric values.

    + +
    + +

    Expression +edm:Neg

    + +
    + +
    + +

    Negation expressions are represented +as an element edm:Neg that MUST contain a single +annotation expression.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Expressions +edm:Add, edm:Sub, edm:Mul, edm:Div, edm:DivBy, and edm:Mod

    + +
    + +
    + +

    These arithmetic expressions are +represented as an element that MUST contain two annotation expressions.

    + +

    They MAY contain edm:Annotation +elements.

    + +
    + +

    Example 73:

    + +
    + +

    <Add>

    + +

    <Path>StartDate</Path>

    + +

    <Path>Duration</Path>

    + +

    </Add>

    + +

    <Sub>

    + +

    <Path>Revenue</Path>

    + +

    <Path>Cost</Path>

    + +

    </Sub>

    + +

    <Neg>

    + +

    <Path>Height</Path>

    + +

    </Neg>

    + +

    <Mul>

    + +

    <Path>NetPrice</Path>

    + +

    <Path>TaxRate</Path>

    + +

    </Mul>

    + +

    <Div>

    + +

    <Path>Quantity</Path>

    + +

    +<Path>QuantityPerParcel</Path>

    + +

    </Div>

    + +

    <DivBy>

    + +

    <Path>Quantity</Path>

    + +

    +<Path>QuantityPerParcel</Path>

    + +

    </DivBy>

    + +

    <Mod>

    + +

    <Path>Quantity</Path>

    + +

    +<Path>QuantityPerParcel</Path>

    + +

    </Mod>

    + +
    + +

    ##subsubsec Apply Client-Side Function

    + +

    The apply expression enables a value to be obtained by +applying a client-side function. The apply expression MAY have operand +expressions. The operand expressions are used as parameters to the function.

    + +
    + +

    Expression edm:Apply

    + +
    + +
    + +

    The edm:Apply +element MUST contain the Function attribute and MAY +contain annotation expressions as operands for the applied function.

    + +

    It MAY contain +more edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Function

    + +
    + +
    + +

    The value of Function +is the qualified name of the client-side +function to apply.

    + +
    + +

    OData defines the following functions. Services MAY support +additional functions that MUST be qualified with a namespace or alias other +than odata. Function names +qualified with odata are reserved for this +specification and its future versions.

    + +

    ##subsubsubsec Canonical Functions

    + +

    All canonical functions defined in OData‑URL +can be used as client-side functions, qualified with the namespace odata. The semantics of these client-side functions is +identical to their counterpart function defined in OData‑URL.

    + +

    For example, the odata.concat +client-side function takes two or more expressions as arguments. Each argument +MUST evaluate to a primitive or enumeration type. It returns a value of type Edm.String that is the concatenation of the literal representations +of the results of the argument expressions. Values of primitive types other +than Edm.String are represented according to the +appropriate alternative in the primitiveValue rule +of OData‑ABNF, i.e. Edm.Binary +as binaryValue, Edm.Boolean +as booleanValue etc.

    + +

    Example 74:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName">
    +<Apply Function="odata.concat">
    + <String>Product: </String>
    + <Path>ProductName</Path>
    + <String> (</String>
    + <Path>Available/Quantity</Path>

    + +

    <String> </String>
    + <Path>Available/Unit</Path>

    + +

    <String> +available)</String>

    + +

    </Apply>
    +</Annotation>

    + +
    + +

    ProductName is of type String, +Quantity in complex type Available +is of type Decimal, and Unit +in Available is of type enumeration, so the result +of the Path expression is represented as the member +name of the enumeration value.

    + +

    ##subsubsubsec Function odata.fillUriTemplate

    + +

    The odata.fillUriTemplate +client-side function takes two or more expressions as arguments and returns a +value of type Edm.String.

    + +

    The first argument MUST be of type Edm.String +and specifies a URI template according to RFC6570, +the other arguments MUST be labeled element +expressions. Each labeled element expression +specifies the template parameter name in its Name +attribute and evaluates to the template parameter value.

    + +

    RFC6570 defines three +kinds of template parameters: simple values, lists of values, and key-value +maps.

    + +

    Simple values are represented as labeled element expressions that evaluate to a +single primitive value. The literal representation of this value according to OData‑ABNF is used to fill the +corresponding template parameter.

    + +

    Lists of values are represented as labeled element expressions that evaluate to a +collection of primitive values.

    + +

    Key-value maps are represented as labeled element expressions that evaluate to a +collection of complex types with two properties that are used in lexicographic +order. The first property is used as key, the second property as value.

    + +

    Example 75: assuming there are no special characters in +values of the Name property of the Actor entity

    + +
    + +

    <Apply Function="odata.fillUriTemplate">

    + +

    +<String>http://host/someAPI/Actors/{actorName}/CV</String>

    + +

    <LabeledElement +Name="actorName" Path="Actor/Name" />

    + +

    </Apply>

    + +
    + +

    ##subsubsubsec Function odata.matchesPattern

    + +

    The odata.matchesPattern +client-side function takes two string expressions as arguments and returns a +Boolean value.

    + +

    The function returns true if the second expression evaluates +to an [ECMAScript] (JavaScript) regular +expression and the result of the first argument expression matches that regular +expression, using syntax and semantics of [ECMAScript] +regular expressions.

    + +

    Example 76: all non-empty FirstName +values not containing the letters b, c, or d evaluate to true

    + +
    + +

    <Apply Function="odata.matchesPattern">

    + +

    <Path>FirstName</Path>

    + +

    <String>^[^b-d]+$</String>

    + +

    </Apply>

    + +
    + +

    ##subsubsubsec Function odata.uriEncode

    + +

    The odata.uriEncode client-side +function takes one argument of primitive type and returns the URL-encoded OData +literal that can be used as a key value in OData URLs or in the query part of +OData URLs.

    + +

    Note: string literals are surrounded by single quotes as +required by the paren-style key syntax.

    + +

    Example 77:

    + +
    + +

    <Apply Function="odata.fillUriTemplate">

    + +

    +<String>http://host/service/Genres({genreName})</String>

    + +

    <LabeledElement Name="genreName">

    + +

    <Apply Function="odata.uriEncode" >

    + +

    <Path>NameOfMovieGenre</Path>

    + +

    </Apply>

    + +

    </LabeledElement>

    + +

    </Apply>

    + +
    + +

    ##subsubsec Cast

    + +

    The cast expression casts the value obtained from its single +child expression to the specified type. The cast expression follows the same +rules as the cast canonical function defined in OData‑URL.

    + +
    + +

    Expression edm:Cast

    + +
    + +
    + +

    The edm:Cast element MUST contain the Type attribute and MUST contain exactly one expression.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is a qualified type name in scope, or the character sequence Collection( followed by the qualified name of a type in +scope, followed by a closing parenthesis ).

    + +

    If the specified type is a primitive +type or a collection of a primitive type, the facet attributes MaxLength, +Unicode, Precision, +Scale, +and SRID +MAY be specified if applicable to the specified primitive type. If the facet +attributes are not specified, their values are considered unspecified.

    + +
    + +

    Example 78:

    + +
    + +

    <Annotation +Term="org.example.display.Threshold">
    +<Cast Type="Edm.Decimal">
    + <Path>Average</Path>
    +</Cast>
    +</Annotation>

    + +
    + +

    ##subsubsec Collection

    + +

    The collection expression enables a value to be obtained +from zero or more item expressions. The value calculated by the collection +expression is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type compatible.

    + +
    + +

    Expression edm:Collection

    + +
    + +
    + +

    The edm:Collection +element contains zero or more child expressions.

    + +
    + +

    Example 79:

    + +
    + +

    <Annotation +Term="org.example.seo.SeoTerms">
    + <Collection>
    + <String>Product</String>
    + <String>Supplier</String>
    + <String>Customer</String>
    +</Collection>
    +</Annotation>

    + +
    + +

    ##subsubsec If-Then-Else

    + +

    The if-then-else expression enables a value to be obtained +by evaluating a condition expression. It MUST contain exactly three +child expressions. There is one exception to this rule: if and only if the if-then-else +expression is a direct child of a collection expression, the third child expression MAY be omitted, reducing it +to an if-then expression. This can be used to conditionally add an element to a +collection.

    + +

    The first child element is the condition and MUST evaluate +to a Boolean result, e.g. the comparison +and logical operators can be used.

    + +

    The second and third child elements are evaluated +conditionally. The result MUST be type compatible with the type expected by the +surrounding expression.

    + +

    If the first expression evaluates to true, +the second expression MUST be evaluated and its value MUST be returned as the +result of the if-then-else expression. If the first expression evaluates to false and a third child element is present, it MUST be +evaluated and its value MUST be returned as the result of the if-then-else +expression. If no third child element is present, nothing is added to the surrounding +collection.

    + +
    + +

    Expression edm:If

    + +
    + +
    + +

    The edm:If +element MUST contain two or three child expressions that MUST use element +notation.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +

    Example 80: the condition is a value +path expression referencing the Boolean property IsFemale +,whose value then determines the value of the edm:If +expression

    + +
    + +

    <Annotation +Term="org.example.person.Gender">
    +<If>
    + <Path>IsFemale</Path>
    + <String>Female</String>
    + <String>Male</String>
    +</If>
    +</Annotation>

    + +
    + +

    ##subsubsec Is-Of

    + +

    The is-of expression checks whether the value obtained from +its single child expression is compatible with the specified type. It returns true if the child expression returns a type that is +compatible with the specified type, and false +otherwise.

    + +
    + +

    Expression edm:IsOf

    + +
    + +
    + +

    The edm:IsOf +element MUST contain the Type +attribute and MUST contain exactly one child expression.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is the qualified name of a type in scope, or the character sequence Collection( followed by the qualified name of a type in +scope, followed by a closing parenthesis ).

    + +

    If the specified type is a primitive +type or a collection of a primitive type, the facet attributes MaxLength, +Unicode, Precision, +Scale, +and SRID +MAY be specified if applicable to the specified primitive type. If the facet +attributes are not specified, their values are considered unspecified.

    + +
    + +

    Example 81:

    + +
    + +

    <Annotation Term="self.IsPreferredCustomer">
    + <IsOf Type="self.PreferredCustomer">
    + <Path>Customer</Path>
    +</IsOf>
    +</Annotation>

    + +
    + +

    ##subsubsec Labeled +Element

    + +

    The labeled element expression assigns a name to its single +child expression. The value of the child expression can then be reused elsewhere +with a labeled element reference +expression.

    + +

    A labeled element expression MUST contain exactly one child +expression. The value of the child expression is also the value of the labeled +element expression.

    + +

    A labeled element expression MUST provide a simple identifier value as its name that MUST +be unique within the schema containing the expression.

    + +
    + +

    Expression edm:LabeledElement

    + +
    + +
    + +

    The edm:LabeledElement +element MUST contain the Name attribute.

    + +

    It MUST contain a child expression +written either in attribute notation or element notation.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the labeled elements name.

    + +
    + +

    Example 82:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName">
    +<LabeledElement Name="CustomerFirstName" Path="FirstName" +/>
    +</Annotation>

    + +

     

    + +

    <Annotation +Term="org.example.display.DisplayName">
    + <LabeledElement Name="CustomerFirstName">
    + <Path>FirstName</Path>
    +</LabeledElement>
    +</Annotation>

    + +
    + +

    ##subsubsec Labeled Element Reference

    + +

    The labeled element reference expression MUST specify the qualified name of a labeled +element expression in scope and returns the value of the identified labeled +element expression as +its value.

    + +
    + +

    Expression edm:LabeledElementReference

    + +
    + +
    + +

    The edm:LabeledElementReference +element MUST contain the qualified name of a labeled element expression in its +body.

    + +
    + +

    Example 83:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName">
    + <LabeledElementReference>Model.CustomerFirstName</LabeledElementReference>
    +</Annotation>

    + +
    + +

    ##subsubsec Null

    + +

    The null expression indicates the absence of a value. The null +expression MAY be annotated.

    + +

    The null expression MUST be +written with element notation.

    + +
    + +

    Expression edm:Null

    + +
    + +
    + +

    The edm:Null element MAY contain edm:Annotation +elements.

    + +
    + +

    Example 84:

    + +
    + +

    <Annotation Term="org.example.display.DisplayName">
    +<Null/>
    +</Annotation>

    + +
    + +

    Example 85:

    + +
    + +

    <Annotation Term="@UI.Address">

    + +

    <Null>

    + +

    <Annotation Term="self.Reason" +String="Private" />

    + +

    </Null>

    + +

    </Annotation>

    + +
    + +

    ##subsubsec Record

    + +

    The record expression enables a new entity type or complex +type instance to be constructed.

    + +

    A record expression MAY specify the structured type of its +result, which MUST resolve to an entity type or complex type in scope. If not +explicitly specified, the type is derived from the expressions context.

    + +

    A record expression contains zero or more property value +expressions. For each single-valued structural or navigation property of the +record expressions type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if the +record expression is the value of an annotation for a term that has a base term whose type is structured and directly +or indirectly inherits from the type of its base term. In this case, property +values that already have been specified in the annotation for the base term or +its base term etc. need not be specified again.

    + +

    For collection-valued properties the absence of a property +value expression is equivalent to specifying an empty collection as its value.

    + +
    + +

    Expression edm:Record

    + +
    + +
    + +

    The edm:Record +element MAY contain the Type attribute and MAY +contain edm:PropertyValue elements.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is the qualified name of a structured type in scope.

    + +
    + +
    + +

    Element +edm:PropertyValue

    + +
    + +
    + +

    The edm:PropertyValue +element MUST contain the Property attribute, and it +MUST contain exactly one expression that MAY be provided using either element +notation or attribute notation.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Property

    + +
    + +
    + +

    The value of Property +is the name of a property of the type of the enclosing edm:Record expression.

    + +
    + +

    Example 86: this annotation morphs the entity type from +example 8 into a structured type with two structural properties GivenName and Surname and two +navigation properties DirectSupervisor and CostCenter. The first three properties simply rename properties +of the annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service

    + +
    + +

    <Annotation +Term="org.example.person.Employee">
    +<Record>
    + <Annotation Term="Core.Description" String="Annotation on +record" />

    + +

    <PropertyValue +Property="GivenName" Path="FirstName">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Annotation +on record member" />

    + +

    </PropertyValue>
    + <PropertyValue Property="Surname" Path="LastName" +/>

    + +

    <PropertyValue +Property="DirectSupervisor" Path="Manager" />

    + +

    <PropertyValue +Property="CostCenter">

    + +

    <UrlRef>

    + +

    <Apply +Function="odata.fillUriTemplate">

    + +

    <String>http://host/anotherservice/CostCenters('{ccid}')</String> +

    + +

    <LabeledElement +Name="ccid" Path="CostCenterID" />

    + +

    </Apply>

    + +

    </UrlRef>

    + +

    </PropertyValue>
    +</Record>
    +</Annotation>

    + +
    + +

    ##subsubsec URL +Reference

    + +

    The URL reference expression enables a value to be obtained +by sending a GET request.

    + +

    The URL reference expression MUST contain exactly one +expression of type Edm.String. Its value is treated +as a URL that MAY be relative or absolute; relative URIs are relative to the +URL of the document containing the URL reference expression, or relative to a +base URL specified in a format-specific way.

    + +

    The response body of the GET +request MUST be returned as the result of the URL reference expression. +The result of the edm:UrlRef expression MUST be +type compatible with the type expected by the surrounding element or +expression.

    + +
    + +

    Expression edm:UrlRef

    + +
    + +
    + +

    The edm:UrlRef +expression MAY be provided using element notation or attribute notation.

    + +

    Relative URLs are relative to the xml:base attribute, see [XML‑Base].

    + +

    In element notation it MAY contain edm:Annotation +elements.

    + +
    + +

    Example 87:

    + +
    + +

    <Annotation Term="org.example.person.Supplier"> +
    +<UrlRef>
    +<Apply Function="odata.fillUriTemplate">
    + <String>http://host/service/Suppliers({suppID})</String>
    + <LabeledElement Name="suppID">
    + <Apply Function="odata.uriEncode">
    + <Path>SupplierId</Path>
    + </Apply>
    + </LabeledElement>
    + </Apply>
    +</UrlRef>
    +</Annotation>

    + +

     

    + +

    <Annotation +Term="Core.LongDescription">

    + +

    +<UrlRef><String>http://host/wiki/HowToUse</String></UrlRef>

    + +

    </Annotation>

    + +

     

    + +

    <Annotation +Term="Core.LongDescription" UrlRef="http://host/wiki/HowToUse" +/>

    + +
    + + + +

    ##sec Identifier and Path Values

    + + + +

    ##subsec Namespace

    + +

    A namespace is a dot-separated sequence of simple identifiers with a maximum length of +511 Unicode characters (code points).

    + +

    ##subsec Simple +Identifier

    + +

    A simple identifier is a Unicode +character sequence with the following restrictions:

    + +
      +
    • It consists of at least one and at most 128 Unicode + characters (code points).
    • +
    • The first character MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L) or Letter + number (Nl).
    • +
    • The remaining characters MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L), Letter + number (Nl), Decimal number (Nd), Non-spacing mark (Mn), Combining + spacing mark (Mc), Connector punctuation (Pc), and Other, format + (Cf).
    • +
    + +

    Non-normatively speaking it starts with a letter or +underscore, followed by at most 127 letters, underscores or digits.

    + +

    ##subsec Qualified +Name

    + +

    For model elements that are direct children of a schema: the +namespace or alias of the schema that defines the model element, followed by a +dot and the name of the model element, see rule qualifiedTypeName +in OData‑ABNF.

    + +

    For built-in primitive types: +the name of the type, prefixed with Edm followed by +a dot.

    + +

    ##subsec Target Path

    + +

    Target paths are +used in attributes of CSDL elements to refer to other CSDL elements or their +nested child elements.

    + +

    The allowed path +expressions are:

    + +

    The qualified name of an entity container, followed by a +forward slash and the name of a container child element

    + +

    The target path of a +container child followed by a forward slash and one or more forward-slash +separated property, navigation property, or type-cast segments

    + +

    Example 88: Target expressions

    + +
    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp

    + +
    + + + +

    ##sec CSDL Examples

    + + + +

    Following are two basic examples of valid EDM models as +represented in CSDL. These examples demonstrate many of the topics covered +above.

    + +

    ##subsec Products +and Categories Example

    + +

    Example +89:

    + +
    + +

    <edmx:Edmx +xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"

    + +

    xmlns="http://docs.oasis-open.org/odata/ns/edm" +Version="4.0">
    + <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml">

    + +

    <edmx:Include +Namespace="Org.OData.Core.V1" Alias="Core">

    + +

    <Annotation +Term="Core.DefaultNamespace" />

    + +

    </edmx:Include>

    + +

    </edmx:Reference>

    + +

    <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.xml">

    + +

    <edmx:Include Alias="Measures" +Namespace="Org.OData.Measures.V1" />

    + +

    </edmx:Reference>

    + +

    <edmx:DataServices>
    + <Schema Namespace="ODataDemo">
    + <EntityType Name="Product" HasStream="true">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.Int32" +Nullable="false" />
    + <Property Name="Description" Type="Edm.String" >
    + <Annotation Term="Core.IsLanguageDependent" />

    + +

    </Property>

    + +

    <Property +Name="ReleaseDate" Type="Edm.Date" />
    + <Property Name="DiscontinuedDate" +Type="Edm.Date" />
    + <Property Name="Rating" Type="Edm.Int32" />
    + <Property Name="Price" Type="Edm.Decimal" +Scale="variable">
    + <Annotation Term="Measures.ISOCurrency" Path="Currency" +/>

    + +

    </Property>

    + +

    <Property +Name="Currency" Type="Edm.String" MaxLength="3" />

    + +

    <NavigationProperty +Name="Category" Type="ODataDemo.Category"

    + +

    Nullable="false" +Partner="Products" />

    + +

    <NavigationProperty +Name="Supplier" Type="ODataDemo.Supplier"

    + +

    +Partner="Products" />
    + </EntityType>
    + <EntityType Name="Category">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.Int32" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" +Nullable="false">
    + <Annotation Term="Core.IsLanguageDependent" />

    + +

    </Property>

    + +

    <NavigationProperty +Name="Products" Partner="Category"

    + +

    Type="Collection(ODataDemo.Product)">
    + <OnDelete Action="Cascade" />

    + +

    </NavigationProperty>
    + </EntityType>
    + <EntityType Name="Supplier">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.String" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" />
    + <Property Name="Address" +Type="ODataDemo.Address" Nullable="false" />
    + <Property Name="Concurrency" Type="Edm.Int32" +Nullable="false" />
    + <NavigationProperty Name="Products" +Partner="Supplier"

    + +

    Type="Collection(ODataDemo.Product)" +/>

    + +

    </EntityType>
    + <EntityType Name="Country">

    + +

    <Key>

    + +

    <PropertyRef Name="Code" +/>

    + +

    </Key>

    + +

    <Property Name="Code" +Type="Edm.String" MaxLength="2"

    + +

    +Nullable="false" />

    + +

    <Property +Name="Name" Type="Edm.String" />

    + +

    </EntityType>

    + +

    <ComplexType +Name="Address">
    + <Property Name="Street" Type="Edm.String" />
    + <Property Name="City" Type="Edm.String" />
    + <Property Name="State" Type="Edm.String" />
    + <Property Name="ZipCode" Type="Edm.String" />
    + <Property Name="CountryName" Type="Edm.String" />
    + <NavigationProperty Name="Country" +Type="ODataDemo.Country">

    + +

    <ReferentialConstraint +Property="CountryName"

    + +

    +ReferencedProperty="Name" />

    + +

    </NavigationProperty>

    + +

    </ComplexType>
    + <Function Name="ProductsByRating">
    + <Parameter Name="Rating" Type="Edm.Int32" />

    + +

    <ReturnType Type="Collection(ODataDemo.Product)" +/>
    + </Function>
    + <EntityContainer Name="DemoService">
    + <EntitySet Name="Products" +EntityType="ODataDemo.Product">
    + <NavigationPropertyBinding Path="Category" +Target="Categories" />

    + +

    </EntitySet>
    + <EntitySet Name="Categories" +EntityType="ODataDemo.Category">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    <Annotation +Term="Core.Description" String="Product Categories" />

    + +

    </EntitySet>
    + <EntitySet Name="Suppliers" +EntityType="ODataDemo.Supplier">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    +<NavigationPropertyBinding Path="Address/Country"

    + +

    Target="Countries" +/>

    + +

    <Annotation Term="Core.OptimisticConcurrency">

    + +

    <Collection>

    + +

    +<PropertyPath>Concurrency</PropertyPath>

    + +

    </Collection>

    + +

    </Annotation>

    + +

    </EntitySet>
    + <Singleton Name="MainSupplier" +Type="self.Supplier">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    <Annotation +Term="Core.Description" String="Primary Supplier" />

    + +

    </Singleton>

    + +

    <EntitySet +Name="Countries" EntityType="ODataDemo.Country" />

    + +

    <FunctionImport +Name="ProductsByRating" EntitySet="Products"

    + +

    Function="ODataDemo.ProductsByRating" +/>
    + </EntityContainer>
    + </Schema>
    + </edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    ##subsec Annotations for Products and +Categories Example

    + +

    Example 90:

    + +
    + +

    <edmx:Edmx +xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    + Version="4.01">
    + <edmx:Reference Uri="http://host/service/$metadata">
    + <edmx:Include Namespace="ODataDemo" Alias="target" +/>

    + +

    </edmx:Reference>

    + +

    <edmx:Reference Uri="http://somewhere/Vocabulary/V1">

    + +

    <edmx:Include Alias="Vocabulary1" +Namespace="Some.Vocabulary.V1" />

    + +

    </edmx:Reference>

    + +

    <edmx:DataServices>
    + <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"
    + Namespace="External.Annotations">
    + <Annotations Target="ODataDemo.Supplier">
    + <Annotation Term="Vocabulary1.EMail">
    + <Null />
    + </Annotation>
    + <Annotation Term="Vocabulary1.AccountID" Path="ID" +/>
    + <Annotation Term="Vocabulary1.Title" String="Supplier +Info" />
    + <Annotation Term="Vocabulary1.DisplayName">
    + <Apply Function="odata.concat">
    + <Path>Name</Path>
    + <String> in </String>
    + <Path>Address/CountryName</Path>
    + </Apply>
    + </Annotation>
    + </Annotations>
    + <Annotations Target="ODataDemo.Product">

    + +

    <Annotation Term="Vocabulary1.Tags">

    + +

    <Collection>

    + +

    <String>MasterData</String>

    + +

    </Collection>

    + +

    </Annotation>

    + +

    </Annotations>

    + +

    </Schema>

    + +

    </edmx:DataServices>
    +</edmx:Edmx>

    + +
    + + + +

    ##sec Conformance

    + + + +

    Conforming services MUST follow all rules of this +specification document for the types, sets, functions, actions, containers and +annotations they expose.

    + +

    In addition, conforming services MUST NOT return 4.01 CSDL +constructs for requests made with OData-MaxVersion:4.0.

    + +

    Specifically, they

    + +

    1. MUST NOT include properties in derived types that overwrite a property +defined in the base type

    + +

    2. MUST NOT include Edm.Untyped

    + +

    3. MUST NOT use path syntax added with 4.01

    + +

    4. MUST NOT use Edm.ModelElementPath and Edm.AnyPropertyPath

    + +

    5. MUST NOT specify referential +constraints to complex types and navigation properties

    + +

    6. MUST NOT include a non-abstract entity type with no inherited or defined +entity key

    + +

    7. MUST NOT include the Core.DefaultNamespace annotation +on included schemas

    + +

    8. MUST NOT return the Unicode facet for terms, parameters, and return +types

    + +

    9. MUST NOT include collections of Edm.ComplexType or +Edm.Untyped

    + +

    10. MUST NOT specify a key as a property of a related entity

    + +

    11. SHOULD NOT include new/unknown values for the AppliesTo +attribute

    + +

    12. SHOULD specify the Nullable facet for +collections

    + +

    13. MAY include new CSDL annotations

    + +

    In addition, OData 4.01 services:

    + +

    14. MUST specify the Nullable facet for +collections

    + +

    15. SHOULD NOT have identifiers within a uniqueness scope (e.g. a schema, a +structural type or an entity container) that differ only by case

    + +

    Conforming clients MUST be prepared to consume a model that +uses any or all constructs defined in this specification, including custom +annotations, and MUST ignore any elements or attributes not defined in this +version of the specification.

    + + + +

    Appendix A. Acknowledgments

    + + + +

    The contributions of the OASIS OData Technical Committee +members, enumerated in OData‑Protocol, +are gratefully acknowledged.

    + + + +

    Appendix +B. Table of XML Elements and +Attributes

    + + + + + +
    +
    + +
    + +

    Element edmx:Edmx. 15

    + +

    Attribute Version. 15

    + +

    Element edmx:DataServices. 15

    + +

    Element edmx:Reference. 15

    + +

    Attribute Uri. 16

    + +

    Element edmx:Include. 16

    + +

    Attribute Namespace. 16

    + +

    Attribute Alias. 17

    + +

    Element edmx:IncludeAnnotations. 17

    + +

    Attribute TermNamespace. 18

    + +

    Attribute Qualifier. 18

    + +

    Attribute TargetNamespace. 18

    + +

    Element edm:Schema. 19

    + +

    Attribute Namespace. 19

    + +

    Attribute Alias. 19

    + +

    Element edm:Annotations. 20

    + +

    Attribute Target. 20

    + +

    Attribute Qualifier. 20

    + +

    Element edm:EntityType. 21

    + +

    Attribute Name. 21

    + +

    Attribute BaseType. 21

    + +

    Attribute Abstract. 22

    + +

    Attribute OpenType. 22

    + +

    Attribute HasStream. 22

    + +

    Element edm:Key. 23

    + +

    Element edm:PropertyRef. 23

    + +

    Attribute Name. 23

    + +

    Attribute Alias. 24

    + +

    Element edm:Property. 25

    + +

    Attribute Name. 25

    + +

    Attribute Type. 25

    + +

    Attribute Nullable. 26

    + +

    Attribute MaxLength. 26

    + +

    Attribute Precision. 27

    + +

    Attribute Scale. 27

    + +

    Attribute Unicode. 28

    + +

    Attribute SRID. 28

    + +

    Attribute DefaultValue. 28

    + +

    Element edm:NavigationProperty. 29

    + +

    Attribute Name. 29

    + +

    Attribute Type. 30

    + +

    Attribute Nullable. 30

    + +

    Attribute Partner. 30

    + +

    Attribute ContainsTarget. 31

    + +

    Element edm:ReferentialConstraint. 31

    + +

    Attribute Property. 32

    + +

    Attribute ReferencedProperty. 32

    + +

    Element edm:OnDelete. 33

    + +

    Attribute Action. 33

    + +

    Element edm:ComplexType. 34

    + +

    Attribute Name. 34

    + +

    Attribute BaseType. 34

    + +

    Attribute Abstract. 35

    + +

    Attribute OpenType. 35

    + +

    Element edm:EnumType. 36

    + +

    Attribute Name. 36

    + +

    Attribute UnderlyingType. 36

    + +

    Attribute IsFlags. 36

    + +

    Element edm:Member. 37

    + +

    Attribute Name. 37

    + +

    Attribute Value. 37

    + +

    Element edm:TypeDefinition. 39

    + +

    Attribute Name. 39

    + +

    Attribute UnderlyingType. 39

    + +

    Element edm:Action. 40

    + +

    Attribute Name. 40

    + +

    Element edm:Function. 41

    + +

    Attribute Name. 41

    + +

    Attribute IsBound. 41

    + +

    Attribute EntitySetPath. 41

    + +

    Attribute IsComposable. 42

    + +

    Element edm:ReturnType. 42

    + +

    Attribute Type. 42

    + +

    Attribute Nullable. 42

    + +

    Element edm:Parameter. 43

    + +

    Attribute Name. 43

    + +

    Attribute Type. 43

    + +

    Attribute Nullable. 43

    + +

    Element edm:EntityContainer. 44

    + +

    Attribute Name. 44

    + +

    Attribute Extends. 45

    + +

    Element edm:EntitySet. 45

    + +

    Attribute Name. 45

    + +

    Attribute EntityType. 45

    + +

    Attribute IncludeInServiceDocument. 46

    + +

    Element edm:Singleton. 46

    + +

    Attribute Name. 46

    + +

    Attribute Type. 46

    + +

    Attribute Nullable. 46

    + +

    Element edm:NavigationPropertyBinding. 47

    + +

    Attribute Path. 47

    + +

    Attribute Target. 47

    + +

    Element edm:ActionImport. 48

    + +

    Attribute Name. 48

    + +

    Attribute Action. 48

    + +

    Attribute EntitySet. 48

    + +

    Element edm:FunctionImport. 48

    + +

    Attribute Name. 48

    + +

    Attribute Function. 48

    + +

    Attribute EntitySet. 48

    + +

    Attribute IncludeInServiceDocument. 49

    + +

    Element edm:Term. 51

    + +

    Attribute Name. 51

    + +

    Attribute Type. 51

    + +

    Attribute DefaultValue. 51

    + +

    Attribute BaseTerm. 51

    + +

    Attribute AppliesTo. 53

    + +

    Element edm:Annotation. 53

    + +

    Attribute Term. 53

    + +

    Attribute Qualifier. 54

    + +

    Expression edm:Binary. 56

    + +

    Expression edm:Bool. 56

    + +

    Expression edm:Date. 57

    + +

    Expression edm:DateTimeOffset. 57

    + +

    Expression edm:Decimal. 57

    + +

    Expression edm:Duration. 58

    + +

    Expression edm:EnumMember. 58

    + +

    Expression edm:Float. 58

    + +

    Expression edm:Guid. 59

    + +

    Expression edm:Int. 59

    + +

    Expression edm:String. 59

    + +

    Expression edm:TimeOfDay. 60

    + +

    Expression edm:AnnotationPath. 63

    + +

    Expression edm:ModelElementPath. 63

    + +

    Expression edm:NavigationPropertyPath. 63

    + +

    Expression edm:PropertyPath. 64

    + +

    Expression edm:Path. 64

    + +

    Expressions edm:And and edm:Or. 65

    + +

    Expression edm:Not. 65

    + +

    Expressions edm:Eq, edm:Ne, +edm:Gt, edm:Ge, edm:Lt, +edm:Le, edm:Has, and edm:In 65

    + +

    Expression edm:Neg. 67

    + +

    Expressions edm:Add, edm:Sub, +edm:Mul, edm:Div, edm:DivBy, +and edm:Mod 67

    + +

    Expression edm:Apply. 68

    + +

    Attribute Function. 68

    + +

    Expression edm:Cast. 69

    + +

    Attribute Type. 69

    + +

    Expression edm:Collection. 70

    + +

    Expression edm:If. 70

    + +

    Expression edm:IsOf. 71

    + +

    Attribute Type. 71

    + +

    Expression edm:LabeledElement. 71

    + +

    Attribute Name. 71

    + +

    Expression edm:LabeledElementReference. 72

    + +

    Expression edm:Null. 72

    + +

    Expression edm:Record. 73

    + +

    Attribute Type. 73

    + +

    Element edm:PropertyValue. 73

    + +

    Attribute Property. 73

    + +

    Expression edm:UrlRef. 74

    + +

     

    + +
    + +
    +
    + +
    + + + +

    Appendix C. Revision +History

    + + + +

     

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Revision

    +
    +

    Date

    +
    +

    Editor

    +
    +

    Changes Made

    +
    +

    Working Draft 01

    +
    +

    2016-09-07

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Imported content from 4.0 Errata 3 specification and + integrated initial 4.01 features

    +
    +

    Committee Specification Draft 01

    +
    +

    2016-12-08

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Integrated 4.01 features

    +
    +

    Committee Specification Draft 02

    +
    +

    2017-06-08

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated normative text from former OData Part 3: CSDL

    +
    +

    Committee Specification Draft 03

    +
    +

    2017-09-22

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +
    +

    Committee Specification Draft 04

    +
    +

    2017-11-10

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +

    Stable order of action and function parameters

    +
    +

    Committee Specification 01

    +
    +

    2017-12-19

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-Material Changes

    +
    +

    Committee Specification Draft 05

    +
    +

    2019-06-21

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    External targeting for annotations on action/function + overloads, parameters, and return types

    +

    Key and index segments for path expressions in annotations

    +

    Nullable singletons

    +
    +

    Committee Specification Draft 06

    +
    +

    2019-09-20

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Redefining entity sets and singletons when extending + entity containers

    +
    +

    Committee Specification 02

    +
    +

    2019-11-05

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    +

    Candidate OASIS Standard 01

    +
    +

    2020-01-15

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    +

    Candidate OASIS Standard 02

    +
    +

    2020-04-09

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    + +

     

    + +
    + + + + diff --git a/odata-csdl/temp/odata-csdl-xml-v4.01-os-raw.md b/odata-csdl/temp/odata-csdl-xml-v4.01-os-raw.md new file mode 100644 index 000000000..0bc53e078 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-xml-v4.01-os-raw.md @@ -0,0 +1,7066 @@ +# ##sec Introduction + +OData services are described in terms of an [Entity +Model](#EntityModel). The Common Schema Definition Language (CSDL) +defines a representation of the entity data model exposed by an OData +service using the Extensible Markup Language (XML) 1.1 (Second Edition) +[**\[XML‑1.1\]**](#BMXML) with further building blocks from the W3C XML +Schema Definition Language (XSD) 1.1 as described in +[**\[XML‑Schema‑1\]**](#BMXMLSchema1) and +[**\[XML‑Schema‑2\]**](#BMXMLSchema2). + +## ##subsec IPR Policy + +This specification is provided under the [RF on RAND +Terms](https://www.oasis-open.org/policies-guidelines/ipr#RF-on-RAND-Mode) +Mode of the [OASIS IPR +Policy](https://www.oasis-open.org/policies-guidelines/ipr), the mode +chosen when the Technical Committee was established. For information on +whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing +terms, please refer to the Intellectual Property Rights section of the +TC's web page (). + +## ##subsec Terminology + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", +"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this +document are to be interpreted as described in [RFC2119](#BMRFC2119). + +## ##subsec Normative References + +[\[ECMAScript\]]{.Refterm}[[         +]{style="font-weight:normal"}]{.Refterm}*ECMAScript 2016 Language +Specification, 7^th^ Edition,* June 2016. Standard ECMA-262. +. + +[\[EPSG\]                   ]{.Refterm}European Petroleum Survey Group +(EPSG). . + +[\[OData-ABNF\]]{.Refterm}         *OData ABNF Construction Rules +Version 4.01*.\ +See link in "Additional artifacts" section on cover +page[.]{style="color: +#222222"}[ ]{.Refterm} + +**[\[OData-EDM]{lang="DE" style="color:windowtext"}**[**[\]]{lang="DE" +style="color:windowtext"}**]{.Hyperlink1}[           *OData EDM XML +Schema*]{lang="DE" style="color:windowtext"}[.\ +]{lang="DE"}See link in "Additional artifacts" section on cover page. + +**[\[OData-EDMX]{lang="NL" style="color:windowtext"}**[**[\]]{lang="NL" +style="color:windowtext"}**]{.Hyperlink1}[        *OData EDMX XML +Schema*]{lang="NL" style="color:windowtext"}[.\ +]{lang="NL"}See link in "Additional artifacts" section on cover page. + +OData-CSDLJSON            *OData Common Schema Definition Language +(CSDL) JSON Representation Version 4.01*. See link in "Related work" +section on cover page. + +**\[OData-JSON**[**\]**]{.Hyperlink1}         *OData JSON Format Version +4.01.*\ +See link in "Related work" section on cover page. + +[\[OData-Protocol\]]{.Refterm}     *OData Version 4.01 Part 1: +Protocol*.\ +See link in "Additional artifacts" section on cover +page[.]{style="color: +#222222"} + +OData-URL           *OData Version 4.01 Part 2: URL Conventions*.\ +See link in "Additional artifacts" section on cover page. + +OData-VocCore     *OData Vocabularies Version 4.0: Core Vocabulary.*\ +See link in "Related work" section on cover page.[[ +]{style="font-size:8.0pt;color:windowtext; +background:yellow"}]{.MsoCommentReference} + +OData-VocMeasures         *OData Vocabularies Version 4.0: Measures +Vocabulary.*\ +See link in "Related work" section on cover page.[[ +]{style="font-size:8.0pt;color:windowtext; +background:yellow"}]{.MsoCommentReference} + +OData-VocValidation        *OData Vocabularies Version 4.0: Validation +Vocabulary.*\ +See link in "Related work" section on cover page.[[ +]{style="font-size:8.0pt;color:windowtext; +background:yellow"}]{.MsoCommentReference} + +[\[RFC2119\]]{.Refterm}               Bradner, S., "Key words for use in +RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. +. + +RFC6570               Gregorio, J., Fielding, R., Hadley, M., +Nottingham, M., and D. Orchard, "URI Template", RFC 6570, March 2012. +. + +[\[XML-1.1\]]{.Refterm}                Extensible Markup Language (XML) +1.1 (Second Edition), F. Yergeau, E. Maler, J. Cowan, T. Bray, C. M. +Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August +2006,\ +.\ +Latest version available at . + +**\[XML-Base\]**             XML Base (Second Edition), J. Marsh, R. +Tobin, Editors, W3C Recommendation, 28 January 2009,\ +.\ +Latest version available at .  + +[\[XML-Schema-1\]]{.Refterm}     W3C XML Schema Definition Language +(XSD) 1.1 Part 1: Structures, D. Beech, M. Maloney, C. M. +Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, Editors, W3C +Recommendation, 5 April 2012, +.\ +Latest version available at . + +[\[XML-Schema-2\]]{.Refterm}     W3C XML Schema Definition Language +(XSD) 1.1 Part 2: DatatypesW3C XML Schema Definition Language (XSD) 1.1 +Part 2: Datatypes, D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. +Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April +2012, .\ +Latest version available at . + +## ##subsec Typographical Conventions + +Keywords defined by this specification use this `monospaced` font. + +`Normative source code uses this paragraph style.` + +Some sections of this specification are illustrated with non-normative +examples. + +Example 1: text describing an example uses this paragraph style + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +Non-normative examples use this paragraph style. +::: + +All examples in this document are non-normative and informative only. + +Representation-specific text is indented and marked with vertical lines. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Representation-Specific Headline +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Normative representation-specific text +::: + +All other text is normative unless otherwise labeled. + +# ##sec XML Representation + +OData CSDL XML is a full representation of the OData Common Schema +Definition Language in the Extensible Markup Language (XML) 1.1 (Second +Edition) [**\[XML‑1.1\]**](#BMXML) with further building blocks from the +W3C XML Schema Definition Language (XSD) 1.1 as described in +[**\[XML‑Schema‑1\]**](#BMXMLSchema1) and +[**\[XML‑Schema‑2\]**](#BMXMLSchema2). + +It is an alternative to the CSDL JSON representation defined in +**\[**[**OData-CSDLJSON**](#BMCSDLJSON)**\]** and neither adds nor +removes features. + +## ##subsec Requesting the XML Representation + +The OData CSDL XML representation can be requested using the `$format` +query option in the request URL with the media type `application/xml`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `xml` which MUST NOT be followed by media type parameters. + +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/xml`, optionally followed by +media type parameters. + +If specified, `$format` overrides any value specified in the `Accept` +header. + +The response MUST contain the `Content-Type` header with a value of +`application/xml`, optionally followed by media type parameters. + +This specification does not define additional parameters for the media +type `application/xml`. + +## ##subsec XML Namespaces + +In addition to the default XML namespace, the elements and attributes +used to describe the entity model of an OData service are defined in one +of the following namespaces. + +### ##subsubsec Namespace EDMX + +Elements and attributes associated with the top-level wrapper that +contains the CSDL used to define the entity model for an OData Service +are qualified with the Entity Data Model for Data Services Packaging +namespace: + +[[· +]{style="font-family:Symbol"}]{.Datatype}`http://docs.oasis-open.org/odata/ns/edmx` + +Prior versions of OData used the following namespace for EDMX: + +[[· ]{style="font-family:Symbol"}]{.Datatype}EDMX version 1.0: +`http://schemas.microsoft.com/ado/2007/06/edmx` + +They are non-normative for this specification. + +In this specification the namespace prefix `edmx` is used to represent +the Entity Data Model for Data Services Packaging namespace, however the +prefix name is not prescriptive. + +### ##subsubsec Namespace EDM + +Elements and attributes that define the entity model exposed by the +OData Service are qualified with the Entity Data Model namespace: + +[[· +]{style="font-family:Symbol"}]{.Datatype}`http://docs.oasis-open.org/odata/ns/edm` + +Prior versions of CSDL used the following namespaces for EDM: + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 1.0: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2006/04/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 1.1: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2007/05/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 1.2: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2008/01/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 2.0: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2008/09/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 3.0: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2009/11/edm]{lang="DE"}]{.Datatype} + +They are non-normative for this specification. + +In this specification the namespace prefix `edm` is used to represent +the Entity Data Model namespace, however the prefix name is not +prescriptive. + +## ##subsec XML Schema Definitions + +This specification contains normative XML schemas for the EDMX and EDM +namespaces; see [OData‑EDMX](#BMEDMX) and +[OData‑EDM](#BMEDM)[.]{style="color:#222222"} + +These XML schemas only define the shape of a well-formed CSDL XML +document and are not descriptive enough to define what a correct CSDL +XML document MUST be in every imaginable use case. This specification +document defines additional rules that correct CSDL XML documents MUST +fulfill. In case of doubt on what makes a CSDL XML document correct the +rules defined in this specification document take precedence. + +## ##subsec XML Document Order + +Client libraries MUST retain the document order of XML elements for CSDL +XML documents because for some elements the order of child elements is +significant. This includes, but is not limited to, [members of +enumeration types](#EnumerationTypeMember) and items within a +[collection expression](#Collection). + +OData does not impose any ordering constraints on XML attributes within +XML elements. + +# ##sec Entity Model + +An OData service exposes a single entity model. This model may be +distributed over several [schemas](#Schema), and these schemas may be +distributed over several physical locations. + +A service is defined by a single CSDL document which can be accessed by +sending a `GET` request to `/$metadata`. This document is +called the metadata document. It may reference other CSDL documents. + +The metadata document contains a single [entity +container](#EntityContainer) that defines the resources exposed by this +service. This entity container MAY [extend](#ExtendinganEntityContainer) +an entity container defined in a [referenced document](#Reference). + +The *model* of the service consists of all CSDL constructs used in its +entity containers. + +The *scope* of a CSDL document is the document itself and all schemas +[included](#IncludedSchema) from directly [referenced +documents](#Reference). All entity types, complex types and other named +elements *in scope* (that is, defined in the document itself or a schema +of a directly referenced document) can be accessed from a referencing +document by their qualified names. This includes the [built-in +primitive](#PrimitiveTypes) and [abstract types](#BuiltInAbstractTypes). + +Referencing another document may alter the model defined by the +referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, +then an [entity set](#EntitySet) of the service defined by the +referencing document may return entities of the derived type. This is +identical to the behavior if the derived type had been defined directly +in the referencing document. + +Note: referencing documents is not recursive. Only named elements +defined in directly referenced documents can be used within the schema. +However, those elements may in turn include elements defined in schemas +referenced by their defining schema. + +## ##subsec Nominal Types + +A nominal type has a name that MUST be a [simple +identifier](#SimpleIdentifier). Nominal types are referenced using their +[qualified name](#QualifiedName). The qualified type name MUST be unique +within a model as it facilitates references to the element from other +parts of the model. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +## ##subsec Structured Types + +Structured types are composed of other model elements. Structured types +are common in entity models as the means of representing entities and +structured properties in an OData service. [Entity types](#EntityType) +and [complex types](#ComplexType) are both structured types. + +Structured Types are composed of zero or more [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty). + +[Open entity types](#OpenEntityType) and [open complex +types](#OpenComplexType) allow properties to be added dynamically to +instances of the open type. + +## ##subsec Primitive Types + +Structured types are composed of other structured types and primitive +types. OData defines the following primitive types: + + **Type** **Meaning** + -------------------------------- ---------------------------------------------------------------- + `Edm.Binary` Binary data + `Edm.Boolean` Binary-valued logic + `Edm.Byte` Unsigned 8-bit integer + `Edm.Date` Date without a time-zone offset + `Edm.DateTimeOffset` Date and time with a time-zone offset, no leap seconds + `Edm.Decimal` Numeric values with decimal representation + `Edm.Double` IEEE 754 binary64 floating-point number (15-17 decimal digits) + `Edm.Duration` Signed duration in days, hours, minutes, and (sub)seconds + `Edm.Guid` 16-byte (128-bit) unique identifier + `Edm.Int16 ` Signed 16-bit integer + `Edm.Int32` Signed 32-bit integer + `Edm.Int64` Signed 64-bit integer + `Edm.SByte` Signed 8-bit integer + `Edm.Single` IEEE 754 binary32 floating-point number (6-9 decimal digits) + `Edm.Stream` Binary data stream + `Edm.String` Sequence of characters + `Edm.TimeOfDay` Clock time 00:00-23:59:59.999999999999 + `Edm.Geography` Abstract base type for all Geography types + `Edm.GeographyPoint` A point in a round-earth coordinate system + `Edm.GeographyLineString` Line string in a round-earth coordinate system + `Edm.GeographyPolygon` Polygon in a round-earth coordinate system + `Edm.GeographyMultiPoint` Collection of points in a round-earth coordinate system + `Edm.GeographyMultiLineString` Collection of line strings in a round-earth coordinate system + `Edm.GeographyMultiPolygon` Collection of polygons in a round-earth coordinate system + `Edm.GeographyCollection` Collection of arbitrary Geography values + `Edm.Geometry` Abstract base type for all Geometry types + `Edm.GeometryPoint` Point in a flat-earth coordinate system + `Edm.GeometryLineString` Line string in a flat-earth coordinate system + `Edm.GeometryPolygon` Polygon in a flat-earth coordinate system + `Edm.GeometryMultiPoint` Collection of points in a flat-earth coordinate system + `Edm.GeometryMultiLineString` Collection of line strings in a flat-earth coordinate system + `Edm.GeometryMultiPolygon` Collection of polygons in a flat-earth coordinate system + `Edm.GeometryCollection` Collection of arbitrary Geometry values + +`Edm.Date` and `Edm.DateTimeOffset` follow +[**\[XML‑Schema‑2\]**](#BMXMLSchema2) and use the proleptic Gregorian +calendar, allowing the year `0000` (equivalent to 1 BCE) and negative +years (year `-0001` being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying +persistency layer, e.g. SQL only supports years `0001` to `9999`. + +`Edm.Decimal with a `[`Scale`](#Scale)` value of floating`, +`Edm.Double`, and `Edm.Single` allow the special numeric values `-INF`, +`INF`, and `NaN`. + +`Edm.Stream` is a primitive type that can be used as a property of an +[entity type](#EntityType) or [complex type](#ComplexType), the +underlying type for a [type definition](#TypeDefinition), or the binding +parameter or return type of an [action](#Action) or +[function](#Function). `Edm.Stream`, or a type definition whose +underlying type is `Edm.Stream`, cannot be used in collections or for +non-binding parameters to functions or actions. + +Some of these types allow [facets](#TypeFacets), defined in section +"[Type Facets](#TypeFacets)". + +See rule `primitiveLiteral` in [OData‑ABNF](#ODataABNF) for the +representation of primitive type values in URLs and +[OData‑JSON](#ODataJSON) for the representation in requests and +responses. + +## ##subsec Built-In Abstract Types + +The following built-in abstract types can be used within a model: + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.PrimitiveType ` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.ComplexType` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.EntityType` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.Untyped` + +Conceptually, these are the abstract base types for primitive types +(including type definitions and enumeration types), complex types, +entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except: + +[· ]{style="font-family:Symbol"}`Edm.EntityType` + +- - cannot be used as the type of a singleton in an entity container + because it doesn't define a structure, which defeats the purpose + of a singleton. + - cannot be used as the type of an entity set because all entities + in an entity set must have the same key fields to uniquely + identify them within the set. + - cannot be the base type of an entity type or complex type.  + +[· ]{style="font-family:Symbol"}`Edm.ComplexType` + +- - cannot be the base type of an entity type or complex type.  + +[· ]{style="font-family:Symbol"}`Edm.PrimitiveType` + +- - cannot be used as the type of a key property of an entity type + or as the underlying type of an enumeration type. + - cannot be used as the underlying type of a type definition in a + CSDL document with a version of `4.0`. + - can be used as the underlying type of a type definition in a + CSDL document with a version of `4.01` or greater. + +[· ]{style="font-family:Symbol"}`Edm.Untyped` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + - cannot be used as the type of a key property of an entity type. + - cannot be the base type of an entity type or complex type.  + - cannot be used as the underlying type of a type definition or + enumeration type. + +[[· +]{style="font-family:Symbol"}]{.Datatype}`Collection(Edm.PrimitiveType)` + +- - cannot be used as the type of a property or term. + - cannot be used as the type of a parameter or the return type of + an action or function. + +[· ]{style="font-family:Symbol"}`Collection(Edm.Untyped)` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + +## ##subsec Built-In Types for defining Vocabulary Terms + +[Vocabulary terms](#Term) can, in addition, use + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.AnnotationPath` + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.PropertyPath` + +[[· +]{style="font-family:Symbol"}]{.Datatype}`Edm.NavigationPropertyPath ` + +[[· +]{style="font-family:Symbol"}]{.Datatype}`Edm.AnyPropertyPath `(`Edm.PropertyPath `or +`Edm.NavigationPropertyPath`) + +[[· ]{style="font-family:Symbol"}]{.Datatype}`Edm.ModelElementPath `(any +model element, including +`Edm.AnnotationPath`,` Edm.NavigationPropertyPath`, and +`Edm.PropertyPath`) + +as the type of a primitive term, or the type of a property of a complex +type (recursively) that is exclusively used as the type of a term. See +section "[Path Expressions](#PathExpressions)" for details. + +## ##subsec Annotations + +Many parts of the model can be decorated with additional information +using [annotations](#Annotation). Annotations are identified by their +term name and an optional qualifier that allows applying the same term +multiple times to the same model element. + +A model element MUST NOT specify more than one annotation for a given +combination of term and qualifier. + +# ##sec CSDL XML Document + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edmx:Edmx` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edmx:Edmx` element is the root element of a CSDL XML document. It +MUST contain the `Version` attribute and it MUST contain exactly one +`edmx:DataServices` element. + +It MAY contain [`edmx:Reference`](#Reference) elements to reference +other CSDL documents. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Version` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `Version` attribute specifies the OData protocol version of the +service. For OData 4.0 responses the value of this attribute MUST be +`4.0.` For OData 4.01 responses the value of this attribute MUST be +`4.01.` Services MUST return an OData 4.0 response if the request was +made with an `OData-MaxVersion `header with a value of `4.0`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edmx:DataServices` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edmx:DataServices` element MUST contain one or more +[`edm:Schema`](#Schema) elements which define the schemas exposed by the +OData service. +::: + +Example 2: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`\ +  \\ +    ...\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Reference + +A reference to an external CSDL document allows to bring part of the +referenced document's content into the scope of the referencing +document. + +A reference MUST specify a URI that uniquely identifies the referenced +document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be +absolute or relative URI; relative URLs are relative to the URL of the +document containing the reference, or relative to a base URL specified +in a format-specific way. + +A reference MAY be annotated. + +The +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation, defined in [OData-VocCore](#ODataVocCore), MAY be used to +indicate a particular version of the referenced schema. If the +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation is present, the `$schemaversion` system query option, defined +[OData‑Protocol](#ODataProtocol), SHOULD be used when retrieving the +referenced schema document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edmx:Reference` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edmx:Reference` element specifies external CSDL documents +referenced by the referencing document. The child elements +[`edmx:Include`](#IncludedSchema) and +[`edmx:IncludeAnnotations`](#IncludedAnnotations) specify which parts of +the referenced document are available for use in the referencing +document. + +The `edmx:Reference` element MUST contain the `Uri` attribute, and it +MUST contain at least one [`edmx:Include`](#IncludedSchema) or +[`edmx:IncludeAnnotations`](#IncludedAnnotations) child element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Uri` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Uri` is an absolute or relative URI; relative URIs are +relative to the `xml:base` attribute, see +[**\[XML‑Base\]**](#BMXMLBase). +::: + +Example 3: references to other CSDL documents + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\\ +  \]{style="color:black"}]{.Datatype} + +`    …` + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +`    …` + +[[  \\ +  \\ +    ...]{style="color:black"}]{.Datatype} + +[[  \\ +  \...\\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Included Schema + +A reference MAY include zero or more schemas from the referenced +document. + +The included schemas are identified via their [namespace](#Namespace). +The same namespace MUST NOT be included more than once, even if it is +declared in more than one referenced document. + +When including a schema, a [simple identifier](#SimpleIdentifier) value +MAY be specified as an alias for the schema that is used in qualified +names instead of the namespace. For example, an alias of `display` might +be assigned to the namespace `org.example.vocabularies.display`. An +alias-qualified name is resolved to a fully qualified name by examining +aliases for included schemas and schemas defined within the document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +If an included schema specifies an alias, the alias MAY be used instead +of the namespace within qualified names to identify model elements of +the included schema. An alias only provides a more convenient notation, +allowing a short string to be substituted for a long namespace. Every +model element that can be identified via an alias-qualified name can +alternatively be identified via its full namespace-qualified name. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +An alias is only valid within the document in which it is declared; a +referencing document may define its own aliases for included schemas. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edmx:Include` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edmx:Include` element specifies a schema to include from the +referenced CSDL document. It MUST provide the `Namespace` attribute and +it MAY provide the `Alias` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Namespace` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Namespace` is the namespace of a schema defined in the +referenced CSDL document. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Alias` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Alias` is a [simple identifier](#SimpleIdentifier) that +can be used in qualified names instead of the namespace. +::: + +Example 4: references to entity models containing definitions of +vocabulary terms + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\\ +  \]{style="color:black"}]{.Datatype} + +`    ` + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +`    ` + +`      ` + +`    ` + +[[  \\ +  \\ +    \]{style="color:black"}]{.Datatype} + +[[  \\ +  \...\\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Included Annotations + +In addition to including whole schemas with all model constructs defined +within that schema, annotations can be included with more flexibility. + +Annotations are selectively included by specifying the +[namespace](#Namespace) of the annotations' term. Consumers can opt not +to inspect the referenced document if none of the term namespaces is of +interest for the consumer. + +In addition, the [qualifier](#Qualifier) of annotations to be included +MAY be specified. For instance, a service author might want to supply a +different set of annotations for various device form factors. If a +qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of +the target namespace, if present) SHOULD be included. If no qualifier is +specified, all annotations within the referenced document from the +specified term namespace (taking into account the target namespace, if +present) SHOULD be included. + +The qualifier also provides consumers insight about what qualifiers are +present in the referenced document. If the consumer is not interested in +that particular qualifier, the consumer can opt not to inspect the +referenced document. + +In addition, the namespace of the annotations' [target](#Target) MAY be +specified. If a target namespace is specified, only those annotations +which apply a term form the specified term namespace to a model element +of the target namespace (with the specified qualifier, if present) +SHOULD be included. If no target namespace is specified, all annotations +within the referenced document from the specified term namespace (taking +into account the qualifier, if present) SHOULD be included. + +The target namespace also provides consumers insight about what +namespaces are present in the referenced document. If the consumer is +not interested in that particular target namespace, the consumer can opt +not to inspect the referenced document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edmx:IncludeAnnotations` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edmx:IncludeAnnotations` element specifies the annotations to +include from the referenced CSDL document. If no +`edmx:IncludeAnnotations` element is specified, a client MAY ignore all +annotations in the referenced document that are not explicitly used in +an [`edm:Path`](#ValuePath) expression of the referencing document. + +The `edmx:IncludeAnnotations` element MUST provide the `TermNamespace` +attribute, and it MAY provide the `Qualifier` and `TargetNamespace` +attribute. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `TermNamespace` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `TermNamespace` is a namespace. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Qualifier` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `TargetNamespace` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `TargetNamespace` is a namespace. +::: + +Example 5: reference documents that contain annotations + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\\ +  \\ +    \\ +    \\ +    \\ +    \\ +  \\ +  \...\\ +\]{style="color:black"}]{.Datatype} +::: + +The following annotations from `http://odata.org/ann/b` are included: + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that use a +term from the `org.example.validation` namespace, and + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that use a +term from the `org.example.display` namespace and specify a `Tablet` +qualifier and + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Sales` namespace and + +[· ]{style="font-family:Symbol;font-style:normal"}Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Person` namespace and specify a `Tablet` qualifier. + +# ##sec Schema + +One or more schemas describe the entity model exposed by an OData +service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms. + +A schema is identified by a [namespace](#Namespace). Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally +unique. A schema cannot span more than one document. + +The schema's namespace is combined with the name of elements in the +entity model to create unique [qualified names](#QualifiedName), so +identifiers that are used to name types MUST be unique within a +namespace to prevent ambiguity. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +The `namespace` MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[[Element +]{lang="DE"}]{#_Toc37318849}[[edm:Schema]{lang="DE"}]{.Datatype} +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +[The ]{lang="DE"}[[edm:Schema]{lang="DE"}]{.Datatype}[ element defines a +schema. ]{lang="DE"}It MUST contain the `Namespace` attribute and it MAY +contain the `Alias` attribute. + +It MAY contain elements [`edm:Action`](#Action), +[`edm:Annotations`](#AnnotationswithExternalTargeting), +[`edm:Annotation`](#Annotation), [`edm:ComplexType`](#ComplexType), +[`edm:EntityContainer`](#EntityContainer), +[`edm:EntityType`](#EntityType), [`edm:EnumType`](#EnumerationType), +[`edm:Function`](#Function), [`edm:Term`](#Term), or +[`edm:TypeDefinition`](#TypeDefinition). +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Namespace` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Namespace` is the namespace of the schema +::: + +## ##subsec Alias + +A schema MAY specify an alias which MUST be a [simple +identifier](#SimpleIdentifier). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +If a schema specifies an alias, the alias MAY be used instead of the +namespace within qualified names to identify model elements of that +schema. An alias only provides a more convenient notation, allowing a +short string to be substituted for a long namespace. Every model element +that can be identified via an alias-qualified name can alternatively be +identified via its full namespace-qualified name. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the +containing document and are not restricted to the schema that defines +them. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Alias` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +Example 6: schema `org.example` with an alias and a description for the +schema + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +` ` + +`  ` + +`  … ` + +`` +::: + +## ##subsec [[ ]{lang="DE"}Annotations with External Targeting](#AnnotationswithExternalTargeting) + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Annotations` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Annotations` element is used to apply a group of annotations to +a single model element. It MUST contain the `Target` attribute and it +MAY contain the `Qualifier` attribute. + +It MUST contain at least one [`edm:Annotation`](#Annotation) element. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Target` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Target` is a path expression identifying the [annotation +target](#Target). It MUST resolve to a model element in scope. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Qualifier` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). +::: + +Example 7: annotations should only be applied to tablet devices + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \]{style="color:black"}]{.Datatype} + +[[  ...\ +\]{style="color:black"}]{.Datatype} +::: + +# ##sec Entity Type + +Entity types are [nominal](#NominalTypes) [structured +types](#StructuredTypes) with a key that consists of one or more +references to [structural properties](#StructuralProperty). An entity +type is the template for an entity: any uniquely identifiable record +such as a customer or order. + +The entity type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +An entity type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to another entity type or collection of entity types. + +All properties MUST have a unique name within an entity type. Properties +MUST NOT have the same name as the declaring entity type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:EntityType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:EntityType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedEntityType), +[`Abstract`](#AbstractEntityType), [`OpenType`](#OpenEntityType), and +[`HasStream`](#MediaEntityType) attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the entity type. + +It MAY contain one [`edm:Key`](#Key) element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the entity type's name. +::: + +Example 8: a simple entity type + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \\ +  \\ +  \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Derived Entity Type + +An entity type can inherit from another entity type by specifying it as +its base type. + +An entity type inherits the [key](#Key) as well as structural and +navigation properties of its base type. + +An entity type MUST NOT introduce an inheritance cycle via the base type +attribute. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `BaseType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `BaseType` is the qualified name of the base type. +::: + +Example 9: a derived entity type based on the previous example + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +Note: the derived type has the same name as one of the properties of its +base type. + +## ##subsec Abstract Entity Type + +An entity type MAY indicate that it is abstract and cannot have +instances. + +For OData 4.0 responses a non-abstract entity type MUST define a +[key](#Key) or derive from a [base type](#DerivedEntityType) with a +defined key. + +An abstract entity type MUST NOT inherit from a non-abstract entity +type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Abstract` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Open Entity Type + +An entity type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +An entity type derived from an open entity type MUST indicate that it is +also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `OpenType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Media Entity Type + +An entity type that does not specify a base type MAY specify that it is +a media entity type. *Media entities* are entities that represent a +media stream, such as a photo. Use a media entity if the out-of-band +stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal +entity with one or more properties of type `Edm.Stream` if the +structured data of the entity is the main topic of interest and the +stream data is just additional information attached to the structured +data. For more information on media entities see +[OData‑Protocol](#ODataProtocol). + +An entity type derived from a media entity type MUST indicate that it is +also a media entity type. + +Media entity types MAY specify a list of acceptable media types using an +annotation with term +[`Core.AcceptableMediaTypes`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#AcceptableMediaTypes), +see [OData‑VocCore](#ODataVocCore). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `HasStream` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `HasStream` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Key + +An entity is uniquely identified within an entity set by its key. A key +MAY be specified if the entity type does not specify a [base +type](#DerivedEntityType) that already has a key declared. + +In order to be specified as the type of an [entity set](#EntitySet) or a +collection-valued [containment navigation +property](#ContainmentNavigationProperty), the entity type MUST either +specify a key or inherit its key from its [base +type](#DerivedEntityType). + +In OData 4.01 responses entity types used for [singletons](#Singleton) +or single-valued [navigation properties](#NavigationProperty) do not +require a key. In OData 4.0 responses entity types used for +[singletons](#Singleton) or single-valued [navigation +properties](#NavigationProperty) MUST have a key defined. + +An entity type (whether or not it is marked as abstract) MAY define a +key only if it doesn't inherit one. + +An entity type's key refers to the set of properties that uniquely +identify an instance of the entity type within an entity set. The key +MUST consist of at least one property. + +Key properties MUST NOT be nullable and MUST be typed with an +[enumeration type](#EnumerationType), one of the following [primitive +types](#PrimitiveTypes), or a [type definition](#TypeDefinition) based +on one of these primitive types: + +- `Edm.Boolean ` +- `Edm.Byte ` +- `Edm.Date ` +- `Edm.DateTimeOffset ` +- `Edm.Decimal ` +- `Edm.Duration ` +- `Edm.Guid ` +- `Edm.Int16 ` +- `Edm.Int32 ` +- `Edm.Int64 ` +- `Edm.SByte ` +- `Edm.String ` +- `Edm.TimeOfDay` + +Key property values MAY be language-dependent, but their values MUST be +unique across all languages and the entity ids (defined in +[OData‑Protocol](#ODataProtocol)) MUST be language independent. + +A key property MUST be a non-nullable primitive property of the entity +type itself, including non-nullable primitive properties of non-nullable +single-valued complex properties, recursively. + +In OData 4.01 the key properties of a directly related entity type MAY +also be part of the key if the navigation property is single-valued and +not nullable. This includes navigation properties of non-nullable +single-valued complex properties (recursively) of the entity type. If a +key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key. + +If the key property is a property of a complex property (recursively) or +of a directly related entity type, the key MUST specify an alias for +that property that MUST be a [simple identifier](#SimpleIdentifier) and +MUST be unique within the set of aliases, structural and navigation +properties of the containing entity type and any of its base types. + +An alias MUST NOT be defined if the key property is a primitive property +of the entity type itself. + +For key properties that are a property of a complex or navigation +property, the alias MUST be used in the key predicate of URLs instead of +the path to the property because the required percent-encoding of the +forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be +used in the query part of URLs, where paths to properties don't require +special encoding and are a standard constituent of expressions anyway. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Key` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Key` element MUST contain at least one `edm:PropertyRef` +element. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:PropertyRef` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:PropertyRef` element MUST contain the `Name` attribute and MAY +contain the `Alias` attribute. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is a path expression leading to a primitive +property. The names of the properties in the path are joined together by +forward slashes. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Alias` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +Example 10: entity type with a simple key + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +Example 11: entity type with a simple key referencing a property of a +[complex type](#ComplexType) + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +`` + +[[  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +Example 12: entity type with a composite key + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \\ +    \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +Example 13 (based on example 11): requests to an entity set `Categories` +of type `Category` must use the alias + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +GET http://host/service/Categories(EntityInfoID=1) +::: + +Example 14 (based on example 11): in a query part the value assigned to +the name attribute must be used + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +GET http://example.org/OData.svc/Categories?\$filter=Info/ID le 100 +::: + +# ##sec [Structural Property](#StructuralProperty) + +A structural property is a property (of a structural type) that has one +of the following types: + +[· ]{style="font-family:Symbol"}[Primitive type](#PrimitiveTypes) + +[· ]{style="font-family:Symbol"}[Complex type](#ComplexType) + +[· ]{style="font-family:Symbol"}[Enumeration type](#EnumerationType) + +[· ]{style="font-family:Symbol"}A collection of one of the above + +A structural property MUST specify a unique name as well as a +[type](#Type). + +The property's name MUST be a [simple identifier](#SimpleIdentifier) +used when referencing, serializing or deserializing the property. It +MUST be unique within the set of structural and navigation properties of +the declaring [structured type](#StructuredTypes), and MUST NOT match +the name of any navigation property in any of its base types. If a +structural property with the same name is defined in any of this type's +base types, then the property's type MUST be a type derived from the +type specified for the property of the base type and constrains this +property to be of the specified subtype for instances of this structured +type. The name MUST NOT match the name of any structural or navigation +property of any of this type's base types for OData 4.0 responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Property` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Property` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the facet attributes +[`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), +[`SRID`](#SRID), and [`DefaultValue`](#DefaultValue). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the property's name. +::: + +Example 15: complex type with two properties + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Type + +The property's type MUST be a [primitive type](#PrimitiveTypes), +[complex type](#ComplexType), or [enumeration type](#EnumerationType) in +scope, or a collection of one of these types. + +A collection-valued property may be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports a stable ordering. + +A collection-valued property may be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. +::: + +Example 16: property `Units` that can have zero or more strings as its +value + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +## ##subsec Type Facets + +Facets modify or constrain the acceptable values of a property. + +For single-valued properties facets apply to the type of the property. +For collection-valued properties the facets apply to the type of the +items in the collection. + +### ##subsubsec Nullable + +A Boolean value specifying whether the property can have the value +`null`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Nullable` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +If no value is specified for a single-valued property, the `Nullable` +attribute defaults to `true`. + +In OData 4.01 responses a collection-valued property MUST specify a +value for the `Nullable` attribute. + +If no value is specified for a collection-valued property, the client +cannot assume any default value. Clients SHOULD be prepared for this +situation even in OData 4.01 responses. +::: + +### ##subsubsec MaxLength + +A positive integer value specifying the maximum length of a binary, +stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length +(number of code points for Unicode). + +If no maximum length is specified, clients SHOULD expect arbitrary +length. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `MaxLength` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `MaxLength` is a positive integer or the symbolic value +`max` as a shorthand for the maximum length supported for the type by +the service. + +Note: the symbolic value `max` is only allowed in OData 4.0 responses; +it is deprecated in OData 4.01. While clients MUST be prepared for this +symbolic value, OData 4.01 and greater services MUST NOT return the +symbolic value `max` and MAY instead specify the concrete maximum length +supported for the type by the service or omit the attribute entirely. +::: + +### ##subsubsec Precision + +For a decimal value: the maximum number of significant decimal digits of +the property's value; it MUST be a positive integer. + +For a temporal value (datetime-with-timezone-offset, duration, or +time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve. + +Note: service authors SHOULD be aware that some clients are unable to +support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential +for data loss when round-tripping values of greater precision. Updating +via `PATCH` and exclusively specifying modified properties will reduce +the risk for unintended data loss. + +Note: duration properties supporting a granularity less than seconds +(e.g. minutes, hours, days) can be annotated with term +[`Measures.DurationGranularity`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Measures.V1.md#DurationGranularity), +see [OData-VocMeasures](#ODataVocMeasures). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Precision` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Precision` is a number. + +If not specified for a decimal property, the decimal property has +arbitrary precision. + +If not specified for a temporal property, the temporal property has a +precision of zero. +::: + +Example 17: [`Precision`](#Precision) facet applied to the +`DateTimeOffset` type + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +### ##subsubsec Scale + +A non-negative integer value specifying the maximum number of digits +allowed to the right of the decimal point, or one of the symbolic values +`floating` or `variable`. + +The value `floating` means that the decimal property represents a +decimal floating-point number whose number of significant digits is the +value of the [`Precision`](#Precision) facet. OData 4.0 responses MUST +NOT specify the value `floating`. + +The value `variable` means that the number of digits to the right of the +decimal point may vary from zero to the value of the +[`Precision`](#Precision) facet. + +An integer value means that the number of digits to the right of the +decimal point may vary from zero to the value of the `Scale` attribute, +and the number of digits to the left of the decimal point may vary from +one to the value of the `Precision` facet minus the value of the `Scale` +facet. If `Precision` is equal to `Scale`, a single zero MUST precede +the decimal point. + +The value of `Scale` MUST be less than or equal to the value of +[`Precision`](#Precision). + +Note: if the underlying data store allows negative scale, services may +use a [`Precision`](#Precision) with the absolute value of the negative +scale added to the actual number of significant decimal digits, and +client-provided values may have to be rounded before being stored. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Scale` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Scale` is a number or one of the symbolic values +`floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +If not specified, the `Scale` facet defaults to zero. +::: + +Example 18: [`Precision`](#Precision)`=3` and `Scale=2`.\ +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +Example 19: `Precision=2` equals `Scale`.\ +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +Example 20: `Precision=3` and a variable `Scale`.\ +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +Example 21: `Precision=7` and a floating `Scale`.\ +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +### ##subsubsec Unicode + +For a string property the `Unicode` facet indicates whether the property +might contain and accept string values with Unicode characters (code +points) beyond the ASCII character set. The value `false` indicates that +the property will only contain and accept string values with characters +limited to the ASCII character set. + +If no value is specified, the `Unicode` facet defaults to `true`. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Unicode` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Unicode` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `true`. +::: + +### ##subsubsec SRID + +For a geometry or geography property the `SRID` facet identifies which +spatial reference system is applied to values of the property on type +instances. + +The value of the `SRID` facet MUST be a non-negative integer or the +special value `variable`. If no value is specified, the attribute +defaults to `0` for `Geometry` types or `4326` for `Geography` types. + +The valid values of the `SRID` facet and their meanings are as defined +by the European Petroleum Survey Group [**\[EPSG\]**](#BMEPSG)**.** + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `SRID` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `$SRID` is a number or the symbolic value `variable`. +::: + +### ##subsubsec Default Value + +A primitive or enumeration property MAY define a default value that is +used if the property is not explicitly represented in an annotation or +the body of a `POST` or `PUT` request. + +If no value is specified, the client SHOULD NOT assume a default value. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `DefaultValue` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. +::: + +# ##sec Navigation Property + +A navigation property allows navigation to related entities. It MUST +specify a unique name as well as a type. + +The navigation property's name MUST be a [simple +identifier](#SimpleIdentifier). It is used when referencing, serializing +or deserializing the navigation property. It MUST be unique within the +set of structural and navigation properties of the declaring [structured +type](#StructuredTypes), and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the +same name is defined in any of this type's base types, then the +navigation property's type MUST be a type derived from the type +specified for the navigation property of the base type, and constrains +this navigation property to be of the specified subtype for instances of +this structured type. The name MUST NOT match the name of any structural +or navigation property of any of this type's base types for OData 4.0 +responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:NavigationProperty` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:NavigationProperty` element MUST contain the `Name` and `Type` +attributes, and it MAY contain the attributes +[`Nullable`](#NullableNavigationProperty), +[`Partner`](#PartnerNavigationProperty), and +[`ContainsTarget`](#ContainmentNavigationProperty). + +It MAY contain child elements +[`edm:ReferentialConstraint`](#ReferentialConstraint) and at most one +child element [`edm:OnDelete`](#OnDeleteAction). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the navigation property's name. +::: + +Example 22: the Product entity type has a navigation property to a +Category, which has a navigation link back to one or more products + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  ...\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +[[\\ +  ...\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Navigation Property Type + +The navigation property's type MUST be an [entity type](#EntityType) in +scope, the [abstract type](#BuiltInAbstractTypes) `Edm.EntityType`, or a +collection of one of these types. + +If the type is a collection, an arbitrary number of entities can be +related. Otherwise there is at most one related entity. + +The related entities MUST be of the specified entity type or one of its +subtypes. + +For a collection-valued containment navigation property the specified +entity type MUST have a [key](#Key) defined. + +A collection-valued navigation property may be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports a stable ordering. + +A collection-valued navigation property may be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued navigation properties the value of `Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `Type` is the +character sequence `Collection(` followed by the qualified name of the +navigation property's item type, followed by a closing parenthesis `)`. +::: + +## ##subsec Nullable Navigation Property + +A Boolean value specifying whether the declaring type MAY have no +related entity. If false, instances of the declaring structured type +MUST always have a related entity. + +Nullable MUST NOT be specified for a collection-valued navigation +property, a collection is allowed to have zero items. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Nullable` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. +::: + +## ##subsec Partner Navigation Property + +A navigation property of an [entity type](#EntityType) MAY specify a +partner navigation property. Navigation properties of complex types MUST +NOT specify a partner. + +If specified, the partner navigation property is identified by a path +relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that +type or a derived type. The path MAY traverse complex types, including +derived complex types, but MUST NOT traverse any navigation properties. +The type of the partner navigation property MUST be the declaring entity +type of the current navigation property or one of its parent entity +types. + +If the partner navigation property is single-valued, it MUST lead back +to the source entity from all related entities. If the partner +navigation property is collection-valued, the source entity MUST be part +of that collection. + +If no partner navigation property is specified, no assumptions can be +made as to whether one of the navigation properties on the target type +will lead back to the source entity. + +If a partner navigation property is specified, this partner navigation +property MUST either specify the current navigation property as its +partner to define a bi-directional relationship or it MUST NOT specify a +partner navigation property. The latter can occur if the partner +navigation property is defined on a complex type, or if the current +navigation property is defined on a type derived from the type of the +partner navigation property. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Partner` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Partner` is the path to the of the partner navigation +property. +::: + +## ##subsec Containment Navigation Property + +A navigation property MAY indicate that instances of its declaring +structured type contain the targets of the navigation property, in which +case the navigation property is called a *containment navigation +property*. + +Containment navigation properties define an implicit entity set for each +instance of its declaring structured type. This implicit entity set is +identified by the read URL of the navigation property for that +structured type instance. + +Instances of the structured type that declares the navigation property, +either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The +canonical URL for contained entities is the canonical URL of the +containing instance, followed by the path segment of the navigation +property and the key of the contained entity, see +[OData‑URL](#ODataURL). + +Entity types used in collection-valued containment navigation properties +MUST have a [key](#Key) defined. + +For items of an ordered collection of complex types (those annotated +with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term defined in [OData-CoreVoc](#ODataVocCore)**)**, the canonical URL +of the item is the canonical URL of the collection appended with a +segment containing the zero-based ordinal of the item. Items within in +an unordered collection of complex types do not have a canonical URL. +Services that support unordered collections of complex types declaring a +containment navigation property, either directly or indirectly via a +property of complex type, MUST specify the URL for the navigation link +within a payload representing that item, according to format-specific +rules. + +OData 4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued +property. + +An entity cannot be referenced by more than one containment relationship +and cannot both belong to an entity set declared within the entity +container and be referenced by a containment relationship. + +Containment navigation properties MUST NOT be specified as the last path +segment in the path of a [navigation property +binding](#NavigationPropertyBinding). + +When a containment navigation property navigates between entity types in +the same inheritance hierarchy, the containment is called *recursive*. + +Containment navigation properties MAY specify a partner navigation +property. If the containment is recursive, the relationship defines a +tree, thus the partner navigation property MUST be +[Nullable](#NullableNavigationProperty) (for the root of the tree) and +single-valued (for the parent of a non-root entity). If the containment +is not recursive, the partner navigation property MUST NOT be nullable. + +An entity type inheritance chain MUST NOT contain more than one +navigation property with a partner navigation property that is a +containment navigation property. + +Note: without a partner navigation property, there is no reliable way +for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity +can also be reached via a non-containment navigation path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `ContainsTarget` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Referential Constraint + +A single-valued navigation property MAY define one or more referential +constraints. A referential constraint asserts that the *dependent +property* (the property defined on the structured type declaring the +navigation property) MUST have the same value as the *principal +property* (the referenced property declared on the entity type that is +the target of the navigation). + +The type of the dependent property MUST match the type of the principal +property, or both types MUST be complex types. + +If the principle property references an entity, then the dependent +property must reference the same entity. + +If the principle property's value is a complex type instance, then the +dependent property's value must be a complex type instance with the same +properties, each with the same values. + +If the navigation property on which the referential constraint is +defined is nullable, or the principal property is nullable, then the +dependent property MUST also be nullable. If both the navigation +property and the principal property are not nullable, then the dependent +property MUST NOT be nullable. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:ReferentialConstraint` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:ReferentialConstraint` element MUST contain the attributes +`Property` and `ReferencedProperty`. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Property` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `Property` attribute specifies the property that takes part in the +referential constraint on the dependent structured type. Its value MUST +be a path expression resolving to a property of the dependent structured +type itself or to a property of a complex property (recursively) of the +dependent structured type. The names of the properties in the path are +joined together by forward slashes. The path is relative to the +dependent structured type declaring the navigation property. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `ReferencedProperty` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `ReferencedProperty` attribute specifies the corresponding property +of the principal entity type. Its value MUST be a path expression +resolving to a property of the principal entity type itself or to a +property of a complex property (recursively) of the principal entity +type that MUST have the same type as the property of the dependent +entity type. The path is relative to the entity type that is the target +of the navigation property. +::: + +Example 23: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  ...\ +  \]{style="color:black"}]{.Datatype} + +`  ` + +[[  \\ +    \\ +    \]{style="color:black"}]{.Datatype} + +`      ` + +`    ` + +`  ` + +`` + +` ` + +`` + +`  ` + +`    ` + +[[  \\ +  \\ +  \\ +  ... ]{style="color:black"}]{.Datatype} + +`` +::: + +## ##subsec On-Delete Action + +A navigation property MAY define an on-delete action that describes the +action the service will take on related entities when the entity on +which the navigation property is defined is deleted. + +The action can have one of the following values: + +- `Cascade`, meaning the related entities will be deleted if the + source entity is deleted, +- `None`, meaning a `DELETE` request on a source entity with related + entities will fail, +- `SetNull`, meaning all properties of related entities that are tied + to properties of the source entity via a referential constraint and + that do not participate in other referential constraints will be set + to null, +- `SetDefault`, meaning all properties of related entities that are + tied to properties of the source entity via a referential constraint + and that do not participate in other referential constraints will be + set to their default value. + +If no on-delete action is specified, the action taken by the service is +not predictable by the client and could vary per entity. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:OnDelete` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:OnDelete` element MUST contain the `Action` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Action` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Action` is one of the values `Cascade`, `None`, `SetNull`, +or `SetDefault`. +::: + +Example 24: deletion of a category implies deletion of the related +products in that category + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  ...\ +  \\ +    \]{style="color:black"}]{.Datatype} + +[[      \]{style="color:black"}]{.Datatype} + +[[    \]{style="color:black"}]{.Datatype} + +`` +::: + +# ##sec Complex Type + +Complex types are keyless [nominal](#NominalTypes) [structured +types](#StructuredTypes). The lack of a key means that instances of +complex types cannot be referenced, created, updated or deleted +independently of an entity type. Complex types allow entity models to +group properties into common structures. + +The complex type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +A complex type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to an entity type or a collection of entity types. + +All properties MUST have a unique name within a complex type. Properties +MUST NOT have the same name as the declaring complex type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:ComplexType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:ComplexType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedComplexType), +[`Abstract`](#AbstractComplexType), and [`OpenType`](#OpenComplexType) +attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the complex type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the complex type's name. +::: + +Example 25: a complex type used by two entity types + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +[[\\ +  ...\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +[[\\ +  ...\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Derived Complex Type + +A complex type can inherit from another complex type by specifying it as +its base type. + +A complex type inherits the structural and navigation properties of its +base type. + +A complex type MUST NOT introduce an inheritance cycle by specifying a +base type. + +The rules for annotations of derived complex types are described in +section 14.2. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `BaseType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `BaseType` is the qualified name of the base type. +::: + +## ##subsec Abstract Complex Type + +A complex type MAY indicate that it is abstract and cannot have +instances. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Abstract` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Open Complex Type + +A complex type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +A complex type derived from an open complex type MUST indicate that it +is also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `OpenType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +# ##sec Enumeration Type + +Enumeration types are [nominal](#NominalTypes) types that represent a +non-empty series of related values. Enumeration types expose these +related values as members of the enumeration. + +The enumeration type's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Although enumeration types have an underlying numeric value, the +preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the `AllowedValues` annotation defined in +[**\[OData-VocCore\].**](#ODataVocCore) + +Enumeration types marked as flags allow values that consist of more than +one enumeration member at a time. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:EnumType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:EnumType` element MUST contain the Name attribute, and it MAY +contain the [`UnderlyingType`](#UnderlyingIntegerType) and +[`IsFlags`](#FlagsEnumerationType) attributes. + +It MUST contain one or more [`edm:Member`](#EnumerationTypeMember) +elements defining the members of the enumeration type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the enumeration type's name. +::: + +Example 26: a simple flags-enabled enumeration + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Underlying Integer Type + +An enumeration type MAY specify one of `Edm.Byte`, `Edm.SByte`, +`Edm.Int16`, `Edm.Int32`, or `Edm.Int64` as its underlying type. + +If not explicitly specified, `Edm.Int32` is used as the underlying type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `UnderlyingType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +## ##subsec Flags Enumeration Type + +An enumeration type MAY indicate that the enumeration type allows +multiple members to be selected simultaneously. + +If not explicitly specified, only one enumeration type member MAY be +selected simultaneously. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `IsFlags` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `IsFlags` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +Example 27: pattern values can be combined, and some combined values +have explicit names + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +` ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`  ` + +`` +::: + +## ##subsec Enumeration Type Member + +Enumeration type values consist of discrete members. + +Each member is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within the +enumeration type. Names are case-sensitive, but service authors SHOULD +NOT choose names that differ only in case. + +Each member MUST specify an associated numeric value that MUST be a +valid value for the underlying type of the enumeration type. + +Enumeration types can have multiple members with the same value. Members +with the same numeric value compare as equal, and members with the same +numeric value can be used interchangeably. + +Enumeration members are sorted by their numeric value. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Member` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Member` element MUST contain the `Name` attribute and it MAY +contain the `Value` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the enumeration member's name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Value` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`false`, either all members MUST specify an integer value for the +`Value` attribute, or all members MUST NOT specify a value for the +`Value` attribute. If no values are specified, the members are assigned +consecutive integer values in the order of their appearance, starting +with zero for the first member. Client libraries MUST preserve elements +in document order. + +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`true`, a non-negative integer value MUST be specified for the `Value` +attribute. A combined value is equivalent to the bitwise OR of the +discrete values. +::: + +Example 28: `FirstClass` has a value of `0`, `TwoDay` a value of 1, and +`Overnight` a value of 2. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \]{style="color:black"}]{.Datatype} + +`    ` + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +`    \ +  \\ +  \]{style="color:black"}]{.Datatype} + +`    \ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +# ##sec Type Definition + +A type definition defines a specialization of one of the [primitive +types](#PrimitiveTypes) or of the built-in abstract type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes). + +The type definition's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Type definitions can be used wherever a primitive type is used (other +than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions +defined using the same underlying type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:TypeDefinition` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:TypeDefinition` element MUST contain the `Name` and +[`UnderlyingType`](#UnderlyingPrimitiveType) attributes. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the type definition's name. +::: + +Example 29: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\ + +  \ + +\ + +  + +\ + +  \ + +\ + +  + +\ + +  \ + +  \ + +\ +::: + +## ##subsec Underlying Primitive Type + +The underlying type of a type definition MUST be a [primitive +type](#PrimitiveTypes) that MUST NOT be another type definition. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `UnderlyingType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), or +[`SRID`](#SRID). + +Additional facets appropriate for the underlying type MAY be specified +when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified. + +For a type definition with underlying type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes) no facets are applicable, +neither in the definition itself nor when the type definition is used, +and these should be ignored by the client. + +Where type definitions are used, the type definition is returned in +place of the primitive type wherever the type is specified in a +response. + +# ##sec [Action and Function](#ActionandFunction) + +## ##subsec Action + +Actions are service-defined operations that MAY have observable side +effects and MAY return a single instance or a collection of instances of +any type. + +The action's name is a [simple identifier](#SimpleIdentifier) that MUST +be unique within its schema. + +Actions cannot be composed with additional path segments. + +An action MAY specify a [return type](#ReturnType) that MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +An action MAY define [parameters](#Parameter) used during the execution +of the action. + +## ##subsec Action Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) actions support +overloading (multiple actions having the same name within the same +schema) by binding parameter type. The combination of action name and +the binding parameter type MUST be unique within a schema. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) actions do not support +overloads. The names of all unbound actions MUST be unique within a +schema. + +An unbound action MAY have the same name as a bound action. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Action` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Action` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverlo) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MAY contain at most one [`edm:ReturnType`](#ReturnType) element and +MAY contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the action's name. +::: + +## ##subsec Function + +Functions are service-defined operations that MUST NOT have observable +side effects and MUST return a single instance or a collection of +instances of any type. + +The function's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +Functions MAY be [composable](#ComposableFunction). + +The function MUST specify a [return type](#ReturnType) which MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +A function MAY define [parameters](#Parameter) to be used during the +execution of the function. + +## ##subsec Function Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading (multiple functions having the same name within the same +schema) subject to the following rules: + +[· ]{style="font-family:Symbol"}The combination of function name, +binding parameter type, and unordered set of non-binding parameter names +MUST be unique within a schema. + +[· ]{style="font-family:Symbol"}The combination of function name, +binding parameter type, and ordered set of parameter types MUST be +unique within a schema. + +[· ]{style="font-family:Symbol"}All bound functions with the same +function name and binding parameter type within a schema MUST specify +the same return type. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading subject to the following rules: + +[· ]{style="font-family:Symbol"}The combination of function name and +unordered set of parameter names MUST be unique within a schema. + +[· ]{style="font-family:Symbol"}The combination of function name and +ordered set of parameter types MUST be unique within a schema. + +[· ]{style="font-family:Symbol"}All unbound functions with the same +function name within a schema MUST specify the same return type. + +An unbound function MAY have the same name as a bound function. + +Note that [type definitions](#ActionandFunction) can be used to +disambiguate overloads for both bound and unbound functions, even if +they specify the same underlying type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Function` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Function` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverlo) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MUST contain one [`edm:ReturnType`](#ReturnType) element, and it MAY +contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the action's name. +::: + +## ##subsec Bound or Unbound Action or Function Overloads + +An action or function overload MAY indicate that it is bound. If not +explicitly indicated, it is unbound. + +Bound actions or functions are invoked on resources matching the type of +the binding parameter. The binding parameter can be of any type, and it +MAY be [Nullable](#Nullable). + +Unbound actions are invoked through an [action import](#ActionImport). + +Unbound functions are invoked as static functions within a filter or +orderby expression, or from the entity container through a [function +import](#FunctionImport). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `IsBound` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `IsBound` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +## ##subsec Entity Set Path + +Bound actions and functions that return an entity or a collection of +entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter +value. + +The entity set path consists of a series of segments joined together +with forward slashes. + +The first segment of the entity set path MUST be the name of the binding +parameter. The remaining segments of the entity set path MUST represent +navigation segments or type casts. + +A navigation segment names the [simple identifier](#SimpleIdentifier) of +the [navigation property](#NavigationProperty) to be traversed. A +type-cast segment names the [qualified name](#QualifiedName) of the +entity type that should be returned from the type cast. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `EntitySetPath` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `EntitySetPath` is the entity set path. +::: + +## ##subsec Composable Function + +A function MAY indicate that it is composable. If not explicitly +indicated, it is not composable. + +A composable function can be invoked with additional path segments or +key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for +the type returned by the composable function. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `IsComposable` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Return Type + +The return type of an action or function overload MAY be any type in +scope, or a collection of any type in scope. + +The facets [`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID) can be +used as appropriate to specify value restrictions of the return type, as +well as the [`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:ReturnType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:ReturnType` element MUST contain the `Type` attribute, and it +MAY contain the attributes `Nullable`, [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued return types the value of `Type` is the qualified name +of the return type. + +For collection-valued return types the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the return item +type, followed by a closing parenthesis `)`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Nullable` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +If the return type is a collection of entity types, the `$Nullable` +member has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + +## ##subsec Parameter + +An action or function overload MAY specify parameters. + +A bound action or function overload MUST specify at least one parameter; +the first parameter is the binding parameter. The order of parameters +MUST NOT change unless the schema version changes. + +Each parameter MUST have a name that is a [simple +identifier](#SimpleIdentifier). The parameter name MUST be unique within +the action or function overload. + +The parameter MUST specify a type. It MAY be any type in scope, or a +collection of any type in scope. + +The facets [`MaxLength`](#MaxLength), [`Precision`](#Precision), +[`Scale`](#Scale), or [`SRID`](#SRID) can be used as appropriate to +specify value restrictions of the parameter, as well as the +[`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Parameter` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Parameter` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the attributes `Nullable`, +[`MaxLength`](#MaxLength), [`Unicode`](#Unicode), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the parameter's name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued parameters the value of `Type` is the qualified name +of the parameter. + +For collection-valued parameters the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the parameter's +type, followed by a closing parenthesis `)`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Nullable` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +The value `true` means that the parameter accepts a `null` value. +::: + +Example 30: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `edm:Parameter` element. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\ + +  \ + +  \ + +\ +::: + +# ##sec Entity Container + +Each metadata document used to describe an OData service MUST define +exactly one entity container. + +The entity container's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Entity containers define the entity sets, singletons, function and +action imports exposed by the service. + +Entity set, singleton, action import, and function import names MUST be +unique within an entity container. + +An [*entity set*](#EntitySet) allows access to entity type instances. +Simple entity models frequently have one entity set per entity type. + +Example 31: one entity set per entity type + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\]{style="color:black"}]{.Datatype} +::: + +Other entity models may expose multiple entity sets per type. + +Example 32: three entity sets referring to the two entity types + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +]{style="color:black"}]{.Datatype}[  \\ +\ ]{style="color:black"} + +`` + +[  \\ +\\ +\]{style="color:black"} +::: + +There are separate entity sets for standard customers and preferred +customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have [navigation +property bindings](#NavigationPropertyBinding) to the orders entity set, +but the orders entity set does not have a navigation property binding +for the Customer navigation property, since it could lead to either set +of customers. + +An entity set can expose instances of the specified entity type as well +as any entity type inherited from the specified entity type. + +A [*singleton*](#Singleton) allows addressing a single entity directly +from the entity container without having to know its key, and without +requiring an entity set. + +A [*function import*](#FunctionImport) or an [*action +import*](#ActionImport) is used to expose a function or action defined +in an entity model as a top level resource. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:EntityContainer` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:EntityContainer` MUST contain one or more +[`edm:EntitySet`](#EntitySet), [`edm:Singleton`](#Singleton), +[`edm:ActionImport`](#ActionImport), or +[`edm:FunctionImport`](#FunctionImport) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the entity container's name. +::: + +Example 33: An entity container aggregates entity sets, singletons, +action imports, and function imports. + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \]{style="color:black"}]{.Datatype} + +`    ` + +`    ` + +`  ` + +[[  \\ +    \]{style="color:black"}]{.Datatype} + +`  ` + +[[  \\ +    \]{style="color:black"}]{.Datatype} + +`  ` + +`  ` + +[[  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Extending an Entity Container + +An entity container MAY specify that it extends another entity container +in scope. All children of the "base" entity container are added to the +"extending" entity container. + +If the "extending" entity container defines an entity set with the same +name as defined in any of its "base" containers, then the entity set's +type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the "base" container. The same +holds for singletons. Action imports and function imports cannot be +redefined, nor can the "extending" container define a child with the +same name as a child of a different kind in a "base" container. + +Note: services should not introduce cycles by extending entity +containers. Clients should be prepared to process cycles introduced by +extending entity containers. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Extends` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Extends` is the qualified name of the entity container to +be extended. +::: + +Example 34: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\ + +   `…` + +\ +::: + +## ##subsec Entity Set + +Entity sets are top-level collection-valued resources. + +An entity set is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An entity set MUST specify a type that MUST be an entity type in scope. + +An entity set MUST contain only instances of its specified entity type +or its subtypes. The entity type MAY be [abstract](#AbstractEntityType) +but MUST have a [key](#Key) defined. + +An entity set MAY indicate whether it is included in the service +document. If not explicitly indicated, it is included. + +Entity sets that cannot be queried without specifying additional query +options SHOULD NOT be included in the service document. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:EntitySet` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:EntitySet` element MUST contain the attributes `Name` and +`EntityType`, and it MAY contain the `IncludeInServiceDocument` +attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the entity set's name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `EntityType` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `EntityType` is the qualified name of an entity type in +scope. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `IncludeInServiceDocument` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `true`. +::: + +## ##subsec Singleton + +Singletons are top-level single-valued resources. + +A singleton is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A singleton MUST specify a type that MUST be an entity type in scope. + +A singleton MUST reference an instance its entity type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Singleton` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Singleton` element MUST include the attributes `Name` and +`Type`, and it MAY contain the `Nullable` attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the singleton's name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Type` is whose value is the [qualified +name](#QualifiedName) of an entity type in scope. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Nullable` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +If no value is specified, the `Nullable` attribute defaults to `false`. + +In OData 4.0 responses this attribute MUST NOT be specified. +::: + +## ##subsec Navigation Property Binding + +If the entity type of an entity set or singleton declares navigation +properties, a navigation property binding allows describing which entity +set or singleton will contain the related entities. + +An [entity set](#EntitySet) or a [singleton](#Singleton) SHOULD contain +a navigation property binding for each [navigation +property](#NavigationProperty) of its entity type, including navigation +properties defined on complex typed properties. + +If omitted, clients MUST assume that the target entity set or singleton +can vary per related entity. + +### ##subsubsec Navigation Property Path Binding + +A navigation property binding MUST specify a path to a navigation +property of the entity set's or singleton\'s declared entity type, or a +navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation +property is defined on a subtype, the path MUST contain the [qualified +name](#QualifiedName) of the subtype, followed by a forward slash, +followed by the navigation property name. If the navigation property is +defined on a complex type used in the definition of the entity set's +entity type, the path attribute MUST contain a forward-slash separated +list of complex property names and qualified type names that describe +the path leading to the navigation property. + +The path can traverse one or more containment navigation properties but +the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment. + +If the path traverses collection-valued complex properties or +collection-valued containment navigation properties, the binding applies +to all items of these collections. + +If the path contains a recursive sub-path (i.e. a path leading back to +the same structured type, the binding applies recursively to any +positive number of cycles through that sub-path. + +OData 4.01 services MAY have a type-cast segment as the last path +segment, allowing to bind instances of different sub-types to different +targets. + +The same navigation property path MUST NOT be specified in more than one +navigation property binding; navigation property bindings are only used +when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths +that differ only in a type-cast segment, allowing to bind instances of +different sub-types to different targets. If paths differ only in +type-cast segments, the most specific path applies. + +### ##subsubsec Binding Target + +A navigation property binding MUST specify a target via a [simple +identifier](#SimpleIdentifier) or [target path](#TargetPath). It +specifies the entity set, singleton, or containment navigation property +that contains the entities. + +If the target is a [simple identifier](#SimpleIdentifier), it MUST +resolve to an entity set or singleton defined in the same entity +container as the enclosing element. + +If the target is a [target path](#TargetPath), it MUST resolve to an +entity set, singleton, or direct or indirect containment navigation +property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties +before ending in a containment navigation property, and there MUST NOT +be any non-containment navigation properties prior to the final segment. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:NavigationPropertyBinding` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:NavigationPropertyBinding` element MUST contain the attributes +`Path` and `Target`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Path` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Path` is a path expression. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Target` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Target` is a [target path](#TargetPath). +::: + +Example 35: for an entity set in the same container as the enclosing +entity set `Categories` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \` + +`` +::: + +Example 36: for an entity set in any container in scope + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \` + +`` +::: + +Example 37: binding `Supplier` on `Products` contained within +`Categories – binding applies to all suppliers of all products of all categories` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \` + +`` +::: + +## ##subsec Action Import + +Action imports sets are top-level resources that are never included in +the service document. + +An action import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An action import MUST specify the name of an unbound action in scope. + +If the imported action returns an entity or a collection of entities, a +[simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:ActionImport` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:ActionImport` element MUST contain the attributes `Name` and +`Action`, and it MAY contain the `EntitySet` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the action import's name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Action` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Action` is the qualified name of an unbound action. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `EntitySet` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. +::: + +## ##subsec Function Import + +Function imports sets are top-level resources. + +A function import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A function import MUST specify the name of an unbound function in scope. +All unbound [overloads](#FunctionOverloads) of an imported function can +be invoked from the entity container. + +If the imported function returns an entity or a collection of entities, +a [simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +A function import for a parameterless function MAY indicate whether it +is included in the service document. If not explicitly indicated, it is +not included. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:FunctionImport` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:FunctionImport` element MUST contain the attributes `Name` and +`Function`, and it MAY contain the attributes `EntitySet` and +`IncludeInServiceDocument`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the function import's name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Function` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Function` is the qualified name of an unbound function. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `EntitySet` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `IncludeInServiceDocument` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `false`. +::: + +# ##sec Vocabulary and Annotation + +Vocabularies and annotations provide the ability to annotate metadata as +well as instance data, and define a powerful extensibility point for +OData. An [*annotation*](#Annotation) applies a [*term*](#Term) to a +model element and defines how to calculate a value for the applied term. + +*Metadata annotations* are terms applied to model elements. Behaviors or +constraints described by a metadata annotation must be consistent with +the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity +type, property, function, action, or parameter. For example, a metadata +annotation may define ranges of valid values for a particular property. +Metadata annotations are applied in CSDL documents describing or +referencing an entity model. + +*Instance annotations* are terms applied to a particular instance within +an OData payload, such as described in [OData‑JSON](#ODataJSON). An +instance annotation can be used to define additional information +associated with a particular result, entity, property, or error. For +example, whether a property is read-only for a particular instance. +Where the same annotation is defined at both the metadata and instance +level, the instance-level annotation overrides the annotation specified +at the metadata level. Annotations that apply across instances should be +specified as metadata annotations. + +A *vocabulary* is a schema containing a set of terms where each +[term](#Term) is a named metadata extension. Anyone can define a +vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary +[OData‑VocCore](#ODataVocCore). + +A [term](#Term) can be used to: + +[· ]{style="font-family:Symbol"}Extend model elements and type instances +with additional information. + +[· ]{style="font-family:Symbol"}Map instances of annotated structured +types to an interface defined by the term type; i.e. annotations allow +viewing instances of a structured type as instances of a differently +structured type specified by the applied term. + +A service SHOULD NOT require a client to interpret annotations. Clients +SHOULD ignore invalid or unknown terms and silently treat unexpected or +invalid values (including invalid type, invalid literal expression, +invalid targets, etc.) as an unknown value for the term. Unknown or +invalid annotations should never result in an error, as long as the +payload remains well-formed. + +Example 38: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \]{style="color:black"}]{.Datatype} + +`    ` + +[[  \\ +  \\ +  \\ +  \\ +  ...  ]{style="color:black"}]{.Datatype} + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +[[    \\ +      \\ +      \\ +      \\ +        \\ +          \Products(\\ +          \ID\\ +          \)\\ +        \\ +      \]{style="color:black"}]{.Datatype} + +[[    \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Term + +A term allows annotating a CSDL element or OData resource representation +with additional data. + +The term's name is a [simple identifier](#SimpleIdentifier) that MUST be +unique within its schema. + +The term's type MUST be a type in scope, or a collection of a type in +scope. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Term` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Term` element MUST contain the attributes `Name` and `Type`. It +MAY contain the attributes `BaseTerm` and `AppliesTo`. + +It MAY specify values for the [`Nullable`](#Nullable), +[ ]{.apple-converted-space}[`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), or [`SRID`](#SRID) facet +attributes, as well as the [`Unicode`](#Unicode) facet attribute for +4.01 and greater payloads. These facets and their implications are +described in section 7.2. + +A `edm:Term` element whose `Type` attribute specifies a primitive or +enumeration type MAY define a value for the `DefaultValue` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the term's name. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `DefaultValue` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of this attribute determines the value of the term when +applied in an [`edm:Annotation`](#Annotation) without providing an +expression. + +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. + +If no value is specified, the `DefaultValue` attribute defaults to +`null`. +::: + +### ##subsubsec Specialized Term + +A term MAY specialize another term in scope by specifying it as its base +type. + +When applying a term with a base term, the base term MUST also be +applied with the same qualifier, and so on until a term without a base +term is reached. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `BaseTerm` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `BaseTerm` is the qualified name of the base term. +::: + +### ##subsubsec Applicability + +The applicability of a term MAY be restricted to a list of model +elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be +extended in future versions of the vocabulary. As the intended usage may +evolve over time, clients SHOULD be prepared for any term to be applied +to any model element and SHOULD be prepared to handle unknown values +within the `AppliesTo` attribute. Applicability is expressed using the +following symbolic values: + + **Symbolic Value** **Model Element** + ------------------------- ----------------------------------------------------------------- + `Action` Action + `ActionImport` Action Import + `Annotation` Annotation + `Apply` Application of a client-side function in an annotation + `Cast` Type Cast annotation expression + `Collection` Entity Set or collection-valued Property or Navigation Property + `ComplexType` Complex Type + `EntityContainer` Entity Container + `EntitySet` Entity Set + `EntityType` Entity Type + `EnumType` Enumeration Type + `Function` Function + `FunctionImport` Function Import + `If` Conditional annotation expression + `Include` Reference to an Included Schema + `IsOf` Type Check annotation expression + `LabeledElement` Labeled Element expression + `Member` Enumeration Member + `NavigationProperty` Navigation Property + `Null` Null annotation expression + `OnDelete` On-Delete Action of a navigation property + `Parameter` Action of Function Parameter + `Property` Property of a structured type + `PropertyValue` Property value of a Record annotation expression + `Record` Record annotation expression + `Reference` Reference to another CSDL document + `ReferentialConstraint` Referential Constraint of a navigation property + `ReturnType` Return Type of an Action or Function + `Schema` Schema + `Singleton` Singleton + `Term` Term + `TypeDefinition` Type Definition + `UrlRef` UrlRef annotation expression + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `AppliesTo` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `AppliesTo` is a whitespace-separated list of symbolic +values from the table above that identify model elements the term is +intended to be applied to. +::: + +Example 39: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData‑VocCore](#ODataVocCore)) + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[\\ +  \\ +    \\ +      Properties and terms annotated with this term MUST contain a valid +URL]{style="color:black"} + +[    \\ +  \]{style="color:black"} + +  \ + +\ +::: + +## ##subsec Annotation + +An annotation applies a [term](#Term) to a model element and defines how +to calculate a value for the term application. Both term and model +element MUST be in scope. Section 14.1.2 specifies which model elements +MAY be annotated with a term. + +The value of an annotation is specified as an *annotation expression*, +which is either a [constant expression](#ConstantExpression) +representing a constant value, or a [dynamic +expression](#DynamicExpression). The most common construct for assigning +an annotation value is a [path expression](#ValuePath) that refers to a +property of the same or a related structured type. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:Annotation` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Annotation` element MUST contain the attribute `Term`, and it +MAY contain the attribute [`Qualifier`](#Qualifier). + +The value of the annotation MAY be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +If no expression is specified for a term with a primitive type, the +annotation evaluates to the [default value](#DefaultValue) of the term +definition. If no expression is specified for a term with a complex +type, the annotation evaluates to a complex instance with default values +for its properties. If no expression is specified for a +collection-valued term, the annotation evaluates to an empty collection. + +An `edm:Annotation` element can be used as a child of the model element +it annotates, or as the child of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element that +targets the model element to be annotated. + +An `edm:Annotation` element MAY contain [`edm:Annotation`](#Annotation) +elements that annotate the annotation. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Term` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Term` is the qualified name of a [term](#Term) in scope. +::: + +Example 40: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \]{style="color:black"}]{.Datatype} + +[[    \]{style="color:black"}]{.Datatype} + +`  ` + +`` + +[[\\ +  \]{style="color:black"}]{.Datatype} + +`` + +`` +::: + +If an entity type or complex type is annotated with a term that itself +has a structured type, an instance of the annotated type may be viewed +as an "instance" of the term, and the qualified term name may be used as +a [term-cast segment](#ref_TermCast) in path expressions. + +Structured types "inherit" annotations from their direct or indirect +base types. If both the type and one of its base types is annotated with +the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or +collection-valued annotation values are not merged. Similarly, +properties of a structured type inherit annotations from identically +named properties of a base type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a \"Label\" +annotation for a UI can propagate from a type definition to all +properties using that type definition and may be overridden at each +property with a more specific label, whereas an annotation marking a +type definition as containing a phone number will propagate to all using +properties but may not be overridden. + +### ##subsubsec Qualifier + +A term can be applied multiple times to the same model element by +providing a qualifier to distinguish the annotations. The qualifier is a +[simple identifier](#SimpleIdentifier). + +The combination of target model element, term, and qualifier uniquely +identifies an annotation. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Qualifier` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Annotation elements that are children of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element MUST NOT +provide a value for the qualifier attribute if the parent +[`edm:Annotations`](#AnnotationswithExternalTargeting) element provides +a value for the qualifier attribute. +::: + +Example 41: annotation should only be applied to tablet devices + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Target + +The target of an annotation is the model element the term is applied to. + +The target of an annotation MAY be specified indirectly by "nesting" the +annotation within the model element. Whether and how this is possible is +described per model element in this specification. + +The target of an annotation MAY also be specified directly; this allows +defining an annotation in a different schema than the targeted model +element. + +This external targeting is only possible for model elements that are +uniquely identified within their parent, and all their ancestor elements +are uniquely identified within their parent: + +- [Action](#Action)[ (single or all overloads)]{style="color:black; + background:white"} +- [Action Import](#ActionImport) +- [Annotation](#Annotation) +- [Complex Type](#ComplexType) +- [Entity Container](#EntityContainer) +- [Entity Set](#EntitySet) +- [Entity Type](#EntityType) +- [Enumeration Type](#EnumerationType) +- [Enumeration Type Member](#EnumerationTypeMember) +- [Function](#Function)[ (single or all + overloads)]{style="color:black;background:white"} +- [Function Import](#FunctionImport) +- [Navigation Property](#NavigationProperty) (via type, entity set, or + singleton) +- [Parameter](#Parameter)[ of an action or function (single overload + or all overloads defining the + parameter)]{style="color:black;background:white"} +- [Property](#StructuralProperty) (via type, entity set, or singleton) +- [Return Type](#ReturnType)[ of an action or function + ([single]{#_Hlk523392241} or all + overloads)]{style="color:black;background:white"} +- [Singleton](#Singleton) +- [Type Definition](#TypeDefinition) + +These are the direct children of a schema with a unique name (i.e. +except actions and functions whose overloads to not possess a natural +identifier), and all direct children of an entity container. + +External targeting is possible for actions, functions, their parameters, +and their return type, either in a way that applies to all overloads of +the action or function or all parameters of that name across all +overloads, or in a way that identifies a single overload. + +External targeting is also possible for properties and navigation +properties of singletons or entities in a particular entity set. These +annotations override annotations on the properties or navigation +properties targeted via the declaring structured type. + +The allowed path expressions are: + +[[· ]{style="font-size:9.0pt;font-family:Symbol; +color:black"}]{.apple-converted-space}[qualified name](#QualifiedName) +of schema child + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName) of schema child followed by a forward slash and +name of child element + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName) of structured type followed by zero or more +property, navigation property, or type-cast segments, each segment +starting with a forward slash + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName) of an entity container followed by a segment +containing a singleton or entity set name and zero or more property, +navigation property, or type-cast segments + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName)[ of an action followed by parentheses containing +the binding parameter *type* of a bound action overload to identify that +bound overload, or by empty parentheses to identify the unbound +overload]{style="color:black;background:white"} + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}[qualified +name](#QualifiedName)[ of a function followed by parentheses containing +the comma-separated list of the parameter *types* of a bound or unbound +function overload in the order of their definition in the function +overload]{style="color:black;background:white"} + +[[· +]{style="font-size:9.0pt;font-family:Symbol;color:black"}]{.Keyword}[qualified +name](#QualifiedName) of an action or function, optionally followed by +parentheses as described in the two previous bullet points to identify a +single overload, followed by a forward slash and either a parameter name +or `$ReturnType` + +[[· +]{style="font-size:9.0pt;font-family:Symbol;color:black"}]{.Keyword}[qualified +name](#QualifiedName) of an entity container followed by a segment +containing an action or function import name, optionally followed by a +forward slash and either a parameter name or `$ReturnType` + +- One of the preceding, followed by a forward slash, an at (`@`), the + [qualified name](#QualifiedName)[ of a term, and optionally a hash + (]{style="color:black;background:white"}`#`) and the qualifier of an + annotation + +All [qualified names](#QualifiedName) used in a target path MUST be in +scope. + +Example 42: Target expressions + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +MySchema.MyEntityType + +MySchema.MyEntityType/MyProperty + +MySchema.MyEntityType/MyNavigationProperty + +MySchema.MyComplexType + +MySchema.MyComplexType/MyProperty + +MySchema.MyComplexType/MyNavigationProperty + +MySchema.MyEnumType + +MySchema.MyEnumType/MyMember + +MySchema.MyTypeDefinition + +MySchema.MyTerm + +MySchema.MyEntityContainer + +MySchema.MyEntityContainer/MyEntitySet + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MyActionImport + +MySchema.MyEntityContainer/MyFunctionImport + +MySchema.MyAction + +MySchema.MyAction(MySchema.MyBindingType) + +MySchema.MyAction(Collection(MySchema.MyBindingType)) + +MySchema.MyAction() + +MySchema.MyFunction + +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType) + +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType) + +MySchema.MyFunction/MyParameter + +MySchema.MyEntityContainer/MyEntitySet/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty +::: + +## ##subsec Constant Expression + +Constant expressions allow assigning a constant value to an applied +term. + +### ##subsubsec Binary + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Binary` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Binary` expression evaluates to a primitive binary value. A +binary expression MUST be assigned a value conforming to the rule +`binaryValue` in [OData‑ABNF](#ODataABNF). + +The binary expression MAY be provided using element notation or +attribute notation. +::: + +Example 43: base64url-encoded binary value (OData) + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \T0RhdGE\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Boolean + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Bool` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Bool` expression evaluates to a primitive Boolean value. A +Boolean expression MUST be assigned a Boolean value. + +The Boolean expression MAY be provided using element notation or +attribute notation. +::: + +Example 44: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \true\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Date + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Date` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Date` expression evaluates to a primitive date value. A date +expression MUST be assigned a value of type `xs:date`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData‑ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. + +The date expression MAY be provided using element notation or attribute +notation. +::: + +Example 45: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \2000-01-01\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec DateTimeOffset + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:DateTimeOffset` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:DateTimeOffset` expression evaluates to a primitive +datetimestamp value with a time-zone offset. A datetimestamp expression +MUST be assigned a value of type `xs:dateTimeStamp`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData‑ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). + +The datetimestamp expression MAY be provided using element notation or +attribute notation`.` +::: + +Example 46: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`\ +\ +\\ +  \2000-01-01T16:00:00.000-09:00\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Decimal + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Decimal` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Decimal` expression evaluates to a primitive decimal value. A +decimal expression MUST be assigned a value conforming to the rule +`decimalValue` in [OData‑ABNF](#ODataABNF). + +The decimal expression MAY be provided using element notation or +attribute notation. +::: + +Example 47: attribute notation + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +Example 48: element notation + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \3.14\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Duration + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Duration` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Duration` expression evaluates to a primitive duration value. A +duration expression MUST be assigned a value of type +`xs:dayTimeDuration`, see [**\[XML‑Schema‑2\]**](#BMXMLSchema2), +[section 3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). + +The duration expression MAY be provided using element notation or +attribute notation. +::: + +Example 49: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \P11DT23H59M59.999999999999S\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Enumeration Member + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:EnumMember  ` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:EnumMember` expression references a +[member](#EnumerationTypeMember) of an [enumeration +type](#EnumerationType). An enumeration member expression MUST be +assigned a value that consists of the qualified name of the enumeration +type, followed by a forward slash and the name of the enumeration +member. If the enumeration type specifies an `IsFlags` attribute with +value `true`, the expression MAY also be assigned a whitespace-separated +list of values. Each of these values MUST resolve to the name of a +member of the enumeration type of the specified term. + +The enumeration member expression MAY be provided using element notation +or attribute notation. +::: + +Example 50: single value + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \org.example.Pattern/Red\\ +\]{style="color:black"}]{.Datatype} +::: + +Example 51: combined value for `IsFlags` enumeration type + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \org.example.Pattern/Red +org.example.Pattern/Striped\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Floating-Point Number + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Float` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Float` expression evaluates to a primitive floating point (or +double) value. A float expression MUST be assigned a value conforming to +the rule `doubleValue` in [OData‑ABNF](#ODataABNF). + +The float expression MAY be provided using element notation or attribute +notation. +::: + +Example 52: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \3.14\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Guid + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Guid` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Guid` expression evaluates to a primitive guid value. A guid +expression MUST be assigned a value conforming to the rule `guidValue` +in [OData‑ABNF](#ODataABNF). + +The guid expression MAY be provided using element notation or attribute +notation`.` +::: + +Example 53: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`\ +\ +\\ +  \21EC2020-3AEA-1069-A2DD-08002B30309D\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Integer + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Int` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Int` expression evaluates to a primitive integer value. An +integer MUST be assigned a value conforming to the rule `int64Value` in +[OData‑ABNF](#ODataABNF). + +The integer expression MAY be provided using element notation or +attribute notation. +::: + +Example 54: attribute notation + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` +::: + +Example 55: element notation + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \42\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec String + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:String` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:String` expression evaluates to a primitive string value. A +string expression MUST be assigned a value of the type `xs:string`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.3.1](http://www.w3.org/TR/xmlschema11-2/#string). + +The string expression MAY be provided using element notation or +attribute notation. +::: + +Example 56: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \Product Catalog\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Time of Day + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:TimeOfDay` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:TimeOfDay` expression evaluates to a primitive time value. A +time-of-day expression MUST be assigned a value conforming to the rule +`timeOfDayValue` in [OData‑ABNF](#ODataABNF). + +The time-of-day expression MAY be provided using element notation or +attribute notation. +::: + +Example 57: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \21:45:00\\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec Dynamic Expression + +Dynamic expressions allow assigning a calculated value to an applied +term. + +### ##subsubsec Path Expressions + +Path expressions allow assigning a value to an applied term or term +component. There are two kinds of path expressions: + +[· ]{style="font-family:Symbol"}[[A *model path* is used within +]{style="font-family:\"Arial\",sans-serif"}]{.Datatype}[Annotation +Path](#AnnotationPath), [Model Element Path](#ModelElementPath), +[Navigation Property Path](#NavigationPropertyPath), and [Property +Path](#PropertyPath) expressions to traverse the model of a service and +resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) `Edm.AnnotationPath`, +`Edm.NavigationPropertyPath`, `Edm.PropertyPath`, and their base types +`Edm.AnyPropertyPath` and `Edm.ModelElementPath`. + +[· ]{style="font-family:Symbol"}An *instance path* is used within a +[Value Path](#ValuePath) expression to traverse a graph of type +instances and resolves to the value identified by the path. It allows +assigning values to terms or term properties of built-in types other +than the `Edm.*Path` types, or of any model-defined type. + +#### ##subsubsubsec Path Syntax + +Model paths and instance paths share a common syntax which is derived +from the path expression syntax of URLs, see [OData‑URL](#ODataURL). + +A path MUST be composed of zero or more path segments joined together by +forward slashes (`/`). + +Paths starting with a forward slash (`/`) are absolute paths, and the +first path segment MUST be the qualified name of a model element, e.g. +an entity container. The remaining path after the second forward slash +is interpreted relative to that model element. + +Example 58: absolute path to an entity set + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +/self.MyEntityContainer/MyEntitySet +::: + +Paths not starting with a forward slash are interpreted relative to the +annotation target, following the rules specified in section "[Path +Evaluation](#PathEvaluation)". + +Example 59: relative path to a property + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +Address/City +::: + +If a path segment is a [qualified name](#QualifiedName), it represents a +[*type cast*]{#ref_TypeCast}, and the segment MUST be the name of a type +in scope. If the type or instance identified by the preceding path part +cannot be cast to the specified type, the path expression evaluates to +the null value. + +Example 60: type-cast segment + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../self.Manager/... +::: + +If a path segment starts with an at (`@`) character, it represents a +[*term cast*]{#ref_TermCast}. The at (`@`) character MUST be followed by +a [qualified name](#QualifiedName) that MAY be followed by a hash (`#`) +character and a [simple identifier](#SimpleIdentifier). The [qualified +name](#QualifiedName) preceding the hash character MUST resolve to a +term that is in scope, the [simple identifier](#SimpleIdentifier) +following the hash sign is interpreted as a [qualifier](#Qualifier) for +the term. If the model element or instance identified by the preceding +path part has not been annotated with that term (and if present, with +that qualifier), the term cast evaluates to the null value. Four special +terms are implicitly "annotated" for media entities and stream +properties: + +- `odata.mediaEditLink` +- `odata.mediaReadLink` +- `odata.mediaContentType` +- `odata.mediaEtag` + +Example 61: term-cast segment + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../@Capabilities.SortRestrictions/... +::: + +If a path segment is a [simple identifier](#SimpleIdentifier), it MUST +be the name of a child model element of the model element identified by +the preceding path part, or a structural or navigation property of the +instance identified by the preceding path part. A sequence of navigation +segments can traverse multiple CSDL documents. The document containing +the path expression only needs to reference the next traversed document +to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document. + +A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path. + +Example 62: property segment in model path + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../Orders/Items/Product/... +::: + +An instance path MUST NOT contain more than one segment representing a +collection-valued construct, e.g. an entity set or a collection-valued +navigation property that is not followed by a key predicate, or a +collection-valued structural property that is not followed by an index +segment. The result of the expression is the collection of instances +resulting from applying any remaining segments that operate on a +single-valued expression to each instance in the collection-valued +segment. + +An instance path MAY terminate in a `$count` segment if the previous +segment is collection-valued, in which case the path evaluates to the +number of items in the collection identified by the preceding segment. + +Example 63: property segments in instance path + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../Addresses/Street + +.../Addresses/\$count +::: + +A model path MAY contain path segments starting with a navigation +property, then followed by an at (`@`) character, then followed by the +[qualified name](#QualifiedName) of a term in scope, and optionally +followed by a hash (`#`) character and a [simple +identifier](#SimpleIdentifier) which is interpreted as a +[qualifier](#Qualifier) for the term. If the navigation property has not +been annotated with that term (and if present, with that qualifier), the +path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity +type specified by the navigation property are addressed via a [term-cast +segment](#ref_TermCast). + +Example 64: model path addressing an annotation on a navigation property + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +.../Items@Capabilities.InsertRestrictions/Insertable +::: + +An instance path MAY contain path segments starting with an entity set +or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see +[OData‑URL](#ODataURL). The key values are either primitive literals or +instance paths. If the key value is a relative instance path, it is +interpreted according to the same rule below as the instance path it is +part of, *not* relative to the instance identified by the preceding path +part. + +Example 65: instance path with entity set and key predicate + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +/self.container/SettingsCollection(\'FeatureXxx\')/IsAvailable + +/self.container/Products(ID=ProductID)/Name +::: + +An instance path MAY contain an index segment immediately following a +path segment representing an ordered collection-valued structural +property. The index is zero-based and MUST be an integer literal. +Negative integers count from the end of the collection, with -1 +representing the last item in the collection. Remaining path segments +are evaluated relative to the identified item of the collection. + +Example 66: instance path with collection-valued structural property and +index segment + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +Addresses/1 + +Addresses/-1/Street +::: + +#### ##subsubsubsec Path Evaluation + +Annotations MAY be embedded within their target, or specified +separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as +*targeting* in the remainder of this section. + +For annotations embedded within or targeting an entity container, the +path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a +segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules +for path expressions targeting the corresponding child element. + +For annotations embedded within or targeting an entity set or a +singleton, the path is evaluated starting at the entity set or +singleton, i.e. an empty path resolves to the entity set or singleton, +and non-empty paths MUST follow the rules for annotations targeting the +declared entity type of the entity set or singleton. + +For annotations embedded within or targeting an entity type or complex +type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be +a structural or navigation property of the type, a [type +cast](#ref_TypeCast), or a [term cast](#ref_TermCast). + +For annotations embedded within a structural or navigation property of +an entity type or complex type, the path is evaluated starting at the +directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other +properties of the same type. An empty path resolves to the enclosing +type, and non-empty paths MUST follow the rules for annotations +targeting the directly enclosing type. + +For annotations targeting a structural or navigation property of an +entity type or complex type, the path is evaluated starting at the +*outermost* entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the +first segment of a non-empty path MUST be a structural or navigation +property of the outermost type, a [type cast](#ref_TypeCast), or a [term +cast](#ref_TermCast). + +For annotations embedded within or targeting an action, action import, +function, function import, parameter, or return type, the first segment +of the path MUST be a parameter name or `$ReturnType`. + +#### ##subsubsubsec Annotation Path + +The annotation path expression provides a value for terms or term +properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.AnnotationPath or Edm.ModelElementPath`. Its argument is a [model +path](#PathExpressions) with the following restriction: + +[[· +]{style="font-family:Symbol"}]{.Datatype}`A non-null path MUST resolve to an annotation. ` + +A term or term property of type `Edm.AnnotationPath` can be annotated +with term `Validation.AllowedTerms` (see +[OData-VocValidation](#ODataVocValidation)) if its intended value is an +annotation path that ends in a term cast with one of the listed terms. + +The value of the annotation path expression is the path itself, not the +value of the annotation identified by the path. This is useful for terms +that reuse or refer to other terms. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:AnnotationPath` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:AnnotationPath` expression MAY be provided using element +notation or attribute notation. +::: + +Example 67: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[\ +]{style="color:black"} + +  + +\ + +  \ + +    \Supplier/@Communication.Contact\ + +    \Customer/@Communication.Contact\ + +  \ + +\ +::: + +#### ##subsubsubsec Model Element Path + +The model element path expression provides a value for terms or term +properties that specify the [built-in +type](#BuiltInTypesfordefiningVocabularyTer)` Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions). + +The value of the model element path expression is the path itself, not +the instance(s) identified by the path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:ModelElementPath` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:ModelElementPath` expression MAY be provided using element +notation or attribute notation. +::: + +Example 68: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +` ` + +` ` + +` ` + +`  /org.example.someAction ` + +`` +::: + +#### ##subsubsubsec Navigation Property Path + +The navigation property path expression provides a value for terms or +term properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. +Its argument is a [model path](#PathExpressions) with the following +restriction: + +[· ]{style="font-family:Symbol"}A non-null path MUST resolve to a model +element whose type is an entity type, or a collection of entity types, +e.g. a navigation property. + +The value of the navigation property path expression is the path itself, +not the instance(s) identified by the path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:NavigationPropertyPath` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:NavigationPropertyPath` expression MAY be provided using +element notation or attribute notation. +::: + +Example 69: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` + +` ` + +`` + +[[  \\ +    \]{style="color:black"}]{.Datatype} + +`      ` + +`        Supplier` + +`        Category` + +`      ` + +`    ` + +`  ` + +`` +::: + +#### ##subsubsubsec Property Path + +The property path expression provides a value for terms or term +properties that specify one of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions) with the following +restriction: + +[· ]{style="font-family:Symbol"}A non-null path MUST resolve to a model +element whose type is a primitive or complex type, an enumeration type, +a type definition, or a collection of one of these types. + +The value of the property path expression is the path itself, not the +value of the property or the value of the term cast identified by the +path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:PropertyPath` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:PropertyPath` MAY be provided using either element notation or +attribute notation. +::: + +Example 70: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` + +` ` + +[[\\ +  \\ +    \]{style="color:black"}]{.Datatype} + +`      ` + +`        CreatedAt` + +`        ChangedAt` + +`      ` + +`    ` + +`  ` + +`` +::: + +#### ##subsubsubsec Value Path + +The` value path` expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation +properties of structured types, and properties of structured types. Its +argument is an [instance path](#PathExpressions). + +The value of the path expression is the instance or collection of +instances identified by the path. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Path` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Path` expression MAY be provided using element notation or +attribute notation. +::: + +Example 71: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +\ +\\ +  \@vCard.Address#work/FullName\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Comparison and Logical Operators + +Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and +they MAY be used anywhere instead of a Boolean expression. + + **Operator** **Description** + -------------------------- ------------------------------- + **Logical Operators** + `And` `Logical and` + `Or` `Logical or` + `Not` `Logical negation` + **Comparison Operators** + `Eq` `Equal` + `Ne` `Not equal` + `Gt` `Greater than` + `Ge` `Greater than or equal` + `Lt` Less than + `Le` `Less than or equal` + `Has` `Has enumeration flag(s) set` + `In` `Is in collection` + +The `And` and `Or` operators require two operand expressions that +evaluate to Boolean values. The `Not` operator requires a single operand +expression that evaluates to a Boolean value. For details on null +handling for comparison operators see [OData‑URL](#ODataURL). + +The other comparison operators require two operand expressions that +evaluate to comparable values. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +`Expressions edm:And and edm:Or` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `And` and `Or` logical expressions are represented as elements +`edm:And` and `edm:Or` that MUST contain two annotation expressions. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`Expression `]{#_Toc37318965}`edm:Not` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Negation expressions are represented as an element `edm:Not` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`Expressions `]{#_Toc37318966}`edm:Eq, edm:Ne, edm:Gt, edm:Ge, edm:Lt, edm:Le, edm:Has, and edm:In` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +All comparison expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +Example 72: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` + +`  IsMale` + +`  IsMarried` + +`` + +`` + +`  IsMale` + +`  IsMarried` + +`` + +`` + +`  IsMale` + +`` + +`` + +`  ` + +`  IsMale` + +`` + +`` + +`  ` + +`  IsMale` + +`` + +`` + +`  Price` + +`  20` + +`` + +`` + +`  Price` + +`  10` + +`` + +`` + +`  Price` + +`  20` + +`` + +`` + +`  Price` + +`  100` + +`` + +`` + +`  Fabric` + +`  org.example.Pattern/Red` + +`` + +`` + +`  Size` + +`  ` + +`    XS` + +`    S` + +`  ` + +`` +::: + +### ##subsubsec Arithmetic Operators + +Annotations MAY use the following arithmetic expressions which evaluate +to a numeric value. These expressions MAY be combined, and they MAY be +used anywhere instead of a numeric expression of the appropriate type. +The semantics and evaluation rules for each arithmetic expression is +identical to the corresponding arithmetic operator defined in +[OData‑URL](#ODataURL). + + **Operator** **Description** + -------------- --------------------------------------------------------------- + `Add` `Addition` + `Sub` `Subtraction` + `Neg` `Negation` + `Mul` `Multiplication` + `Div` `Division (with integer result for integer operands)` + `DivBy` `Division (with fractional result also for integer operands)` + `Mod` `Modulo` + +The `Neg` operator requires a single operand expression that evaluates +to a numeric value. The other arithmetic operators require two operand +expressions that evaluate to numeric values. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`Expression `]{#_Toc37318967}`edm:Neg` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +Negation expressions are represented as an element `edm:Neg` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +[`Expressions `]{#_Toc37318968}`edm:Add, edm:Sub, edm:Mul, edm:Div, edm:DivBy, and edm:Mod` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +These arithmetic expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +Example 73: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` + +`  StartDate` + +`  Duration` + +`` + +`` + +`  Revenue` + +`  Cost` + +`` + +`` + +`  Height` + +`` + +`` + +`  NetPrice` + +`  TaxRate` + +`` + +`
    ` + +`  Quantity` + +`  QuantityPerParcel` + +`
    ` + +`` + +`  Quantity` + +`  QuantityPerParcel` + +`` + +`` + +`  Quantity` + +`  QuantityPerParcel` + +`` +::: + +### ##subsubsec Apply Client-Side Function + +The apply expression enables a value to be obtained by applying a +client-side function. The apply expression MAY have operand expressions. +The operand expressions are used as parameters to the function. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Apply` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Apply` element MUST contain the `Function` attribute and MAY +contain annotation expressions as operands for the applied function. + +It MAY contain more [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Function` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Function` is the [qualified name](#QualifiedName) of the +client-side function to apply. +::: + +OData defines the following functions. Services MAY support additional +functions that MUST be qualified with a namespace or alias other than +`odata`. Function names qualified with `odata` are reserved for this +specification and its future versions. + +#### ##subsubsubsec Canonical Functions + +All canonical functions defined in [OData‑URL](#ODataURL) can be used as +client-side functions, qualified with the namespace `odata`. The +semantics of these client-side functions is identical to their +counterpart function defined in [OData‑URL](#ODataURL). + +For example, the `odata.concat` client-side function takes two or more +expressions as arguments. Each argument MUST evaluate to a primitive or +enumeration type. It returns a value of type `Edm.String` that is the +concatenation of the literal representations of the results of the +argument expressions. Values of primitive types other than `Edm.String` +are represented according to the appropriate alternative in the +`primitiveValue` rule of [OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as +`binaryValue`, `Edm.Boolean` as `booleanValue` etc. + +Example 74: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \Product: \\ +    \ProductName\\ +    \ (\\ +    +\Available/Quantity\]{style="color:black"}]{.Datatype} + +[[    \ \\ +    \Available/Unit\]{style="color:black"}]{.Datatype} + +`    available)` + +[[  \\ +\]{style="color:black"}]{.Datatype} +::: + +`ProductName` is of type `String`, `Quantity` in complex type +`Available` is of type `Decimal`, and `Unit` in `Available` is of type +enumeration, so the result of the `Path` expression is represented as +the member name of the enumeration value. + +#### ##subsubsubsec [Function `odata.fillUriTemplate`](#FunctionodatafillUriTemplate) + +The `odata.fillUriTemplate` client-side function takes two or more +expressions as arguments and returns a value of type `Edm.String.` + +The first argument MUST be of type `Edm.String` and specifies a URI +template according to [RFC6570](#rfc6570), the other arguments MUST be +[labeled element expressions](#LabeledElement). Each [labeled element +expression](#LabeledElement) specifies the template parameter name in +its `Name` attribute and evaluates to the template parameter value. + +[RFC6570](#rfc6570) defines three kinds of template parameters: simple +values, lists of values, and key-value maps. + +Simple values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a single primitive value. +The literal representation of this value according to +[OData‑ABNF](#ODataABNF) is used to fill the corresponding template +parameter. + +Lists of values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of primitive +values. + +Key-value maps are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of complex +types with two properties that are used in lexicographic order. The +first property is used as key, the second property as value. + +Example 75: assuming there are no special characters in values of the +`Name property of the Actor` entity + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\ + +  \http://host/someAPI/Actors/{actorName}/CV\ + +  \ + +\ +::: + +#### ##subsubsubsec [Function `odata.matchesPattern`](#FunctionodatamatchesPattern) + +The `odata.matchesPattern` client-side function takes two string +expressions as arguments and returns a Boolean value`.` + +The function returns true if the second expression evaluates to an +[**\[ECMAScript\]**](#ECMAScript) (JavaScript) regular expression and +the result of the first argument expression matches that regular +expression, using syntax and semantics of +[**\[ECMAScript\]**](#ECMAScript) regular expressions. + +Example 76: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\ + +  \FirstName\ + +  \\^\[\^b-d\]+\$\ + +\ +::: + +#### ##subsubsubsec [Function `odata.uriEncode`](#FunctionodatauriEncode) + +The `odata.uriEncode `client-side function takes one argument of +primitive type and returns the URL-encoded OData literal that can be +used as a key value in OData URLs or in the query part of OData URLs. + +Note: string literals are surrounded by single quotes as required by the +paren-style key syntax. + +Example 77: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +\ + +  \http://host/service/Genres({genreName})\ + +  \ + +    \ + +      \NameOfMovieGenre\ + +    \ + +  \ + +\ +::: + +### ##subsubsec Cast + +The cast expression casts the value obtained from its single child +expression to the specified type. The cast expression follows the same +rules as the `cast` canonical function defined in +[OData‑URL](#ODataURL). + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Cast` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Cast` element MUST contain the `Type` attribute and MUST +contain exactly one expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Type` is a qualified type name in scope, or the character +sequence `Collection(` followed by the qualified name of a type in +scope, followed by a closing parenthesis `)`. + +If the specified type is a primitive type or a collection of a primitive +type, the facet attributes [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet attributes are not specified, their values +are considered unspecified. +::: + +Example 78: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \Average\\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Collection + +The collection expression enables a value to be obtained from zero or +more item expressions. The value calculated by the collection expression +is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type +compatible. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Collection` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Collection` element contains zero or more child expressions. +::: + +Example 79: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \Product\\ +    \Supplier\\ +    \Customer\\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec If-Then-Else + +The if-then-else expression enables a value to be obtained by evaluating +a *condition expression*. It MUST contain exactly three child +expressions. There is one exception to this rule: if and only if the +if-then-else expression is a direct child of a collection expression`,` +the third child expression MAY be omitted, reducing it to an if-then +expression. This can be used to conditionally add an element to a +collection. + +The first child element is the condition and MUST evaluate to a Boolean +result, e.g. the [comparison and logical +operators](#ComparisonandLogicalOperators) can be used. + +The second and third child elements are evaluated conditionally. The +result MUST be type compatible with the type expected by the surrounding +expression. + +If the first expression evaluates to `true`, the second expression MUST +be evaluated and its value MUST be returned as the result of the +if-then-else expression. If the first expression evaluates to `false` +and a third child element is present, it MUST be evaluated and its value +MUST be returned as the result of the if-then-else expression. If no +third child element is present, nothing is added to the surrounding +collection. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:If` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:If` element MUST contain two or three child expressions that +MUST use element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +Example 80: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale` ,whose value then determines +the value of the `edm:If` expression + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \IsFemale\\ +    \Female\\ +    \Male\\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Is-Of + +The is-of expression checks whether the value obtained from its single +child expression is compatible with the specified type. It returns +`true` if the child expression returns a type that is compatible with +the specified type, and `false` otherwise. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:IsOf` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:IsOf` element MUST contain the `Type` attribute and MUST +contain exactly one child expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Type` is the qualified name of a type in scope, or the +character sequence `Collection(` followed by the qualified name of a +type in scope, followed by a closing parenthesis `)`. + +If the specified type is a primitive type or a collection of a primitive +type, the facet attributes [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet attributes are not specified, their values +are considered unspecified. +::: + +Example 81: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \Customer\\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec [Labeled Element](#LabeledElement) + +The labeled element expression assigns a name to its single child +expression. The value of the child expression can then be reused +elsewhere with a [labeled element reference +expression](#LabeledElementReference). + +A labeled element expression MUST contain exactly one child expression. +The value of the child expression is also the value of the labeled +element expression. + +A labeled element expression MUST provide a [simple +identifier](#SimpleIdentifier) value as its name that MUST be unique +within the schema containing the expression. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:LabeledElement` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:LabeledElement` element MUST contain the Name attribute. + +It MUST contain a child expression written either in attribute notation +or element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Name` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Name` is the labeled element's name. +::: + +Example 82: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +[[\\ +  \\ +    \FirstName\\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Labeled Element Reference + +The labeled element reference expression MUST specify the [qualified +name](#QualifiedName) of a [labeled element expression](#LabeledElement) +in scope and returns the value of the identified labeled element +expression as its value. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:LabeledElementReference` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The edm:LabeledElementReference element MUST contain the qualified name +of a labeled element expression in its body. +::: + +Example 83: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  +\Model.CustomerFirstName\\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec Null + +The null expression indicates the absence of a value. The null +expression MAY be annotated. + +The null expression MUST be written with element notation. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Null` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The edm:Null element MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +Example 84: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +Example 85: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`` + +`  ` + +`    ` + +`  ` + +`` +::: + +### ##subsubsec Record + +The record expression enables a new entity type or complex type instance +to be constructed. + +A record expression MAY specify the structured type of its result, which +MUST resolve to an entity type or complex type in scope. If not +explicitly specified, the type is derived from the expression's context. + +A record expression contains zero or more property value expressions. +For each single-valued structural or navigation property of the record +expression's type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if +the record expression is the value of an annotation for a term that has +a [base term](#SpecializedTerm) whose type is structured and directly or +indirectly inherits from the type of its base term. In this case, +property values that already have been specified in the annotation for +the base term or its base term etc. need not be specified again. + +For collection-valued properties the absence of a property value +expression is equivalent to specifying an empty collection as its value. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:Record` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:Record` element MAY contain the `Type` attribute and MAY +contain `edm:PropertyValue` elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Type` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Type` is the qualified name of a structured type in scope. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Element `edm:PropertyValue` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:PropertyValue` element MUST contain the `Property` attribute, +and it MUST contain exactly one expression that MAY be provided using +either element notation or attribute notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Attribute `Property` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The value of `Property` is the name of a property of the type of the +enclosing `edm:Record` expression. +::: + +Example 86: this annotation "morphs" the entity type from example 8 into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \]{style="color:black"}]{.Datatype} + +`    ` + +`      ` + +[[    \\ +    \]{style="color:black"}]{.Datatype} + +`    ` + +`    ` + +`      ` + +`        ` + +`          http://host/anotherservice/CostCenters('{ccid}') ` + +`           ` + +`         ` + +`      ` + +[[    \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +### ##subsubsec URL Reference + +The URL reference expression enables a value to be obtained by sending a +`GET` request. + +The URL reference expression MUST contain exactly one expression of type +`Edm.String`. Its value is treated as a URL that MAY be relative or +absolute; relative URIs are relative to the URL of the document +containing the URL reference expression, or relative to a base URL +specified in a format-specific way. + +The response body of the `GET` request MUST be returned as the result of +the` `URL reference expression. The result of the` edm:UrlRef` +expression MUST be type compatible with the type expected by the +surrounding element or expression. + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:0in"} +Expression `edm:UrlRef` +::: + +::: {style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 8.0pt; +margin-left:21.55pt;margin-right:21.55pt"} +The `edm:UrlRef` expression MAY be provided using element notation or +attribute notation. + +Relative URLs are relative to the `xml:base` attribute, see +[**\[XML‑Base\]**](#BMXMLBase). + +In element notation it MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + + Example 87: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \\ +      \http://host/service/Suppliers({suppID})\\ +      \\ +      \\ +        \SupplierId\\ +      \\ +      \\ +     \\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +`` + +`  http://host/wiki/HowToUse` + +`` + +` ` + +`` +::: + +# ##sec Identifier and Path Values + +## ##subsec Namespace + +A namespace is a dot-separated sequence of [simple +identifier](#SimpleIdentifier)s with a maximum length of 511 Unicode +characters (code points). + +## ##subsec Simple Identifier + +A simple identifier is a Unicode character sequence with the following +restrictions: + +- It consists of at least one and at most 128 Unicode characters (code + points). +- The first character MUST be the underscore character (U+005F) or any + character in the Unicode category "Letter (L)" or "Letter number + (Nl)". +- The remaining characters MUST be the underscore character (U+005F) + or any character in the Unicode category "Letter (L)", "Letter + number (Nl)", "Decimal number (Nd)", "Non-spacing mark (Mn)", + "Combining spacing mark (Mc)", "Connector punctuation (Pc)", and + "Other, format (Cf)". + +Non-normatively speaking it starts with a letter or underscore, followed +by at most 127 letters, underscores or digits. + +## ##subsec Qualified Name + +For model elements that are direct children of a schema: the namespace +or alias of the schema that defines the model element, followed by a dot +and the name of the model element, see rule `qualifiedTypeName` in +[OData‑ABNF](#ODataABNF). + +For built-in [primitive types](#PrimitiveTypes): the name of the type, +prefixed with `Edm` followed by a dot. + +## ##subsec Target Path + +Target paths are used in attributes of CSDL elements to refer to other +CSDL elements or their nested child elements. + +The allowed path expressions are: + +[[· ]{style="font-size:9.0pt;font-family:Symbol; +color:black"}]{.apple-converted-space}The [qualified +name](#QualifiedName) of an entity container, followed by a forward +slash and the name of a container child element + +[· ]{style="font-size:9.0pt;font-family:Symbol;color:black"}The target +path of a container child followed by a forward slash and one or more +forward-slash separated property, navigation property, or type-cast +segments + +Example 88: Target expressions + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +MySchema.MyEntityContainer/MyEntitySet + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty + +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp +::: + +# ##sec CSDL Examples + +Following are two basic examples of valid EDM models as represented in +CSDL. These examples demonstrate many of the topics covered above. + +## ##subsec [Products and Categories Example](#ProductsandCategoriesExample) + +Example 89: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +`\ +  \]{style="color:black"}]{.Datatype} + +`    ` + +`      ` + +`    ` + +`  ` + +`  ` + +`    ` + +`  ` + +[[  \\ +    \\ +      \\ +        \\ +          \\ +        \\ +        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`        ` + +[[        \\ +        \\ +        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`        ` + +`        ` + +`        ` + +`        \ +      \\ +      \\ +        \\ +         \\ +        \\ +        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`        ` + +`        \ +          \]{style="color:black"}]{.Datatype} + +[[        \\ +      \\ +      \\ +        \\ +          \\ +        \\ +        \\ +        \\ +        \\ +        \\ +        \` + +[[      \\ +      \]{style="color:black"}]{.Datatype} + +`        ` + +`          ` + +`        ` + +`        ` + +`        ` + +`      ` + +[[      \\ +        \\ +        \\ +        \\ +        \\ +        \\ +        \]{style="color:black"}]{.Datatype} + +`          ` + +`        ` + +[[      \\ +      \\ +        \]{style="color:black"}]{.Datatype} + +[[        \\ +      \\ +      \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +[[        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`          ` + +[[        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`          ` + +`          ` + +`            ` + +`              Concurrency` + +`            ` + +`          ` + +[[        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`          ` + +`        ` + +`        ` + +`        \ +      \\ +    \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +## ##subsec [Annotations for Products and Categories Example](#AnnotationsforProductsandCategoriesE) + +Example 90: + +::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: +solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; +background:#D9D9D9;margin-left:.3in;margin-right:.3in"} +[[\\ +  \\ +    \]{style="color:black"}]{.Datatype} + +`  ` + +`  ` + +`    ` + +`  ` + +[[  \\ +    \\ +      \\ +        \\ +          \\ +        \\ +        \\ +        \\ +        \\ +        \\ +            \Name\\ +            \ in \\ +            \Address/CountryName\\ +          \\ +        \\ +      \\ +      \]{style="color:black"}]{.Datatype} + +`        ` + +`          ` + +`            MasterData` + +`          ` + +`        ` + +`      ` + +`  ` + +[[  \\ +\]{style="color:black"}]{.Datatype} +::: + +# ##sec Conformance + +Conforming services MUST follow all rules of this specification document +for the types, sets, functions, actions, containers and annotations they +expose. + +In addition, conforming services MUST NOT return 4.01 CSDL constructs +for requests made with `OData-MaxVersion:4.0`. + +Specifically, they + +1\. MUST NOT include properties in derived types that overwrite a +property defined in the base type + +2\. MUST NOT include [[Edm.Untyped]{style="font-family: +\"Courier New\";color:windowtext"}](#EntityModel) + +3\. MUST NOT use [path syntax](#PathSyntax) added with 4.01 + +4\. MUST NOT use +[[Edm.ModelElementPath]{style="font-family:\"Courier New\"; +color:windowtext"}](#EntityModel) and +[[Edm.AnyPropertyPath]{style="font-family:\"Courier New\";color:windowtext"}](#EntityModel) + +5\. MUST NOT specify [referential constraints](#ReferentialConstraint) +to complex types and navigation properties + +6\. MUST NOT include a non-abstract entity type with no inherited or +defined [entity key](#Key) + +7\. MUST NOT include the +[`Core.DefaultNamespace`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#DefaultNamespace) +annotation on [included schemas](#IncludedSchema) + +8\. MUST NOT return the Unicode facet for terms, parameters, and return +types + +9\. MUST NOT include collections of +[[Edm.ComplexType]{style="font-family:\"Courier New\";color:windowtext"}](#EntityModel) +or +[[Edm.Untyped]{style="font-family:\"Courier New\";color:windowtext"}](#EntityModel) + +10\. MUST NOT specify a key as a property of a related entity + +11\. SHOULD NOT include new/unknown values for the +[`AppliesTo`](#Applicability) attribute + +12\. SHOULD specify the [Nullable](#Nullable) facet for collections + +13\. MAY include new CSDL annotations + +In addition, OData 4.01 services: + +14\. MUST specify the [Nullable](#Nullable) facet for collections + +15\. SHOULD NOT have identifiers within a uniqueness scope (e.g. a +schema, a structural type or an entity container) that differ only by +case + +Conforming clients MUST be prepared to consume a model that uses any or +all constructs defined in this specification, including custom +annotations, and MUST ignore any elements or attributes not defined in +this version of the specification. + +Appendix A. [Acknowledgments](#Acknowledgments) + +The contributions of the OASIS OData Technical Committee members, +enumerated in [OData‑Protocol](#ODataProtocol), are gratefully +acknowledged. + +Appendix B. [Table of XML Elements and +Attributes](#TableofXMLElementsandAttributes) + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection3 +[Element `edmx:Edmx`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318837) + +[Attribute `Version`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318838) + +[Element `edmx:DataServices`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318839) + +[Element `edmx:Reference`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318840) + +[Attribute `Uri`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37318841) + +[Element `edmx:Include`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37318842) + +[Attribute `Namespace`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37318843) + +[Attribute `Alias`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37318844) + +[Element `edmx:IncludeAnnotations`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37318845) + +[Attribute `TermNamespace`[. +]{style="color:windowtext;display:none"}[18]{style="color:windowtext;display:none"}](#_Toc37318846) + +[Attribute `Qualifier`[. +]{style="color:windowtext;display:none"}[18]{style="color:windowtext;display:none"}](#_Toc37318847) + +[Attribute `TargetNamespace`[. ]{style="color:windowtext;display: +none"}[18]{style="color:windowtext;display:none"}](#_Toc37318848) + +[[Element ]{lang="DE"}[edm:Schema]{lang="DE" +style="font-family:\"Courier New\""}[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37318849) + +[Attribute `Namespace`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37318850) + +[Attribute `Alias`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37318851) + +[Element `edm:Annotations`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37318852) + +[Attribute `Target`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37318853) + +[Attribute `Qualifier`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37318854) + +[Element `edm:EntityType`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37318855) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37318856) + +[Attribute `BaseType`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37318857) + +[Attribute `Abstract`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37318858) + +[Attribute `OpenType`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37318859) + +[Attribute `HasStream`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37318860) + +[Element `edm:Key`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37318861) + +[Element `edm:PropertyRef`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37318862) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37318863) + +[Attribute `Alias`[. +]{style="color:windowtext;display:none"}[24]{style="color:windowtext;display:none"}](#_Toc37318864) + +[Element `edm:Property`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37318865) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37318866) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37318867) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[26]{style="color:windowtext;display:none"}](#_Toc37318868) + +[Attribute `MaxLength`[. +]{style="color:windowtext;display:none"}[26]{style="color:windowtext;display:none"}](#_Toc37318869) + +[Attribute `Precision`[. +]{style="color:windowtext;display:none"}[27]{style="color:windowtext;display:none"}](#_Toc37318870) + +[Attribute `Scale`[. +]{style="color:windowtext;display:none"}[27]{style="color:windowtext;display:none"}](#_Toc37318871) + +[Attribute `Unicode`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37318872) + +[Attribute `SRID`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37318873) + +[Attribute `DefaultValue`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37318874) + +[Element `edm:NavigationProperty`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37318875) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37318876) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37318877) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37318878) + +[Attribute `Partner`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37318879) + +[Attribute `ContainsTarget`[. +]{style="color:windowtext;display:none"}[31]{style="color:windowtext;display:none"}](#_Toc37318880) + +[Element `edm:ReferentialConstraint`[. +]{style="color:windowtext;display:none"}[31]{style="color:windowtext;display:none"}](#_Toc37318881) + +[Attribute `Property`[. +]{style="color:windowtext;display:none"}[32]{style="color:windowtext;display:none"}](#_Toc37318882) + +[Attribute `ReferencedProperty`[. ]{style="color:windowtext; +display:none"}[32]{style="color:windowtext;display:none"}](#_Toc37318883) + +[Element `edm:OnDelete`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37318884) + +[Attribute `Action`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37318885) + +[Element `edm:ComplexType`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37318886) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37318887) + +[Attribute `BaseType`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37318888) + +[Attribute `Abstract`[. +]{style="color:windowtext;display:none"}[35]{style="color:windowtext;display:none"}](#_Toc37318889) + +[Attribute `OpenType`[. +]{style="color:windowtext;display:none"}[35]{style="color:windowtext;display:none"}](#_Toc37318890) + +[Element `edm:EnumType`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318891) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318892) + +[Attribute `UnderlyingType`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318893) + +[Attribute `IsFlags`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318894) + +[Element `edm:Member`[. +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37318895) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37318896) + +[Attribute `Value`[. +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37318897) + +[Element `edm:TypeDefinition`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37318898) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37318899) + +[Attribute `UnderlyingType`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37318900) + +[Element `edm:Action`[. +]{style="color:windowtext;display:none"}[40]{style="color:windowtext;display:none"}](#_Toc37318901) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[40]{style="color:windowtext;display:none"}](#_Toc37318902) + +[Element `edm:Function`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318903) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318904) + +[Attribute `IsBound`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318905) + +[Attribute `EntitySetPath`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318906) + +[Attribute `IsComposable`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318907) + +[Element `edm:ReturnType`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318908) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318909) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318910) + +[Element `edm:Parameter`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318911) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318912) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318913) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318914) + +[Element `edm:EntityContainer`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37318915) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37318916) + +[Attribute `Extends`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318917) + +[Element `edm:EntitySet`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318918) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318919) + +[Attribute `EntityType`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318920) + +[Attribute `IncludeInServiceDocument`[. ]{style="color:windowtext; +display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318921) + +[Element `edm:Singleton`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318922) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318923) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318924) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318925) + +[Element `edm:NavigationPropertyBinding`[. +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37318926) + +[Attribute `Path`[. +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37318927) + +[Attribute `Target`[. +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37318928) + +[Element `edm:ActionImport`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318929) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318930) + +[Attribute `Action`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318931) + +[Attribute `EntitySet`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318932) + +[Element `edm:FunctionImport`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318933) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318934) + +[Attribute `Function`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318935) + +[Attribute `EntitySet`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318936) + +[Attribute `IncludeInServiceDocument`[. ]{style="color:windowtext; +display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37318937) + +[Element `edm:Term`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318938) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318939) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318940) + +[Attribute `DefaultValue`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318941) + +[Attribute `BaseTerm`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318942) + +[Attribute `AppliesTo`[. +]{style="color:windowtext;display:none"}[53]{style="color:windowtext;display:none"}](#_Toc37318943) + +[Element `edm:Annotation`[. +]{style="color:windowtext;display:none"}[53]{style="color:windowtext;display:none"}](#_Toc37318944) + +[Attribute `Term`[. +]{style="color:windowtext;display:none"}[53]{style="color:windowtext;display:none"}](#_Toc37318945) + +[Attribute `Qualifier`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37318946) + +[Expression `edm:Binary`[. +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37318947) + +[Expression `edm:Bool`[. +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37318948) + +[Expression `edm:Date`[. +]{style="color:windowtext;display:none"}[57]{style="color:windowtext;display:none"}](#_Toc37318949) + +[Expression `edm:DateTimeOffset`[. ]{style="color:windowtext; +display:none"}[57]{style="color:windowtext;display:none"}](#_Toc37318950) + +[Expression `edm:Decimal`[. +]{style="color:windowtext;display:none"}[57]{style="color:windowtext;display:none"}](#_Toc37318951) + +[Expression `edm:Duration`[. +]{style="color:windowtext;display:none"}[58]{style="color:windowtext;display:none"}](#_Toc37318952) + +[Expression `edm:EnumMember`[. +]{style="color:windowtext;display:none"}[58]{style="color:windowtext;display:none"}](#_Toc37318953) + +[Expression `edm:Float`[. +]{style="color:windowtext;display:none"}[58]{style="color:windowtext;display:none"}](#_Toc37318954) + +[Expression `edm:Guid`[. +]{style="color:windowtext;display:none"}[59]{style="color:windowtext;display:none"}](#_Toc37318955) + +[Expression `edm:Int`[. +]{style="color:windowtext;display:none"}[59]{style="color:windowtext;display:none"}](#_Toc37318956) + +[Expression `edm:String`[. +]{style="color:windowtext;display:none"}[59]{style="color:windowtext;display:none"}](#_Toc37318957) + +[Expression `edm:TimeOfDay`[. +]{style="color:windowtext;display:none"}[60]{style="color:windowtext;display:none"}](#_Toc37318958) + +[Expression `edm:AnnotationPath`[. ]{style="color:windowtext; +display:none"}[63]{style="color:windowtext;display:none"}](#_Toc37318959) + +[Expression `edm:ModelElementPath`[. ]{style="color:windowtext; +display:none"}[63]{style="color:windowtext;display:none"}](#_Toc37318960) + +[Expression `edm:NavigationPropertyPath`[. ]{style="color:windowtext; +display:none"}[63]{style="color:windowtext;display:none"}](#_Toc37318961) + +[Expression `edm:PropertyPath`[. ]{style="color:windowtext;display: +none"}[64]{style="color:windowtext;display:none"}](#_Toc37318962) + +[Expression `edm:Path`[. +]{style="color:windowtext;display:none"}[64]{style="color:windowtext;display:none"}](#_Toc37318963) + +[Expressions `edm:And` and `edm:Or`[. +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37318964) + +[Expression `edm:Not`[. +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37318965) + +[Expressions `edm:Eq`, `edm:Ne`, `edm:Gt`, `edm:Ge`, `edm:Lt`, `edm:Le`, +`edm:Has`, and `edm:In`[  +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37318966) + +[Expression `edm:Neg`[. +]{style="color:windowtext;display:none"}[67]{style="color:windowtext;display:none"}](#_Toc37318967) + +[Expressions `edm:Add`, `edm:Sub`, `edm:Mul`, `edm:Div`, `edm:DivBy`, +and `edm:Mod`[  +]{style="color:windowtext;display:none"}[67]{style="color:windowtext;display:none"}](#_Toc37318968) + +[Expression `edm:Apply`[. +]{style="color:windowtext;display:none"}[68]{style="color:windowtext;display:none"}](#_Toc37318969) + +[Attribute `Function`[. +]{style="color:windowtext;display:none"}[68]{style="color:windowtext;display:none"}](#_Toc37318970) + +[Expression `edm:Cast`[. +]{style="color:windowtext;display:none"}[69]{style="color:windowtext;display:none"}](#_Toc37318971) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[69]{style="color:windowtext;display:none"}](#_Toc37318972) + +[Expression `edm:Collection`[. +]{style="color:windowtext;display:none"}[70]{style="color:windowtext;display:none"}](#_Toc37318973) + +[Expression `edm:If`[. +]{style="color:windowtext;display:none"}[70]{style="color:windowtext;display:none"}](#_Toc37318974) + +[Expression `edm:IsOf`[. +]{style="color:windowtext;display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318975) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318976) + +[Expression `edm:LabeledElement`[. ]{style="color:windowtext; +display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318977) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318978) + +[Expression `edm:LabeledElementReference`[. ]{style="color:windowtext; +display:none"}[72]{style="color:windowtext;display:none"}](#_Toc37318979) + +[Expression `edm:Null`[. +]{style="color:windowtext;display:none"}[72]{style="color:windowtext;display:none"}](#_Toc37318980) + +[Expression `edm:Record`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318981) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318982) + +[Element `edm:PropertyValue`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318983) + +[Attribute `Property`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318984) + +[Expression `edm:UrlRef`[. +]{style="color:windowtext;display:none"}[74]{style="color:windowtext;display:none"}](#_Toc37318985) + +  +::: + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection4 +Appendix C. [Revision History](#RevisionHistory) + +  + ++-----------------+-----------------+-----------------+-----------------+ +| **Revision** | **Date** | **Editor** | **Changes | +| | | | Made** | ++-----------------+-----------------+-----------------+-----------------+ +| Working Draft | 2016-09-07 | Michael Pizzo | Imported | +| 01 | | | content from | +| | | Ralf Handl | 4.0 Errata 3 | +| | | | specification | +| | | | and integrated | +| | | | initial 4.01 | +| | | | features | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2016-12-08 | Michael Pizzo | Integrated 4.01 | +| Specification | | | features | +| Draft 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-06-08 | Michael Pizzo | Incorporated | +| Specification | | | normative text | +| Draft 02 | | Ralf Handl | from former | +| | | | OData Part 3: | +| | | | CSDL | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-09-22 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 03 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-11-10 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 04 | | Ralf Handl | | +| | | | Stable order of | +| | | | action and | +| | | | function | +| | | | parameters | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-12-19 | Michael Pizzo | Non-Material | +| Specification | | | Changes | +| 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-06-21 | Michael Pizzo | External | +| Specification | | | targeting for | +| Draft 05 | | Ralf Handl | annotations on | +| | | | action/function | +| | | | overloads, | +| | | | parameters, and | +| | | | return types | +| | | | | +| | | | Key and index | +| | | | segments for | +| | | | path | +| | | | expressions in | +| | | | annotations | +| | | | | +| | | | Nullable | +| | | | singletons | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-09-20 | Michael Pizzo | Redefining | +| Specification | | | entity sets and | +| Draft 06 | | Ralf Handl | singletons when | +| | | | extending | +| | | | entity | +| | | | containers | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-11-05 | Michael Pizzo | Non-material | +| Specification | | | changes | +| 02 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Candidate OASIS | 2020-01-15 | Michael Pizzo | Non-material | +| Standard 01 | | | changes | +| | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Candidate OASIS | 2020-04-09 | Michael Pizzo | Non-material | +| Standard 02 | | | changes | +| | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ + +  +::: diff --git a/odata-csdl/temp/odata-csdl-xml-v4.01-os.html b/odata-csdl/temp/odata-csdl-xml-v4.01-os.html new file mode 100644 index 000000000..fef581398 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-xml-v4.01-os.html @@ -0,0 +1,14911 @@ + + + + + + +OData Common Schema Definition Language (CSDL) XML Representation +Version 4.01 + + + + + + +
    + +

    +OASIS logo

    + +
    + +

    OData Common Schema Definition +Language (CSDL) XML Representation Version 4.01

    + +

    OASIS Standard

    + +

    11 May 2020

    + +
    + +

    This stage:

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/odata-csdl-xml-v4.01-os.docx +(Authoritative)

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/odata-csdl-xml-v4.01-os.html

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/odata-csdl-xml-v4.01-os.pdf

    + +

    Previous stage:

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/cos01/odata-csdl-xml-v4.01-cos01.docx +(Authoritative)

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/cos01/odata-csdl-xml-v4.01-cos01.html

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/cos01/odata-csdl-xml-v4.01-cos01.pdf

    + +

    Latest stage:

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.docx +(Authoritative)

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html

    + +

    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.pdf

    + +

    Technical Committee:

    + +

    OASIS +Open Data Protocol (OData) TC

    + +

    Chairs:

    + +

    Ralf Handl (ralf.handl@sap.com), SAP SE

    + +

    Michael Pizzo (mikep@microsoft.com), +Microsoft

    + +

    Editors:

    + +

    Michael Pizzo (mikep@microsoft.com), Microsoft

    + +

    Ralf Handl (ralf.handl@sap.com), +SAP SE

    + +

    Martin Zurmuehl (martin.zurmuehl@sap.com), SAP SE

    + +

    Additional artifacts:

    + +

    This prose specification is one component of +a Work Product that also includes:

    + +

             +XML schemas: OData EDMX XML Schema and OData EDM +XML Schema. https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/schemas/.

    + +

    Related work:

    + +

    This specification replaces or supersedes:

    + +

             +OData Version 4.0 Part 3: Common Schema Definition Language +(CSDL). Edited by Michael Pizzo, Ralf Handl, and Martin Zurmuehl. OASIS +Standard. Latest stage: http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part3-csdl.html

    + +

    This specification is related to:

    + +

             +OData Version 4.01. Edited by Michael Pizzo, Ralf Handl, +and Martin Zurmuehl. A multi-part Work Product which includes:

    + +

    o    OData +Version 4.01. Part 1: Protocol. Latest stage: https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html.

    + +

    o    +OData Version 4.01. Part 2: URL Conventions. Latest +stage: https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html.

    + +

    o    ABNF +components: OData ABNF Construction Rules Version 4.01 and OData ABNF Test +Cases. https://docs.oasis-open.org/odata/odata/v4.01/os/abnf/.

    + +

             +OData Common Schema Definition Language (CSDL) JSON +Representation Version 4.01. Edited by Michael Pizzo, Ralf Handl, and +Martin Zurmuehl. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html.

    + +

             +OData Vocabularies Version 4.0. Edited by Michael +Pizzo, Ralf Handl, and Ram Jeyaraman. Latest stage: http://docs.oasis-open.org/odata/odata-vocabularies/v4.0/odata-vocabularies-v4.0.html.

    + +

             +OData JSON Format Version 4.01. Edited by Michael Pizzo, +Ralf Handl, and Mark Biamonte. Latest stage: https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html.

    + +

    Declared XML namespaces:

    + +

             +http://docs.oasis-open.org/odata/ns/edmx

    + +

             +http://docs.oasis-open.org/odata/ns/edm

    + +

    Abstract:

    + +

    OData services are described by an Entity Model (EDM). The Common +Schema Definition Language (CSDL) defines specific representations of the +entity data model exposed by an OData service using, XML, JSON, and other +formats. This document (OData CSDL XML Representation) specifically defines the +XML representation of CSDL.

    + +

    Status:

    + +

    This document was last revised or approved by the membership +of OASIS on the above date. The level of approval is also listed above. Check +the Latest stage location noted above for possible later revisions of this +document. Any other numbered Versions and other technical work produced by the +Technical Committee (TC) are listed at https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=odata#technical.

    + +

    TC members should send comments on this specification to the +TCs email list. Others should send comments to the TCs public comment list, +after subscribing to it by following the instructions at the Send +A Comment button on the TCs web page at https://www.oasis-open.org/committees/odata/.

    + +

    This specification is provided under the RF on +RAND Terms Mode of the OASIS IPR Policy, +the mode chosen when the Technical Committee was established. For information +on whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing terms, +please refer to the Intellectual Property Rights section of the TCs web page (https://www.oasis-open.org/committees/odata/ipr.php).

    + +

    Note that any machine-readable content (Computer +Language Definitions) declared Normative for this Work Product is provided +in separate plain text files. In the event of a discrepancy between any such +plain text file and display content in the Work Product's prose narrative +document(s), the content in the separate plain text file prevails.

    + +

    Citation format:

    + +

    When referencing this specification the following citation +format should be used:

    + +

    [OData-CSDL-XML-v4.01]

    + +

    OData Common Schema Definition Language (CSDL) XML +Representation Version 4.01. Edited by Michael Pizzo, Ralf Handl, and Martin +Zurmuehl. 11 May 2020. OASIS Standard. https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/os/odata-csdl-xml-v4.01-os.html. Latest stage: https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html.

    + +
    + +

    Notices

    + +
    + +

    Copyright OASIS Open 2020. All Rights Reserved.

    + +

    All capitalized terms in the following text have the +meanings assigned to them in the OASIS Intellectual Property Rights Policy (the +"OASIS IPR Policy"). The full Policy may be +found at the OASIS website.

    + +

    This document and translations of it may be copied and +furnished to others, and derivative works that comment on or otherwise explain +it or assist in its implementation may be prepared, copied, published, and +distributed, in whole or in part, without restriction of any kind, provided +that the above copyright notice and this section are included on all such +copies and derivative works. However, this document itself may not be modified +in any way, including by removing the copyright notice or references to OASIS, +except as needed for the purpose of developing any document or deliverable +produced by an OASIS Technical Committee (in which case the rules applicable to +copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required +to translate it into languages other than English.

    + +

    The limited permissions granted above are perpetual and will +not be revoked by OASIS or its successors or assigns.

    + +

    This document and the information contained herein is +provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF +THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED +WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

    + +

    OASIS requests that any OASIS Party or any other party that +believes it has patent claims that would necessarily be infringed by +implementations of this OASIS Committee Specification or OASIS Standard, to +notify OASIS TC Administrator and provide an indication of its willingness to +grant patent licenses to such patent claims in a manner consistent with the IPR +Mode of the OASIS Technical Committee that produced this specification.

    + +

    OASIS invites any party to contact the OASIS TC +Administrator if it is aware of a claim of ownership of any patent claims that +would necessarily be infringed by implementations of this specification by a +patent holder that is not willing to provide a license to such patent claims in +a manner consistent with the IPR Mode of the OASIS Technical Committee that +produced this specification. OASIS may include such claims on its website, but +disclaims any obligation to do so.

    + +

    OASIS takes no position regarding the validity or scope of +any intellectual property or other rights that might be claimed to pertain to +the implementation or use of the technology described in this document or the +extent to which any license under such rights might or might not be available; +neither does it represent that it has made any effort to identify any such rights. +Information on OASIS' procedures with respect to rights in any document or +deliverable produced by an OASIS Technical Committee can be found on the OASIS +website. Copies of claims of rights made available for publication and any +assurances of licenses to be made available, or the result of an attempt made +to obtain a general license or permission for the use of such proprietary +rights by implementers or users of this OASIS Committee Specification or OASIS +Standard, can be obtained from the OASIS TC Administrator. OASIS makes no +representation that any information or list of intellectual property rights +will at any time be complete, or that any claims in such list are, in fact, +Essential Claims.

    + +

    The name "OASIS" is a trademark of OASIS, the owner and developer of this +specification, and should be used only to refer to the organization and its +official outputs. OASIS welcomes reference to, and implementation and use of, +specifications, while reserving the right to enforce its marks against +misleading uses. Please see https://www.oasis-open.org/policies-guidelines/trademark +for above guidance.

    + +
    + +

    Table of Contents

    + +
    + +

    1 Introduction. 7

    + +

    1.0 IPR Policy. 7

    + +

    1.1 Terminology. 7

    + +

    1.2 Normative References. 7

    + +

    1.3 Typographical Conventions. 8

    + +

    2 XML +Representation. 9

    + +

    2.1 Requesting the XML Representation. 9

    + +

    2.2 XML Namespaces. 9

    + +

    2.2.1 Namespace EDMX. 9

    + +

    2.2.2 Namespace EDM.. 9

    + +

    2.3 XML Schema Definitions. 10

    + +

    2.4 XML Document Order 10

    + +

    3 Entity Model 11

    + +

    3.1 Nominal Types. 11

    + +

    3.2 Structured Types. 11

    + +

    3.3 Primitive Types. 11

    + +

    3.4 Built-In Abstract Types. 13

    + +

    3.5 Built-In Types for defining +Vocabulary Terms. 14

    + +

    3.6 Annotations. 14

    + +

    4 CSDL XML +Document 15

    + +

    4.1 Reference. 15

    + +

    4.2 Included Schema. 16

    + +

    4.3 Included Annotations. 17

    + +

    5 Schema. 19

    + +

    5.1 Alias. 19

    + +

    5.2 Annotations with External +Targeting. 20

    + +

    6 Entity Type. 21

    + +

    6.1 Derived Entity Type. 21

    + +

    6.2 Abstract Entity Type. 22

    + +

    6.3 Open Entity Type. 22

    + +

    6.4 Media Entity Type. 22

    + +

    6.5 Key. 22

    + +

    7 Structural +Property. 25

    + +

    7.1 Type. 25

    + +

    7.2 Type Facets. 26

    + +

    7.2.1 Nullable. 26

    + +

    7.2.2 MaxLength. 26

    + +

    7.2.3 Precision. 26

    + +

    7.2.4 Scale. 27

    + +

    7.2.5 Unicode. 28

    + +

    7.2.6 SRID. 28

    + +

    7.2.7 Default Value. 28

    + +

    8 Navigation +Property. 29

    + +

    8.1 Navigation Property Type. 29

    + +

    8.2 Nullable Navigation Property. 30

    + +

    8.3 Partner Navigation Property. 30

    + +

    8.4 Containment Navigation Property. 30

    + +

    8.5 Referential Constraint 31

    + +

    8.6 On-Delete Action. 32

    + +

    9 Complex Type. 34

    + +

    9.1 Derived Complex Type. 34

    + +

    9.2 Abstract Complex Type. 35

    + +

    9.3 Open Complex Type. 35

    + +

    10 Enumeration +Type. 36

    + +

    10.1 Underlying Integer Type. 36

    + +

    10.2 Flags Enumeration Type. 36

    + +

    10.3 Enumeration Type Member 37

    + +

    11 Type Definition. 39

    + +

    11.1 Underlying Primitive Type. 39

    + +

    12 Action and +Function. 40

    + +

    12.1 Action. 40

    + +

    12.2 Action Overloads. 40

    + +

    12.3 Function. 40

    + +

    12.4 Function Overloads. 40

    + +

    12.5 Bound or Unbound Action or +Function Overloads. 41

    + +

    12.6 Entity Set Path. 41

    + +

    12.7 Composable Function. 42

    + +

    12.8 Return Type. 42

    + +

    12.9 Parameter 42

    + +

    13 Entity +Container 44

    + +

    13.1 Extending an Entity Container 45

    + +

    13.2 Entity Set 45

    + +

    13.3 Singleton. 46

    + +

    13.4 Navigation Property Binding. 46

    + +

    13.4.1 Navigation Property Path +Binding. 46

    + +

    13.4.2 Binding Target 47

    + +

    13.5 Action Import 47

    + +

    13.6 Function Import 48

    + +

    14 Vocabulary and +Annotation. 50

    + +

    14.1 Term.. 51

    + +

    14.1.1 Specialized Term.. 51

    + +

    14.1.2 Applicability. 51

    + +

    14.2 Annotation. 53

    + +

    14.2.1 Qualifier 54

    + +

    14.2.2 Target 54

    + +

    14.3 Constant Expression. 56

    + +

    14.3.1 Binary. 56

    + +

    14.3.2 Boolean. 56

    + +

    14.3.3 Date. 57

    + +

    14.3.4 DateTimeOffset 57

    + +

    14.3.5 Decimal 57

    + +

    14.3.6 Duration. 58

    + +

    14.3.7 Enumeration Member 58

    + +

    14.3.8 Floating-Point Number 58

    + +

    14.3.9 Guid. 59

    + +

    14.3.10 Integer 59

    + +

    14.3.11 String. 59

    + +

    14.3.12 Time of Day. 60

    + +

    14.4 Dynamic Expression. 60

    + +

    14.4.1 Path Expressions. 60

    + +

    14.4.1.1 Path Syntax. 60

    + +

    14.4.1.2 Path Evaluation. 62

    + +

    14.4.1.3 Annotation Path. 62

    + +

    14.4.1.4 Model Element Path. 63

    + +

    14.4.1.5 Navigation Property Path. 63

    + +

    14.4.1.6 Property Path. 64

    + +

    14.4.1.7 Value Path. 64

    + +

    14.4.2 Comparison and Logical +Operators. 65

    + +

    14.4.3 Arithmetic Operators. 66

    + +

    14.4.4 Apply Client-Side Function. 67

    + +

    14.4.4.1 Canonical Functions. 68

    + +

    14.4.4.2 Function odata.fillUriTemplate. 68

    + +

    14.4.4.3 Function odata.matchesPattern. 69

    + +

    14.4.4.4 Function odata.uriEncode. 69

    + +

    14.4.5 Cast 69

    + +

    14.4.6 Collection. 70

    + +

    14.4.7 If-Then-Else. 70

    + +

    14.4.8 Is-Of 71

    + +

    14.4.9 Labeled Element 71

    + +

    14.4.10 Labeled Element Reference. 72

    + +

    14.4.11 Null 72

    + +

    14.4.12 Record. 72

    + +

    14.4.13 URL Reference. 73

    + +

    15 Identifier and +Path Values. 75

    + +

    15.1 Namespace. 75

    + +

    15.2 Simple Identifier 75

    + +

    15.3 Qualified Name. 75

    + +

    15.4 Target Path. 75

    + +

    16 CSDL Examples. 76

    + +

    16.1 Products and Categories Example. 76

    + +

    16.2 Annotations for Products and +Categories Example. 78

    + +

    17 Conformance. 79

    + +

    Appendix A. Acknowledgments. 80

    + +

    Appendix B. Table of XML Elements and +Attributes. 81

    + +

    Appendix C. Revision History. 83

    + +

     

    + +
    + +
    +
    + +
    + + + +

    OData services are described in terms of an Entity Model. The Common Schema Definition Language +(CSDL) defines a representation of the entity data model exposed by an OData +service using the Extensible Markup Language (XML) 1.1 (Second Edition) [XML‑1.1] with further building blocks from the +W3C XML Schema Definition Language (XSD) 1.1 as described in [XML‑Schema‑1] and [XML‑Schema‑2].

    + +

    1.0 IPR Policy

    + +

    This specification is provided under the RF on +RAND Terms Mode of the OASIS IPR Policy, +the mode chosen when the Technical Committee was established. For information +on whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing terms, +please refer to the Intellectual Property Rights section of the TCs web page (https://www.oasis-open.org/committees/odata/ipr.php).

    + +

    1.1 Terminology

    + +

    The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL +NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this +document are to be interpreted as described in [RFC2119].

    + +

    1.2 Normative References

    + +

    [ECMAScript] ECMAScript +2016 Language Specification, 7th Edition, June 2016. Standard +ECMA-262. http://www.ecma-international.org/publications/standards/Ecma-262.htm. +

    + +

    [EPSG] European +Petroleum Survey Group (EPSG). http://www.epsg.org/. +

    + +

    [OData-ABNF] OData +ABNF Construction Rules Version 4.01.
    +See link in Additional artifacts section on cover page.

    + +

    [OData-EDM] OData EDM XML Schema.
    +
    See link in Additional artifacts section on cover page.

    + +

    [OData-EDMX] OData EDMX XML Schema.
    +
    See link in Additional artifacts section on cover page.

    + +

    [OData-CSDLJSON] OData Common Schema Definition +Language (CSDL) JSON Representation Version 4.01. See link in Related +work section on cover page.

    + +

    [OData-JSON] OData JSON Format Version 4.01. +
    +See link in Related work section on cover page.

    + +

    [OData-Protocol] OData +Version 4.01 Part 1: Protocol.
    +See link in Additional artifacts section on cover page.

    + +

    [OData-URL] OData +Version 4.01 Part 2: URL Conventions.
    +See link in Additional artifacts section on cover page.

    + +

    [OData-VocCore] OData Vocabularies +Version 4.0: Core Vocabulary.
    +See link in Related work section on cover page.

    + +

    [OData-VocMeasures] OData +Vocabularies Version 4.0: Measures Vocabulary.
    +See link in Related work section on cover page.

    + +

    [OData-VocValidation] OData +Vocabularies Version 4.0: Validation Vocabulary.
    +See link in Related work section on cover page.

    + +

    [RFC2119] Bradner, +S., Key words for use in RFCs to Indicate Requirement Levels, BCP 14, RFC +2119, March 1997. https://tools.ietf.org/html/rfc2119.

    + +

    [RFC6570] Gregorio, J., +Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, URI Template, RFC +6570, March 2012. http://tools.ietf.org/html/rfc6570. +

    + +

    [XML-1.1] Extensible +Markup Language (XML) 1.1 (Second Edition), F. Yergeau, E. Maler, J. Cowan, T. +Bray, C. M. Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August +2006,
    +http://www.w3.org/TR/2006/REC-xml11-20060816. +
    +Latest version available at http://www.w3.org/TR/xml11/.

    + +

    [XML-Base] XML Base +(Second Edition), J. Marsh, R. Tobin, Editors, W3C Recommendation, 28 January +2009,
    +http://www.w3.org/TR/2009/REC-xmlbase-20090128/. +
    +Latest version available at http://www.w3.org/TR/xmlbase/. +

    + +

    [XML-Schema-1] W3C +XML Schema Definition Language (XSD) 1.1 Part 1: Structures, D. Beech, M. +Maloney, C. M. Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, +Editors, W3C Recommendation, 5 April 2012, http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/.
    +Latest version available at http://www.w3.org/TR/xmlschema11-1/. +

    + +

    [XML-Schema-2] W3C +XML Schema Definition Language (XSD) 1.1 Part 2: DatatypesW3C XML Schema +Definition Language (XSD) 1.1 Part 2: Datatypes, D. Peterson, S. Gao, C. M. +Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C +Recommendation, 5 April 2012, http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/.
    +Latest version available at http://www.w3.org/TR/xmlschema11-2/.

    + +

    1.3 Typographical Conventions

    + +

    Keywords defined by this specification use this monospaced font.

    + +

    Normative source code uses this paragraph style.

    + +

    Some sections of this specification are illustrated with +non-normative examples.

    + +

    Example 1: text describing an example uses this paragraph +style

    + +
    + +

    Non-normative examples use this paragraph style.

    + +
    + +

    All examples in this document are non-normative and +informative only.

    + +

    Representation-specific text is indented and marked with +vertical lines.

    + +
    + +

    Representation-Specific +Headline

    + +
    + +
    + +

    Normative representation-specific text

    + +
    + +

    All other text is normative unless otherwise labeled.

    + + + +

    OData CSDL XML is a full representation of the OData Common +Schema Definition Language in the Extensible Markup Language (XML) 1.1 (Second +Edition) [XML‑1.1] with further building +blocks from the W3C XML Schema Definition Language (XSD) 1.1 as described in [XML‑Schema‑1] and [XML‑Schema‑2].

    + +

    It is an alternative to the CSDL JSON representation defined +in [OData-CSDLJSON] and neither +adds nor removes features.

    + +

    2.1 Requesting the XML Representation

    + +

    The OData CSDL XML representation can be requested using the +$format query option in the request URL with the media +type application/xml, optionally followed by media +type parameters, or the case-insensitive abbreviation xml +which MUST NOT be followed by media type parameters.

    + +

    Alternatively, this representation can be requested using +the Accept header with the media type application/xml, optionally followed by media type +parameters.

    + +

    If specified, $format overrides +any value specified in the Accept header.

    + +

    The response MUST contain the Content-Type +header with a value of application/xml, optionally +followed by media type parameters.

    + +

    This specification does not define additional parameters for +the media type application/xml.

    + +

    2.2 XML +Namespaces

    + +

    In addition to the default XML namespace, the elements and +attributes used to describe the entity model of an OData service are defined in +one of the following namespaces.

    + +

    2.2.1 Namespace EDMX

    + +

    Elements and attributes associated with the top-level +wrapper that contains the CSDL used to define the entity model for an OData +Service are qualified with the Entity Data Model for Data Services Packaging +namespace:

    + +

             +http://docs.oasis-open.org/odata/ns/edmx

    + +

    Prior versions of OData used the following namespace for +EDMX:

    + +

             +EDMX version 1.0: http://schemas.microsoft.com/ado/2007/06/edmx

    + +

    They are non-normative for this specification.

    + +

    In this specification the namespace prefix edmx is used to represent the Entity Data Model for Data +Services Packaging namespace, however the prefix name is not prescriptive.

    + +

    2.2.2 Namespace EDM

    + +

    Elements and attributes that define the entity model exposed +by the OData Service are qualified with the Entity Data Model namespace:

    + +

             +http://docs.oasis-open.org/odata/ns/edm

    + +

    Prior versions of CSDL used the following namespaces for +EDM:

    + +

             +CSDL version 1.0: http://schemas.microsoft.com/ado/2006/04/edm

    + +

             +CSDL version 1.1: http://schemas.microsoft.com/ado/2007/05/edm

    + +

             +CSDL version 1.2: http://schemas.microsoft.com/ado/2008/01/edm

    + +

             +CSDL version 2.0: http://schemas.microsoft.com/ado/2008/09/edm

    + +

             +CSDL version 3.0: http://schemas.microsoft.com/ado/2009/11/edm

    + +

    They are non-normative for this specification.

    + +

    In this specification the namespace prefix edm is used to represent the Entity Data Model namespace, +however the prefix name is not prescriptive.

    + +

    2.3 XML Schema Definitions

    + +

    This specification contains normative XML schemas for the +EDMX and EDM namespaces; see [OData‑EDMX] +and [OData‑EDM].

    + +

    These XML schemas only define the shape of a well-formed +CSDL XML document and are not descriptive enough to define what a correct CSDL +XML document MUST be in every imaginable use case. This specification document +defines additional rules that correct CSDL XML documents MUST fulfill. In case +of doubt on what makes a CSDL XML document correct the rules defined in this +specification document take precedence.

    + +

    2.4 XML Document Order

    + +

    Client libraries MUST retain +the document order of XML elements for CSDL XML documents because for some +elements the order of child elements is significant. This includes, but is not +limited to, members of enumeration types +and items within a collection expression.

    + +

    OData does not impose any ordering constraints on XML +attributes within XML elements.

    + +
    + +

    3     +Entity Model

    + +
    + +

    An OData service exposes a single entity model. This model +may be distributed over several schemas, and these +schemas may be distributed over several physical locations.

    + +

    A service is defined by a single CSDL document which can be +accessed by sending a GET request to <serviceRoot>/$metadata. This document is called +the metadata document. It may reference other CSDL documents.

    + +

    The metadata document contains a single entity container that defines the resources +exposed by this service. This entity container MAY extend an entity container defined +in a referenced document.

    + +

    The model of the service consists of all CSDL +constructs used in its entity containers.

    + +

    The scope of a CSDL document is the document itself +and all schemas included from directly referenced documents. All entity types, complex types +and other named elements in scope (that is, defined in the document +itself or a schema of a directly referenced document) can be accessed from a +referencing document by their qualified names. This includes the built-in primitive and abstract types.

    + +

    Referencing another document may alter the model defined by +the referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, then an entity set of the service defined by the referencing +document may return entities of the derived type. This is identical to the +behavior if the derived type had been defined directly in the referencing +document.

    + +

    Note: referencing documents is not recursive. Only named +elements defined in directly referenced documents can be used within the +schema. However, those elements may in turn include elements defined in schemas +referenced by their defining schema.

    + +

    3.1 Nominal +Types

    + +

    A nominal type has a name that MUST be a simple identifier. Nominal types are +referenced using their qualified name. The +qualified type name MUST be unique within a model as it facilitates references +to the element from other parts of the model.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    3.2 Structured Types

    + +

    Structured types are composed of other model elements. +Structured types are common in entity models as the means of representing +entities and structured properties in an OData service. Entity types and complex +types are both structured types.

    + +

    Structured +Types are composed of zero or more structural +properties and navigation properties.

    + +

    Open entity types and open complex types allow properties to be added +dynamically to instances of the open type.

    + +

    3.3 +Primitive Types

    + +

    Structured types are composed of other structured types and +primitive types. OData defines the following primitive types:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Type

    +
    +

    Meaning

    +
    +

    Edm.Binary

    +
    +

    Binary data

    +
    +

    Edm.Boolean

    +
    +

    Binary-valued logic

    +
    +

    Edm.Byte

    +
    +

    Unsigned 8-bit integer

    +
    +

    Edm.Date

    +
    +

    Date without a time-zone offset

    +
    +

    Edm.DateTimeOffset

    +
    +

    Date and time with a time-zone offset, no leap seconds

    +
    +

    Edm.Decimal

    +
    +

    Numeric values with decimal representation

    +
    +

    Edm.Double

    +
    +

    IEEE 754 binary64 floating-point number (15-17 decimal + digits)

    +
    +

    Edm.Duration

    +
    +

    Signed duration in days, hours, minutes, and (sub)seconds

    +
    +

    Edm.Guid

    +
    +

    16-byte (128-bit) unique identifier

    +
    +

    Edm.Int16

    +
    +

    Signed 16-bit integer

    +
    +

    Edm.Int32

    +
    +

    Signed 32-bit integer

    +
    +

    Edm.Int64

    +
    +

    Signed 64-bit integer

    +
    +

    Edm.SByte

    +
    +

    Signed 8-bit integer

    +
    +

    Edm.Single

    +
    +

    IEEE 754 binary32 floating-point number (6-9 decimal + digits)

    +
    +

    Edm.Stream

    +
    +

    Binary data stream

    +
    +

    Edm.String

    +
    +

    Sequence of characters

    +
    +

    Edm.TimeOfDay

    +
    +

    Clock time 00:00-23:59:59.999999999999

    +
    +

    Edm.Geography

    +
    +

    Abstract base type for all Geography types

    +
    +

    Edm.GeographyPoint

    +
    +

    A point in a round-earth coordinate system

    +
    +

    Edm.GeographyLineString

    +
    +

    Line string in a round-earth coordinate system

    +
    +

    Edm.GeographyPolygon

    +
    +

    Polygon in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiPoint

    +
    +

    Collection of points in a round-earth coordinate system

    +
    +

    Edm.GeographyMultiLineString

    +
    +

    Collection of line strings in a round-earth coordinate + system

    +
    +

    Edm.GeographyMultiPolygon

    +
    +

    Collection of polygons in a round-earth coordinate system

    +
    +

    Edm.GeographyCollection

    +
    +

    Collection of arbitrary Geography values

    +
    +

    Edm.Geometry

    +
    +

    Abstract base type for all Geometry types

    +
    +

    Edm.GeometryPoint

    +
    +

    Point in a flat-earth coordinate system

    +
    +

    Edm.GeometryLineString

    +
    +

    Line string in a flat-earth coordinate system

    +
    +

    Edm.GeometryPolygon

    +
    +

    Polygon in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiPoint

    +
    +

    Collection of points in a flat-earth coordinate system

    +
    +

    Edm.GeometryMultiLineString

    +
    +

    Collection of line strings in a flat-earth coordinate + system

    +
    +

    Edm.GeometryMultiPolygon

    +
    +

    Collection of polygons in a flat-earth coordinate system

    +
    +

    Edm.GeometryCollection

    +
    +

    Collection of arbitrary Geometry values

    +
    + +

    Edm.Date and Edm.DateTimeOffset follow [XML‑Schema‑2] +and use the proleptic Gregorian calendar, allowing the year 0000 (equivalent to 1 BCE) and negative years (year -0001 being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying persistency +layer, e.g. SQL only supports years 0001 to 9999.

    + +

    Edm.Decimal with a Scale value of floating, Edm.Double, and Edm.Single allow the special numeric values -INF, INF, and NaN.

    + +

    Edm.Stream is a primitive type +that can be used as a property of an entity type +or complex type, the underlying type for a type definition, or the binding parameter or +return type of an action or function. +Edm.Stream, or a type definition whose underlying +type is Edm.Stream, cannot be used in collections +or for non-binding parameters to functions or actions.

    + +

    Some of these types allow facets, +defined in section Type Facets.

    + +

    See rule primitiveLiteral in [OData‑ABNF] for the representation of primitive +type values in URLs and [OData‑JSON] for the +representation in requests and responses.

    + +

    3.4 +Built-In Abstract Types

    + +

    The following built-in abstract types can be used within a +model:

    + +

             +Edm.PrimitiveType 

    + +

             +Edm.ComplexType

    + +

             +Edm.EntityType

    + +

             +Edm.Untyped

    + +

    Conceptually, these are the abstract base types for +primitive types (including type definitions and enumeration types), complex +types, entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except:

    + +

             +Edm.EntityType

    + +
      +
        +
      • cannot be used as the type of a singleton in an entity container + because it doesnt define a structure, which defeats the purpose of a + singleton.
      • +
      • cannot be used as the type of an entity set because all + entities in an entity set must have the same key fields to uniquely + identify them within the set.
      • +
      • cannot be the base type of an entity type or complex type. 
      • +
      +
    + +

             +Edm.ComplexType

    + +
      +
        +
      • cannot be the base type of an entity type or complex type. 
      • +
      +
    + +

             +Edm.PrimitiveType

    + +
      +
        +
      • cannot be used as the type of a key property of an entity + type or as the underlying type of an enumeration type.
      • +
      • cannot be used as the underlying type of a type definition + in a CSDL document with a version of 4.0.
      • +
      • can be used as the underlying type of a type definition + in a CSDL document with a version of 4.01 or + greater.
      • +
      +
    + +

             +Edm.Untyped

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      • cannot be used as the type of a key property of an entity + type.
      • +
      • cannot be the base type of an entity type or complex type. 
      • +
      • cannot be used as the underlying type of a type + definition or enumeration type.
      • +
      +
    + +

             +Collection(Edm.PrimitiveType)

    + +
      +
        +
      • cannot be used as the type of a property or term.
      • +
      • cannot be used as the type of a parameter or the return + type of an action or function.
      • +
      +
    + +

             +Collection(Edm.Untyped)

    + +
      +
        +
      • cannot be returned in a payload with an OData-Version header of 4.0. + Services should treat untyped properties as dynamic properties in 4.0 payloads.
      • +
      +
    + +

    3.5 Built-In Types for defining +Vocabulary Terms

    + +

    Vocabulary terms can, in addition, use

    + +

             +Edm.AnnotationPath

    + +

             +Edm.PropertyPath

    + +

             +Edm.NavigationPropertyPath 

    + +

             +Edm.AnyPropertyPath (Edm.PropertyPath or Edm.NavigationPropertyPath)

    + +

             +Edm.ModelElementPath (any +model element, including Edm.AnnotationPath, Edm.NavigationPropertyPath, and Edm.PropertyPath)

    + +

    as the type of a primitive term, or the type of a property +of a complex type (recursively) that is exclusively used as the type of a term. +See section Path Expressions for details.

    + +

    3.6 Annotations

    + +

    Many parts of the model can be decorated with additional +information using annotations. Annotations are +identified by their term name and an optional qualifier that allows applying +the same term multiple times to the same model element.

    + +

    A model element MUST NOT specify more than one annotation +for a given combination of term and qualifier.

    + +
    + +

    4     +CSDL XML Document

    + +
    + +
    + +

    Element +edmx:Edmx

    + +
    + +
    + +

    The edmx:Edmx +element is the root element of a CSDL XML document. It MUST contain the Version attribute and it MUST contain exactly one edmx:DataServices element.

    + +

    It MAY contain edmx:Reference elements to +reference other CSDL documents.

    + +
    + +
    + +

    Attribute +Version

    + +
    + +
    + +

    The Version +attribute specifies the OData protocol version of the service. For OData 4.0 +responses the value of this attribute MUST be 4.0. +For OData 4.01 responses the value of this attribute MUST be 4.01. Services MUST return an OData 4.0 response if the +request was made with an OData-MaxVersion header +with a value of 4.0.

    + +
    + +
    + +

    Element edmx:DataServices

    + +
    + +
    + +

    The edmx:DataServices +element MUST contain one or more edm:Schema elements which define the schemas exposed +by the OData service.

    + +
    + +

    Example 2:

    + +
    + +

    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"

    + +

    Version="4.01">
    +<edmx:DataServices>
    +
    + </edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    4.1 Reference

    + +

    A reference to an external CSDL document allows to bring +part of the referenced documents content into the scope of the referencing +document.

    + +

    A reference MUST specify a URI that uniquely identifies the +referenced document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be absolute +or relative URI; relative URLs are relative to the URL of the document +containing the reference, or relative to a base URL specified in a +format-specific way.

    + +

    A reference MAY be annotated.

    + +

    The Core.SchemaVersion annotation, +defined in [OData-VocCore], MAY be used to +indicate a particular version of the referenced schema. If the Core.SchemaVersion annotation is +present, the $schemaversion system query option, +defined [OData‑Protocol], SHOULD +be used when retrieving the referenced schema document.

    + +
    + +

    Element edmx:Reference

    + +
    + +
    + +

    The edmx:Reference +element specifies external CSDL documents referenced by the referencing +document. The child elements edmx:Include and edmx:IncludeAnnotations +specify which parts of the referenced document are available for use in the +referencing document.

    + +

    The edmx:Reference +element MUST contain +the Uri attribute, and it MUST contain at least one +edmx:Include +or edmx:IncludeAnnotations +child element.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Uri

    + +
    + +
    + +

    The value of Uri +is an absolute or relative URI; relative URIs are relative to the xml:base attribute, see [XML‑Base].

    + +
    + +

    Example +3: references to other CSDL documents

    + +
    + +

    <?xml version="1.0" +encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    + Version="4.0">
    +<edmx:Reference Uri="http://vocabs.odata.org/capabilities/v1">

    + +

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://vocabs.odata.org/core/v1">

    + +

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://example.org/display/v1">
    +

    + +

    </edmx:Reference>
    +<edmx:DataServices></edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    4.2 Included +Schema

    + +

    A reference MAY include zero or more schemas from the +referenced document.

    + +

    The included schemas are identified via their namespace. The same +namespace MUST NOT be included more than once, even if it is declared in more +than one referenced document.

    + +

    When including a schema, a simple +identifier value MAY be specified as an alias for the schema that is used +in qualified names instead of the namespace. For example, an alias of display might be assigned to the namespace org.example.vocabularies.display. An alias-qualified name +is resolved to a fully qualified name by examining aliases for included schemas +and schemas defined within the document.

    + +
    + +

    If an included schema specifies an +alias, the alias MAY be used instead of the namespace within qualified names to +identify model elements of the included schema. An alias only provides a more +convenient notation, allowing a short string to be substituted for a long +namespace. Every model element that can be identified via an alias-qualified +name can alternatively be identified via its full namespace-qualified name.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document.

    + +

    The alias MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +

    An alias is only valid within the document in which it is +declared; a referencing document may define its own aliases for included +schemas.

    + +
    + +

    Element edmx:Include

    + +
    + +
    + +

    The edmx:Include +element specifies a schema to include from the referenced CSDL document. It +MUST provide the Namespace attribute and it MAY +provide the Alias attribute.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Namespace

    + +
    + +
    + +

    The value of Namespace +is the namespace of a schema defined in the referenced CSDL document.

    + +
    + +
    + +

    Attribute Alias

    + +
    + +
    + +

    The value of Alias +is a simple identifier that can be used in +qualified names instead of the namespace.

    + +
    + +

    Example 4: references to entity models containing +definitions of vocabulary terms

    + +
    + +

    <?xml version="1.0" +encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    + Version="4.0">
    +<edmx:Reference Uri="http://vocabs.odata.org/capabilities/v1">

    + +

    <edmx:Include +Namespace="Org.OData.Capabilities.V1" />

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://vocabs.odata.org/core/v1">

    + +

    <edmx:Include +Namespace="Org.OData.Core.V1" Alias="Core">

    + +

    <Annotation +Term="Core.DefaultNamespace" />

    + +

    </edmx:Include>

    + +

    </edmx:Reference>
    +<edmx:Reference Uri="http://example.org/display/v1">
    + <edmx:Include Alias="UI" +Namespace="org.example.display" />

    + +

    </edmx:Reference>
    +<edmx:DataServices></edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    4.3 Included +Annotations

    + +

    In addition to including whole schemas with all model +constructs defined within that schema, annotations can be included with more +flexibility.

    + +

    Annotations are selectively included by specifying the namespace of the +annotations term. Consumers can opt not to inspect the referenced document if +none of the term namespaces is of interest for the consumer.

    + +

    In addition, the qualifier of +annotations to be included MAY be specified. For instance, a service author +might want to supply a different set of annotations for various device form +factors. If a qualifier is specified, only those annotations from the specified +term namespace with the specified qualifier (applied to a model element of the +target namespace, if present) SHOULD be included. If no qualifier is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the target namespace, if present) SHOULD be +included.

    + +

    The qualifier also provides consumers insight about what +qualifiers are present in the referenced document. If the consumer is not +interested in that particular qualifier, the consumer can opt not to inspect +the referenced document.

    + +

    In addition, the namespace of the annotations target MAY be specified. If a target namespace is +specified, only those annotations which apply a term form the specified term +namespace to a model element of the target namespace (with the specified +qualifier, if present) SHOULD be included. If no target namespace is specified, +all annotations within the referenced document from the specified term +namespace (taking into account the qualifier, if present) SHOULD be included.

    + +

    The target namespace also provides consumers insight about +what namespaces are present in the referenced document. If the consumer is not +interested in that particular target namespace, the consumer can opt not to +inspect the referenced document.

    + +
    + +

    Element edmx:IncludeAnnotations

    + +
    + +
    + +

    The edmx:IncludeAnnotations +element specifies the annotations to include from the referenced CSDL document. +If no edmx:IncludeAnnotations element is specified, +a client MAY ignore all annotations in the referenced document that are not +explicitly used in an edm:Path +expression of the referencing document.

    + +

    The edmx:IncludeAnnotations +element MUST provide the TermNamespace attribute, +and it MAY provide the Qualifier and TargetNamespace attribute.

    + +
    + +
    + +

    Attribute TermNamespace

    + +
    + +
    + +

    The value of TermNamespace +is a namespace.

    + +
    + +
    + +

    Attribute Qualifier

    + +
    + +
    + +

    The value of Qualifier +is a simple identifier.

    + +
    + +
    + +

    Attribute TargetNamespace +

    + +
    + +
    + +

    The value of TargetNamespace +is a namespace.

    + +
    + +

    Example 5: reference documents that contain annotations

    + +
    + +

    <?xml version="1.0" +encoding="UTF-8" standalone="yes"?>
    +<edmx:Edmx xmlns:edmx=
    "http://docs.oasis-open.org/odata/ns/edmx"

    + +

    Version="4.0">
    + <edmx:Reference Uri="http://odata.org/ann/b">
    + <edmx:IncludeAnnotations +TermNamespace="org.example.validation" />
    + <edmx:IncludeAnnotations TermNamespace="org.example.display"

    + +

    Qualifier="Tablet" +/>
    + <edmx:IncludeAnnotations TermNamespace="org.example.hcm"
    + TargetNamespace="com.example.Sales" />
    + <edmx:IncludeAnnotations TermNamespace="org.example.hcm"

    + +

    Qualifier="Tablet"
    + TargetNamespace="com.example.Person" />
    +</edmx:Reference>
    +<edmx:DataServices></edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    The following annotations from http://odata.org/ann/b +are included:

    + +

             +Annotations that use a term from the org.example.validation +namespace, and

    + +

             +Annotations that use a term from the org.example.display +namespace and specify a Tablet +qualifier and

    + +

             +Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Sales +namespace and

    + +

             +Annotations that apply a term from the org.example.hcm +namespace to an element of the com.example.Person +namespace and specify a Tablet +qualifier.

    + +
    + +

    5     +Schema

    + +
    + +

    One or more schemas describe the entity model exposed by an +OData service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms.

    + +

    A schema +is identified by a namespace. Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally unique. A +schema cannot span more than one document.

    + +

    The schemas namespace is combined with the name of elements +in the entity model to create unique qualified +names, so identifiers that are used to name +types MUST be unique within a namespace to prevent ambiguity.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    The namespace +MUST NOT be one of the reserved values Edm, odata, System, or Transient.

    + +
    + +

    Element edm:Schema

    + +
    + +
    + +

    The edm:Schema element +defines a schema. It MUST contain the Namespace +attribute and it MAY contain the Alias attribute.

    + +

    It MAY contain elements edm:Action, edm:Annotations, edm:Annotation, edm:ComplexType, edm:EntityContainer, edm:EntityType, edm:EnumType, edm:Function, edm:Term, or edm:TypeDefinition.

    + +
    + +
    + +

    Attribute Namespace

    + +
    + +
    + +

    The value of Namespace +is the namespace of the schema

    + +
    + +

    5.1 +Alias

    + +

    A schema MAY specify an alias which MUST be a simple identifier.

    + +
    + +

    If a schema specifies an alias, the +alias MAY be used instead of the namespace within qualified names to identify +model elements of that schema. An alias only provides a more convenient +notation, allowing a short string to be substituted for a long namespace. Every +model element that can be identified via an alias-qualified name can +alternatively be identified via its full namespace-qualified name.

    + +
    + +

    Aliases are document-global, so all schemas defined within +or included into a document MUST have different aliases, and aliases MUST +differ from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the containing +document and are not restricted to the schema that defines them.

    + +

    The alias MUST NOT be one of the reserved +values Edm, odata, System, or Transient.

    + +
    + +

    Attribute Alias

    + +
    + +
    + +

    The value of Alias +is a simple identifier.

    + +
    + +

    Example 6: schema org.example +with an alias and a description for the schema

    + +
    + +

    <Schema +Namespace="org.example" Alias="self">

    + +

    <Annotation Term="Core.Description" +String="Example schema" />

    + +

    + +

    </Schema>

    + +
    + +

    5.2 Annotations +with External Targeting

    + +
    + +

    Element edm:Annotations

    + +
    + +
    + +

    The edm:Annotations +element is used to apply a group of annotations to a single model element. It MUST contain the Target attribute and it MAY contain the Qualifier attribute.

    + +

    It MUST +contain at least one edm:Annotation element.

    + +
    + +
    + +

    Attribute Target

    + +
    + +
    + +

    The value of Target +is a path expression identifying the annotation target. +It MUST resolve to a model element in scope.

    + +
    + +
    + +

    Attribute Qualifier

    + +
    + +
    + +

    The value of Qualifier +is a simple identifier.

    + +
    + +

    Example 7: annotations should only be applied to tablet +devices

    + +
    + +

    <Annotations Target="org.example.Person" +Qualifier="Tablet">
    + <Annotation Term="Core.Description" String="Dummy" +/>

    + +


    +</Annotations>

    + +
    + + + +

    Entity types are nominal structured types with a key that consists of +one or more references to structural +properties. An entity type is the template for an entity: any uniquely +identifiable record such as a customer or order.

    + +

    The entity types name is a simple +identifier that MUST be unique within its +schema.

    + +

    An entity type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, +complex, or enumeration types. A navigation +property is a named reference to another entity type or collection of +entity types.

    + +

    All properties MUST have a unique name within an entity +type. Properties MUST NOT have the same name as the declaring entity type. They +MAY have the same name as one of the direct or indirect base types or derived +types.

    + +
    + +

    Element edm:EntityType

    + +
    + +
    + +

    The edm:EntityType +element MUST contain the Name attribute, and it MAY +contain the BaseType, +Abstract, +OpenType, +and HasStream +attributes.

    + +

    It MAY contain edm:Property +and edm:NavigationProperty +elements describing the properties of the entity type.

    + +

    It MAY contain one edm:Key element.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the entity types name.

    + +
    + +

    Example 8: a simple entity type

    + +
    + +

    <EntityType Name="Employee">
    +<Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.String" +Nullable="false" />
    + <Property Name="FirstName" Type="Edm.String" +Nullable="false" />
    + <Property Name="LastName" Type="Edm.String" +Nullable="false" />
    + <NavigationProperty Name="Manager" Type="self.Manager" +/>
    +</EntityType>

    + +
    + +

    6.1 Derived +Entity Type

    + +

    An entity type can inherit from another entity type by +specifying it as its base type.

    + +

    An entity type inherits the key as +well as structural and navigation properties of its base type.

    + +

    An entity type MUST NOT introduce an inheritance cycle via +the base type attribute.

    + +
    + +

    Attribute BaseType

    + +
    + +
    + +

    The value of BaseType +is the qualified name of the base type.

    + +
    + +

    Example 9: a derived entity type based on the previous +example

    + +
    + +

    <EntityType Name="Manager" +BaseType="self.Employee">
    + <Property Name="AnnualBudget" Type="Edm.Decimal" />
    + <NavigationProperty Name="Employees" Type="Collection(self.Employee)" +/>
    +</EntityType>

    + +
    + +

    Note: the derived type has the same name +as one of the properties of its base type.

    + +

    6.2 Abstract Entity Type

    + +

    An entity type MAY indicate that it is abstract and cannot +have instances.

    + +

    For OData 4.0 responses a +non-abstract entity type MUST define a key or derive +from a base type with a defined key.

    + +

    An abstract entity type MUST NOT inherit from a non-abstract +entity type.

    + +
    + +

    Attribute +Abstract

    + +
    + +
    + +

    The value of Abstract +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    6.3 Open +Entity Type

    + +

    An entity type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    An entity type derived from an open entity type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see [OData‑Protocol].

    + +
    + +

    Attribute OpenType

    + +
    + +
    + +

    The value of OpenType +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    6.4 Media +Entity Type

    + +

    An entity type that does not specify a base type MAY specify +that it is a media entity type. Media entities are entities that +represent a media stream, such as a photo. Use a media entity if the +out-of-band stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal entity +with one or more properties of type Edm.Stream if +the structured data of the entity is the main topic of interest and the stream +data is just additional information attached to the structured data. For more +information on media entities see [OData‑Protocol].

    + +

    An entity type derived from a media entity type MUST +indicate that it is also a media entity type.

    + +

    Media entity types MAY specify a list of acceptable media +types using an annotation with term Core.AcceptableMediaTypes, see [OData‑VocCore].

    + +
    + +

    Attribute HasStream

    + +
    + +
    + +

    The value of HasStream +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    6.5 Key

    + +

    An entity is uniquely identified within an entity set by its +key. A key MAY be specified if the entity type does not specify a base type that already has a key declared.

    + +

    In order to be specified as the type of an entity set or a collection-valued containment navigation property, +the entity type MUST either specify a key or inherit its key from its base type.

    + +

    In OData +4.01 responses entity types used for singletons +or single-valued navigation properties do +not require a key. In OData 4.0 responses entity types used +for singletons or single-valued navigation properties MUST have a key +defined.

    + +

    An entity type (whether or not it is marked as abstract) MAY +define a key only if it doesnt inherit one.

    + +

    An entity types key refers to the set of properties that +uniquely identify an instance of the entity type within an entity set. The key +MUST consist of at least one property.

    + +

    Key properties MUST NOT be nullable and MUST be typed with +an enumeration type, +one of the following primitive types, or a type definition based on one of these primitive +types:

    + +
      +
    • Edm.Boolean
    • +
    • Edm.Byte
    • +
    • Edm.Date
    • +
    • Edm.DateTimeOffset
    • +
    • Edm.Decimal
    • +
    • Edm.Duration
    • +
    • Edm.Guid
    • +
    • Edm.Int16
    • +
    • Edm.Int32
    • +
    • Edm.Int64
    • +
    • Edm.SByte
    • +
    • Edm.String
    • +
    • Edm.TimeOfDay
    • +
    + +

    Key property values MAY be language-dependent, but their +values MUST be unique across all languages and the entity ids (defined in [OData‑Protocol]) MUST be language +independent.

    + +

    A key property MUST be a non-nullable primitive property of +the entity type itself, including non-nullable primitive properties of +non-nullable single-valued complex properties, recursively.

    + +

    In OData 4.01 the key properties of a directly related +entity type MAY also be part of the key if the navigation property is +single-valued and not nullable. This includes navigation properties of +non-nullable single-valued complex properties (recursively) of the entity type. +If a key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key.

    + +

    If the key property is a property of a complex property +(recursively) or of a directly related entity type, the key MUST specify an +alias for that property that MUST be a simple +identifier and MUST be unique within the set of aliases, structural and +navigation properties of the containing entity type and any of its base types.

    + +

    An alias MUST NOT be defined if the key property is a primitive +property of the entity type itself.

    + +

    For key properties that are a property of a complex or +navigation property, the alias MUST be used in the key predicate of URLs +instead of the path to the property because the required percent-encoding of +the forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be used in +the query part of URLs, where paths to properties dont require special +encoding and are a standard constituent of expressions anyway.

    + +
    + +

    Element edm:Key

    + +
    + +
    + +

    The edm:Key +element MUST contain at least one edm:PropertyRef +element.

    + +
    + +
    + +

    Element edm:PropertyRef

    + +
    + +
    + +

    The edm:PropertyRef +element MUST contain the Name attribute and MAY +contain the Alias attribute.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is a path expression leading to a primitive property. The names of the +properties in the path are joined together by forward slashes.

    + +
    + +
    + +

    Attribute Alias +

    + +
    + +
    + +

    The value of Alias +is a simple identifier.

    + +
    + +

    Example 10: entity type with a simple key

    + +
    + +

    <EntityType +Name="Category">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.Int32" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" />
    +</EntityType>

    + +
    + +

    Example 11: +entity type with a simple key referencing a property of a complex type

    + +
    + +

    <EntityType Name="Category">
    + <Key>
    + <PropertyRef Name="Info/ID" Alias="EntityInfoID" +/>
    +</Key>
    + <Property Name="Info" Type="Sales.EntityInfo" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" />
    +</EntityType>

    + +

     

    + +

    <ComplexType +Name="EntityInfo">

    + +

    <Property Name="ID" +Type="Edm.Int32" Nullable="false" />
    + <Property Name="Created" Type="Edm.DateTimeOffset" +/>
    +</ComplexType>

    + +
    + +

    Example 12: entity type with a composite key

    + +
    + +

    <EntityType +Name="OrderLine">
    + <Key>
    + <PropertyRef Name="OrderID" />
    + <PropertyRef Name="LineNumber" />
    +</Key>
    +<Property Name="OrderID" Type="Edm.Int32" +Nullable="false" />
    +<Property Name="LineNumber" Type="Edm.Int32" +Nullable="false" />
    +</EntityType>

    + +
    + +

    Example 13 (based on example 11): +requests to an entity set Categories +of type Category must use the +alias

    + +
    + +

    GET http://host/service/Categories(EntityInfoID=1)

    + +
    + +

    Example 14 (based on example 11): +in a query part the value assigned to the name attribute must be used

    + +
    + +

    GET http://example.org/OData.svc/Categories?$filter=Info/ID le 100

    + +
    + +
    + +

    7     Structural Property

    + +
    + +

    A structural property is a property (of a structural type) +that has one of the following types:

    + +

             +Primitive type

    + +

             +Complex type

    + +

             +Enumeration type

    + +

             +A collection of one of the above

    + +

    A structural property MUST specify a +unique name as well as a type.

    + +

    The propertys name MUST be a simple identifier used when referencing, +serializing or deserializing the property. It MUST be unique within the set of +structural and navigation properties of the declaring structured type, +and MUST NOT match the name of any navigation property in any of its base +types. If a structural property with the same name is defined in any of this +types base types, then the propertys type MUST be a type derived from the +type specified for the property of the base type and constrains this property +to be of the specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are +case-sensitive, but service authors SHOULD NOT choose names that differ only in +case.

    + +
    + +

    Element edm:Property

    + +
    + +
    + +

    The edm:Property +element MUST contain the Name and the Type attribute, and it MAY contain the facet attributes Nullable, +MaxLength, +Unicode, +Precision, +Scale, SRID, and DefaultValue.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the propertys name.

    + +
    + +

    Example 15: complex type with two properties

    + +
    + +

    <ComplexType +Name="Measurement">
    +<Property Name="Dimension" Type="Edm.String" +Nullable="false" MaxLength="50"

    + +

    DefaultValue="Unspecified" +/>
    +<Property Name="Length" Type="Edm.Decimal" +Nullable="false" Precision="18"

    + +

    Scale="2" />
    +</ComplexType>

    + +
    + +

    7.1 Type

    + +

    The propertys type MUST be a primitive +type, complex type, or enumeration type in scope, or a collection of +one of these types.

    + +

    A collection-valued property may be annotated with the Core.Ordered +term, defined in [OData-CoreVoc]), to +specify that it supports a stable ordering.

    + +

    A collection-valued property may be annotated with the Core.PositionalInsert +term, defined in [OData-CoreVoc]), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued properties the value +of Type is the qualified name of the propertys +type.

    + +

    For collection-valued properties the +value of Type is the character sequence Collection( followed by the qualified name of the +propertys item type, followed by a closing parenthesis ).

    + +
    + +

    Example 16: property Units +that can have zero or more strings as its value

    + +
    + +

    <Property Name="Units" +Type="Collection(Edm.String)" />

    + +
    + +

    7.2 Type Facets

    + +

    Facets modify or constrain the acceptable values of a +property.

    + +

    For single-valued properties facets apply to the type of the +property. For collection-valued properties the facets apply to the type of the +items in the collection.

    + +

    7.2.1 Nullable

    + +

    A Boolean value specifying whether the property can have the +value null.

    + +
    + +

    Attribute Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false.

    + +

    For single-valued properties the value +true means that the property allows the null value.

    + +

    For collection-valued properties the +property value will always be a collection that MAY be empty. In this case the Nullable attribute applies to items of the collection and +specifies whether the collection MAY contain null +values.

    + +

    If no value is specified for a +single-valued property, the Nullable attribute +defaults to true.

    + +

    In OData 4.01 responses a +collection-valued property MUST specify a value for the Nullable +attribute.

    + +

    If no value is specified for a +collection-valued property, the client cannot assume any default value. Clients +SHOULD be prepared for this situation even in OData 4.01 responses.

    + +
    + +

    7.2.2 MaxLength

    + +

    A positive integer value specifying the maximum length of a +binary, stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length (number +of code points for Unicode).

    + +

    If no maximum length is specified, clients +SHOULD expect arbitrary length.

    + +
    + +

    Attribute MaxLength

    + +
    + +
    + +

    The value of MaxLength +is a positive integer or the symbolic value max as a shorthand for the maximum length +supported for the type by the service.

    + +

    Note: the symbolic value max is only allowed in OData 4.0 responses; it is deprecated +in OData 4.01. While clients MUST be prepared for this symbolic value, OData +4.01 and greater services MUST NOT return the symbolic value max and MAY instead specify the concrete maximum length +supported for the type by the service or omit the attribute entirely.

    + +
    + +

    7.2.3 Precision

    + +

    For a decimal value: the maximum number of significant +decimal digits of the propertys value; it MUST be a positive integer.

    + +

    For a temporal value (datetime-with-timezone-offset, +duration, or time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve.

    + +

    Note: service authors SHOULD be aware that some clients are +unable to support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential for data +loss when round-tripping values of greater precision. Updating via PATCH and exclusively specifying modified properties will +reduce the risk for unintended data loss.

    + +

    Note: +duration properties supporting a granularity less than seconds (e.g. minutes, +hours, days) can be annotated with term Measures.DurationGranularity, see [OData-VocMeasures].

    + +
    + +

    Attribute Precision

    + +
    + +
    + +

    The value of Precision +is a number.

    + +

    If not specified for a decimal +property, the decimal property has arbitrary precision.

    + +

    If not specified for a temporal +property, the temporal property has a precision of zero.

    + +
    + +

    Example 17: Precision facet applied to the DateTimeOffset type

    + +
    + +

    <Property +Name="SuggestedTimes" Type="Collection(Edm.DateTimeOffset)"

    + +

    Precision="6" +/>

    + +
    + +

    7.2.4 Scale

    + +

    A non-negative integer value specifying the maximum number +of digits allowed to the right of the decimal point, or one of the symbolic +values floating or variable.

    + +

    The value floating means that the +decimal property represents a decimal floating-point number whose number of +significant digits is the value of the Precision facet. OData 4.0 responses +MUST NOT specify the value floating.

    + +

    The value variable +means that the number of digits to the right of the decimal point may vary from +zero to the value of the Precision facet.

    + +

    An integer value means that the number of digits to the +right of the decimal point may vary from zero to the value of the Scale attribute, and the number of digits to the left of +the decimal point may vary from one to the value of the Precision +facet minus the value of the Scale facet. If Precision is equal to Scale, +a single zero MUST precede the decimal point.

    + +

    The value of Scale MUST be less +than or equal to the value of Precision.

    + +

    Note: if the underlying data store allows negative scale, services +may use a Precision +with the absolute value of the negative scale added to the actual number of +significant decimal digits, and client-provided values may have to be rounded +before being stored.

    + +
    + +

    Attribute Scale

    + +
    + +
    + +

    The value of Scale +is a number or one of the symbolic values floating +or variable.

    + +

    Services SHOULD use lower-case values; +clients SHOULD accept values in a case-insensitive manner.

    + +

    If not specified, the Scale facet defaults to zero.

    + +
    + +

    Example 18: Precision=3 and Scale=2.
    +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3

    + +
    + +

    <Property Name="Amount32" +Type="Edm.Decimal" Precision="3" Scale="2" />

    + +
    + +

    Example 19: Precision=2 +equals Scale.
    +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2

    + +
    + +

    <Property Name="Amount22" +Type="Edm.Decimal" Precision="2" Scale="2" />

    + +
    + +

    Example 20: Precision=3 and a +variable Scale.
    +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed values: 12.34, +1234 and 123.4 due to the limited precision.

    + +
    + +

    <Property Name="Amount3v" +Type="Edm.Decimal" Precision="3" Scale="variable" +/>

    + +
    + +

    Example +21: Precision=7 and a floating Scale.
    +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: 1e-102 +and 1e97 due to the limited precision.

    + +
    + +

    <Property Name="Amount7f" +Type="Edm.Decimal" Precision="7" Scale="floating" +/>

    + +
    + +

    7.2.5 Unicode

    + +

    For a string property the Unicode +facet indicates whether the property might contain and accept string values +with Unicode characters (code points) beyond the ASCII character set. The value +false indicates that the property will only contain +and accept string values with characters limited to the ASCII character set.

    + +

    If no value is specified, the Unicode +facet defaults to true.

    + +
    + +

    Attribute +Unicode

    + +
    + +
    + +

    The value of Unicode +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +
    + +

    7.2.6 SRID

    + +

    For a geometry or geography property the SRID facet identifies which spatial reference system is +applied to values of the property on type instances.

    + +

    The value of the SRID facet MUST +be a non-negative integer or the special value variable. +If no value is specified, the attribute defaults to 0 +for Geometry types or 4326 +for Geography types.

    + +

    The valid values of the SRID +facet and their meanings are as defined by the European Petroleum Survey Group [EPSG].

    + +
    + +

    Attribute SRID

    + +
    + +
    + +

    The value of $SRID +is a number or the symbolic value variable.

    + +
    + +

    7.2.7 Default +Value

    + +

    A primitive or enumeration property MAY define a default +value that is used if the property is not explicitly represented in an +annotation or the body of a POST or PUT request.

    + +

    If no value is specified, the client SHOULD NOT assume a +default value.

    + +
    + +

    Attribute DefaultValue

    + +
    + +
    + +

    Default values of type Edm.String MUST be represented according to the XML +escaping rules for character data in attribute values. Values of other +primitive types MUST be represented according to the appropriate alternative in +the primitiveValue rule defined in [OData‑ABNF], +i.e. Edm.Binary as binaryValue, +Edm.Boolean as booleanValue +etc.

    + +
    + +
    + +

    8     Navigation Property

    + +
    + +

    A navigation property allows +navigation to related entities. It MUST specify a unique name as well as a +type.

    + +

    The navigation propertys name MUST be a simple identifier. It +is used when referencing, serializing or deserializing the navigation property. +It MUST be unique within the set of structural and navigation properties of the +declaring structured type, and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the same name +is defined in any of this types base types, then the navigation propertys +type MUST be a type derived from the type specified for the navigation property +of the base type, and constrains this navigation property to be of the +specified subtype for instances of this structured type. The name MUST NOT match the +name of any structural or navigation property of any of this types base types +for OData 4.0 responses.

    + +

    Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +
    + +

    Element edm:NavigationProperty

    + +
    + +
    + +

    The edm:NavigationProperty element MUST contain the Name and Type attributes, and +it MAY contain the attributes Nullable, Partner, +and ContainsTarget.

    + +

    It MAY contain child elements edm:ReferentialConstraint +and at most one child element edm:OnDelete.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the navigation propertys name.

    + +
    + +

    Example 22: the Product entity type has a navigation +property to a Category, which has a navigation link back to one or more +products

    + +
    + +

    <EntityType +Name="Product">
    +
    + <NavigationProperty Name="Category" Type="self.Category" +Nullable="false"

    + +

    +Partner="Products" />
    + <NavigationProperty Name="Supplier" Type="self.Supplier" +/>
    +</EntityType>

    + +

     

    + +

    <EntityType +Name="Category">
    +
    + <NavigationProperty Name="Products" Type="Collection(self.Product)" +

    + +

    +Partner="Category" />
    +</EntityType>

    + +
    + +

    8.1 Navigation +Property Type

    + +

    The navigation propertys type MUST be an entity type in scope, the abstract type Edm.EntityType, +or a collection of one of these types.

    + +

    If the type is a collection, an arbitrary number of entities +can be related. Otherwise there is at most one related entity.

    + +

    The related entities MUST be of the specified entity type or +one of its subtypes.

    + +

    For a collection-valued containment navigation property the +specified entity type MUST have a key defined.

    + +

    A collection-valued navigation property may be annotated +with the Core.Ordered +term, defined in [OData-CoreVoc]), to +specify that it supports a stable ordering.

    + +

    A collection-valued navigation property may be annotated +with the Core.PositionalInsert +term, defined in [OData-CoreVoc]), to +specify that it supports inserting items into a specific ordinal position.

    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued navigation +properties the value of Type is the qualified name +of the navigation propertys type.

    + +

    For collection-valued navigation +properties the value of Type is the character +sequence Collection( followed by the qualified name +of the navigation propertys item type, followed by a closing parenthesis ).

    + +
    + +

    8.2 Nullable Navigation Property

    + +

    A Boolean value specifying whether the declaring type MAY +have no related entity. If false, instances of the declaring structured type +MUST always have a related entity.

    + +

    Nullable MUST NOT be specified for a collection-valued +navigation property, a collection is allowed to have zero items.

    + +
    + +

    Attribute +Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +
    + +

    8.3 Partner Navigation Property

    + +

    A navigation property of an entity +type MAY specify a partner navigation property. Navigation properties of +complex types MUST NOT specify a partner.

    + +

    If specified, the partner navigation property is identified +by a path relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that type or +a derived type. The path MAY traverse complex types, including derived complex +types, but MUST NOT traverse any navigation properties. The type of the partner +navigation property MUST be the declaring entity type of the current navigation +property or one of its parent entity types.

    + +

    If the partner navigation property +is single-valued, it MUST lead back to the source entity from all related +entities. If the partner navigation property is collection-valued, the source +entity MUST be part of that collection.

    + +

    If no partner navigation property +is specified, no assumptions can be made as to whether one of the navigation +properties on the target type will lead back to the source entity.

    + +

    If a partner navigation property +is specified, this partner navigation property MUST either specify the current +navigation property as its partner to define a bi-directional +relationship or it MUST NOT specify a partner navigation property. The latter +can occur if the partner navigation property is defined on a complex type, or +if the current navigation property is defined on a type derived from the type +of the partner navigation property.

    + +
    + +

    Attribute Partner

    + +
    + +
    + +

    The value of Partner +is the path to the of the partner navigation property.

    + +
    + +

    8.4 Containment Navigation Property

    + +

    A navigation property MAY indicate that instances of its +declaring structured type contain the targets of the navigation property, in +which case the navigation property is called a containment navigation +property.

    + +

    Containment navigation properties define an implicit entity +set for each instance of its declaring structured type. This implicit entity +set is identified by the read URL of the navigation property for that structured +type instance.

    + +

    Instances of the structured type that declares the navigation +property, either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The canonical +URL for contained entities is the canonical URL of the containing instance, +followed by the path segment of the navigation property and the key of the +contained entity, see [OData‑URL].

    + +

    Entity types used in collection-valued containment +navigation properties MUST have a key defined.

    + +

    For items of an ordered collection of complex types (those +annotated with the Core.Ordered +term defined in [OData-CoreVoc]), the +canonical URL of the item is the canonical URL of the collection appended with +a segment containing the zero-based ordinal of the item. Items within in an +unordered collection of complex types do not have a canonical URL. Services +that support unordered collections of complex types declaring a containment +navigation property, either directly or indirectly via a property of complex +type, MUST specify the URL for the navigation link within a payload representing +that item, according to format-specific rules.

    + +

    OData +4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued property.

    + +

    An entity cannot be referenced by more than one containment +relationship and cannot both belong to an entity set declared within the entity +container and be referenced by a containment relationship.

    + +

    Containment navigation properties MUST NOT be specified as +the last path segment in the path of a navigation +property binding.

    + +

    When a containment navigation property navigates between +entity types in the same inheritance hierarchy, the containment is called recursive. +

    + +

    Containment navigation properties MAY specify a partner +navigation property. If the containment is recursive, the relationship defines +a tree, thus the partner navigation property MUST be Nullable (for the root of the tree) +and single-valued (for the parent of a non-root entity). If the containment is +not recursive, the partner navigation property MUST NOT be nullable.

    + +

    An entity type inheritance chain MUST NOT contain more than +one navigation property with a partner navigation property that is a +containment navigation property.

    + +

    Note: without a partner navigation property, there is no +reliable way for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity can also +be reached via a non-containment navigation path.

    + +
    + +

    Attribute ContainsTarget

    + +
    + +
    + +

    The value of ContainsTarget +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    8.5 Referential Constraint

    + +

    A single-valued navigation property MAY define one or more +referential constraints. A referential constraint asserts that the dependent +property (the property defined on the structured type declaring the +navigation property) MUST have the same value as the principal property +(the referenced property declared on the entity type that is the target of the +navigation).

    + +

    The type of the dependent property MUST match the type of +the principal property, or both types MUST be complex types.

    + +

    If the principle property references an entity, then the +dependent property must reference the same entity.

    + +

    If the principle propertys value is a complex type +instance, then the dependent propertys value must be a complex type instance +with the same properties, each with the same values.

    + +

    If the navigation property on which the referential +constraint is defined is nullable, or the principal property is nullable, then +the dependent property MUST also be nullable. If both the navigation property +and the principal property are not nullable, then the dependent property MUST +NOT be nullable.

    + +
    + +

    Element edm:ReferentialConstraint

    + +
    + +
    + +

    The edm:ReferentialConstraint +element MUST contain the attributes Property and ReferencedProperty.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Property

    + +
    + +
    + +

    The Property +attribute specifies the property that takes part in the referential constraint +on the dependent structured type. Its value MUST be a path expression resolving +to a property of the dependent structured type itself or to a property of a complex +property (recursively) of the dependent structured type. The names of the +properties in the path are joined together by forward slashes. The path is +relative to the dependent structured type declaring the navigation property.

    + +
    + +
    + +

    Attribute ReferencedProperty

    + +
    + +
    + +

    The ReferencedProperty +attribute specifies the corresponding property of the principal entity type. +Its value MUST be a path expression resolving to a property of the principal entity +type itself or to a property of a complex property (recursively) of the principal +entity type that MUST have the same type as the property of the dependent +entity type. The path is relative to the entity type that is the target of the +navigation property.

    + +
    + +

    Example 23: the category must exist for a product in that +category to exist. The CategoryID of the product is +identical to the ID of the category, and the CategoryKind property of the product is identical to the Kind property of the category.

    + +
    + +

    <EntityType +Name="Product">
    +
    + <Property Name="CategoryID" Type="Edm.String" +Nullable="false"/>

    + +

    <Property Name="CategoryKind" +Type="Edm.String" Nullable="true" />

    + +

    <NavigationProperty +Name="Category" Type="self.Category" Nullable="false">
    + <ReferentialConstraint Property="CategoryID" ReferencedProperty="ID" +/>
    + <ReferentialConstraint Property="CategoryKind" +ReferencedProperty="Kind">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Referential +Constraint to non-key property" />

    + +

    </ReferentialConstraint>

    + +

    </NavigationProperty>

    + +

    </EntityType>

    + +

     

    + +

    <EntityType +Name="Category">

    + +

    <Key>

    + +

    <PropertyRef +Name="ID" />

    + +

    </Key>
    + <Property Name="ID" Type="Edm.String" +Nullable="false" />
    + <Property Name="Kind" Type="Edm.String" +Nullable="true" />
    +

    + +

    </EntityType>

    + +
    + +

    8.6 On-Delete +Action

    + +

    A navigation property MAY define an on-delete action that +describes the action the service will take on related entities when the entity +on which the navigation property is defined is deleted.

    + +

    The action can have one of the following values:

    + +
      +
    • Cascade, meaning the related + entities will be deleted if the source entity is deleted,
    • +
    • None, meaning a DELETE request on a source entity with related + entities will fail,
    • +
    • SetNull, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to null,
    • +
    • SetDefault, meaning all + properties of related entities that are tied to properties of the source + entity via a referential constraint and that do not participate in other + referential constraints will be set to their default value.
    • +
    + +

    If no on-delete action is specified, the action taken by the +service is not predictable by the client and could vary per entity.

    + +
    + +

    Element edm:OnDelete

    + +
    + +
    + +

    The edm:OnDelete +element MUST contain the Action attribute.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Action

    + +
    + +
    + +

    The value of Action +is one of the values Cascade, None, +SetNull, or SetDefault.

    + +
    + +

    Example 24: deletion of a category implies deletion of the +related products in that category

    + +
    + +

    <EntityType Name="Category">
    +
    + <NavigationProperty Name="Products" Type="Collection(self.Product)">
    + <OnDelete Action="Cascade">

    + +

    <Annotation +Term="Core.Description"
    + String="Delete all products in this category" />

    + +

    </OnDelete
    + </NavigationProperty>

    + +

    </EntityType>

    + +
    + + + +

    Complex types are keyless nominal +structured types. The lack of a key means +that instances of complex types cannot be referenced, created, updated or +deleted independently of an entity type. Complex types allow entity models to +group properties into common structures.

    + +

    The complex types name is a simple +identifier that MUST be unique within its schema.

    + +

    A complex type can define two types of properties. A structural property is a named reference to +a primitive, complex, or enumeration type, or a collection of primitive, +complex, or enumeration types. A navigation +property is a named reference to an entity type or a collection of entity +types.

    + +

    All properties MUST have a unique name within a complex +type. Properties MUST NOT have the same name as the declaring complex type. +They MAY have the same name as one of the direct or indirect base types or +derived types.

    + +
    + +

    Element edm:ComplexType

    + +
    + +
    + +

    The edm:ComplexType +element MUST contain the Name attribute, and it MAY +contain the BaseType, +Abstract, +and OpenType +attributes.

    + +

    It MAY contain edm:Property +and edm:NavigationProperty +elements describing the properties of the complex type.

    + +

    It MAY contain edm:Annotation elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the complex types name.

    + +
    + +

    Example 25: a complex type used by two entity types

    + +
    + +

    <ComplexType +Name="Dimensions">
    +<Property Name="Height" Nullable="false" +Type="Edm.Decimal" />
    +<Property Name="Weight" Nullable="false" +Type="Edm.Decimal" />
    +<Property Name="Length" Nullable="false" +Type="Edm.Decimal" />
    +</ComplexType>

    + +

     

    + +

    <EntityType +Name="Product">
    +
    + <Property Name="ProductDimensions" Type="self.Dimensions" +/>
    +<Property Name="ShippingDimensions" Type="self.Dimensions" +/>
    +</EntityType>

    + +

     

    + +

    <EntityType +Name="ShipmentBox">
    +
    + <Property Name="Dimensions" Type="self.Dimensions" +/>
    +</EntityType>

    + +
    + +

    9.1 Derived +Complex Type

    + +

    A complex type can inherit from another complex type by +specifying it as its base type.

    + +

    A complex type inherits the structural and navigation +properties of its base type.

    + +

    A complex type MUST NOT introduce an inheritance cycle by +specifying a base type.

    + +

    The rules for annotations of derived +complex types are described in section 14.2.

    + +
    + +

    Attribute BaseType

    + +
    + +
    + +

    The value of BaseType +is the qualified name of the base type.

    + +
    + +

    9.2 Abstract +Complex Type

    + +

    A complex type MAY indicate that it is abstract and cannot +have instances.

    + +
    + +

    Attribute +Abstract

    + +
    + +
    + +

    The value of Abstract +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    9.3 Open +Complex Type

    + +

    A complex type MAY indicate that it is open and allows +clients to add properties dynamically to instances of the type by specifying +uniquely named property values in the payload used to insert or update an +instance of the type.

    + +

    A complex type derived from an open complex type MUST +indicate that it is also open.

    + +

    Note: structural and navigation properties MAY be returned +by the service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see [OData‑Protocol].

    + +
    + +

    Attribute +OpenType

    + +
    + +
    + +

    The value of OpenType +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + + + +

    Enumeration types are nominal +types that represent a non-empty series of related values. Enumeration types +expose these related values as members of the enumeration.

    + +

    The enumeration types name is a simple identifier that MUST be unique within +its schema.

    + +

    Although enumeration types have an underlying numeric value, +the preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the AllowedValues annotation defined +in [OData-VocCore].

    + +

    Enumeration types marked as flags allow values that consist +of more than one enumeration member at a time.

    + +
    + +

    Element edm:EnumType

    + +
    + +
    + +

    The edm:EnumType +element MUST contain the Name attribute, and it MAY contain the UnderlyingType +and IsFlags +attributes.

    + +

    It MUST contain one or more edm:Member +elements defining the members of the enumeration type.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the enumeration types name.

    + +
    + +

    Example 26: a simple flags-enabled +enumeration

    + +
    + +

    <EnumType +Name="FileAccess" UnderlyingType="Edm.Int32" +IsFlags="true">
    +<Member Name="Read" Value="1" />
    +<Member Name="Write" Value="2" />
    +<Member Name="Create" Value="4" />
    +<Member Name="Delete" Value="8" />
    +</EnumType>

    + +
    + +

    10.1 Underlying Integer Type

    + +

    An enumeration type MAY specify one of Edm.Byte, +Edm.SByte, Edm.Int16, Edm.Int32, or Edm.Int64 as +its underlying type.

    + +

    If not explicitly specified, Edm.Int32 +is used as the underlying type.

    + +
    + +

    Attribute +UnderlyingType

    + +
    + +
    + +

    The value of UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    10.2 Flags Enumeration Type

    + +

    An enumeration type MAY indicate that the enumeration type +allows multiple members to be selected simultaneously.

    + +

    If not explicitly specified, only one +enumeration type member MAY be selected simultaneously.

    + +
    + +

    Attribute IsFlags

    + +
    + +
    + +

    The value of IsFlags +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    Example 27: pattern values can be combined, and some +combined values have explicit names

    + +
    + +

    <EnumType Name="Pattern" +UnderlyingType="Edm.Int32" IsFlags="true">

    + +

    <Member Name="Plain" Value="0" +/>

    + +

    <Member Name="Red" Value="1" +/>

    + +

    <Member Name="Blue" Value="2" +/>

    + +

    <Member Name="Yellow" Value="4" +/>

    + +

    <Member Name="Solid" Value="8" +/>

    + +

    <Member Name="Striped" +Value="16" />

    + +

    <Member Name="SolidRed" +Value="9" />

    + +

    <Member +Name="SolidBlue" Value="10" />

    + +

    <Member +Name="SolidYellow" Value="12" />

    + +

    <Member +Name="RedBlueStriped" Value="19" />

    + +

    <Member +Name="RedYellowStriped" Value="21" />

    + +

    <Member +Name="BlueYellowStriped" Value="22" />

    + +

    </EnumType>

    + +
    + +

    10.3 Enumeration Type Member

    + +

    Enumeration type values consist of discrete members.

    + +

    Each member is identified by its name, a simple identifier that MUST be unique within +the enumeration type. Names are case-sensitive, but service authors SHOULD NOT +choose names that differ only in case.

    + +

    Each member MUST specify an associated numeric value that +MUST be a valid value for the underlying type of the enumeration type.

    + +

    Enumeration types can have multiple members with the same value. Members with the same +numeric value compare as equal, and members with the same numeric value can be +used interchangeably.

    + +

    Enumeration +members are sorted by their numeric value.

    + +
    + +

    Element edm:Member

    + +
    + +
    + +

    The edm:Member +element MUST contain the Name attribute and it MAY +contain the Value attribute.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the enumeration members name.

    + +
    + +
    + +

    Attribute Value

    + +
    + +
    + +

    If the IsFlags +attribute has a value of false, either all members +MUST specify an integer value for the Value +attribute, or all members MUST NOT specify a value for the Value attribute. If no values are specified, the members +are assigned consecutive integer values in the order of their appearance, +starting with zero for the first member. Client libraries MUST preserve +elements in document order.

    + +

    If the IsFlags +attribute has a value of true, a non-negative +integer value MUST be specified for the Value +attribute. A combined value is equivalent to the bitwise OR of the discrete +values.

    + +
    + +

    Example 28: FirstClass has a +value of 0, TwoDay a +value of 1, and Overnight a value of 2.

    + +
    + +

    <EnumType +Name="ShippingMethod">
    +<Member Name="FirstClass">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Shipped +with highest priority" />

    + +

    </Member>
    + <Member Name="TwoDay">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Shipped +within two days" />
    + </Member>
    + <Member Name="Overnight">

    + +

    <Annotation Term="Core.Description"

    + +

    String="Shipped +overnight" />
    + </Member>
    +</EnumType>

    + +
    + +
    + +

    11    Type Definition

    + +
    + +

    A +type definition defines a specialization of one of the primitive types or of the built-in abstract type Edm.PrimitiveType.

    + +

    The type definitions name is a simple identifier that MUST be unique within +its schema.

    + +

    Type definitions can be used wherever a primitive type is +used (other than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions defined +using the same underlying type.

    + +

    It is up +to the definition of a term to specify whether and how annotations with this +term propagate to places where the annotated type definition is used, and +whether they can be overridden.

    + +
    + +

    Element edm:TypeDefinition

    + +
    + +
    + +

    The edm:TypeDefinition +element MUST contain the Name and UnderlyingType +attributes.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the type definitions name.

    + +
    + +

    Example 29:

    + +
    + +

    <TypeDefinition Name="Length" +UnderlyingType="Edm.Int32">

    + +

    <Annotation +Term="Org.OData.Measures.V1.Unit"

    + +

    String="Centimeters" />

    + +

    </TypeDefinition>

    + +

     

    + +

    <TypeDefinition Name="Weight" +UnderlyingType="Edm.Int32">

    + +

    <Annotation +Term="Org.OData.Measures.V1.Unit"

    + +

    String="Kilograms" />

    + +

    </TypeDefinition>

    + +

     

    + +

    <ComplexType Name="Size">

    + +

    <Property Name="Height" +Type="self.Length" />

    + +

    <Property Name="Weight" +Type="self.Weight" />

    + +

    </ComplexType>

    + +
    + +

    11.1 Underlying Primitive Type

    + +

    The underlying type of a type definition MUST be a primitive type that MUST NOT be another type +definition.

    + +
    + +

    Attribute UnderlyingType

    + +
    + +
    + +

    The value of UnderlyingType +is the qualified name of the underlying type.

    + +
    + +

    The type definition MAY specify facets applicable to the +underlying type. Possible facets are: MaxLength, Unicode, Precision, Scale, or SRID.

    + +

    Additional facets appropriate for the underlying type MAY be +specified when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified.

    + +

    For a type definition with underlying type Edm.PrimitiveType +no facets are applicable, neither in the definition itself nor when the type +definition is used, and these should be ignored by the client.

    + +

    Where type definitions are used, the type definition is +returned in place of the primitive type wherever the type is specified in a +response.

    + + + +

    12.1 Action

    + +

    Actions are service-defined operations that MAY have +observable side effects and MAY return a single instance or a collection of +instances of any type.

    + +

    The actions name is a simple +identifier that MUST be unique within its schema.

    + +

    Actions cannot be composed with additional path segments.

    + +

    An action MAY specify a return type that MUST be a primitive, entity or +complex type, or a collection of primitive, entity or complex types in scope.

    + +

    An action MAY define parameters +used during the execution of the action.

    + +

    12.2 Action Overloads

    + +

    Bound +actions support overloading (multiple actions having the same name within the +same schema) by binding parameter type. The combination of action name and the +binding parameter type MUST be unique within a schema.

    + +

    Unbound +actions do not support overloads. The names of all unbound actions MUST be +unique within a schema.

    + +

    An unbound action MAY have the same name as a bound action.

    + +
    + +

    Element edm:Action

    + +
    + +
    + +

    The edm:Action +element MUST contain the Name attribute and it MAY +contain the IsBound and EntitySetPath +attributes.

    + +

    It MAY contain at most one edm:ReturnType +element and MAY contain edm:Parameter +elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the actions name.

    + +
    + +

    12.3 +Function

    + +

    Functions are service-defined operations that MUST NOT have +observable side effects and MUST return a single instance or a collection of +instances of any type.

    + +

    The functions name is a simple +identifier that MUST be unique within its schema.

    + +

    Functions MAY be composable.

    + +

    The function MUST specify a return +type which MUST be a primitive, entity or complex type, or a collection of +primitive, entity or complex types in scope.

    + +

    A function MAY define parameters +to be used during the execution of the function.

    + +

    12.4 Function +Overloads

    + +

    Bound +functions support overloading (multiple functions having the same name within +the same schema) subject to the following rules:

    + +

             +The combination of function name, binding parameter type, and +unordered set of non-binding parameter names MUST be unique within a schema.

    + +

             +The combination of function name, binding parameter type, and +ordered set of parameter types MUST be unique within a schema.

    + +

             +All bound functions with the same function name and binding +parameter type within a schema MUST specify the same return type.

    + +

    Unbound +functions support overloading subject to the following rules:

    + +

             +The combination of function name and unordered set of parameter +names MUST be unique within a schema.

    + +

             +The combination of function name and ordered set of parameter +types MUST be unique within a schema.

    + +

             +All unbound functions with the same function name within a schema +MUST specify the same return type.

    + +

    An unbound +function MAY have the same name as a bound function.

    + +

    Note that type definitions +can be used to disambiguate overloads for both bound and unbound functions, +even if they specify the same underlying type.

    + +
    + +

    Element edm:Function

    + +
    + +
    + +

    The edm:Function +element MUST contain the Name attribute and it MAY +contain the IsBound and EntitySetPath +attributes.

    + +

    It MUST contain one edm:ReturnType +element, and it MAY contain edm:Parameter elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the actions name.

    + +
    + +

    12.5 Bound or Unbound Action or +Function Overloads

    + +

    An action or function overload MAY indicate that it is +bound. If not explicitly indicated, it is unbound.

    + +

    Bound actions or functions are invoked on resources matching +the type of the binding parameter. The binding parameter can be of any type, +and it MAY be Nullable.

    + +

    Unbound actions are invoked through an action import.

    + +

    Unbound functions are invoked as static functions within a +filter or orderby expression, or from the entity container through a function import.

    + +
    + +

    Attribute IsBound

    + +
    + +
    + +

    The value of IsBound +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    12.6 Entity +Set Path

    + +

    Bound actions and functions that +return an entity or a collection of entities MAY specify an entity set path if +the entity set of the returned entities depends on the entity set of the +binding parameter value.

    + +

    The entity set path consists of a series of segments joined +together with forward slashes.

    + +

    The first segment of the entity set path MUST be the name of +the binding parameter. The remaining segments of the entity set path MUST +represent navigation segments or type casts.

    + +

    A navigation segment names the simple identifier of the navigation property to be traversed. A +type-cast segment names the qualified name of +the entity type that should be returned from the type cast.

    + +
    + +

    Attribute EntitySetPath

    + +
    + +
    + +

    The value of EntitySetPath +is the entity set path.

    + +
    + +

    12.7 +Composable Function

    + +

    A function MAY indicate that it is composable. If not +explicitly indicated, it is not composable.

    + +

    A composable function can be invoked with additional path +segments or key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for the type +returned by the composable function.

    + +
    + +

    Attribute IsComposable

    + +
    + +
    + +

    The value of IsComposable +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + +

    12.8 Return Type

    + +

    The return type of an action or function overload MAY be any +type in scope, or a collection of any type in scope.

    + +

    The facets Nullable, MaxLength, Precision, Scale, and SRID can be used as appropriate to +specify value restrictions of the return type, as well as the Unicode +facet for 4.01 and greater payloads.

    + +
    + +

    Element +edm:ReturnType

    + +
    + +
    + +

    The edm:ReturnType +element MUST contain the Type attribute, and it MAY +contain the attributes Nullable, MaxLength, +Unicode, +Precision, +Scale, +and SRID.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued return types the +value of Type is the qualified name of the return +type.

    + +

    For collection-valued return types the +value of Type is the character sequence Collection( followed by the qualified name of the return +item type, followed by a closing parenthesis ).

    + +
    + +
    + +

    Attribute +Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +

    If the return type is a collection of +entity types, the $Nullable member has no meaning +and MUST NOT be specified.

    + +

    For other collection-valued return +types the result will always be a collection that MAY be empty. In this case +the Nullable attribute applies to items of the +collection and specifies whether the collection MAY contain null values.

    + +

    For single-valued return types the +value true means that the action or function MAY +return a single null value. The value false means that the action or function will never return +a null value and instead will fail with an error +response if it cannot compute a result.

    + +
    + +

    12.9 Parameter

    + +

    An action or function overload MAY specify parameters.

    + +

    A bound action or function overload MUST specify at least +one parameter; the first parameter is the binding parameter. The order of parameters MUST NOT change unless the schema +version changes.

    + +

    Each parameter MUST have a name that is a simple identifier. The parameter name MUST be +unique within the action or function overload.

    + +

    The parameter MUST specify a type. It MAY be any type in +scope, or a collection of any type in scope.

    + +

    The facets MaxLength, Precision, Scale, or SRID can be used as appropriate to +specify value restrictions of the parameter, as well as the Unicode +facet for 4.01 and greater payloads.

    + +
    + +

    Element edm:Parameter

    + +
    + +
    + +

    The edm:Parameter +element MUST contain the Name and the Type attribute, and it MAY contain the attributes Nullable, MaxLength, Unicode, Precision, Scale, and SRID.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is +the parameters name.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued parameters the value +of Type is the qualified name of the parameter.

    + +

    For collection-valued parameters the +value of Type is the character sequence Collection( followed by the qualified name of the +parameters type, followed by a closing parenthesis ).

    + +
    + +
    + +

    Attribute Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +

    The value true +means that the parameter accepts a null value.

    + +
    + +

    Example +30: a function returning the top-selling products for a given year. In this case +the year must be specified as a parameter of the function with the edm:Parameter element.

    + +
    + +

    <Function Name="TopSellingProducts">

    + +

    <Parameter Name="Year" Type="Edm.Decimal" +Precision="4" Scale="0" />

    + +

    <ReturnType Type="Collection(self.Product)" +/>

    + +

    </Function>

    + +
    + + + +

    Each metadata document used to describe an OData service +MUST define exactly one entity container.

    + +

    The entity containers name is a simple identifier that MUST be unique within +its schema.

    + +

    Entity containers define the entity sets, singletons, +function and action imports exposed by the service.

    + +

    Entity set, singleton, action import, and function import +names MUST be unique within an entity container.

    + +

    An entity +set allows access to entity type instances. Simple entity models +frequently have one entity set per entity type.

    + +

    Example 31: one entity set per entity type

    + +
    + +

    <EntitySet Name="Products" +EntityType="self.Product" />
    +<EntitySet Name="Categories" EntityType="self.Category" +/>

    + +
    + +

    Other entity models may +expose multiple entity sets per type.

    + +

    Example 32: three entity sets referring to the two entity +types

    + +
    + +

    <EntitySet Name="StandardCustomers" +EntityType="self.Customer">
    +
    <NavigationPropertyBinding +Path="Orders" Target="Orders" />
    +</EntitySet>

    + +

    <EntitySet Name="PreferredCustomers" +EntityType="self.Customer">

    + +

    <NavigationPropertyBinding Path="Orders" +Target="Orders" />
    +</EntitySet>
    +<EntitySet Name="Orders" EntityType="self.Order" />

    + +
    + +

    There are separate entity sets for standard customers and +preferred customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have navigation property bindings to the +orders entity set, but the orders entity set does not have a navigation +property binding for the Customer navigation property, since it could lead to +either set of customers.

    + +

    An entity set can expose instances of the specified entity +type as well as any entity type inherited from the specified entity type.

    + +

    A singleton allows +addressing a single entity directly from the entity container without having to +know its key, and without requiring an entity set.

    + +

    A function import or an action import is used to expose a function +or action defined in an entity model as a top level resource.

    + +
    + +

    Element edm:EntityContainer

    + +
    + +
    + +

    The edm:EntityContainer +MUST contain one or more edm:EntitySet, edm:Singleton, edm:ActionImport, +or edm:FunctionImport +elements.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the entity containers name.

    + +
    + +

    Example 33: +An entity container aggregates entity sets, singletons, action imports, and +function imports.

    + +
    + +

    <EntityContainer +Name="DemoService">
    +<EntitySet Name="Products" EntityType="self.Product">

    + +

    <NavigationPropertyBinding +Path="Category" Target="Categories" />

    + +

    <NavigationPropertyBinding +Path="Supplier" Target="Suppliers" />

    + +

    </EntitySet>

    + +

    <EntitySet +Name="Categories" EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    </EntitySet>

    + +

    <EntitySet +Name="Suppliers" EntityType="self.Supplier">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    </EntitySet>

    + +

    <Singleton +Name="MainSupplier" Type="self.Supplier" />

    + +

    <ActionImport +Name="LeaveRequestApproval" Action="self.Approval" />
    +<FunctionImport Name="ProductsByRating" Function="self.ProductsByRating" +

    + +

    EntitySet="Products" +/>
    +</EntityContainer>

    + +
    + +

    13.1 Extending an Entity Container

    + +

    An entity container MAY specify that it extends another +entity container in scope. All children of the base entity container are +added to the extending entity container.

    + +

    If the extending entity container defines an entity set +with the same name as defined in any of its base containers, then the entity +sets type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the base container. The same holds +for singletons. Action imports and function imports cannot be redefined, nor +can the extending container define a child with the same name as a child of a +different kind in a base container.

    + +

    Note: services should not introduce cycles by extending +entity containers. Clients should be prepared to process cycles introduced by +extending entity containers.

    + +
    + +

    Attribute Extends

    + +
    + +
    + +

    The value of Extends +is the qualified name of the entity container to be extended.

    + +
    + +

    Example 34: the entity container Extending +will contain all child elements that it defines itself, plus all child elements +of the Base entity container located in SomeOtherSchema

    + +
    + +

    <EntityContainer Name="Extending" +Extends="Some.Other.Schema.Base">

    + +

    + +

    </EntityContainer>

    + +
    + +

    13.2 Entity Set

    + +

    Entity sets are top-level collection-valued resources.

    + +

    An entity set is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An entity set MUST specify a type that MUST be an entity +type in scope.

    + +

    An entity set MUST contain only instances of its specified +entity type or its subtypes. The entity type MAY be abstract but MUST have a key +defined.

    + +

    An entity set MAY indicate whether it is included in the +service document. If not explicitly indicated, it is included.

    + +

    Entity sets that cannot be queried without specifying +additional query options SHOULD NOT be included in the service document.

    + +
    + +

    Element edm:EntitySet

    + +
    + +
    + +

    The edm:EntitySet element MUST contain the attributes Name and EntityType, and it +MAY contain the IncludeInServiceDocument attribute.

    + +

    It MAY contain edm:NavigationPropertyBinding +elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is the entity sets name.

    + +
    + +
    + +

    Attribute EntityType

    + +
    + +
    + +

    The value of EntityType +is the qualified name of an entity type in scope.

    + +
    + +
    + +

    Attribute IncludeInServiceDocument

    + +
    + +
    + +

    The value of IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the attribute means true.

    + +
    + +

    13.3 Singleton

    + +

    Singletons are top-level single-valued resources.

    + +

    A singleton is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    A singleton MUST specify a type that MUST be an entity type +in scope.

    + +

    A singleton MUST reference an instance its entity type.

    + +
    + +

    Element edm:Singleton

    + +
    + +
    + +

    The edm:Singleton element MUST include the attributes Name and Type, and it MAY +contain the Nullable attribute.

    + +

    It MAY contain edm:NavigationPropertyBinding +elements.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is the singletons name.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is whose value is the qualified name of an +entity type in scope.

    + +
    + +
    + +

    Attribute +Nullable

    + +
    + +
    + +

    The value of Nullable +is one of the Boolean literals true or false.

    + +

    If no value is specified, the Nullable attribute defaults to false. +

    + +

    In OData 4.0 responses this attribute +MUST NOT be specified.

    + +
    + +

    13.4 Navigation Property Binding

    + +

    If the entity type of an entity set or singleton declares +navigation properties, a navigation property binding allows describing which +entity set or singleton will contain the related entities.

    + +

    An entity set or a singleton SHOULD contain a navigation property +binding for each navigation property of +its entity type, including navigation properties defined on complex typed +properties.

    + +

    If omitted, clients MUST assume that the target entity set +or singleton can vary per related entity.

    + +

    13.4.1 Navigation +Property Path Binding

    + +

    A navigation property binding MUST specify a path to a +navigation property of the entity sets or singleton's declared entity type, or +a navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation property is +defined on a subtype, the path MUST contain the qualified +name of the subtype, followed by a forward slash, followed by the +navigation property name. If the navigation property is defined on a complex +type used in the definition of the entity sets entity type, the path attribute +MUST contain a forward-slash separated list of complex property names and qualified +type names that describe the path leading to the navigation property.

    + +

    The path can traverse one or more containment navigation +properties but the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment.

    + +

    If the path traverses collection-valued complex properties +or collection-valued containment navigation properties, the binding applies to +all items of these collections.

    + +

    If the path contains a recursive sub-path (i.e. a path +leading back to the same structured type, the binding applies recursively to +any positive number of cycles through that sub-path.

    + +

    OData 4.01 services MAY have a type-cast segment as the last +path segment, allowing to bind instances of different sub-types to different +targets.

    + +

    The same navigation property path MUST NOT be specified in +more than one navigation property binding; navigation property bindings are +only used when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths that +differ only in a type-cast segment, allowing to bind instances of different +sub-types to different targets. If paths differ only in type-cast segments, the +most specific path applies.

    + +

    13.4.2 Binding Target

    + +

    A navigation property binding MUST specify a target via a simple identifier or target +path. It specifies the entity set, singleton, or containment navigation +property that contains the entities.

    + +

    If the target is a simple +identifier, it MUST resolve to an entity set or singleton defined in the +same entity container as the enclosing element.

    + +

    If the target is a target path, +it MUST resolve to an entity set, singleton, or direct or indirect containment +navigation property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties before +ending in a containment navigation property, and there MUST NOT be any +non-containment navigation properties prior to the final segment.

    + +
    + +

    Element edm:NavigationPropertyBinding

    + +
    + +
    + +

    The edm:NavigationPropertyBinding +element MUST contain the attributes Path and Target.

    + +
    + +
    + +

    Attribute Path

    + +
    + +
    + +

    The value of Path +is a path expression.

    + +
    + +
    + +

    Attribute Target

    + +
    + +
    + +

    The value of Target +is a target path.

    + +
    + +

    Example 35: for an entity set in the same container as the +enclosing entity set Categories

    + +
    + +

    <EntitySet +Name="Categories" EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products"

    + +

    +Target="SomeSet" />

    + +

    </EntitySet>

    + +
    + +

    Example 36: for an entity set in any container in scope

    + +
    + +

    <EntitySet +Name="Categories" EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products"

    + +

    Target="SomeModel.SomeContainer/SomeSet" +/>

    + +

    </EntitySet>

    + +
    + +

    Example 37: binding Supplier +on Products contained within Categories binding applies +to all suppliers of all products of all categories

    + +
    + +

    <EntitySet Name="Categories" +EntityType="self.Category">
    + <NavigationPropertyBinding Path="Products/Supplier"

    + +

    +Target="Suppliers" />

    + +

    </EntitySet>

    + +
    + +

    13.5 Action +Import

    + +

    Action imports sets are top-level resources that are never +included in the service document.

    + +

    An action import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    An action import MUST specify the name of an unbound action +in scope.

    + +

    If the imported action +returns an entity or a collection of entities, a simple +identifier or target path value MAY be +specified to identify the entity set that contains the returned entities. If a simple identifier is specified, it MUST +resolve to an entity set defined in the same entity container. If a target path is specified, it MUST resolve to an +entity set in scope.

    + +
    + +

    Element edm:ActionImport

    + +
    + +
    + +

    The edm:ActionImport +element MUST contain the attributes Name and Action, and it MAY contain the EntitySet +attribute.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the action imports name.

    + +
    + +
    + +

    Attribute Action

    + +
    + +
    + +

    The value of Action +is the qualified name of an unbound action.

    + +
    + +
    + +

    Attribute EntitySet

    + +
    + +
    + +

    The value of EntitySet +is either the unqualified name of an entity set in the same entity container or +a path to an entity set in a different entity container.

    + +
    + +

    13.6 Function Import

    + +

    Function imports sets are top-level resources.

    + +

    A function import is identified by its name, a simple identifier that MUST be unique within +its entity container.

    + +

    A function import MUST specify the name of an unbound +function in scope. All unbound overloads +of an imported function can be invoked from the entity container.

    + +

    If +the imported function returns an entity or a collection of entities, a simple identifier or target +path value MAY be specified to identify the entity set that contains the +returned entities. If a simple identifier +is specified, it MUST resolve to an entity set defined in the same entity +container. If a target path is specified, it MUST +resolve to an entity set in scope.

    + +

    A function import for a +parameterless function MAY indicate whether it is included in the service +document. If not explicitly indicated, it is not included.

    + +
    + +

    Element edm:FunctionImport

    + +
    + +
    + +

    The edm:FunctionImport +element MUST contain the attributes Name and Function, and it MAY contain the attributes EntitySet and IncludeInServiceDocument.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the function imports name.

    + +
    + +
    + +

    Attribute Function

    + +
    + +
    + +

    The value of Function +is the qualified name of an unbound function.

    + +
    + +
    + +

    Attribute EntitySet

    + +
    + +
    + +

    The value of EntitySet +is either the unqualified name of an entity set in the same entity container or +a path to an entity set in a different entity container.

    + +
    + +
    + +

    Attribute IncludeInServiceDocument

    + +
    + +
    + +

    The value of IncludeInServiceDocument +is one of the Boolean literals true or false. Absence of the attribute means false.

    + +
    + + + +

    Vocabularies and annotations provide the ability to annotate +metadata as well as instance data, and define a powerful extensibility point +for OData. An annotation applies a term to a +model element and defines how to calculate a value for the applied term.

    + +

    Metadata annotations are terms applied to model +elements. Behaviors or constraints described by a metadata annotation must be +consistent with the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity type, +property, function, action, or parameter. For example, a metadata annotation +may define ranges of valid values for a particular property. Metadata +annotations are applied in CSDL documents describing or referencing an entity +model.

    + +

    Instance annotations are terms applied to a +particular instance within an OData payload, such as described in [OData‑JSON]. An +instance annotation can be used to define additional information associated +with a particular result, entity, property, or error. For example, whether a +property is read-only for a particular instance. Where the same annotation is +defined at both the metadata and instance level, the instance-level annotation +overrides the annotation specified at the metadata level. Annotations that +apply across instances should be specified as metadata annotations.

    + +

    A vocabulary is a schema containing a set of terms +where each term is a named metadata extension. Anyone +can define a vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary [OData‑VocCore].

    + +

    A term can be used to:

    + +

             +Extend model elements and type instances with additional +information.

    + +

             +Map instances of annotated structured types to an interface +defined by the term type; i.e. annotations allow viewing instances of a +structured type as instances of a differently structured type specified by the +applied term.

    + +

    A service SHOULD NOT require a client to interpret +annotations. Clients SHOULD ignore invalid or unknown terms and silently treat unexpected +or invalid values (including invalid type, invalid literal expression, invalid +targets, etc.) as an unknown value for the term. Unknown or invalid annotations +should never result in an error, as long as the payload remains well-formed.

    + +

    Example 38: the Product entity +type is extended with a DisplayName +by a metadata annotation that binds the term DisplayName to the value of the property Name. The Product +entity type also includes an annotation that allows its instances to be viewed +as instances of the type specified by the term SearchResult

    + +
    + +

    <EntityType +Name="Product">
    + <Key>

    + +

    <PropertyRef Name="ID" +/>

    + +

    </Key>
    + <Property Name="ID" Nullable="false" +Type="Edm.Int32" />
    + <Property Name="Name" Type="Edm.String" />
    + <Property Name="Description" Type="Edm.String" />
    +

    + +

    <Annotation Term="UI.DisplayName" +Path="Name" />
    +<Annotation Term="SearchVocabulary.SearchResult">

    + +

    <Record>
    + <PropertyValue Property="Title" Path="Name" />
    + <PropertyValue Property="Abstract" Path="Description" +/>
    + <PropertyValue Property="Url">
    + <Apply Function="odata.concat">
    + <String>Products(</String>
    + <Path>ID</Path>
    + <String>)</String>
    + </Apply>
    + </PropertyValue>

    + +

    </Record>
    +</Annotation>
    +</EntityType>

    + +
    + +

    14.1 Term

    + +

    A term allows annotating a CSDL element or OData resource +representation with additional data.

    + +

    The terms name is a simple +identifier that MUST be unique within its schema.

    + +

    The terms type MUST be a type in scope, or a collection of a +type in scope.

    + +
    + +

    Element edm:Term

    + +
    + +
    + +

    The +edm:Term element MUST contain the attributes Name and Type. It MAY contain +the attributes BaseTerm and AppliesTo.

    + +

    It MAY specify values for the Nullable, + MaxLength, Precision, Scale, or SRID facet attributes, as well as +the Unicode +facet attribute for 4.01 and greater payloads. These facets and their +implications are described in section 7.2.

    + +

    A edm:Term +element whose Type attribute specifies a primitive +or enumeration type MAY define a value for the DefaultValue +attribute.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name is the terms name.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    For single-valued properties the value +of Type is the qualified name of the propertys +type.

    + +

    For collection-valued properties the value +of Type is the character sequence Collection( followed by the qualified name of the +propertys item type, followed by a closing parenthesis ).

    + +
    + +
    + +

    Attribute DefaultValue

    + +
    + +
    + +

    The value of this attribute determines +the value of the term when applied in an edm:Annotation without providing +an expression.

    + +

    Default +values of type Edm.String MUST be represented +according to the XML escaping rules for character data in attribute values. +Values of other primitive types MUST be represented according to the +appropriate alternative in the primitiveValue rule +defined in [OData‑ABNF], i.e. Edm.Binary as binaryValue, Edm.Boolean as booleanValue +etc.

    + +

    If no value is specified, the DefaultValue attribute defaults to null.

    + +
    + +

    14.1.1 Specialized +Term

    + +

    A term MAY specialize another term in scope by specifying it +as its base type.

    + +

    When applying a term with a base term, the base term MUST +also be applied with the same qualifier, and so on until a term without a base +term is reached.

    + +
    + +

    Attribute BaseTerm

    + +
    + +
    + +

    The value of BaseTerm +is the qualified name of the base term.

    + +
    + +

    14.1.2 Applicability

    + +

    The applicability of a term MAY be restricted to a list of +model elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be extended in +future versions of the vocabulary. As the intended usage may evolve over time, +clients SHOULD be prepared for any term to be applied to any model element and +SHOULD be prepared to handle unknown values within the AppliesTo attribute. Applicability is expressed using the +following symbolic values:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Symbolic Value

    +
    +

    Model Element

    +
    +

    Action

    +
    +

    Action

    +
    +

    ActionImport

    +
    +

    Action Import

    +
    +

    Annotation

    +
    +

    Annotation

    +
    +

    Apply

    +
    +

    Application of a client-side function in an annotation

    +
    +

    Cast

    +
    +

    Type Cast annotation expression

    +
    +

    Collection

    +
    +

    Entity Set or collection-valued Property or Navigation + Property

    +
    +

    ComplexType

    +
    +

    Complex Type

    +
    +

    EntityContainer

    +
    +

    Entity Container

    +
    +

    EntitySet

    +
    +

    Entity Set

    +
    +

    EntityType

    +
    +

    Entity Type

    +
    +

    EnumType

    +
    +

    Enumeration Type

    +
    +

    Function

    +
    +

    Function

    +
    +

    FunctionImport

    +
    +

    Function Import

    +
    +

    If

    +
    +

    Conditional annotation expression

    +
    +

    Include

    +
    +

    Reference to an Included Schema

    +
    +

    IsOf

    +
    +

    Type Check annotation expression

    +
    +

    LabeledElement

    +
    +

    Labeled Element expression

    +
    +

    Member

    +
    +

    Enumeration Member

    +
    +

    NavigationProperty

    +
    +

    Navigation Property

    +
    +

    Null

    +
    +

    Null annotation expression

    +
    +

    OnDelete

    +
    +

    On-Delete Action of a navigation property

    +
    +

    Parameter

    +
    +

    Action of Function Parameter

    +
    +

    Property

    +
    +

    Property of a structured type

    +
    +

    PropertyValue

    +
    +

    Property value of a Record annotation expression

    +
    +

    Record

    +
    +

    Record annotation expression

    +
    +

    Reference

    +
    +

    Reference to another CSDL document

    +
    +

    ReferentialConstraint

    +
    +

    Referential Constraint of a navigation property

    +
    +

    ReturnType

    +
    +

    Return Type of an Action or Function

    +
    +

    Schema

    +
    +

    Schema

    +
    +

    Singleton

    +
    +

    Singleton

    +
    +

    Term

    +
    +

    Term

    +
    +

    TypeDefinition

    +
    +

    Type Definition

    +
    +

    UrlRef

    +
    +

    UrlRef annotation expression

    +
    + +
    + +

    Attribute AppliesTo

    + +
    + +
    + +

    The value of AppliesTo +is a whitespace-separated list of symbolic values from the table above that +identify model elements the term is intended to be applied to.

    + +
    + +

    Example 39: the IsURL term can +be applied to properties and terms that are of type Edm.String +(the Core.Tag type and the two Core terms +are defined in [OData‑VocCore])

    + +
    + +

    <Term Name="IsURL" Type="Core.Tag" +Nullable="false" DefaultValue="true"
    + AppliesTo="Property Term">
    + <Annotation Term="Core.Description">
    + <String>
    + Properties and terms annotated with this term MUST contain a valid URL

    + +

    </String>
    + </Annotation>

    + +

    <Annotation Term="Core.RequiresType" +String="Edm.String" />

    + +

    </Term>

    + +
    + +

    14.2 +Annotation

    + +

    An +annotation applies a term to +a model element and defines how to calculate a value for the term application. +Both term and model element MUST be in scope. Section 14.1.2 specifies which +model elements MAY be annotated with a term.

    + +

    The value of an annotation is +specified as an annotation expression, which is either a constant expression representing a constant +value, or a dynamic expression. The most common construct for +assigning an annotation value is a path expression that refers to a property of the same or a related +structured type.

    + +
    + +

    Element edm:Annotation

    + +
    + +
    + +

    The edm:Annotation +element MUST contain the attribute Term, and it MAY +contain the attribute Qualifier.

    + +

    The value of the annotation MAY be a constant expression or dynamic expression.

    + +

    If no expression is specified for a +term with a primitive type, the annotation evaluates to the default value of the term definition. If no +expression is specified for a term with a complex type, the annotation +evaluates to a complex instance with default values for its properties. If no +expression is specified for a collection-valued term, the annotation evaluates +to an empty collection.

    + +

    An edm:Annotation +element can be used as a child of the model element it annotates, or as the +child of an edm:Annotations element that +targets the model element to be annotated.

    + +

    An edm:Annotation +element MAY contain edm:Annotation +elements that annotate the annotation.

    + +
    + +
    + +

    Attribute Term

    + +
    + +
    + +

    The value of Term +is the qualified name of a term in scope.

    + +
    + +

    Example 40: term Measures.ISOCurrency, +once applied with a constant value, once with a path value

    + +
    + +

    <Property Name="AmountInReportingCurrency" +Type="Edm.Decimal">
    + <Annotation Term="Measures.ISOCurrency" String="USD">

    + +

    <Annotation +Term="Core.Description"
    + String="The parent companys currency" />

    + +

    </Annotation>

    + +

    </Property>

    + +

    <Property Name="AmountInTransactionCurrency" +Type="Edm.Decimal">
    + <Annotation Term="Measures.ISOCurrency" Path="Currency" +/>

    + +

    </Property>

    + +

    <Property Name="Currency" +Type="Edm.String" MaxLength="3" />

    + +
    + +

    If an entity type or complex type is annotated with a term +that itself has a structured type, an instance of the annotated type may be +viewed as an instance of the term, and the qualified term name may be used as +a term-cast segment in path expressions.

    + +

    Structured types inherit annotations from their direct or +indirect base types. If both the type and one of its base types is annotated +with the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or collection-valued +annotation values are not merged. Similarly, properties of a structured type +inherit annotations from identically named properties of a base type.

    + +

    It is up to the definition of a term to specify whether and +how annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a "Label" +annotation for a UI can propagate from a type definition to all properties +using that type definition and may be overridden at each property with a more +specific label, whereas an annotation marking a type definition as containing a +phone number will propagate to all using properties but may not be overridden.

    + +

    14.2.1 Qualifier

    + +

    A +term can be applied multiple times to the same model element by providing a +qualifier to distinguish the annotations. The qualifier is a simple identifier.

    + +

    The combination of target model +element, term, and qualifier uniquely identifies an annotation.

    + +
    + +

    Attribute Qualifier

    + +
    + +
    + +

    Annotation elements that are children +of an edm:Annotations element MUST NOT provide a value for +the qualifier attribute if the parent edm:Annotations +element provides a value for the qualifier attribute.

    + +
    + +

    Example 41: annotation should only be applied to tablet +devices

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName" Path="FirstName"
    + Qualifier="Tablet" />

    + +
    + +

    14.2.2 Target

    + +

    The target of an annotation is the model element the term is +applied to.

    + +

    The target of an annotation MAY be specified indirectly by +nesting the annotation within the model element. Whether and how this is +possible is described per model element in this specification.

    + +

    The target of an annotation MAY also be specified directly; +this allows defining an annotation in a different schema than the targeted +model element.

    + +

    This external +targeting is only possible for model elements that are uniquely identified +within their parent, and all their ancestor elements are uniquely identified +within their parent:

    + + + +

    These are the +direct children of a schema with a unique name (i.e. except actions and +functions whose overloads to not possess a natural identifier), and all direct +children of an entity container.

    + +

    External targeting is possible for +actions, functions, their parameters, and their return type, either in a way +that applies to all overloads of the action or function or all parameters of +that name across all overloads, or in a way that identifies a single overload.

    + +

    External +targeting is also possible for properties and navigation properties of +singletons or entities in a particular entity set. These annotations override +annotations on the properties or navigation properties targeted via the +declaring structured type.

    + +

    The allowed path +expressions are:

    + +

             +qualified +name of schema child

    + +

             +qualified +name of schema child followed +by a forward slash and name of child element

    + +

             +qualified +name of structured type +followed by zero or more property, navigation property, or type-cast segments, +each segment starting with a forward slash

    + +

             +qualified +name of an entity +container followed by a segment containing a singleton or entity set name and +zero or more property, navigation property, or type-cast segments

    + +

             +qualified +name of an action +followed by parentheses containing the binding parameter type of a bound +action overload to identify that bound overload, or by empty parentheses to +identify the unbound overload

    + +

             +qualified +name of a function +followed by parentheses containing the comma-separated list of the parameter types +of a bound or unbound function overload in the order of their definition in the +function overload

    + +

             +qualified +name of an action or +function, optionally followed by parentheses as described in the two previous +bullet points to identify a single overload, followed by a forward slash and +either a parameter name or $ReturnType

    + +

             +qualified +name of an entity +container followed by a segment containing an action or function import name, +optionally followed by a forward slash and either a parameter name or $ReturnType

    + +
      +
    • One of the + preceding, followed by a forward slash, an at (@), the qualified name of a term, and optionally a hash (#) and the + qualifier of an annotation
    • +
    + +

    All qualified names used in a target path MUST be in scope.

    + +

    Example 42: Target expressions

    + +
    + +

    MySchema.MyEntityType

    + +

    MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityType/MyNavigationProperty

    + +

    MySchema.MyComplexType

    + +

    MySchema.MyComplexType/MyProperty

    + +

    MySchema.MyComplexType/MyNavigationProperty

    + +

    MySchema.MyEnumType

    + +

    MySchema.MyEnumType/MyMember

    + +

    MySchema.MyTypeDefinition

    + +

    MySchema.MyTerm

    + +

    MySchema.MyEntityContainer

    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MyActionImport

    + +

    MySchema.MyEntityContainer/MyFunctionImport

    + +

    MySchema.MyAction

    + +

    MySchema.MyAction(MySchema.MyBindingType)

    + +

    MySchema.MyAction(Collection(MySchema.MyBindingType))

    + +

    MySchema.MyAction()

    + +

    MySchema.MyFunction

    + +

    MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType)

    + +

    MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType)

    + +

    MySchema.MyFunction/MyParameter

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty

    + +

    MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty

    + +
    + +

    14.3 +Constant Expression

    + +

    Constant expressions allow assigning a constant value to an +applied term.

    + +

    14.3.1 Binary

    + +
    + +

    Expression edm:Binary

    + +
    + +
    + +

    The edm:Binary +expression evaluates to a primitive binary value. A binary expression MUST be +assigned a value conforming to the rule binaryValue +in [OData‑ABNF].

    + +

    The binary expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 43: base64url-encoded binary value (OData)

    + +
    + +

    <Annotation +Term="org.example.display.Thumbnail" Binary="T0RhdGE" />
    +
    +<Annotation Term="org.example.display.Thumbnail">
    + <Binary>T0RhdGE</Binary>
    +</Annotation>

    + +
    + +

    14.3.2 Boolean

    + +
    + +

    Expression edm:Bool

    + +
    + +
    + +

    The edm:Bool +expression evaluates to a primitive Boolean value. A Boolean expression MUST be +assigned a Boolean value.

    + +

    The Boolean expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 44:

    + +
    + +

    <Annotation +Term="org.example.display.ReadOnly" Bool="true" />
    +
    +<Annotation Term="org.example.display.ReadOnly">
    + <Bool>true</Bool>
    +</Annotation>

    + +
    + +

    14.3.3 Date

    + +
    + +

    Expression edm:Date

    + +
    + +
    + +

    The edm:Date +expression evaluates to a primitive date value. A date expression MUST be +assigned a value of type xs:date, see [XML‑Schema‑2], section 3.3.9. The value +MUST also conform to rule dateValue in [OData‑ABNF], i.e. it MUST NOT contain a +time-zone offset.

    + +

    The date expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 45:

    + +
    + +

    <Annotation Term="org.example.vCard.birthDay" +Date="2000-01-01" />
    +
    +<Annotation Term="org.example.vCard.birthDay">
    +<Date>2000-01-01</Date>
    +</Annotation>

    + +
    + +

    14.3.4 DateTimeOffset

    + +
    + +

    Expression edm:DateTimeOffset

    + +
    + +
    + +

    The edm:DateTimeOffset +expression evaluates to a primitive datetimestamp value with a time-zone +offset. A datetimestamp expression MUST be assigned a value of type xs:dateTimeStamp, see [XML‑Schema‑2], +section 3.4.28. +The value MUST also conform to rule dateTimeOffsetValue +in [OData‑ABNF], i.e. it MUST NOT contain an +end-of-day fragment (24:00:00).

    + +

    The datetimestamp expression MAY be +provided using element notation or attribute notation.

    + +
    + +

    Example 46:

    + +
    + +

    <Annotation +Term="org.example.display.LastUpdated"

    + +

    DateTimeOffset="2000-01-01T16:00:00.000Z" +/>
    +
    +<Annotation Term="org.example.display.LastUpdated">
    + <DateTimeOffset>2000-01-01T16:00:00.000-09:00</DateTimeOffset>
    +</Annotation>

    + +
    + +

    14.3.5 Decimal

    + +
    + +

    Expression edm:Decimal

    + +
    + +
    + +

    The edm:Decimal +expression evaluates to a primitive decimal value. A decimal expression MUST be +assigned a value conforming to the rule decimalValue +in [OData‑ABNF].

    + +

    The decimal expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 47: attribute notation

    + +
    + +

    <Annotation +Term="org.example.display.Width" Decimal="3.14" />

    + +
    + +

    Example 48: element notation

    + +
    + +

    <Annotation +Term="org.example.display.Width">
    +<Decimal>3.14</Decimal>
    +</Annotation>

    + +
    + +

    14.3.6 Duration

    + +
    + +

    Expression edm:Duration

    + +
    + +
    + +

    The edm:Duration +expression evaluates to a primitive duration value. A duration expression MUST +be assigned a value of type xs:dayTimeDuration, see +[XML‑Schema‑2], section 3.4.27.

    + +

    The duration expression MAY be +provided using element notation or attribute notation.

    + +
    + +

    Example 49:

    + +
    + +

    <Annotation Term="org.example.task.duration" +Duration="P7D" />
    +
    +<Annotation Term="org.example.task.duration">
    + <Duration>P11DT23H59M59.999999999999S</Duration>
    +</Annotation>

    + +
    + +

    14.3.7 Enumeration Member

    + +
    + +

    Expression edm:EnumMember

    + +
    + +
    + +

    The edm:EnumMember +expression references a member of an enumeration type. An enumeration member +expression MUST be assigned a value that consists of the qualified name of the +enumeration type, followed by a forward slash and the name of the enumeration +member. If the enumeration type specifies an IsFlags +attribute with value true, the expression MAY also +be assigned a whitespace-separated list of values. Each of these values MUST +resolve to the name of a member of the enumeration type of the specified term.

    + +

    The enumeration member expression MAY +be provided using element notation or attribute notation.

    + +
    + +

    Example 50: single value

    + +
    + +

    <Annotation Term="org.example.HasPattern"
    + EnumMember="org.example.Pattern/Red" />
    +
    +<Annotation Term="org.example.HasPattern">
    +<EnumMember>org.example.Pattern/Red</EnumMember>
    +</Annotation>

    + +
    + +

    Example 51: combined value for IsFlags +enumeration type

    + +
    + +

    <Annotation Term="org.example.HasPattern"
    + EnumMember="org.example.Pattern/Red +org.example.Pattern/Striped" />
    +
    +<Annotation Term="org.example.HasPattern">
    +<EnumMember>org.example.Pattern/Red org.example.Pattern/Striped</EnumMember>
    +</Annotation>

    + +
    + +

    14.3.8 Floating-Point Number

    + +
    + +

    Expression edm:Float

    + +
    + +
    + +

    The edm:Float +expression evaluates to a primitive floating point (or double) value. A float expression +MUST be assigned a value conforming to the rule doubleValue +in [OData‑ABNF].

    + +

    The float expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 52:

    + +
    + +

    <Annotation +Term="org.example.display.Width" Float="3.14" />
    +
    +<Annotation Term="org.example.display.Width">
    +<Float>3.14</Float>
    +</Annotation>

    + +
    + +

    14.3.9 Guid

    + +
    + +

    Expression edm:Guid

    + +
    + +
    + +

    The edm:Guid +expression evaluates to a primitive guid value. A guid expression MUST be +assigned a value conforming to the rule guidValue +in [OData‑ABNF].

    + +

    The guid expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 53:

    + +
    + +

    <Annotation +Term="org.example.display.Id"

    + +

    Guid="21EC2020-3AEA-1069-A2DD-08002B30309D" +/>
    +
    +<Annotation Term="org.example.display.Id">
    +<Guid>21EC2020-3AEA-1069-A2DD-08002B30309D</Guid>
    +</Annotation>

    + +
    + +

    14.3.10 Integer

    + +
    + +

    Expression edm:Int

    + +
    + +
    + +

    The edm:Int +expression evaluates to a primitive integer value. An integer MUST be assigned +a value conforming to the rule int64Value in [OData‑ABNF].

    + +

    The integer expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 54: attribute notation

    + +
    + +

    <Annotation +Term="org.example.display.Width" Int="42" />

    + +
    + +

    Example 55: element notation

    + +
    + +

    <Annotation +Term="org.example.display.Width">
    + <Int>42</Int>
    +</Annotation>

    + +
    + +

    14.3.11 String

    + +
    + +

    Expression edm:String

    + +
    + +
    + +

    The edm:String +expression evaluates to a primitive string value. A string expression MUST be +assigned a value of the type xs:string, see [XML‑Schema‑2], section 3.3.1.

    + +

    The string expression MAY be provided +using element notation or attribute notation.

    + +
    + +

    Example 56:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName" String="Product Catalog" +/>
    +
    +<Annotation Term="org.example.display.DisplayName">
    + <String>Product Catalog</String>
    +</Annotation>

    + +
    + +

    14.3.12 Time of Day

    + +
    + +

    Expression edm:TimeOfDay

    + +
    + +
    + +

    The edm:TimeOfDay +expression evaluates to a primitive time value. A time-of-day expression MUST +be assigned a value conforming to the rule timeOfDayValue +in [OData‑ABNF].

    + +

    The time-of-day expression MAY be +provided using element notation or attribute notation.

    + +
    + +

    Example 57:

    + +
    + +

    <Annotation +Term="org.example.display.EndTime" TimeOfDay="21:45:00" +/>
    +
    +<Annotation Term="org.example.display.EndTime">
    + <TimeOfDay>21:45:00</TimeOfDay>
    +</Annotation>

    + +
    + +

    14.4 Dynamic +Expression

    + +

    Dynamic expressions allow assigning a calculated value to an +applied term.

    + +

    14.4.1 Path +Expressions

    + +

    Path expressions allow +assigning a value to an applied term or term component. There are two kinds of +path expressions:

    + +

             +A +model path is used within Annotation +Path, Model Element Path, Navigation Property Path, and Property Path expressions to traverse the model of +a service and resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the built-in types Edm.AnnotationPath, Edm.NavigationPropertyPath, +Edm.PropertyPath, and their base types Edm.AnyPropertyPath and Edm.ModelElementPath.

    + +

             +An instance path is used within a Value +Path expression to traverse a graph of type instances and resolves to the +value identified by the path. It allows assigning values to terms or term +properties of built-in types other than the Edm.*Path +types, or of any model-defined type.

    + +

    14.4.1.1 Path Syntax

    + +

    Model paths and instance paths share a common syntax which +is derived from the path expression syntax of URLs, see [OData‑URL].

    + +

    A path MUST be composed of zero or more path segments joined +together by forward slashes (/).

    + +

    Paths starting with a forward slash (/) +are absolute paths, and the first path segment MUST be the qualified name of a +model element, e.g. an entity container. The remaining path after the second +forward slash is interpreted relative to that model element.

    + +

    Example 58: absolute path to an entity set

    + +
    + +

    /self.MyEntityContainer/MyEntitySet

    + +
    + +

    Paths not starting with a forward slash are interpreted +relative to the annotation target, following the rules specified in section Path Evaluation.

    + +

    Example 59: relative path to a property

    + +
    + +

    Address/City

    + +
    + +

    If a path segment is a qualified +name, it represents a type cast, and the +segment MUST be the name of a type in scope. If the type or instance identified +by the preceding path part cannot be cast to the specified type, the path +expression evaluates to the null value.

    + +

    Example 60: type-cast segment

    + +
    + +

    /self.Manager/

    + +
    + +

    If a path segment starts with an at (@) +character, it represents a term cast. The at +(@) character MUST be followed by a qualified name that +MAY be followed by a hash (#) character and a simple identifier. The qualified name preceding +the hash character MUST resolve to a term that is in scope, the simple identifier following +the hash sign is interpreted as a qualifier for +the term. If the model element or instance identified by the preceding path +part has not been annotated with that term (and if present, with that +qualifier), the term cast evaluates to the null value. Four special terms are implicitly +annotated for media entities and stream properties:

    + +
      +
    • odata.mediaEditLink
    • +
    • odata.mediaReadLink
    • +
    • odata.mediaContentType
    • +
    • odata.mediaEtag
    • +
    + +

    Example 61: term-cast segment

    + +
    + +

    /@Capabilities.SortRestrictions/

    + +
    + +

    If a path segment is a simple +identifier, it MUST be the name of a child model element of the model +element identified by the preceding path part, or a structural or navigation +property of the instance identified by the preceding path part. A sequence of +navigation segments can traverse multiple CSDL documents. The document +containing the path expression only needs to reference the next traversed +document to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document.

    + +

    A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path.

    + +

    Example 62: property segment in model path

    + +
    + +

    /Orders/Items/Product/

    + +
    + +

    An instance path MUST NOT contain +more than one segment representing a collection-valued construct, e.g. an +entity set or a collection-valued navigation property that is not followed by a +key predicate, or a collection-valued structural property that is not followed +by an index segment. The result of the expression is the collection of +instances resulting from applying any remaining segments that operate on a +single-valued expression to each instance in the collection-valued segment.

    + +

    An instance path MAY terminate in a $count +segment if the previous segment is collection-valued, in which case the path +evaluates to the number of items in the collection identified by the preceding +segment.

    + +

    Example 63: property segments in instance path

    + +
    + +

    /Addresses/Street

    + +

    /Addresses/$count

    + +
    + +

    A model path MAY contain path segments starting with a +navigation property, then followed by an at (@) +character, then followed by the qualified name of a term in scope, and optionally followed by a +hash (#) character and a simple identifier which is interpreted as a qualifier for the term. If the navigation property +has not been annotated with that term (and if present, with that qualifier), +the path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity type +specified by the navigation property are addressed via a term-cast +segment.

    + +

    Example 64: model path addressing an annotation on a +navigation property

    + +
    + +

    /Items@Capabilities.InsertRestrictions/Insertable

    + +
    + +

    An instance path MAY contain path segments starting with an +entity set or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see [OData‑URL]. +The key values are either primitive literals or instance paths. If the key +value is a relative instance path, it is interpreted according to the same rule +below as the instance path it is part of, not relative to the instance +identified by the preceding path part.

    + +

    Example 65: instance path with entity set and key predicate

    + +
    + +

    /self.container/SettingsCollection('FeatureXxx')/IsAvailable +

    + +

    /self.container/Products(ID=ProductID)/Name

    + +
    + +

    An instance path MAY contain an index segment immediately +following a path segment representing an ordered collection-valued structural property. +The index is zero-based and MUST be an integer literal. Negative integers count +from the end of the collection, with -1 representing the last item in the +collection. Remaining path segments are evaluated relative to the identified +item of the collection.

    + +

    Example 66: instance path with collection-valued structural +property and index segment

    + +
    + +

    Addresses/1

    + +

    Addresses/-1/Street

    + +
    + +

    14.4.1.2 Path +Evaluation

    + +

    Annotations MAY be embedded within their target, or +specified separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as targeting +in the remainder of this section.

    + +

    For annotations embedded within or targeting an entity container, +the path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a segment +identifying a container child (entity set, function import, action import, or +singleton). The subsequent segments follow the rules for path expressions +targeting the corresponding child element.

    + +

    For annotations embedded within or targeting an entity set +or a singleton, the path is evaluated starting at the entity set or singleton, +i.e. an empty path resolves to the entity set or singleton, and non-empty paths +MUST follow the rules for annotations targeting the declared entity type of the +entity set or singleton.

    + +

    For annotations embedded within or targeting an entity type +or complex type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be a +structural or navigation property of the type, a type +cast, or a term cast.

    + +

    For annotations embedded within a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other properties of +the same type. An empty path resolves to the enclosing type, and non-empty +paths MUST follow the rules for annotations targeting the directly enclosing +type.

    + +

    For annotations targeting a structural or navigation +property of an entity type or complex type, the path is evaluated starting at +the outermost entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the first +segment of a non-empty path MUST be a structural or navigation property of the +outermost type, a type cast, or a term cast.

    + +

    For annotations embedded within or targeting an action, +action import, function, function import, parameter, or return type, the first +segment of the path MUST be a parameter name or $ReturnType.

    + +

    14.4.1.3 Annotation +Path

    + +

    The annotation path expression provides a value for terms or +term properties that specify the built-in types Edm.AnnotationPath or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

             +A +non-null path MUST resolve to an annotation.

    + +

    A term or term property of type Edm.AnnotationPath +can be annotated with term Validation.AllowedTerms +(see [OData-VocValidation]) if its +intended value is an annotation path that ends in a term cast with one of the +listed terms.

    + +

    The value of the annotation path expression is the path +itself, not the value of the annotation identified by the path. This is useful +for terms that reuse or refer to other terms.

    + +
    + +

    Expression edm:AnnotationPath

    + +
    + +
    + +

    The edm:AnnotationPath +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 67:

    + +
    + +

    <Annotation Term="UI.ReferenceFacet"
    + AnnotationPath="Product/Supplier/@UI.LineItem" />

    + +

     

    + +

    <Annotation Term="UI.CollectionFacet" +Qualifier="Contacts">

    + +

    <Collection>

    + +

    +<AnnotationPath>Supplier/@Communication.Contact</AnnotationPath>

    + +

    +<AnnotationPath>Customer/@Communication.Contact</AnnotationPath>

    + +

    </Collection>

    + +

    </Annotation>

    + +
    + +

    14.4.1.4 +Model Element Path

    + +

    The model element path expression provides a value for terms +or term properties that specify the built-in type Edm.ModelElementPath. Its argument is a model path.

    + +

    The value of the model element path expression is the path +itself, not the instance(s) identified by the path.

    + +
    + +

    Expression edm:ModelElementPath

    + +
    + +
    + +

    The edm:ModelElementPath +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 68:

    + +
    + +

    <Annotation Term="org.example.MyFavoriteModelElement" +

    + +

    ModelElementPath="/org.example.someAction" +/>

    + +

     

    + +

    <Annotation Term="org.example.MyFavoriteModelElement"> +

    + +

    <ModelElementPath>/org.example.someAction</ModelElementPath> +

    + +

    </Annotation>

    + +
    + +

    14.4.1.5 Navigation Property Path

    + +

    The navigation property path expression provides a value for +terms or term properties that specify the built-in types Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

             +A non-null path MUST resolve to a model element whose type is an +entity type, or a collection of entity types, e.g. a navigation property.

    + +

    The value of the navigation property path expression is the +path itself, not the instance(s) identified by the path.

    + +
    + +

    Expression edm:NavigationPropertyPath

    + +
    + +
    + +

    The edm:NavigationPropertyPath +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 69:

    + +
    + +

    <Annotation Term="UI.HyperLink" +NavigationPropertyPath="Supplier" />

    + +

     

    + +

    <Annotation Term="Capabilities.UpdateRestrictions">

    + +

    <Record>
    + <PropertyValue Property="NonUpdatableNavigationProperties">

    + +

    <Collection>

    + +

    <NavigationPropertyPath>Supplier</NavigationPropertyPath>

    + +

    <NavigationPropertyPath>Category</NavigationPropertyPath>

    + +

    </Collection>

    + +

    </PropertyValue>

    + +

    </Record>

    + +

    </Annotation>

    + +
    + +

    14.4.1.6 +Property Path

    + +

    The property path expression provides a value for terms or +term properties that specify one of the built-in types Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath. Its argument is a model path with the following restriction:

    + +

             +A non-null path MUST resolve to a model element whose type is a primitive or complex type, an +enumeration type, a type definition, or a collection of one of these +types.

    + +

    The value of the property path expression is the path +itself, not the value of the property or the value of the term cast identified +by the path.

    + +
    + +

    Expression edm:PropertyPath

    + +
    + +
    + +

    The edm:PropertyPath +MAY be provided using either element notation or attribute notation.

    + +
    + +

    Example 70:

    + +
    + +

    <Annotation Term="UI.RefreshOnChangeOf" +PropertyPath="ChangedAt" />

    + +

     

    + +

    <Annotation Term="Capabilities.UpdateRestrictions">
    + <Record>
    + <PropertyValue Property="NonUpdatableProperties">

    + +

    <Collection>

    + +

    <PropertyPath>CreatedAt</PropertyPath>

    + +

    <PropertyPath>ChangedAt</PropertyPath>

    + +

    </Collection>

    + +

    </PropertyValue>

    + +

    </Record>

    + +

    </Annotation>

    + +
    + +

    14.4.1.7 Value Path

    + +

    The +value path expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity containers, +entity sets, entity types, complex types, navigation properties of structured +types, and properties of structured types. Its argument is an instance path.

    + +

    The value of the path expression is the instance or +collection of instances identified by the path.

    + +
    + +

    Expression edm:Path

    + +
    + +
    + +

    The edm:Path +expression MAY be provided using element notation or attribute notation.

    + +
    + +

    Example 71:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName" Path="FirstName" +/>
    +
    +<Annotation Term="org.example.display.DisplayName">
    +<Path>@vCard.Address#work/FullName</Path>
    +</Annotation>

    + +
    + +

    14.4.2 Comparison and Logical Operators

    + +

    Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and they MAY +be used anywhere instead of a Boolean expression.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Logical Operators

    +
    +

    And

    +
    +

    Logical + and

    +
    +

    Or

    +
    +

    Logical + or

    +
    +

    Not

    +
    +

    Logical + negation

    +
    +

    Comparison Operators

    +
    +

    Eq

    +
    +

    Equal

    +
    +

    Ne

    +
    +

    Not + equal

    +
    +

    Gt

    +
    +

    Greater + than

    +
    +

    Ge

    +
    +

    Greater + than or equal

    +
    +

    Lt

    +
    +

    Less than

    +
    +

    Le

    +
    +

    Less + than or equal

    +
    +

    Has

    +
    +

    Has + enumeration flag(s) set

    +
    +

    In

    +
    +

    Is + in collection

    +
    + +

    The And and Or operators require two operand expressions that +evaluate to Boolean values. The Not operator +requires a single operand expression that evaluates to a Boolean value. For +details on null handling for comparison operators see [OData‑URL].

    + +

    The other comparison operators require two operand +expressions that evaluate to comparable values.

    + +
    + +

    Expressions edm:And and edm:Or

    + +
    + +
    + +

    The And +and Or logical expressions are represented as +elements edm:And and edm:Or +that MUST contain two annotation expressions.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Expression +edm:Not

    + +
    + +
    + +

    Negation expressions are represented +as an element edm:Not that MUST contain a single +annotation expression.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Expressions +edm:Eq, edm:Ne, edm:Gt, +edm:Ge, edm:Lt, edm:Le, +edm:Has, and edm:In

    + +
    + +
    + +

    All comparison expressions are +represented as an element that MUST contain two annotation expressions.

    + +

    They MAY contain edm:Annotation +elements.

    + +
    + +

    Example 72:

    + +
    + +

    <And>

    + +

    <Path>IsMale</Path>

    + +

    <Path>IsMarried</Path>

    + +

    </And>

    + +

    <Or>

    + +

    <Path>IsMale</Path>

    + +

    <Path>IsMarried</Path>

    + +

    </Or>

    + +

    <Not>

    + +

    <Path>IsMale</Path>

    + +

    </Not>

    + +

    <Eq>

    + +

    <Null />

    + +

    <Path>IsMale</Path>

    + +

    </Eq>

    + +

    <Ne>

    + +

    <Null />

    + +

    <Path>IsMale</Path>

    + +

    </Ne>

    + +

    <Gt>

    + +

    <Path>Price</Path>

    + +

    <Int>20</Int>

    + +

    </Gt>

    + +

    <Ge>

    + +

    <Path>Price</Path>

    + +

    <Int>10</Int>

    + +

    </Ge>

    + +

    <Lt>

    + +

    <Path>Price</Path>

    + +

    <Int>20</Int>

    + +

    </Lt>

    + +

    <Le>

    + +

    <Path>Price</Path>

    + +

    <Int>100</Int>

    + +

    </Le>

    + +

    <Has>

    + +

    <Path>Fabric</Path>

    + +

    +<EnumMember>org.example.Pattern/Red</EnumMember>

    + +

    </Has>

    + +

    <In>

    + +

    <Path>Size</Path>

    + +

    <Collection>

    + +

    <String>XS</String>

    + +

    <String>S</String>

    + +

    </Collection>

    + +

    </In>

    + +
    + +

    14.4.3 Arithmetic Operators

    + +

    Annotations MAY use the following arithmetic expressions +which evaluate to a numeric value. These expressions MAY be combined, and they MAY +be used anywhere instead of a numeric expression of the appropriate type. The +semantics and evaluation rules for each arithmetic expression is identical to +the corresponding arithmetic operator defined in [OData‑URL].

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Operator

    +
    +

    Description

    +
    +

    Add

    +
    +

    Addition

    +
    +

    Sub

    +
    +

    Subtraction

    +
    +

    Neg

    +
    +

    Negation

    +
    +

    Mul

    +
    +

    Multiplication

    +
    +

    Div

    +
    +

    Division + (with integer result for integer operands)

    +
    +

    DivBy

    +
    +

    Division + (with fractional result also for integer operands)

    +
    +

    Mod

    +
    +

    Modulo

    +
    + +

    The Neg operator requires a +single operand expression that evaluates to a numeric value. The other arithmetic +operators require two operand expressions that evaluate to numeric values.

    + +
    + +

    Expression +edm:Neg

    + +
    + +
    + +

    Negation expressions are represented +as an element edm:Neg that MUST contain a single +annotation expression.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Expressions +edm:Add, edm:Sub, edm:Mul, edm:Div, edm:DivBy, and edm:Mod

    + +
    + +
    + +

    These arithmetic expressions are +represented as an element that MUST contain two annotation expressions.

    + +

    They MAY contain edm:Annotation +elements.

    + +
    + +

    Example 73:

    + +
    + +

    <Add>

    + +

    <Path>StartDate</Path>

    + +

    <Path>Duration</Path>

    + +

    </Add>

    + +

    <Sub>

    + +

    <Path>Revenue</Path>

    + +

    <Path>Cost</Path>

    + +

    </Sub>

    + +

    <Neg>

    + +

    <Path>Height</Path>

    + +

    </Neg>

    + +

    <Mul>

    + +

    <Path>NetPrice</Path>

    + +

    <Path>TaxRate</Path>

    + +

    </Mul>

    + +

    <Div>

    + +

    <Path>Quantity</Path>

    + +

    +<Path>QuantityPerParcel</Path>

    + +

    </Div>

    + +

    <DivBy>

    + +

    <Path>Quantity</Path>

    + +

    +<Path>QuantityPerParcel</Path>

    + +

    </DivBy>

    + +

    <Mod>

    + +

    <Path>Quantity</Path>

    + +

    +<Path>QuantityPerParcel</Path>

    + +

    </Mod>

    + +
    + +

    14.4.4 Apply Client-Side Function

    + +

    The apply expression enables a value to be obtained by +applying a client-side function. The apply expression MAY have operand +expressions. The operand expressions are used as parameters to the function.

    + +
    + +

    Expression edm:Apply

    + +
    + +
    + +

    The edm:Apply +element MUST contain the Function attribute and MAY +contain annotation expressions as operands for the applied function.

    + +

    It MAY contain +more edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Function

    + +
    + +
    + +

    The value of Function +is the qualified name of the client-side +function to apply.

    + +
    + +

    OData defines the following functions. Services MAY support +additional functions that MUST be qualified with a namespace or alias other +than odata. Function names +qualified with odata are reserved for this +specification and its future versions.

    + +

    14.4.4.1 Canonical Functions

    + +

    All canonical functions defined in [OData‑URL] +can be used as client-side functions, qualified with the namespace odata. The semantics of these client-side functions is +identical to their counterpart function defined in [OData‑URL].

    + +

    For example, the odata.concat +client-side function takes two or more expressions as arguments. Each argument +MUST evaluate to a primitive or enumeration type. It returns a value of type Edm.String that is the concatenation of the literal representations +of the results of the argument expressions. Values of primitive types other +than Edm.String are represented according to the +appropriate alternative in the primitiveValue rule +of [OData‑ABNF], i.e. Edm.Binary +as binaryValue, Edm.Boolean +as booleanValue etc.

    + +

    Example 74:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName">
    +<Apply Function="odata.concat">
    + <String>Product: </String>
    + <Path>ProductName</Path>
    + <String> (</String>
    + <Path>Available/Quantity</Path>

    + +

    <String> </String>
    + <Path>Available/Unit</Path>

    + +

    <String> +available)</String>

    + +

    </Apply>
    +</Annotation>

    + +
    + +

    ProductName is of type String, +Quantity in complex type Available +is of type Decimal, and Unit +in Available is of type enumeration, so the result +of the Path expression is represented as the member +name of the enumeration value.

    + +

    14.4.4.2 +Function odata.fillUriTemplate

    + +

    The odata.fillUriTemplate +client-side function takes two or more expressions as arguments and returns a +value of type Edm.String.

    + +

    The first argument MUST be of type Edm.String +and specifies a URI template according to [RFC6570], +the other arguments MUST be labeled element +expressions. Each labeled element expression +specifies the template parameter name in its Name +attribute and evaluates to the template parameter value.

    + +

    [RFC6570] defines three +kinds of template parameters: simple values, lists of values, and key-value +maps.

    + +

    Simple values are represented as labeled element expressions that evaluate to a +single primitive value. The literal representation of this value according to [OData‑ABNF] is used to fill the +corresponding template parameter.

    + +

    Lists of values are represented as labeled element expressions that evaluate to a +collection of primitive values.

    + +

    Key-value maps are represented as labeled element expressions that evaluate to a +collection of complex types with two properties that are used in lexicographic +order. The first property is used as key, the second property as value.

    + +

    Example 75: assuming there are no special characters in +values of the Name property of the Actor entity

    + +
    + +

    <Apply Function="odata.fillUriTemplate">

    + +

    +<String>http://host/someAPI/Actors/{actorName}/CV</String>

    + +

    <LabeledElement +Name="actorName" Path="Actor/Name" />

    + +

    </Apply>

    + +
    + +

    14.4.4.3 +Function odata.matchesPattern

    + +

    The odata.matchesPattern +client-side function takes two string expressions as arguments and returns a +Boolean value.

    + +

    The function returns true if the second expression evaluates +to an [ECMAScript] (JavaScript) regular +expression and the result of the first argument expression matches that regular +expression, using syntax and semantics of [ECMAScript] +regular expressions.

    + +

    Example 76: all non-empty FirstName +values not containing the letters b, c, or d evaluate to true

    + +
    + +

    <Apply Function="odata.matchesPattern">

    + +

    <Path>FirstName</Path>

    + +

    <String>^[^b-d]+$</String>

    + +

    </Apply>

    + +
    + +

    14.4.4.4 Function odata.uriEncode

    + +

    The odata.uriEncode client-side +function takes one argument of primitive type and returns the URL-encoded OData +literal that can be used as a key value in OData URLs or in the query part of +OData URLs.

    + +

    Note: string literals are surrounded by single quotes as +required by the paren-style key syntax.

    + +

    Example 77:

    + +
    + +

    <Apply Function="odata.fillUriTemplate">

    + +

    +<String>http://host/service/Genres({genreName})</String>

    + +

    <LabeledElement Name="genreName">

    + +

    <Apply Function="odata.uriEncode" >

    + +

    <Path>NameOfMovieGenre</Path>

    + +

    </Apply>

    + +

    </LabeledElement>

    + +

    </Apply>

    + +
    + +

    14.4.5 Cast

    + +

    The cast expression casts the value obtained from its single +child expression to the specified type. The cast expression follows the same +rules as the cast canonical function defined in [OData‑URL].

    + +
    + +

    Expression edm:Cast

    + +
    + +
    + +

    The edm:Cast element MUST contain the Type attribute and MUST contain exactly one expression.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is a qualified type name in scope, or the character sequence Collection( followed by the qualified name of a type in +scope, followed by a closing parenthesis ).

    + +

    If the specified type is a primitive +type or a collection of a primitive type, the facet attributes MaxLength, +Unicode, Precision, +Scale, +and SRID +MAY be specified if applicable to the specified primitive type. If the facet +attributes are not specified, their values are considered unspecified.

    + +
    + +

    Example 78:

    + +
    + +

    <Annotation +Term="org.example.display.Threshold">
    +<Cast Type="Edm.Decimal">
    + <Path>Average</Path>
    +</Cast>
    +</Annotation>

    + +
    + +

    14.4.6 Collection

    + +

    The collection expression enables a value to be obtained +from zero or more item expressions. The value calculated by the collection +expression is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type compatible.

    + +
    + +

    Expression edm:Collection

    + +
    + +
    + +

    The edm:Collection +element contains zero or more child expressions.

    + +
    + +

    Example 79:

    + +
    + +

    <Annotation +Term="org.example.seo.SeoTerms">
    + <Collection>
    + <String>Product</String>
    + <String>Supplier</String>
    + <String>Customer</String>
    +</Collection>
    +</Annotation>

    + +
    + +

    14.4.7 +If-Then-Else

    + +

    The if-then-else expression enables a value to be obtained +by evaluating a condition expression. It MUST contain exactly three +child expressions. There is one exception to this rule: if and only if the if-then-else +expression is a direct child of a collection expression, the third child expression MAY be omitted, reducing it +to an if-then expression. This can be used to conditionally add an element to a +collection.

    + +

    The first child element is the condition and MUST evaluate +to a Boolean result, e.g. the comparison +and logical operators can be used.

    + +

    The second and third child elements are evaluated +conditionally. The result MUST be type compatible with the type expected by the +surrounding expression.

    + +

    If the first expression evaluates to true, +the second expression MUST be evaluated and its value MUST be returned as the +result of the if-then-else expression. If the first expression evaluates to false and a third child element is present, it MUST be +evaluated and its value MUST be returned as the result of the if-then-else +expression. If no third child element is present, nothing is added to the surrounding +collection.

    + +
    + +

    Expression edm:If

    + +
    + +
    + +

    The edm:If +element MUST contain two or three child expressions that MUST use element +notation.

    + +

    It MAY contain edm:Annotation +elements.

    + +
    + +

    Example 80: the condition is a value +path expression referencing the Boolean property IsFemale +,whose value then determines the value of the edm:If +expression

    + +
    + +

    <Annotation +Term="org.example.person.Gender">
    +<If>
    + <Path>IsFemale</Path>
    + <String>Female</String>
    + <String>Male</String>
    +</If>
    +</Annotation>

    + +
    + +

    14.4.8 +Is-Of

    + +

    The is-of expression checks whether the value obtained from +its single child expression is compatible with the specified type. It returns true if the child expression returns a type that is +compatible with the specified type, and false +otherwise.

    + +
    + +

    Expression edm:IsOf

    + +
    + +
    + +

    The edm:IsOf +element MUST contain the Type +attribute and MUST contain exactly one child expression.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is the qualified name of a type in scope, or the character sequence Collection( followed by the qualified name of a type in +scope, followed by a closing parenthesis ).

    + +

    If the specified type is a primitive +type or a collection of a primitive type, the facet attributes MaxLength, +Unicode, Precision, +Scale, +and SRID +MAY be specified if applicable to the specified primitive type. If the facet +attributes are not specified, their values are considered unspecified.

    + +
    + +

    Example 81:

    + +
    + +

    <Annotation Term="self.IsPreferredCustomer">
    + <IsOf Type="self.PreferredCustomer">
    + <Path>Customer</Path>
    +</IsOf>
    +</Annotation>

    + +
    + +

    14.4.9 Labeled +Element

    + +

    The labeled element expression assigns a name to its single +child expression. The value of the child expression can then be reused elsewhere +with a labeled element reference +expression.

    + +

    A labeled element expression MUST contain exactly one child +expression. The value of the child expression is also the value of the labeled +element expression.

    + +

    A labeled element expression MUST provide a simple identifier value as its name that MUST +be unique within the schema containing the expression.

    + +
    + +

    Expression edm:LabeledElement

    + +
    + +
    + +

    The edm:LabeledElement +element MUST contain the Name attribute.

    + +

    It MUST contain a child expression +written either in attribute notation or element notation.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Name

    + +
    + +
    + +

    The value of Name +is the labeled elements name.

    + +
    + +

    Example 82:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName">
    +<LabeledElement Name="CustomerFirstName" Path="FirstName" +/>
    +</Annotation>

    + +

     

    + +

    <Annotation +Term="org.example.display.DisplayName">
    + <LabeledElement Name="CustomerFirstName">
    + <Path>FirstName</Path>
    +</LabeledElement>
    +</Annotation>

    + +
    + +

    14.4.10 Labeled Element Reference

    + +

    The labeled element reference expression MUST specify the qualified name of a labeled +element expression in scope and returns the value of the identified labeled +element expression as +its value.

    + +
    + +

    Expression edm:LabeledElementReference

    + +
    + +
    + +

    The edm:LabeledElementReference +element MUST contain the qualified name of a labeled element expression in its +body.

    + +
    + +

    Example 83:

    + +
    + +

    <Annotation +Term="org.example.display.DisplayName">
    + <LabeledElementReference>Model.CustomerFirstName</LabeledElementReference>
    +</Annotation>

    + +
    + +

    14.4.11 Null

    + +

    The null expression indicates the absence of a value. The null +expression MAY be annotated.

    + +

    The null expression MUST be +written with element notation.

    + +
    + +

    Expression edm:Null

    + +
    + +
    + +

    The edm:Null element MAY contain edm:Annotation +elements.

    + +
    + +

    Example 84:

    + +
    + +

    <Annotation Term="org.example.display.DisplayName">
    +<Null/>
    +</Annotation>

    + +
    + +

    Example 85:

    + +
    + +

    <Annotation Term="@UI.Address">

    + +

    <Null>

    + +

    <Annotation Term="self.Reason" +String="Private" />

    + +

    </Null>

    + +

    </Annotation>

    + +
    + +

    14.4.12 Record

    + +

    The record expression enables a new entity type or complex +type instance to be constructed.

    + +

    A record expression MAY specify the structured type of its +result, which MUST resolve to an entity type or complex type in scope. If not +explicitly specified, the type is derived from the expressions context.

    + +

    A record expression contains zero or more property value +expressions. For each single-valued structural or navigation property of the +record expressions type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if the +record expression is the value of an annotation for a term that has a base term whose type is structured and directly +or indirectly inherits from the type of its base term. In this case, property +values that already have been specified in the annotation for the base term or +its base term etc. need not be specified again.

    + +

    For collection-valued properties the absence of a property +value expression is equivalent to specifying an empty collection as its value.

    + +
    + +

    Expression edm:Record

    + +
    + +
    + +

    The edm:Record +element MAY contain the Type attribute and MAY +contain edm:PropertyValue elements.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Type

    + +
    + +
    + +

    The value of Type +is the qualified name of a structured type in scope.

    + +
    + +
    + +

    Element +edm:PropertyValue

    + +
    + +
    + +

    The edm:PropertyValue +element MUST contain the Property attribute, and it +MUST contain exactly one expression that MAY be provided using either element +notation or attribute notation.

    + +

    It MAY contain +edm:Annotation +elements.

    + +
    + +
    + +

    Attribute Property

    + +
    + +
    + +

    The value of Property +is the name of a property of the type of the enclosing edm:Record expression.

    + +
    + +

    Example 86: this annotation morphs the entity type from +example 8 into a structured type with two structural properties GivenName and Surname and two +navigation properties DirectSupervisor and CostCenter. The first three properties simply rename properties +of the annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service

    + +
    + +

    <Annotation +Term="org.example.person.Employee">
    +<Record>
    + <Annotation Term="Core.Description" String="Annotation on +record" />

    + +

    <PropertyValue +Property="GivenName" Path="FirstName">

    + +

    <Annotation +Term="Core.Description"

    + +

    String="Annotation +on record member" />

    + +

    </PropertyValue>
    + <PropertyValue Property="Surname" Path="LastName" +/>

    + +

    <PropertyValue +Property="DirectSupervisor" Path="Manager" />

    + +

    <PropertyValue +Property="CostCenter">

    + +

    <UrlRef>

    + +

    <Apply +Function="odata.fillUriTemplate">

    + +

    <String>http://host/anotherservice/CostCenters('{ccid}')</String> +

    + +

    <LabeledElement +Name="ccid" Path="CostCenterID" />

    + +

    </Apply>

    + +

    </UrlRef>

    + +

    </PropertyValue>
    +</Record>
    +</Annotation>

    + +
    + +

    14.4.13 URL +Reference

    + +

    The URL reference expression enables a value to be obtained +by sending a GET request.

    + +

    The URL reference expression MUST contain exactly one +expression of type Edm.String. Its value is treated +as a URL that MAY be relative or absolute; relative URIs are relative to the +URL of the document containing the URL reference expression, or relative to a +base URL specified in a format-specific way.

    + +

    The response body of the GET +request MUST be returned as the result of the URL reference expression. +The result of the edm:UrlRef expression MUST be +type compatible with the type expected by the surrounding element or +expression.

    + +
    + +

    Expression edm:UrlRef

    + +
    + +
    + +

    The edm:UrlRef +expression MAY be provided using element notation or attribute notation.

    + +

    Relative URLs are relative to the xml:base attribute, see [XML‑Base].

    + +

    In element notation it MAY contain edm:Annotation +elements.

    + +
    + +

    Example 87:

    + +
    + +

    <Annotation Term="org.example.person.Supplier"> +
    +<UrlRef>
    +<Apply Function="odata.fillUriTemplate">
    + <String>http://host/service/Suppliers({suppID})</String>
    + <LabeledElement Name="suppID">
    + <Apply Function="odata.uriEncode">
    + <Path>SupplierId</Path>
    + </Apply>
    + </LabeledElement>
    + </Apply>
    +</UrlRef>
    +</Annotation>

    + +

     

    + +

    <Annotation +Term="Core.LongDescription">

    + +

    +<UrlRef><String>http://host/wiki/HowToUse</String></UrlRef>

    + +

    </Annotation>

    + +

     

    + +

    <Annotation +Term="Core.LongDescription" UrlRef="http://host/wiki/HowToUse" +/>

    + +
    + + + +

    15.1 Namespace

    + +

    A namespace is a dot-separated sequence of simple identifiers with a maximum length of +511 Unicode characters (code points).

    + +

    15.2 Simple +Identifier

    + +

    A simple identifier is a Unicode +character sequence with the following restrictions:

    + +
      +
    • It consists of at least one and at most 128 Unicode + characters (code points).
    • +
    • The first character MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L) or Letter + number (Nl).
    • +
    • The remaining characters MUST be the underscore character + (U+005F) or any character in the Unicode category Letter (L), Letter + number (Nl), Decimal number (Nd), Non-spacing mark (Mn), Combining + spacing mark (Mc), Connector punctuation (Pc), and Other, format + (Cf).
    • +
    + +

    Non-normatively speaking it starts with a letter or +underscore, followed by at most 127 letters, underscores or digits.

    + +

    15.3 Qualified +Name

    + +

    For model elements that are direct children of a schema: the +namespace or alias of the schema that defines the model element, followed by a +dot and the name of the model element, see rule qualifiedTypeName +in [OData‑ABNF].

    + +

    For built-in primitive types: +the name of the type, prefixed with Edm followed by +a dot.

    + +

    15.4 Target Path

    + +

    Target paths are +used in attributes of CSDL elements to refer to other CSDL elements or their +nested child elements.

    + +

    The allowed path +expressions are:

    + +

             +The qualified name of an entity container, followed by a +forward slash and the name of a container child element

    + +

             +The target path of a +container child followed by a forward slash and one or more forward-slash +separated property, navigation property, or type-cast segments

    + +

    Example 88: Target expressions

    + +
    + +

    MySchema.MyEntityContainer/MyEntitySet

    + +

    MySchema.MyEntityContainer/MySingleton

    + +

    MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty

    + +

    MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty

    + +

    MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp

    + +
    + + + +

    Following are two basic examples of valid EDM models as +represented in CSDL. These examples demonstrate many of the topics covered +above.

    + +

    16.1 Products +and Categories Example

    + +

    Example +89:

    + +
    + +

    <edmx:Edmx +xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"

    + +

    xmlns="http://docs.oasis-open.org/odata/ns/edm" +Version="4.0">
    + <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml">

    + +

    <edmx:Include +Namespace="Org.OData.Core.V1" Alias="Core">

    + +

    <Annotation +Term="Core.DefaultNamespace" />

    + +

    </edmx:Include>

    + +

    </edmx:Reference>

    + +

    <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.xml">

    + +

    <edmx:Include Alias="Measures" +Namespace="Org.OData.Measures.V1" />

    + +

    </edmx:Reference>

    + +

    <edmx:DataServices>
    + <Schema Namespace="ODataDemo">
    + <EntityType Name="Product" HasStream="true">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.Int32" +Nullable="false" />
    + <Property Name="Description" Type="Edm.String" >
    + <Annotation Term="Core.IsLanguageDependent" />

    + +

    </Property>

    + +

    <Property +Name="ReleaseDate" Type="Edm.Date" />
    + <Property Name="DiscontinuedDate" +Type="Edm.Date" />
    + <Property Name="Rating" Type="Edm.Int32" />
    + <Property Name="Price" Type="Edm.Decimal" +Scale="variable">
    + <Annotation Term="Measures.ISOCurrency" Path="Currency" +/>

    + +

    </Property>

    + +

    <Property +Name="Currency" Type="Edm.String" MaxLength="3" />

    + +

    <NavigationProperty +Name="Category" Type="ODataDemo.Category"

    + +

    Nullable="false" +Partner="Products" />

    + +

    <NavigationProperty +Name="Supplier" Type="ODataDemo.Supplier"

    + +

    +Partner="Products" />
    + </EntityType>
    + <EntityType Name="Category">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.Int32" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" +Nullable="false">
    + <Annotation Term="Core.IsLanguageDependent" />

    + +

    </Property>

    + +

    <NavigationProperty +Name="Products" Partner="Category"

    + +

    Type="Collection(ODataDemo.Product)">
    + <OnDelete Action="Cascade" />

    + +

    </NavigationProperty>
    + </EntityType>
    + <EntityType Name="Supplier">
    + <Key>
    + <PropertyRef Name="ID" />
    + </Key>
    + <Property Name="ID" Type="Edm.String" +Nullable="false" />
    + <Property Name="Name" Type="Edm.String" />
    + <Property Name="Address" +Type="ODataDemo.Address" Nullable="false" />
    + <Property Name="Concurrency" Type="Edm.Int32" +Nullable="false" />
    + <NavigationProperty Name="Products" +Partner="Supplier"

    + +

    Type="Collection(ODataDemo.Product)" +/>

    + +

    </EntityType>
    + <EntityType Name="Country">

    + +

    <Key>

    + +

    <PropertyRef Name="Code" +/>

    + +

    </Key>

    + +

    <Property Name="Code" +Type="Edm.String" MaxLength="2"

    + +

    +Nullable="false" />

    + +

    <Property +Name="Name" Type="Edm.String" />

    + +

    </EntityType>

    + +

    <ComplexType +Name="Address">
    + <Property Name="Street" Type="Edm.String" />
    + <Property Name="City" Type="Edm.String" />
    + <Property Name="State" Type="Edm.String" />
    + <Property Name="ZipCode" Type="Edm.String" />
    + <Property Name="CountryName" Type="Edm.String" />
    + <NavigationProperty Name="Country" +Type="ODataDemo.Country">

    + +

    <ReferentialConstraint +Property="CountryName"

    + +

    +ReferencedProperty="Name" />

    + +

    </NavigationProperty>

    + +

    </ComplexType>
    + <Function Name="ProductsByRating">
    + <Parameter Name="Rating" Type="Edm.Int32" />

    + +

    <ReturnType Type="Collection(ODataDemo.Product)" +/>
    + </Function>
    + <EntityContainer Name="DemoService">
    + <EntitySet Name="Products" +EntityType="ODataDemo.Product">
    + <NavigationPropertyBinding Path="Category" +Target="Categories" />

    + +

    </EntitySet>
    + <EntitySet Name="Categories" +EntityType="ODataDemo.Category">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    <Annotation +Term="Core.Description" String="Product Categories" />

    + +

    </EntitySet>
    + <EntitySet Name="Suppliers" +EntityType="ODataDemo.Supplier">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    +<NavigationPropertyBinding Path="Address/Country"

    + +

    Target="Countries" +/>

    + +

    <Annotation Term="Core.OptimisticConcurrency">

    + +

    <Collection>

    + +

    +<PropertyPath>Concurrency</PropertyPath>

    + +

    </Collection>

    + +

    </Annotation>

    + +

    </EntitySet>
    + <Singleton Name="MainSupplier" +Type="self.Supplier">
    + <NavigationPropertyBinding Path="Products" +Target="Products" />

    + +

    <Annotation +Term="Core.Description" String="Primary Supplier" />

    + +

    </Singleton>

    + +

    <EntitySet +Name="Countries" EntityType="ODataDemo.Country" />

    + +

    <FunctionImport +Name="ProductsByRating" EntitySet="Products"

    + +

    Function="ODataDemo.ProductsByRating" +/>
    + </EntityContainer>
    + </Schema>
    + </edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +

    16.2 Annotations for Products and +Categories Example

    + +

    Example 90:

    + +
    + +

    <edmx:Edmx +xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
    + Version="4.01">
    + <edmx:Reference Uri="http://host/service/$metadata">
    + <edmx:Include Namespace="ODataDemo" Alias="target" +/>

    + +

    </edmx:Reference>

    + +

    <edmx:Reference Uri="http://somewhere/Vocabulary/V1">

    + +

    <edmx:Include Alias="Vocabulary1" +Namespace="Some.Vocabulary.V1" />

    + +

    </edmx:Reference>

    + +

    <edmx:DataServices>
    + <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"
    + Namespace="External.Annotations">
    + <Annotations Target="ODataDemo.Supplier">
    + <Annotation Term="Vocabulary1.EMail">
    + <Null />
    + </Annotation>
    + <Annotation Term="Vocabulary1.AccountID" Path="ID" +/>
    + <Annotation Term="Vocabulary1.Title" String="Supplier +Info" />
    + <Annotation Term="Vocabulary1.DisplayName">
    + <Apply Function="odata.concat">
    + <Path>Name</Path>
    + <String> in </String>
    + <Path>Address/CountryName</Path>
    + </Apply>
    + </Annotation>
    + </Annotations>
    + <Annotations Target="ODataDemo.Product">

    + +

    <Annotation Term="Vocabulary1.Tags">

    + +

    <Collection>

    + +

    <String>MasterData</String>

    + +

    </Collection>

    + +

    </Annotation>

    + +

    </Annotations>

    + +

    </Schema>

    + +

    </edmx:DataServices>
    +</edmx:Edmx>

    + +
    + +
    + +

    17    Conformance

    + +
    + +

    Conforming services MUST follow all rules of this +specification document for the types, sets, functions, actions, containers and +annotations they expose.

    + +

    In addition, conforming services MUST NOT return 4.01 CSDL +constructs for requests made with OData-MaxVersion:4.0.

    + +

    Specifically, they

    + +

    1.     +MUST NOT include properties in derived types that overwrite a property +defined in the base type

    + +

    2.     +MUST NOT include Edm.Untyped

    + +

    3.     +MUST NOT use path syntax added with 4.01

    + +

    4.     +MUST NOT use Edm.ModelElementPath and Edm.AnyPropertyPath

    + +

    5.     +MUST NOT specify referential +constraints to complex types and navigation properties

    + +

    6.     +MUST NOT include a non-abstract entity type with no inherited or defined +entity key

    + +

    7.     +MUST NOT include the Core.DefaultNamespace annotation +on included schemas

    + +

    8.     +MUST NOT return the Unicode facet for terms, parameters, and return +types

    + +

    9.     +MUST NOT include collections of Edm.ComplexType or +Edm.Untyped

    + +

    10.  +MUST NOT specify a key as a property of a related entity

    + +

    11.  +SHOULD NOT include new/unknown values for the AppliesTo +attribute

    + +

    12.  +SHOULD specify the Nullable facet for +collections

    + +

    13.  +MAY include new CSDL annotations

    + +

    In addition, OData 4.01 services:

    + +

    14.  +MUST specify the Nullable facet for +collections

    + +

    15.  +SHOULD NOT have identifiers within a uniqueness scope (e.g. a schema, a +structural type or an entity container) that differ only by case

    + +

    Conforming clients MUST be prepared to consume a model that +uses any or all constructs defined in this specification, including custom +annotations, and MUST ignore any elements or attributes not defined in this +version of the specification.

    + + + +

    The contributions of the OASIS OData Technical Committee +members, enumerated in [OData‑Protocol], +are gratefully acknowledged.

    + + + +
    + +
    +
    + +
    + +

    Element edmx:Edmx. 15

    + +

    Attribute Version. 15

    + +

    Element edmx:DataServices. 15

    + +

    Element edmx:Reference. 15

    + +

    Attribute Uri. 16

    + +

    Element edmx:Include. 16

    + +

    Attribute Namespace. 16

    + +

    Attribute Alias. 17

    + +

    Element edmx:IncludeAnnotations. 17

    + +

    Attribute TermNamespace. 18

    + +

    Attribute Qualifier. 18

    + +

    Attribute TargetNamespace. 18

    + +

    Element edm:Schema. 19

    + +

    Attribute Namespace. 19

    + +

    Attribute Alias. 19

    + +

    Element edm:Annotations. 20

    + +

    Attribute Target. 20

    + +

    Attribute Qualifier. 20

    + +

    Element edm:EntityType. 21

    + +

    Attribute Name. 21

    + +

    Attribute BaseType. 21

    + +

    Attribute Abstract. 22

    + +

    Attribute OpenType. 22

    + +

    Attribute HasStream. 22

    + +

    Element edm:Key. 23

    + +

    Element edm:PropertyRef. 23

    + +

    Attribute Name. 23

    + +

    Attribute Alias. 24

    + +

    Element edm:Property. 25

    + +

    Attribute Name. 25

    + +

    Attribute Type. 25

    + +

    Attribute Nullable. 26

    + +

    Attribute MaxLength. 26

    + +

    Attribute Precision. 27

    + +

    Attribute Scale. 27

    + +

    Attribute Unicode. 28

    + +

    Attribute SRID. 28

    + +

    Attribute DefaultValue. 28

    + +

    Element edm:NavigationProperty. 29

    + +

    Attribute Name. 29

    + +

    Attribute Type. 30

    + +

    Attribute Nullable. 30

    + +

    Attribute Partner. 30

    + +

    Attribute ContainsTarget. 31

    + +

    Element edm:ReferentialConstraint. 31

    + +

    Attribute Property. 32

    + +

    Attribute ReferencedProperty. 32

    + +

    Element edm:OnDelete. 33

    + +

    Attribute Action. 33

    + +

    Element edm:ComplexType. 34

    + +

    Attribute Name. 34

    + +

    Attribute BaseType. 34

    + +

    Attribute Abstract. 35

    + +

    Attribute OpenType. 35

    + +

    Element edm:EnumType. 36

    + +

    Attribute Name. 36

    + +

    Attribute UnderlyingType. 36

    + +

    Attribute IsFlags. 36

    + +

    Element edm:Member. 37

    + +

    Attribute Name. 37

    + +

    Attribute Value. 37

    + +

    Element edm:TypeDefinition. 39

    + +

    Attribute Name. 39

    + +

    Attribute UnderlyingType. 39

    + +

    Element edm:Action. 40

    + +

    Attribute Name. 40

    + +

    Element edm:Function. 41

    + +

    Attribute Name. 41

    + +

    Attribute IsBound. 41

    + +

    Attribute EntitySetPath. 41

    + +

    Attribute IsComposable. 42

    + +

    Element edm:ReturnType. 42

    + +

    Attribute Type. 42

    + +

    Attribute Nullable. 42

    + +

    Element edm:Parameter. 43

    + +

    Attribute Name. 43

    + +

    Attribute Type. 43

    + +

    Attribute Nullable. 43

    + +

    Element edm:EntityContainer. 44

    + +

    Attribute Name. 44

    + +

    Attribute Extends. 45

    + +

    Element edm:EntitySet. 45

    + +

    Attribute Name. 45

    + +

    Attribute EntityType. 45

    + +

    Attribute IncludeInServiceDocument. 46

    + +

    Element edm:Singleton. 46

    + +

    Attribute Name. 46

    + +

    Attribute Type. 46

    + +

    Attribute Nullable. 46

    + +

    Element edm:NavigationPropertyBinding. 47

    + +

    Attribute Path. 47

    + +

    Attribute Target. 47

    + +

    Element edm:ActionImport. 48

    + +

    Attribute Name. 48

    + +

    Attribute Action. 48

    + +

    Attribute EntitySet. 48

    + +

    Element edm:FunctionImport. 48

    + +

    Attribute Name. 48

    + +

    Attribute Function. 48

    + +

    Attribute EntitySet. 48

    + +

    Attribute IncludeInServiceDocument. 49

    + +

    Element edm:Term. 51

    + +

    Attribute Name. 51

    + +

    Attribute Type. 51

    + +

    Attribute DefaultValue. 51

    + +

    Attribute BaseTerm. 51

    + +

    Attribute AppliesTo. 53

    + +

    Element edm:Annotation. 53

    + +

    Attribute Term. 53

    + +

    Attribute Qualifier. 54

    + +

    Expression edm:Binary. 56

    + +

    Expression edm:Bool. 56

    + +

    Expression edm:Date. 57

    + +

    Expression edm:DateTimeOffset. 57

    + +

    Expression edm:Decimal. 57

    + +

    Expression edm:Duration. 58

    + +

    Expression edm:EnumMember. 58

    + +

    Expression edm:Float. 58

    + +

    Expression edm:Guid. 59

    + +

    Expression edm:Int. 59

    + +

    Expression edm:String. 59

    + +

    Expression edm:TimeOfDay. 60

    + +

    Expression edm:AnnotationPath. 63

    + +

    Expression edm:ModelElementPath. 63

    + +

    Expression edm:NavigationPropertyPath. 63

    + +

    Expression edm:PropertyPath. 64

    + +

    Expression edm:Path. 64

    + +

    Expressions edm:And and edm:Or. 65

    + +

    Expression edm:Not. 65

    + +

    Expressions edm:Eq, edm:Ne, +edm:Gt, edm:Ge, edm:Lt, +edm:Le, edm:Has, and edm:In 65

    + +

    Expression edm:Neg. 67

    + +

    Expressions edm:Add, edm:Sub, +edm:Mul, edm:Div, edm:DivBy, +and edm:Mod 67

    + +

    Expression edm:Apply. 68

    + +

    Attribute Function. 68

    + +

    Expression edm:Cast. 69

    + +

    Attribute Type. 69

    + +

    Expression edm:Collection. 70

    + +

    Expression edm:If. 70

    + +

    Expression edm:IsOf. 71

    + +

    Attribute Type. 71

    + +

    Expression edm:LabeledElement. 71

    + +

    Attribute Name. 71

    + +

    Expression edm:LabeledElementReference. 72

    + +

    Expression edm:Null. 72

    + +

    Expression edm:Record. 73

    + +

    Attribute Type. 73

    + +

    Element edm:PropertyValue. 73

    + +

    Attribute Property. 73

    + +

    Expression edm:UrlRef. 74

    + +

     

    + +
    + +
    +
    + +
    + +
    + +

    Appendix C. Revision +History

    + +
    + +

     

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Revision

    +
    +

    Date

    +
    +

    Editor

    +
    +

    Changes Made

    +
    +

    Working Draft 01

    +
    +

    2016-09-07

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Imported content from 4.0 Errata 3 specification and + integrated initial 4.01 features

    +
    +

    Committee Specification Draft 01

    +
    +

    2016-12-08

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Integrated 4.01 features

    +
    +

    Committee Specification Draft 02

    +
    +

    2017-06-08

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated normative text from former OData Part 3: CSDL

    +
    +

    Committee Specification Draft 03

    +
    +

    2017-09-22

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +
    +

    Committee Specification Draft 04

    +
    +

    2017-11-10

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Incorporated review feedback

    +

    Stable order of action and function parameters

    +
    +

    Committee Specification 01

    +
    +

    2017-12-19

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-Material Changes

    +
    +

    Committee Specification Draft 05

    +
    +

    2019-06-21

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    External targeting for annotations on action/function + overloads, parameters, and return types

    +

    Key and index segments for path expressions in annotations

    +

    Nullable singletons

    +
    +

    Committee Specification Draft 06

    +
    +

    2019-09-20

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Redefining entity sets and singletons when extending + entity containers

    +
    +

    Committee Specification 02

    +
    +

    2019-11-05

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    +

    Candidate OASIS Standard 01

    +
    +

    2020-01-15

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    +

    Candidate OASIS Standard 02

    +
    +

    2020-04-09

    +
    +

    Michael Pizzo

    +

    Ralf Handl

    +
    +

    Non-material changes

    +
    + +

     

    + +
    + + + + diff --git a/odata-csdl/temp/odata-csdl-xml-v4.01-os.md b/odata-csdl/temp/odata-csdl-xml-v4.01-os.md new file mode 100644 index 000000000..dc2ba3c25 --- /dev/null +++ b/odata-csdl/temp/odata-csdl-xml-v4.01-os.md @@ -0,0 +1,6428 @@ +# ##sec Introduction + +OData services are described in terms of an [Entity +Model](#EntityModel). The Common Schema Definition Language (CSDL) +defines a representation of the entity data model exposed by an OData +service using the Extensible Markup Language (XML) 1.1 (Second Edition) +[**\[XML‑1.1\]**](#BMXML) with further building blocks from the W3C XML +Schema Definition Language (XSD) 1.1 as described in +[**\[XML‑Schema‑1\]**](#BMXMLSchema1) and +[**\[XML‑Schema‑2\]**](#BMXMLSchema2). + +## ##subsec IPR Policy + +This specification is provided under the [RF on RAND +Terms](https://www.oasis-open.org/policies-guidelines/ipr#RF-on-RAND-Mode) +Mode of the [OASIS IPR +Policy](https://www.oasis-open.org/policies-guidelines/ipr), the mode +chosen when the Technical Committee was established. For information on +whether any patents have been disclosed that may be essential to +implementing this specification, and any offers of patent licensing +terms, please refer to the Intellectual Property Rights section of the +TC's web page (). + +## ##subsec Terminology + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", +"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this +document are to be interpreted as described in [RFC2119](#BMRFC2119). + +## ##subsec Normative References + +[\[ECMAScript\]]{.Refterm}[[         +]{style="font-weight:normal"}]{.Refterm}*ECMAScript 2016 Language +Specification, 7^th^ Edition,* June 2016. Standard ECMA-262. +. + +[\[EPSG\]                   ]{.Refterm}European Petroleum Survey Group +(EPSG). . + +[\[OData-ABNF\]]{.Refterm}         *OData ABNF Construction Rules +Version 4.01*.\ +See link in "Additional artifacts" section on cover +page[.]{style="color: +#222222"}[ ]{.Refterm} + +**[\[OData-EDM]{lang="DE" style="color:windowtext"}**[**[\]]{lang="DE" +style="color:windowtext"}**]{.Hyperlink1}[           *OData EDM XML +Schema*]{lang="DE" style="color:windowtext"}[.\ +]{lang="DE"}See link in "Additional artifacts" section on cover page. + +**[\[OData-EDMX]{lang="NL" style="color:windowtext"}**[**[\]]{lang="NL" +style="color:windowtext"}**]{.Hyperlink1}[        *OData EDMX XML +Schema*]{lang="NL" style="color:windowtext"}[.\ +]{lang="NL"}See link in "Additional artifacts" section on cover page. + +OData-CSDLJSON            *OData Common Schema Definition Language +(CSDL) JSON Representation Version 4.01*. See link in "Related work" +section on cover page. + +**\[OData-JSON**[**\]**]{.Hyperlink1}         *OData JSON Format Version +4.01.*\ +See link in "Related work" section on cover page. + +[\[OData-Protocol\]]{.Refterm}     *OData Version 4.01 Part 1: +Protocol*.\ +See link in "Additional artifacts" section on cover +page[.]{style="color: +#222222"} + +OData-URL           *OData Version 4.01 Part 2: URL Conventions*.\ +See link in "Additional artifacts" section on cover page. + +OData-VocCore     *OData Vocabularies Version 4.0: Core Vocabulary.*\ +See link in "Related work" section on cover page.[[ +]{style="font-size:8.0pt;color:windowtext; +background:yellow"}]{.MsoCommentReference} + +OData-VocMeasures         *OData Vocabularies Version 4.0: Measures +Vocabulary.*\ +See link in "Related work" section on cover page.[[ +]{style="font-size:8.0pt;color:windowtext; +background:yellow"}]{.MsoCommentReference} + +OData-VocValidation        *OData Vocabularies Version 4.0: Validation +Vocabulary.*\ +See link in "Related work" section on cover page.[[ +]{style="font-size:8.0pt;color:windowtext; +background:yellow"}]{.MsoCommentReference} + +[\[RFC2119\]]{.Refterm}               Bradner, S., "Key words for use in +RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. +. + +RFC6570               Gregorio, J., Fielding, R., Hadley, M., +Nottingham, M., and D. Orchard, "URI Template", RFC 6570, March 2012. +. + +[\[XML-1.1\]]{.Refterm}                Extensible Markup Language (XML) +1.1 (Second Edition), F. Yergeau, E. Maler, J. Cowan, T. Bray, C. M. +Sperberg-McQueen, J. Paoli, Editors, W3C Recommendation, 16 August +2006,\ +.\ +Latest version available at . + +**\[XML-Base\]**             XML Base (Second Edition), J. Marsh, R. +Tobin, Editors, W3C Recommendation, 28 January 2009,\ +.\ +Latest version available at .  + +[\[XML-Schema-1\]]{.Refterm}     W3C XML Schema Definition Language +(XSD) 1.1 Part 1: Structures, D. Beech, M. Maloney, C. M. +Sperberg-McQueen, H. S. Thompson, S. Gao, N. Mendelsohn, Editors, W3C +Recommendation, 5 April 2012, +.\ +Latest version available at . + +[\[XML-Schema-2\]]{.Refterm}     W3C XML Schema Definition Language +(XSD) 1.1 Part 2: DatatypesW3C XML Schema Definition Language (XSD) 1.1 +Part 2: Datatypes, D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. +Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April +2012, .\ +Latest version available at . + +## ##subsec Typographical Conventions + +Keywords defined by this specification use this `monospaced` font. + +`Normative source code uses this paragraph style.` + +Some sections of this specification are illustrated with non-normative +examples. + +::: {.varxml .example} +Example ##ex: text describing an example uses this paragraph style +``` +Non-normative examples use this paragraph style. +``` +::: + +All examples in this document are non-normative and informative only. + +Representation-specific text is indented and marked with vertical lines. + +::: {.varxml .rep} +Representation-Specific Headline +::: + +::: csdl +Normative representation-specific text +::: + +All other text is normative unless otherwise labeled. + +# ##sec XML Representation + +OData CSDL XML is a full representation of the OData Common Schema +Definition Language in the Extensible Markup Language (XML) 1.1 (Second +Edition) [**\[XML‑1.1\]**](#BMXML) with further building blocks from the +W3C XML Schema Definition Language (XSD) 1.1 as described in +[**\[XML‑Schema‑1\]**](#BMXMLSchema1) and +[**\[XML‑Schema‑2\]**](#BMXMLSchema2). + +It is an alternative to the CSDL JSON representation defined in +**\[**[**OData-CSDLJSON**](#BMCSDLJSON)**\]** and neither adds nor +removes features. + +## ##subsec Requesting the XML Representation + +The OData CSDL XML representation can be requested using the `$format` +query option in the request URL with the media type `application/xml`, +optionally followed by media type parameters, or the case-insensitive +abbreviation `xml` which MUST NOT be followed by media type parameters. + +Alternatively, this representation can be requested using the `Accept` +header with the media type `application/xml`, optionally followed by +media type parameters. + +If specified, `$format` overrides any value specified in the `Accept` +header. + +The response MUST contain the `Content-Type` header with a value of +`application/xml`, optionally followed by media type parameters. + +This specification does not define additional parameters for the media +type `application/xml`. + +## ##subsec XML Namespaces + +In addition to the default XML namespace, the elements and attributes +used to describe the entity model of an OData service are defined in one +of the following namespaces. + +### ##subsubsec Namespace EDMX + +Elements and attributes associated with the top-level wrapper that +contains the CSDL used to define the entity model for an OData Service +are qualified with the Entity Data Model for Data Services Packaging +namespace: +- `http://docs.oasis-open.org/odata/ns/edmx` + +Prior versions of OData used the following namespace for EDMX: +- EDMX version 1.0: +`http://schemas.microsoft.com/ado/2007/06/edmx` + +They are non-normative for this specification. + +In this specification the namespace prefix `edmx` is used to represent +the Entity Data Model for Data Services Packaging namespace, however the +prefix name is not prescriptive. + +### ##subsubsec Namespace EDM + +Elements and attributes that define the entity model exposed by the +OData Service are qualified with the Entity Data Model namespace: +- `http://docs.oasis-open.org/odata/ns/edm` + +Prior versions of CSDL used the following namespaces for EDM: + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 1.0: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2006/04/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 1.1: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2007/05/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 1.2: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2008/01/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 2.0: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2008/09/edm]{lang="DE"}]{.Datatype} + +[· ]{lang="DE" style="font-family:Symbol"}[CSDL version 3.0: +]{lang="DE"}[[http://schemas.microsoft.com/ado/2009/11/edm]{lang="DE"}]{.Datatype} + +They are non-normative for this specification. + +In this specification the namespace prefix `edm` is used to represent +the Entity Data Model namespace, however the prefix name is not +prescriptive. + +## ##subsec XML Schema Definitions + +This specification contains normative XML schemas for the EDMX and EDM +namespaces; see [OData‑EDMX](#BMEDMX) and +[OData‑EDM](#BMEDM)[.]{style="color:#222222"} + +These XML schemas only define the shape of a well-formed CSDL XML +document and are not descriptive enough to define what a correct CSDL +XML document MUST be in every imaginable use case. This specification +document defines additional rules that correct CSDL XML documents MUST +fulfill. In case of doubt on what makes a CSDL XML document correct the +rules defined in this specification document take precedence. + +## ##subsec XML Document Order + +Client libraries MUST retain the document order of XML elements for CSDL +XML documents because for some elements the order of child elements is +significant. This includes, but is not limited to, [members of +enumeration types](#EnumerationTypeMember) and items within a +[collection expression](#Collection). + +OData does not impose any ordering constraints on XML attributes within +XML elements. + +# ##sec Entity Model + +An OData service exposes a single entity model. This model may be +distributed over several [schemas](#Schema), and these schemas may be +distributed over several physical locations. + +A service is defined by a single CSDL document which can be accessed by +sending a `GET` request to `/$metadata`. This document is +called the metadata document. It may reference other CSDL documents. + +The metadata document contains a single [entity +container](#EntityContainer) that defines the resources exposed by this +service. This entity container MAY [extend](#ExtendinganEntityContainer) +an entity container defined in a [referenced document](#Reference). + +The *model* of the service consists of all CSDL constructs used in its +entity containers. + +The *scope* of a CSDL document is the document itself and all schemas +[included](#IncludedSchema) from directly [referenced +documents](#Reference). All entity types, complex types and other named +elements *in scope* (that is, defined in the document itself or a schema +of a directly referenced document) can be accessed from a referencing +document by their qualified names. This includes the [built-in +primitive](#PrimitiveTypes) and [abstract types](#BuiltInAbstractTypes). + +Referencing another document may alter the model defined by the +referencing document. For instance, if a referenced document defines an +entity type derived from an entity type in the referencing document, +then an [entity set](#EntitySet) of the service defined by the +referencing document may return entities of the derived type. This is +identical to the behavior if the derived type had been defined directly +in the referencing document. + +Note: referencing documents is not recursive. Only named elements +defined in directly referenced documents can be used within the schema. +However, those elements may in turn include elements defined in schemas +referenced by their defining schema. + +## ##subsec Nominal Types + +A nominal type has a name that MUST be a [simple +identifier](#SimpleIdentifier). Nominal types are referenced using their +[qualified name](#QualifiedName). The qualified type name MUST be unique +within a model as it facilitates references to the element from other +parts of the model. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +## ##subsec Structured Types + +Structured types are composed of other model elements. Structured types +are common in entity models as the means of representing entities and +structured properties in an OData service. [Entity types](#EntityType) +and [complex types](#ComplexType) are both structured types. + +Structured Types are composed of zero or more [structural +properties](#StructuralProperty) and [navigation +properties](#NavigationProperty). + +[Open entity types](#OpenEntityType) and [open complex +types](#OpenComplexType) allow properties to be added dynamically to +instances of the open type. + +## ##subsec Primitive Types + +Structured types are composed of other structured types and primitive +types. OData defines the following primitive types: + + **Type** **Meaning** + -------------------------------- ---------------------------------------------------------------- + `Edm.Binary` Binary data + `Edm.Boolean` Binary-valued logic + `Edm.Byte` Unsigned 8-bit integer + `Edm.Date` Date without a time-zone offset + `Edm.DateTimeOffset` Date and time with a time-zone offset, no leap seconds + `Edm.Decimal` Numeric values with decimal representation + `Edm.Double` IEEE 754 binary64 floating-point number (15-17 decimal digits) + `Edm.Duration` Signed duration in days, hours, minutes, and (sub)seconds + `Edm.Guid` 16-byte (128-bit) unique identifier + `Edm.Int16 ` Signed 16-bit integer + `Edm.Int32` Signed 32-bit integer + `Edm.Int64` Signed 64-bit integer + `Edm.SByte` Signed 8-bit integer + `Edm.Single` IEEE 754 binary32 floating-point number (6-9 decimal digits) + `Edm.Stream` Binary data stream + `Edm.String` Sequence of characters + `Edm.TimeOfDay` Clock time 00:00-23:59:59.999999999999 + `Edm.Geography` Abstract base type for all Geography types + `Edm.GeographyPoint` A point in a round-earth coordinate system + `Edm.GeographyLineString` Line string in a round-earth coordinate system + `Edm.GeographyPolygon` Polygon in a round-earth coordinate system + `Edm.GeographyMultiPoint` Collection of points in a round-earth coordinate system + `Edm.GeographyMultiLineString` Collection of line strings in a round-earth coordinate system + `Edm.GeographyMultiPolygon` Collection of polygons in a round-earth coordinate system + `Edm.GeographyCollection` Collection of arbitrary Geography values + `Edm.Geometry` Abstract base type for all Geometry types + `Edm.GeometryPoint` Point in a flat-earth coordinate system + `Edm.GeometryLineString` Line string in a flat-earth coordinate system + `Edm.GeometryPolygon` Polygon in a flat-earth coordinate system + `Edm.GeometryMultiPoint` Collection of points in a flat-earth coordinate system + `Edm.GeometryMultiLineString` Collection of line strings in a flat-earth coordinate system + `Edm.GeometryMultiPolygon` Collection of polygons in a flat-earth coordinate system + `Edm.GeometryCollection` Collection of arbitrary Geometry values + +`Edm.Date` and `Edm.DateTimeOffset` follow +[**\[XML‑Schema‑2\]**](#BMXMLSchema2) and use the proleptic Gregorian +calendar, allowing the year `0000` (equivalent to 1 BCE) and negative +years (year `-0001` being equivalent to 2 BCE etc.). The supported date +range is service-specific and typically depends on the underlying +persistency layer, e.g. SQL only supports years `0001` to `9999`. + +`Edm.Decimal with a `[`Scale`](#Scale)` value of floating`, +`Edm.Double`, and `Edm.Single` allow the special numeric values `-INF`, +`INF`, and `NaN`. + +`Edm.Stream` is a primitive type that can be used as a property of an +[entity type](#EntityType) or [complex type](#ComplexType), the +underlying type for a [type definition](#TypeDefinition), or the binding +parameter or return type of an [action](#Action) or +[function](#Function). `Edm.Stream`, or a type definition whose +underlying type is `Edm.Stream`, cannot be used in collections or for +non-binding parameters to functions or actions. + +Some of these types allow [facets](#TypeFacets), defined in section +"[Type Facets](#TypeFacets)". + +See rule `primitiveLiteral` in [OData‑ABNF](#ODataABNF) for the +representation of primitive type values in URLs and +[OData‑JSON](#ODataJSON) for the representation in requests and +responses. + +## ##subsec Built-In Abstract Types + +The following built-in abstract types can be used within a model: +- `Edm.PrimitiveType ` +- `Edm.ComplexType` +- `Edm.EntityType` +- `Edm.Untyped` + +Conceptually, these are the abstract base types for primitive types +(including type definitions and enumeration types), complex types, +entity types, or any type or collection of types, respectively, and can +be used anywhere a corresponding concrete type can be used, except: +- `Edm.EntityType` + +- - cannot be used as the type of a singleton in an entity container + because it doesn't define a structure, which defeats the purpose + of a singleton. + - cannot be used as the type of an entity set because all entities + in an entity set must have the same key fields to uniquely + identify them within the set. + - cannot be the base type of an entity type or complex type.  +- `Edm.ComplexType` + +- - cannot be the base type of an entity type or complex type.  +- `Edm.PrimitiveType` + +- - cannot be used as the type of a key property of an entity type + or as the underlying type of an enumeration type. + - cannot be used as the underlying type of a type definition in a + CSDL document with a version of `4.0`. + - can be used as the underlying type of a type definition in a + CSDL document with a version of `4.01` or greater. +- `Edm.Untyped` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + - cannot be used as the type of a key property of an entity type. + - cannot be the base type of an entity type or complex type.  + - cannot be used as the underlying type of a type definition or + enumeration type. +- `Collection(Edm.PrimitiveType)` + +- - cannot be used as the type of a property or term. + - cannot be used as the type of a parameter or the return type of + an action or function. +- `Collection(Edm.Untyped)` + +- - cannot be returned in a payload with an `OData-Version` header + of `4.0`. Services should treat untyped properties as dynamic + properties in `4.0` payloads. + +## ##subsec Built-In Types for defining Vocabulary Terms + +[Vocabulary terms](#Term) can, in addition, use +- `Edm.AnnotationPath` +- `Edm.PropertyPath` +- `Edm.NavigationPropertyPath ` +- `Edm.AnyPropertyPath `(`Edm.PropertyPath `or +`Edm.NavigationPropertyPath`) +- `Edm.ModelElementPath `(any +model element, including +`Edm.AnnotationPath`,` Edm.NavigationPropertyPath`, and +`Edm.PropertyPath`) + +as the type of a primitive term, or the type of a property of a complex +type (recursively) that is exclusively used as the type of a term. See +section "[Path Expressions](#PathExpressions)" for details. + +## ##subsec Annotations + +Many parts of the model can be decorated with additional information +using [annotations](#Annotation). Annotations are identified by their +term name and an optional qualifier that allows applying the same term +multiple times to the same model element. + +A model element MUST NOT specify more than one annotation for a given +combination of term and qualifier. + +# ##sec CSDL XML Document + +::: {.varxml .rep} +Element `edmx:Edmx` +::: + +::: csdl +The `edmx:Edmx` element is the root element of a CSDL XML document. It +MUST contain the `Version` attribute and it MUST contain exactly one +`edmx:DataServices` element. + +It MAY contain [`edmx:Reference`](#Reference) elements to reference +other CSDL documents. +::: + +::: {.varxml .rep} +Attribute `Version` +::: + +::: csdl +The `Version` attribute specifies the OData protocol version of the +service. For OData 4.0 responses the value of this attribute MUST be +`4.0.` For OData 4.01 responses the value of this attribute MUST be +`4.01.` Services MUST return an OData 4.0 response if the request was +made with an `OData-MaxVersion `header with a value of `4.0`. +::: + +::: {.varxml .rep} +Element `edmx:DataServices` +::: + +::: csdl +The `edmx:DataServices` element MUST contain one or more +[`edm:Schema`](#Schema) elements which define the schemas exposed by the +OData service. +::: + +::: {.varxml .example} +Example ##ex: +``` +\ +  \\ +    ...\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Reference + +A reference to an external CSDL document allows to bring part of the +referenced document's content into the scope of the referencing +document. + +A reference MUST specify a URI that uniquely identifies the referenced +document, so two references MUST NOT specify the same URI. The URI +SHOULD be a URL that locates the referenced document. If the URI is not +dereferencable it SHOULD identify a well-known schema. The URI MAY be +absolute or relative URI; relative URLs are relative to the URL of the +document containing the reference, or relative to a base URL specified +in a format-specific way. + +A reference MAY be annotated. + +The +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation, defined in [OData-VocCore](#ODataVocCore), MAY be used to +indicate a particular version of the referenced schema. If the +[`Core.SchemaVersion`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#SchemaVersion) +annotation is present, the `$schemaversion` system query option, defined +[OData‑Protocol](#ODataProtocol), SHOULD be used when retrieving the +referenced schema document. + +::: {.varxml .rep} +Element `edmx:Reference` +::: + +::: csdl +The `edmx:Reference` element specifies external CSDL documents +referenced by the referencing document. The child elements +[`edmx:Include`](#IncludedSchema) and +[`edmx:IncludeAnnotations`](#IncludedAnnotations) specify which parts of +the referenced document are available for use in the referencing +document. + +The `edmx:Reference` element MUST contain the `Uri` attribute, and it +MUST contain at least one [`edmx:Include`](#IncludedSchema) or +[`edmx:IncludeAnnotations`](#IncludedAnnotations) child element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Uri` +::: + +::: csdl +The value of `Uri` is an absolute or relative URI; relative URIs are +relative to the `xml:base` attribute, see +[**\[XML‑Base\]**](#BMXMLBase). +::: + +::: {.varxml .example} +Example ##ex: references to other CSDL documents +``` +[[\\ +\\ +  \]{style="color:black"}]{.Datatype} +::: + +`    …` + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +`    …` + +[[  \\ +  \\ +    ...]{style="color:black"}]{.Datatype} + +[[  \\ +  \...\\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Included Schema + +A reference MAY include zero or more schemas from the referenced +document. + +The included schemas are identified via their [namespace](#Namespace). +The same namespace MUST NOT be included more than once, even if it is +declared in more than one referenced document. + +When including a schema, a [simple identifier](#SimpleIdentifier) value +MAY be specified as an alias for the schema that is used in qualified +names instead of the namespace. For example, an alias of `display` might +be assigned to the namespace `org.example.vocabularies.display`. An +alias-qualified name is resolved to a fully qualified name by examining +aliases for included schemas and schemas defined within the document. + +::: csdl +If an included schema specifies an alias, the alias MAY be used instead +of the namespace within qualified names to identify model elements of +the included schema. An alias only provides a more convenient notation, +allowing a short string to be substituted for a long namespace. Every +model element that can be identified via an alias-qualified name can +alternatively be identified via its full namespace-qualified name. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +An alias is only valid within the document in which it is declared; a +referencing document may define its own aliases for included schemas. + +::: {.varxml .rep} +Element `edmx:Include` +::: + +::: csdl +The `edmx:Include` element specifies a schema to include from the +referenced CSDL document. It MUST provide the `Namespace` attribute and +it MAY provide the `Alias` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Namespace` +::: + +::: csdl +The value of `Namespace` is the namespace of a schema defined in the +referenced CSDL document. +::: + +::: {.varxml .rep} +Attribute `Alias` +::: + +::: csdl +The value of `Alias` is a [simple identifier](#SimpleIdentifier) that +can be used in qualified names instead of the namespace. +::: + +::: {.varxml .example} +Example ##ex: references to entity models containing definitions of +vocabulary terms +``` +[[\\ +\\ +  \]{style="color:black"}]{.Datatype} +::: + +`    ` + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +`    +      +    ` + +[[  \\ +  \\ +    \]{style="color:black"}]{.Datatype} + +[[  \\ +  \...\\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Included Annotations + +In addition to including whole schemas with all model constructs defined +within that schema, annotations can be included with more flexibility. + +Annotations are selectively included by specifying the +[namespace](#Namespace) of the annotations' term. Consumers can opt not +to inspect the referenced document if none of the term namespaces is of +interest for the consumer. + +In addition, the [qualifier](#Qualifier) of annotations to be included +MAY be specified. For instance, a service author might want to supply a +different set of annotations for various device form factors. If a +qualifier is specified, only those annotations from the specified term +namespace with the specified qualifier (applied to a model element of +the target namespace, if present) SHOULD be included. If no qualifier is +specified, all annotations within the referenced document from the +specified term namespace (taking into account the target namespace, if +present) SHOULD be included. + +The qualifier also provides consumers insight about what qualifiers are +present in the referenced document. If the consumer is not interested in +that particular qualifier, the consumer can opt not to inspect the +referenced document. + +In addition, the namespace of the annotations' [target](#Target) MAY be +specified. If a target namespace is specified, only those annotations +which apply a term form the specified term namespace to a model element +of the target namespace (with the specified qualifier, if present) +SHOULD be included. If no target namespace is specified, all annotations +within the referenced document from the specified term namespace (taking +into account the qualifier, if present) SHOULD be included. + +The target namespace also provides consumers insight about what +namespaces are present in the referenced document. If the consumer is +not interested in that particular target namespace, the consumer can opt +not to inspect the referenced document. + +::: {.varxml .rep} +Element `edmx:IncludeAnnotations` +::: + +::: csdl +The `edmx:IncludeAnnotations` element specifies the annotations to +include from the referenced CSDL document. If no +`edmx:IncludeAnnotations` element is specified, a client MAY ignore all +annotations in the referenced document that are not explicitly used in +an [`edm:Path`](#ValuePath) expression of the referencing document. + +The `edmx:IncludeAnnotations` element MUST provide the `TermNamespace` +attribute, and it MAY provide the `Qualifier` and `TargetNamespace` +attribute. +::: + +::: {.varxml .rep} +Attribute `TermNamespace` +::: + +::: csdl +The value of `TermNamespace` is a namespace. +::: + +::: {.varxml .rep} +Attribute `Qualifier` +::: + +::: csdl +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .rep} +Attribute `TargetNamespace` +::: + +::: csdl +The value of `TargetNamespace` is a namespace. +::: + +::: {.varxml .example} +Example ##ex: reference documents that contain annotations +``` +[[\\ +\\ +  \\ +    \\ +    \\ +    \\ +    \\ +  \\ +  \...\\ +\]{style="color:black"}]{.Datatype} +``` + +The following annotations from `http://odata.org/ann/b` are included: +- Annotations that use a +term from the `org.example.validation` namespace, and +- Annotations that use a +term from the `org.example.display` namespace and specify a `Tablet` +qualifier and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Sales` namespace and +- Annotations that apply +a term from the `org.example.hcm` namespace to an element of the +`com.example.Person` namespace and specify a `Tablet` qualifier. + +# ##sec Schema + +One or more schemas describe the entity model exposed by an OData +service. The schema acts as a namespace for elements of the entity model +such as entity types, complex types, enumerations and terms. + +A schema is identified by a [namespace](#Namespace). Schema namespaces +MUST be unique within the scope of a document and SHOULD be globally +unique. A schema cannot span more than one document. + +The schema's namespace is combined with the name of elements in the +entity model to create unique [qualified names](#QualifiedName), so +identifiers that are used to name types MUST be unique within a +namespace to prevent ambiguity. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +The `namespace` MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {.varxml .rep} +[[Element +]{lang="DE"}]{#_Toc37318849}[[edm:Schema]{lang="DE"}]{.Datatype} +::: + +::: csdl +[The ]{lang="DE"}[[edm:Schema]{lang="DE"}]{.Datatype}[ element defines a +schema. ]{lang="DE"}It MUST contain the `Namespace` attribute and it MAY +contain the `Alias` attribute. + +It MAY contain elements [`edm:Action`](#Action), +[`edm:Annotations`](#AnnotationswithExternalTargeting), +[`edm:Annotation`](#Annotation), [`edm:ComplexType`](#ComplexType), +[`edm:EntityContainer`](#EntityContainer), +[`edm:EntityType`](#EntityType), [`edm:EnumType`](#EnumerationType), +[`edm:Function`](#Function), [`edm:Term`](#Term), or +[`edm:TypeDefinition`](#TypeDefinition). +::: + +::: {.varxml .rep} +Attribute `Namespace` +::: + +::: csdl +The value of `Namespace` is the namespace of the schema +::: + +## ##subsec Alias + +A schema MAY specify an alias which MUST be a [simple +identifier](#SimpleIdentifier). + +::: csdl +If a schema specifies an alias, the alias MAY be used instead of the +namespace within qualified names to identify model elements of that +schema. An alias only provides a more convenient notation, allowing a +short string to be substituted for a long namespace. Every model element +that can be identified via an alias-qualified name can alternatively be +identified via its full namespace-qualified name. +::: + +Aliases are document-global, so all schemas defined within or included +into a document MUST have different aliases, and aliases MUST differ +from the namespaces of all schemas defined within or included into a +document. Aliases defined by a schema can be used throughout the +containing document and are not restricted to the schema that defines +them. + +The alias MUST NOT be one of the reserved values `Edm`, `odata`, +`System`, or `Transient`. + +::: {.varxml .rep} +Attribute `Alias` +::: + +::: csdl +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example ##ex: schema `org.example` with an alias and a description for the +schema +``` + +  … + +``` +::: + +## ##subsec [[ ]{lang="DE"}Annotations with External Targeting](#AnnotationswithExternalTargeting) + +::: {.varxml .rep} +Element `edm:Annotations` +::: + +::: csdl +The `edm:Annotations` element is used to apply a group of annotations to +a single model element. It MUST contain the `Target` attribute and it +MAY contain the `Qualifier` attribute. + +It MUST contain at least one [`edm:Annotation`](#Annotation) element. +::: + +::: {.varxml .rep} +Attribute `Target` +::: + +::: csdl +The value of `Target` is a path expression identifying the [annotation +target](#Target). It MUST resolve to a model element in scope. +::: + +::: {.varxml .rep} +Attribute `Qualifier` +::: + +::: csdl +The value of `Qualifier` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example ##ex: annotations should only be applied to tablet devices +``` +[[\\ +  \]{style="color:black"}]{.Datatype} +::: + +[[  ...\ +\]{style="color:black"}]{.Datatype} +``` + +# ##sec Entity Type + +Entity types are [nominal](#NominalTypes) [structured +types](#StructuredTypes) with a key that consists of one or more +references to [structural properties](#StructuralProperty). An entity +type is the template for an entity: any uniquely identifiable record +such as a customer or order. + +The entity type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +An entity type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to another entity type or collection of entity types. + +All properties MUST have a unique name within an entity type. Properties +MUST NOT have the same name as the declaring entity type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {.varxml .rep} +Element `edm:EntityType` +::: + +::: csdl +The `edm:EntityType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedEntityType), +[`Abstract`](#AbstractEntityType), [`OpenType`](#OpenEntityType), and +[`HasStream`](#MediaEntityType) attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the entity type. + +It MAY contain one [`edm:Key`](#Key) element. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the entity type's name. +::: + +::: {.varxml .example} +Example ##ex: a simple entity type +``` +[[\\ +  \\ +    \\ +  \\ +  \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +## ##subsec Derived Entity Type + +An entity type can inherit from another entity type by specifying it as +its base type. + +An entity type inherits the [key](#Key) as well as structural and +navigation properties of its base type. + +An entity type MUST NOT introduce an inheritance cycle via the base type +attribute. + +::: {.varxml .rep} +Attribute `BaseType` +::: + +::: csdl +The value of `BaseType` is the qualified name of the base type. +::: + +::: {.varxml .example} +Example ##ex: a derived entity type based on the previous example +``` +[[\\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +Note: the derived type has the same name as one of the properties of its +base type. + +## ##subsec Abstract Entity Type + +An entity type MAY indicate that it is abstract and cannot have +instances. + +For OData 4.0 responses a non-abstract entity type MUST define a +[key](#Key) or derive from a [base type](#DerivedEntityType) with a +defined key. + +An abstract entity type MUST NOT inherit from a non-abstract entity +type. + +::: {.varxml .rep} +Attribute `Abstract` +::: + +::: csdl +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Open Entity Type + +An entity type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +An entity type derived from an open entity type MUST indicate that it is +also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {.varxml .rep} +Attribute `OpenType` +::: + +::: csdl +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Media Entity Type + +An entity type that does not specify a base type MAY specify that it is +a media entity type. *Media entities* are entities that represent a +media stream, such as a photo. Use a media entity if the out-of-band +stream is the main topic of interest and the media entity is just +additional structured information attached to the stream. Use a normal +entity with one or more properties of type `Edm.Stream` if the +structured data of the entity is the main topic of interest and the +stream data is just additional information attached to the structured +data. For more information on media entities see +[OData‑Protocol](#ODataProtocol). + +An entity type derived from a media entity type MUST indicate that it is +also a media entity type. + +Media entity types MAY specify a list of acceptable media types using an +annotation with term +[`Core.AcceptableMediaTypes`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#AcceptableMediaTypes), +see [OData‑VocCore](#ODataVocCore). + +::: {.varxml .rep} +Attribute `HasStream` +::: + +::: csdl +The value of `HasStream` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Key + +An entity is uniquely identified within an entity set by its key. A key +MAY be specified if the entity type does not specify a [base +type](#DerivedEntityType) that already has a key declared. + +In order to be specified as the type of an [entity set](#EntitySet) or a +collection-valued [containment navigation +property](#ContainmentNavigationProperty), the entity type MUST either +specify a key or inherit its key from its [base +type](#DerivedEntityType). + +In OData 4.01 responses entity types used for [singletons](#Singleton) +or single-valued [navigation properties](#NavigationProperty) do not +require a key. In OData 4.0 responses entity types used for +[singletons](#Singleton) or single-valued [navigation +properties](#NavigationProperty) MUST have a key defined. + +An entity type (whether or not it is marked as abstract) MAY define a +key only if it doesn't inherit one. + +An entity type's key refers to the set of properties that uniquely +identify an instance of the entity type within an entity set. The key +MUST consist of at least one property. + +Key properties MUST NOT be nullable and MUST be typed with an +[enumeration type](#EnumerationType), one of the following [primitive +types](#PrimitiveTypes), or a [type definition](#TypeDefinition) based +on one of these primitive types: + +- `Edm.Boolean ` +- `Edm.Byte ` +- `Edm.Date ` +- `Edm.DateTimeOffset ` +- `Edm.Decimal ` +- `Edm.Duration ` +- `Edm.Guid ` +- `Edm.Int16 ` +- `Edm.Int32 ` +- `Edm.Int64 ` +- `Edm.SByte ` +- `Edm.String ` +- `Edm.TimeOfDay` + +Key property values MAY be language-dependent, but their values MUST be +unique across all languages and the entity ids (defined in +[OData‑Protocol](#ODataProtocol)) MUST be language independent. + +A key property MUST be a non-nullable primitive property of the entity +type itself, including non-nullable primitive properties of non-nullable +single-valued complex properties, recursively. + +In OData 4.01 the key properties of a directly related entity type MAY +also be part of the key if the navigation property is single-valued and +not nullable. This includes navigation properties of non-nullable +single-valued complex properties (recursively) of the entity type. If a +key property of a related entity type is part of the key, all key +properties of the related entity type MUST also be part of the key. + +If the key property is a property of a complex property (recursively) or +of a directly related entity type, the key MUST specify an alias for +that property that MUST be a [simple identifier](#SimpleIdentifier) and +MUST be unique within the set of aliases, structural and navigation +properties of the containing entity type and any of its base types. + +An alias MUST NOT be defined if the key property is a primitive property +of the entity type itself. + +For key properties that are a property of a complex or navigation +property, the alias MUST be used in the key predicate of URLs instead of +the path to the property because the required percent-encoding of the +forward slash separating segments of the path to the property would make +URL construction and parsing rather complicated. The alias MUST NOT be +used in the query part of URLs, where paths to properties don't require +special encoding and are a standard constituent of expressions anyway. + +::: {.varxml .rep} +Element `edm:Key` +::: + +::: csdl +The `edm:Key` element MUST contain at least one `edm:PropertyRef` +element. +::: + +::: {.varxml .rep} +Element `edm:PropertyRef` +::: + +::: csdl +The `edm:PropertyRef` element MUST contain the `Name` attribute and MAY +contain the `Alias` attribute. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is a path expression leading to a primitive +property. The names of the properties in the path are joined together by +forward slashes. +::: + +::: {.varxml .rep} +Attribute `Alias` +::: + +::: csdl +The value of `Alias` is a [simple identifier](#SimpleIdentifier). +::: + +::: {.varxml .example} +Example ##ex: entity type with a simple key +``` +[[\\ +  \\ +    \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +::: {.varxml .example} +Example ##ex: entity type with a simple key referencing a property of a +[complex type](#ComplexType) +``` +[[\\ +  \\ +    \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +`  +` + +[[  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +::: {.varxml .example} +Example ##ex: entity type with a composite key +``` +[[\\ +  \\ +    \\ +    \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +Example 13 (based on example 11): requests to an entity set `Categories` +of type `Category` must use the alias +``` +GET http://host/service/Categories(EntityInfoID=1) +``` + +Example 14 (based on example 11): in a query part the value assigned to +the name attribute must be used +``` +GET http://example.org/OData.svc/Categories?\$filter=Info/ID le 100 +``` + +# ##sec [Structural Property](#StructuralProperty) + +A structural property is a property (of a structural type) that has one +of the following types: +- [Primitive type](#PrimitiveTypes) +- [Complex type](#ComplexType) +- [Enumeration type](#EnumerationType) +- A collection of one of the above + +A structural property MUST specify a unique name as well as a +[type](#Type). + +The property's name MUST be a [simple identifier](#SimpleIdentifier) +used when referencing, serializing or deserializing the property. It +MUST be unique within the set of structural and navigation properties of +the declaring [structured type](#StructuredTypes), and MUST NOT match +the name of any navigation property in any of its base types. If a +structural property with the same name is defined in any of this type's +base types, then the property's type MUST be a type derived from the +type specified for the property of the base type and constrains this +property to be of the specified subtype for instances of this structured +type. The name MUST NOT match the name of any structural or navigation +property of any of this type's base types for OData 4.0 responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {.varxml .rep} +Element `edm:Property` +::: + +::: csdl +The `edm:Property` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the facet attributes +[`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), +[`SRID`](#SRID), and [`DefaultValue`](#DefaultValue). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the property's name. +::: + +::: {.varxml .example} +Example ##ex: complex type with two properties +``` +[[\\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Type + +The property's type MUST be a [primitive type](#PrimitiveTypes), +[complex type](#ComplexType), or [enumeration type](#EnumerationType) in +scope, or a collection of one of these types. + +A collection-valued property may be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports a stable ordering. + +A collection-valued property may be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. +::: + +::: {.varxml .example} +Example ##ex: property `Units` that can have zero or more strings as its +value +``` + +``` +::: + +## ##subsec Type Facets + +Facets modify or constrain the acceptable values of a property. + +For single-valued properties facets apply to the type of the property. +For collection-valued properties the facets apply to the type of the +items in the collection. + +### ##subsubsec Nullable + +A Boolean value specifying whether the property can have the value +`null`. + +::: {.varxml .rep} +Attribute `Nullable` +::: + +::: csdl +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +For single-valued properties the value `true` means that the property +allows the `null` value. + +For collection-valued properties the property value will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +If no value is specified for a single-valued property, the `Nullable` +attribute defaults to `true`. + +In OData 4.01 responses a collection-valued property MUST specify a +value for the `Nullable` attribute. + +If no value is specified for a collection-valued property, the client +cannot assume any default value. Clients SHOULD be prepared for this +situation even in OData 4.01 responses. +::: + +### ##subsubsec MaxLength + +A positive integer value specifying the maximum length of a binary, +stream or string value. For binary or stream values this is the octet +length of the binary data, for string values it is the character length +(number of code points for Unicode). + +If no maximum length is specified, clients SHOULD expect arbitrary +length. + +::: {.varxml .rep} +Attribute `MaxLength` +::: + +::: csdl +The value of `MaxLength` is a positive integer or the symbolic value +`max` as a shorthand for the maximum length supported for the type by +the service. + +Note: the symbolic value `max` is only allowed in OData 4.0 responses; +it is deprecated in OData 4.01. While clients MUST be prepared for this +symbolic value, OData 4.01 and greater services MUST NOT return the +symbolic value `max` and MAY instead specify the concrete maximum length +supported for the type by the service or omit the attribute entirely. +::: + +### ##subsubsec Precision + +For a decimal value: the maximum number of significant decimal digits of +the property's value; it MUST be a positive integer. + +For a temporal value (datetime-with-timezone-offset, duration, or +time-of-day): the number of decimal places allowed in the seconds +portion of the value; it MUST be a non-negative integer between zero and +twelve. + +Note: service authors SHOULD be aware that some clients are unable to +support a precision greater than 28 for decimal properties and 7 for +temporal properties. Client developers MUST be aware of the potential +for data loss when round-tripping values of greater precision. Updating +via `PATCH` and exclusively specifying modified properties will reduce +the risk for unintended data loss. + +Note: duration properties supporting a granularity less than seconds +(e.g. minutes, hours, days) can be annotated with term +[`Measures.DurationGranularity`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Measures.V1.md#DurationGranularity), +see [OData-VocMeasures](#ODataVocMeasures). + +::: {.varxml .rep} +Attribute `Precision` +::: + +::: csdl +The value of `Precision` is a number. + +If not specified for a decimal property, the decimal property has +arbitrary precision. + +If not specified for a temporal property, the temporal property has a +precision of zero. +::: + +::: {.varxml .example} +Example ##ex: [`Precision`](#Precision) facet applied to the +`DateTimeOffset` type +``` + +``` +::: + +### ##subsubsec Scale + +A non-negative integer value specifying the maximum number of digits +allowed to the right of the decimal point, or one of the symbolic values +`floating` or `variable`. + +The value `floating` means that the decimal property represents a +decimal floating-point number whose number of significant digits is the +value of the [`Precision`](#Precision) facet. OData 4.0 responses MUST +NOT specify the value `floating`. + +The value `variable` means that the number of digits to the right of the +decimal point may vary from zero to the value of the +[`Precision`](#Precision) facet. + +An integer value means that the number of digits to the right of the +decimal point may vary from zero to the value of the `Scale` attribute, +and the number of digits to the left of the decimal point may vary from +one to the value of the `Precision` facet minus the value of the `Scale` +facet. If `Precision` is equal to `Scale`, a single zero MUST precede +the decimal point. + +The value of `Scale` MUST be less than or equal to the value of +[`Precision`](#Precision). + +Note: if the underlying data store allows negative scale, services may +use a [`Precision`](#Precision) with the absolute value of the negative +scale added to the actual number of significant decimal digits, and +client-provided values may have to be rounded before being stored. + +::: {.varxml .rep} +Attribute `Scale` +::: + +::: csdl +The value of `Scale` is a number or one of the symbolic values +`floating` or `variable`. + +Services SHOULD use lower-case values; clients SHOULD accept values in a +case-insensitive manner. + +If not specified, the `Scale` facet defaults to zero. +::: + +::: {.varxml .example} +Example ##ex: [`Precision`](#Precision)`=3` and `Scale=2`.\ +Allowed values: 1.23, 0.23, 3.14 and 0.7, not allowed values: 123, 12.3 +``` + +``` +::: + +::: {.varxml .example} +Example ##ex: `Precision=2` equals `Scale`.\ +Allowed values: 0.23, 0.7, not allowed values: 1.23, 1.2 +``` + +``` +::: + +::: {.varxml .example} +Example ##ex: `Precision=3` and a variable `Scale`.\ +Allowed values: 0.123, 1.23, 0.23, 0.7, 123 and 12.3, not allowed +values: 12.34, 1234 and 123.4 due to the limited precision. +``` + +``` +::: + +::: {.varxml .example} +Example ##ex: `Precision=7` and a floating `Scale`.\ +Allowed values: -1.234567e3, 1e-101, 9.999999e96, not allowed values: +1e-102 and 1e97 due to the limited precision. +``` + +``` +::: + +### ##subsubsec Unicode + +For a string property the `Unicode` facet indicates whether the property +might contain and accept string values with Unicode characters (code +points) beyond the ASCII character set. The value `false` indicates that +the property will only contain and accept string values with characters +limited to the ASCII character set. + +If no value is specified, the `Unicode` facet defaults to `true`. + +::: {.varxml .rep} +Attribute `Unicode` +::: + +::: csdl +The value of `Unicode` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `true`. +::: + +### ##subsubsec SRID + +For a geometry or geography property the `SRID` facet identifies which +spatial reference system is applied to values of the property on type +instances. + +The value of the `SRID` facet MUST be a non-negative integer or the +special value `variable`. If no value is specified, the attribute +defaults to `0` for `Geometry` types or `4326` for `Geography` types. + +The valid values of the `SRID` facet and their meanings are as defined +by the European Petroleum Survey Group [**\[EPSG\]**](#BMEPSG)**.** + +::: {.varxml .rep} +Attribute `SRID` +::: + +::: csdl +The value of `$SRID` is a number or the symbolic value `variable`. +::: + +### ##subsubsec Default Value + +A primitive or enumeration property MAY define a default value that is +used if the property is not explicitly represented in an annotation or +the body of a `POST` or `PUT` request. + +If no value is specified, the client SHOULD NOT assume a default value. + +::: {.varxml .rep} +Attribute `DefaultValue` +::: + +::: csdl +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. +::: + +# ##sec Navigation Property + +A navigation property allows navigation to related entities. It MUST +specify a unique name as well as a type. + +The navigation property's name MUST be a [simple +identifier](#SimpleIdentifier). It is used when referencing, serializing +or deserializing the navigation property. It MUST be unique within the +set of structural and navigation properties of the declaring [structured +type](#StructuredTypes), and MUST NOT match the name of any structural +property in any of its base types. If a navigation property with the +same name is defined in any of this type's base types, then the +navigation property's type MUST be a type derived from the type +specified for the navigation property of the base type, and constrains +this navigation property to be of the specified subtype for instances of +this structured type. The name MUST NOT match the name of any structural +or navigation property of any of this type's base types for OData 4.0 +responses. + +Names are case-sensitive, but service authors SHOULD NOT choose names +that differ only in case. + +::: {.varxml .rep} +Element `edm:NavigationProperty` +::: + +::: csdl +The `edm:NavigationProperty` element MUST contain the `Name` and `Type` +attributes, and it MAY contain the attributes +[`Nullable`](#NullableNavigationProperty), +[`Partner`](#PartnerNavigationProperty), and +[`ContainsTarget`](#ContainmentNavigationProperty). + +It MAY contain child elements +[`edm:ReferentialConstraint`](#ReferentialConstraint) and at most one +child element [`edm:OnDelete`](#OnDeleteAction). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the navigation property's name. +::: + +::: {.varxml .example} +Example ##ex: the Product entity type has a navigation property to a +Category, which has a navigation link back to one or more products +``` +[[\\ +  ...\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +[[\\ +  ...\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Navigation Property Type + +The navigation property's type MUST be an [entity type](#EntityType) in +scope, the [abstract type](#BuiltInAbstractTypes) `Edm.EntityType`, or a +collection of one of these types. + +If the type is a collection, an arbitrary number of entities can be +related. Otherwise there is at most one related entity. + +The related entities MUST be of the specified entity type or one of its +subtypes. + +For a collection-valued containment navigation property the specified +entity type MUST have a [key](#Key) defined. + +A collection-valued navigation property may be annotated with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports a stable ordering. + +A collection-valued navigation property may be annotated with the +[`Core.PositionalInsert`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#PositionalInsert) +term, defined in [OData-CoreVoc](#ODataVocCore)**)**, to specify that it +supports inserting items into a specific ordinal position. + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +For single-valued navigation properties the value of `Type` is the +qualified name of the navigation property's type. + +For collection-valued navigation properties the value of `Type` is the +character sequence `Collection(` followed by the qualified name of the +navigation property's item type, followed by a closing parenthesis `)`. +::: + +## ##subsec Nullable Navigation Property + +A Boolean value specifying whether the declaring type MAY have no +related entity. If false, instances of the declaring structured type +MUST always have a related entity. + +Nullable MUST NOT be specified for a collection-valued navigation +property, a collection is allowed to have zero items. + +::: {.varxml .rep} +Attribute `Nullable` +::: + +::: csdl +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. +::: + +## ##subsec Partner Navigation Property + +A navigation property of an [entity type](#EntityType) MAY specify a +partner navigation property. Navigation properties of complex types MUST +NOT specify a partner. + +If specified, the partner navigation property is identified by a path +relative to the entity type specified as the type of the navigation +property. This path MUST lead to a navigation property defined on that +type or a derived type. The path MAY traverse complex types, including +derived complex types, but MUST NOT traverse any navigation properties. +The type of the partner navigation property MUST be the declaring entity +type of the current navigation property or one of its parent entity +types. + +If the partner navigation property is single-valued, it MUST lead back +to the source entity from all related entities. If the partner +navigation property is collection-valued, the source entity MUST be part +of that collection. + +If no partner navigation property is specified, no assumptions can be +made as to whether one of the navigation properties on the target type +will lead back to the source entity. + +If a partner navigation property is specified, this partner navigation +property MUST either specify the current navigation property as its +partner to define a bi-directional relationship or it MUST NOT specify a +partner navigation property. The latter can occur if the partner +navigation property is defined on a complex type, or if the current +navigation property is defined on a type derived from the type of the +partner navigation property. + +::: {.varxml .rep} +Attribute `Partner` +::: + +::: csdl +The value of `Partner` is the path to the of the partner navigation +property. +::: + +## ##subsec Containment Navigation Property + +A navigation property MAY indicate that instances of its declaring +structured type contain the targets of the navigation property, in which +case the navigation property is called a *containment navigation +property*. + +Containment navigation properties define an implicit entity set for each +instance of its declaring structured type. This implicit entity set is +identified by the read URL of the navigation property for that +structured type instance. + +Instances of the structured type that declares the navigation property, +either directly or indirectly via a property of complex type, contain +the entities referenced by the containment navigation property. The +canonical URL for contained entities is the canonical URL of the +containing instance, followed by the path segment of the navigation +property and the key of the contained entity, see +[OData‑URL](#ODataURL). + +Entity types used in collection-valued containment navigation properties +MUST have a [key](#Key) defined. + +For items of an ordered collection of complex types (those annotated +with the +[`Core.Ordered`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#Ordered) +term defined in [OData-CoreVoc](#ODataVocCore)**)**, the canonical URL +of the item is the canonical URL of the collection appended with a +segment containing the zero-based ordinal of the item. Items within in +an unordered collection of complex types do not have a canonical URL. +Services that support unordered collections of complex types declaring a +containment navigation property, either directly or indirectly via a +property of complex type, MUST specify the URL for the navigation link +within a payload representing that item, according to format-specific +rules. + +OData 4.0 responses MUST NOT specify a complex type declaring a +containment navigation property as the type of a collection-valued +property. + +An entity cannot be referenced by more than one containment relationship +and cannot both belong to an entity set declared within the entity +container and be referenced by a containment relationship. + +Containment navigation properties MUST NOT be specified as the last path +segment in the path of a [navigation property +binding](#NavigationPropertyBinding). + +When a containment navigation property navigates between entity types in +the same inheritance hierarchy, the containment is called *recursive*. + +Containment navigation properties MAY specify a partner navigation +property. If the containment is recursive, the relationship defines a +tree, thus the partner navigation property MUST be +[Nullable](#NullableNavigationProperty) (for the root of the tree) and +single-valued (for the parent of a non-root entity). If the containment +is not recursive, the partner navigation property MUST NOT be nullable. + +An entity type inheritance chain MUST NOT contain more than one +navigation property with a partner navigation property that is a +containment navigation property. + +Note: without a partner navigation property, there is no reliable way +for a client to determine which entity contains a given contained +entity. This may lead to problems for clients if the contained entity +can also be reached via a non-containment navigation path. + +::: {.varxml .rep} +Attribute `ContainsTarget` +::: + +::: csdl +The value of `ContainsTarget` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Referential Constraint + +A single-valued navigation property MAY define one or more referential +constraints. A referential constraint asserts that the *dependent +property* (the property defined on the structured type declaring the +navigation property) MUST have the same value as the *principal +property* (the referenced property declared on the entity type that is +the target of the navigation). + +The type of the dependent property MUST match the type of the principal +property, or both types MUST be complex types. + +If the principle property references an entity, then the dependent +property must reference the same entity. + +If the principle property's value is a complex type instance, then the +dependent property's value must be a complex type instance with the same +properties, each with the same values. + +If the navigation property on which the referential constraint is +defined is nullable, or the principal property is nullable, then the +dependent property MUST also be nullable. If both the navigation +property and the principal property are not nullable, then the dependent +property MUST NOT be nullable. + +::: {.varxml .rep} +Element `edm:ReferentialConstraint` +::: + +::: csdl +The `edm:ReferentialConstraint` element MUST contain the attributes +`Property` and `ReferencedProperty`. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Property` +::: + +::: csdl +The `Property` attribute specifies the property that takes part in the +referential constraint on the dependent structured type. Its value MUST +be a path expression resolving to a property of the dependent structured +type itself or to a property of a complex property (recursively) of the +dependent structured type. The names of the properties in the path are +joined together by forward slashes. The path is relative to the +dependent structured type declaring the navigation property. +::: + +::: {.varxml .rep} +Attribute `ReferencedProperty` +::: + +::: csdl +The `ReferencedProperty` attribute specifies the corresponding property +of the principal entity type. Its value MUST be a path expression +resolving to a property of the principal entity type itself or to a +property of a complex property (recursively) of the principal entity +type that MUST have the same type as the property of the dependent +entity type. The path is relative to the entity type that is the target +of the navigation property. +::: + +::: {.varxml .example} +Example ##ex: the category must exist for a product in that category to +exist. The `CategoryID` of the product is identical to the `ID` of the +category, and the `CategoryKind` property of the product is identical to +the `Kind` property of the category. +``` +[[\\ +  ...\ +  \]{style="color:black"}]{.Datatype} +::: + +`  ` + +[[  \\ +    \\ +    \]{style="color:black"}]{.Datatype} + +`      +    + +  + +    ` + +[[  \\ +  \\ +  \\ +  ... ]{style="color:black"}]{.Datatype} + +` +``` + +## ##subsec On-Delete Action + +A navigation property MAY define an on-delete action that describes the +action the service will take on related entities when the entity on +which the navigation property is defined is deleted. + +The action can have one of the following values: + +- `Cascade`, meaning the related entities will be deleted if the + source entity is deleted, +- `None`, meaning a `DELETE` request on a source entity with related + entities will fail, +- `SetNull`, meaning all properties of related entities that are tied + to properties of the source entity via a referential constraint and + that do not participate in other referential constraints will be set + to null, +- `SetDefault`, meaning all properties of related entities that are + tied to properties of the source entity via a referential constraint + and that do not participate in other referential constraints will be + set to their default value. + +If no on-delete action is specified, the action taken by the service is +not predictable by the client and could vary per entity. + +::: {.varxml .rep} +Element `edm:OnDelete` +::: + +::: csdl +The `edm:OnDelete` element MUST contain the `Action` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Action` +::: + +::: csdl +The value of `Action` is one of the values `Cascade`, `None`, `SetNull`, +or `SetDefault`. +::: + +::: {.varxml .example} +Example ##ex: deletion of a category implies deletion of the related +products in that category +``` +[[\\ +  ...\ +  \\ +    \]{style="color:black"}]{.Datatype} +::: + +[[      \]{style="color:black"}]{.Datatype} + +[[    \]{style="color:black"}]{.Datatype} + +` +``` + +# ##sec Complex Type + +Complex types are keyless [nominal](#NominalTypes) [structured +types](#StructuredTypes). The lack of a key means that instances of +complex types cannot be referenced, created, updated or deleted +independently of an entity type. Complex types allow entity models to +group properties into common structures. + +The complex type's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +A complex type can define two types of properties. A [structural +property](#StructuralProperty) is a named reference to a primitive, +complex, or enumeration type, or a collection of primitive, complex, or +enumeration types. A [navigation property](#NavigationProperty) is a +named reference to an entity type or a collection of entity types. + +All properties MUST have a unique name within a complex type. Properties +MUST NOT have the same name as the declaring complex type. They MAY have +the same name as one of the direct or indirect base types or derived +types. + +::: {.varxml .rep} +Element `edm:ComplexType` +::: + +::: csdl +The `edm:ComplexType` element MUST contain the `Name` attribute, and it +MAY contain the [`BaseType`](#DerivedComplexType), +[`Abstract`](#AbstractComplexType), and [`OpenType`](#OpenComplexType) +attributes. + +It MAY contain [`edm:Property`](#StructuralProperty) and +[`edm:NavigationProperty`](#NavigationProperty) elements describing the +properties of the complex type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the complex type's name. +::: + +::: {.varxml .example} +Example ##ex: a complex type used by two entity types +``` +[[\\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +` ` + +[[\\ +  ...\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} + +` ` + +[[\\ +  ...\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Derived Complex Type + +A complex type can inherit from another complex type by specifying it as +its base type. + +A complex type inherits the structural and navigation properties of its +base type. + +A complex type MUST NOT introduce an inheritance cycle by specifying a +base type. + +The rules for annotations of derived complex types are described in +section 14.2. + +::: {.varxml .rep} +Attribute `BaseType` +::: + +::: csdl +The value of `BaseType` is the qualified name of the base type. +::: + +## ##subsec Abstract Complex Type + +A complex type MAY indicate that it is abstract and cannot have +instances. + +::: {.varxml .rep} +Attribute `Abstract` +::: + +::: csdl +The value of `Abstract` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Open Complex Type + +A complex type MAY indicate that it is open and allows clients to add +properties dynamically to instances of the type by specifying uniquely +named property values in the payload used to insert or update an +instance of the type. + +A complex type derived from an open complex type MUST indicate that it +is also open. + +Note: structural and navigation properties MAY be returned by the +service on instances of any structured type, whether or not the type is +marked as open. Clients MUST always be prepared to deal with additional +properties on instances of any structured type, see +[OData‑Protocol](#ODataProtocol). + +::: {.varxml .rep} +Attribute `OpenType` +::: + +::: csdl +The value of `OpenType` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +# ##sec Enumeration Type + +Enumeration types are [nominal](#NominalTypes) types that represent a +non-empty series of related values. Enumeration types expose these +related values as members of the enumeration. + +The enumeration type's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Although enumeration types have an underlying numeric value, the +preferred representation for an enumeration value is the member name. +Discrete sets of numeric values should be represented as numeric values +annotated with the `AllowedValues` annotation defined in +[**\[OData-VocCore\].**](#ODataVocCore) + +Enumeration types marked as flags allow values that consist of more than +one enumeration member at a time. + +::: {.varxml .rep} +Element `edm:EnumType` +::: + +::: csdl +The `edm:EnumType` element MUST contain the Name attribute, and it MAY +contain the [`UnderlyingType`](#UnderlyingIntegerType) and +[`IsFlags`](#FlagsEnumerationType) attributes. + +It MUST contain one or more [`edm:Member`](#EnumerationTypeMember) +elements defining the members of the enumeration type. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the enumeration type's name. +::: + +::: {.varxml .example} +Example ##ex: a simple flags-enabled enumeration +``` +[[\\ +  \\ +  \\ +  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +## ##subsec Underlying Integer Type + +An enumeration type MAY specify one of `Edm.Byte`, `Edm.SByte`, +`Edm.Int16`, `Edm.Int32`, or `Edm.Int64` as its underlying type. + +If not explicitly specified, `Edm.Int32` is used as the underlying type. + +::: {.varxml .rep} +Attribute `UnderlyingType` +::: + +::: csdl +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +## ##subsec Flags Enumeration Type + +An enumeration type MAY indicate that the enumeration type allows +multiple members to be selected simultaneously. + +If not explicitly specified, only one enumeration type member MAY be +selected simultaneously. + +::: {.varxml .rep} +Attribute `IsFlags` +::: + +::: csdl +The value of `IsFlags` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +::: {.varxml .example} +Example ##ex: pattern values can be combined, and some combined values +have explicit names +``` + + +``` +::: + +## ##subsec Enumeration Type Member + +Enumeration type values consist of discrete members. + +Each member is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within the +enumeration type. Names are case-sensitive, but service authors SHOULD +NOT choose names that differ only in case. + +Each member MUST specify an associated numeric value that MUST be a +valid value for the underlying type of the enumeration type. + +Enumeration types can have multiple members with the same value. Members +with the same numeric value compare as equal, and members with the same +numeric value can be used interchangeably. + +Enumeration members are sorted by their numeric value. + +::: {.varxml .rep} +Element `edm:Member` +::: + +::: csdl +The `edm:Member` element MUST contain the `Name` attribute and it MAY +contain the `Value` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the enumeration member's name. +::: + +::: {.varxml .rep} +Attribute `Value` +::: + +::: csdl +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`false`, either all members MUST specify an integer value for the +`Value` attribute, or all members MUST NOT specify a value for the +`Value` attribute. If no values are specified, the members are assigned +consecutive integer values in the order of their appearance, starting +with zero for the first member. Client libraries MUST preserve elements +in document order. + +If the [`IsFlags`](#FlagsEnumerationType) attribute has a value of +`true`, a non-negative integer value MUST be specified for the `Value` +attribute. A combined value is equivalent to the bitwise OR of the +discrete values. +::: + +::: {.varxml .example} +Example ##ex: `FirstClass` has a value of `0`, `TwoDay` a value of 1, and +`Overnight` a value of 2. +``` +[[\\ +  \]{style="color:black"}]{.Datatype} +::: + +`    ` + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +`    \ +  \\ +  \]{style="color:black"}]{.Datatype} + +`    \ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +# ##sec Type Definition + +A type definition defines a specialization of one of the [primitive +types](#PrimitiveTypes) or of the built-in abstract type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes). + +The type definition's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Type definitions can be used wherever a primitive type is used (other +than as the underlying type in a new type definition) and are +type-comparable with their underlying types and any type definitions +defined using the same underlying type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated type +definition is used, and whether they can be overridden. + +::: {.varxml .rep} +Element `edm:TypeDefinition` +::: + +::: csdl +The `edm:TypeDefinition` element MUST contain the `Name` and +[`UnderlyingType`](#UnderlyingPrimitiveType) attributes. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the type definition's name. +::: + +::: {.varxml .example} +Example ##ex: +``` +\ +::: + +  \ + +\ + +  + +\ + +  \ + +\ + +  + +\ + +  \ + +  \ + +\ +``` + +## ##subsec Underlying Primitive Type + +The underlying type of a type definition MUST be a [primitive +type](#PrimitiveTypes) that MUST NOT be another type definition. + +::: {.varxml .rep} +Attribute `UnderlyingType` +::: + +::: csdl +The value of `UnderlyingType` is the qualified name of the underlying +type. +::: + +The type definition MAY specify facets applicable to the underlying +type. Possible facets are: [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), or +[`SRID`](#SRID). + +Additional facets appropriate for the underlying type MAY be specified +when the type definition is used but the facets specified in the type +definition MUST NOT be re-specified. + +For a type definition with underlying type +[`Edm.PrimitiveType`](#BuiltInAbstractTypes) no facets are applicable, +neither in the definition itself nor when the type definition is used, +and these should be ignored by the client. + +Where type definitions are used, the type definition is returned in +place of the primitive type wherever the type is specified in a +response. + +# ##sec [Action and Function](#ActionandFunction) + +## ##subsec Action + +Actions are service-defined operations that MAY have observable side +effects and MAY return a single instance or a collection of instances of +any type. + +The action's name is a [simple identifier](#SimpleIdentifier) that MUST +be unique within its schema. + +Actions cannot be composed with additional path segments. + +An action MAY specify a [return type](#ReturnType) that MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +An action MAY define [parameters](#Parameter) used during the execution +of the action. + +## ##subsec Action Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) actions support +overloading (multiple actions having the same name within the same +schema) by binding parameter type. The combination of action name and +the binding parameter type MUST be unique within a schema. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) actions do not support +overloads. The names of all unbound actions MUST be unique within a +schema. + +An unbound action MAY have the same name as a bound action. + +::: {.varxml .rep} +Element `edm:Action` +::: + +::: csdl +The `edm:Action` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverlo) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MAY contain at most one [`edm:ReturnType`](#ReturnType) element and +MAY contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the action's name. +::: + +## ##subsec Function + +Functions are service-defined operations that MUST NOT have observable +side effects and MUST return a single instance or a collection of +instances of any type. + +The function's name is a [simple identifier](#SimpleIdentifier) that +MUST be unique within its schema. + +Functions MAY be [composable](#ComposableFunction). + +The function MUST specify a [return type](#ReturnType) which MUST be a +primitive, entity or complex type, or a collection of primitive, entity +or complex types in scope. + +A function MAY define [parameters](#Parameter) to be used during the +execution of the function. + +## ##subsec Function Overloads + +[Bound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading (multiple functions having the same name within the same +schema) subject to the following rules: +- The combination of function name, +binding parameter type, and unordered set of non-binding parameter names +MUST be unique within a schema. +- The combination of function name, +binding parameter type, and ordered set of parameter types MUST be +unique within a schema. +- All bound functions with the same +function name and binding parameter type within a schema MUST specify +the same return type. + +[Unbound](#BoundorUnboundActionorFunctionOverlo) functions support +overloading subject to the following rules: +- The combination of function name and +unordered set of parameter names MUST be unique within a schema. +- The combination of function name and +ordered set of parameter types MUST be unique within a schema. +- All unbound functions with the same +function name within a schema MUST specify the same return type. + +An unbound function MAY have the same name as a bound function. + +Note that [type definitions](#ActionandFunction) can be used to +disambiguate overloads for both bound and unbound functions, even if +they specify the same underlying type. + +::: {.varxml .rep} +Element `edm:Function` +::: + +::: csdl +The `edm:Function` element MUST contain the `Name` attribute and it MAY +contain the [`IsBound`](#BoundorUnboundActionorFunctionOverlo) and +[`EntitySetPath`](#EntitySetPath) attributes. + +It MUST contain one [`edm:ReturnType`](#ReturnType) element, and it MAY +contain [`edm:Parameter`](#Parameter) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the action's name. +::: + +## ##subsec Bound or Unbound Action or Function Overloads + +An action or function overload MAY indicate that it is bound. If not +explicitly indicated, it is unbound. + +Bound actions or functions are invoked on resources matching the type of +the binding parameter. The binding parameter can be of any type, and it +MAY be [Nullable](#Nullable). + +Unbound actions are invoked through an [action import](#ActionImport). + +Unbound functions are invoked as static functions within a filter or +orderby expression, or from the entity container through a [function +import](#FunctionImport). + +::: {.varxml .rep} +Attribute `IsBound` +::: + +::: csdl +The value of `IsBound` is one of the Boolean literals `true` or `false`. +Absence of the attribute means `false`. +::: + +## ##subsec Entity Set Path + +Bound actions and functions that return an entity or a collection of +entities MAY specify an entity set path if the entity set of the +returned entities depends on the entity set of the binding parameter +value. + +The entity set path consists of a series of segments joined together +with forward slashes. + +The first segment of the entity set path MUST be the name of the binding +parameter. The remaining segments of the entity set path MUST represent +navigation segments or type casts. + +A navigation segment names the [simple identifier](#SimpleIdentifier) of +the [navigation property](#NavigationProperty) to be traversed. A +type-cast segment names the [qualified name](#QualifiedName) of the +entity type that should be returned from the type cast. + +::: {.varxml .rep} +Attribute `EntitySetPath` +::: + +::: csdl +The value of `EntitySetPath` is the entity set path. +::: + +## ##subsec Composable Function + +A function MAY indicate that it is composable. If not explicitly +indicated, it is not composable. + +A composable function can be invoked with additional path segments or +key predicates appended to the resource path that identifies the +composable function, and with system query options as appropriate for +the type returned by the composable function. + +::: {.varxml .rep} +Attribute `IsComposable` +::: + +::: csdl +The value of `IsComposable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `false`. +::: + +## ##subsec Return Type + +The return type of an action or function overload MAY be any type in +scope, or a collection of any type in scope. + +The facets [`Nullable`](#Nullable), [`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID) can be +used as appropriate to specify value restrictions of the return type, as +well as the [`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +::: {.varxml .rep} +Element `edm:ReturnType` +::: + +::: csdl +The `edm:ReturnType` element MUST contain the `Type` attribute, and it +MAY contain the attributes `Nullable`, [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +For single-valued return types the value of `Type` is the qualified name +of the return type. + +For collection-valued return types the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the return item +type, followed by a closing parenthesis `)`. +::: + +::: {.varxml .rep} +Attribute `Nullable` +::: + +::: csdl +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +If the return type is a collection of entity types, the `$Nullable` +member has no meaning and MUST NOT be specified. + +For other collection-valued return types the result will always be a +collection that MAY be empty. In this case the `Nullable` attribute +applies to items of the collection and specifies whether the collection +MAY contain `null` values. + +For single-valued return types the value `true` means that the action or +function MAY return a single `null` value. The value `false` means that +the action or function will never return a `null` value and instead will +fail with an error response if it cannot compute a result. +::: + +## ##subsec Parameter + +An action or function overload MAY specify parameters. + +A bound action or function overload MUST specify at least one parameter; +the first parameter is the binding parameter. The order of parameters +MUST NOT change unless the schema version changes. + +Each parameter MUST have a name that is a [simple +identifier](#SimpleIdentifier). The parameter name MUST be unique within +the action or function overload. + +The parameter MUST specify a type. It MAY be any type in scope, or a +collection of any type in scope. + +The facets [`MaxLength`](#MaxLength), [`Precision`](#Precision), +[`Scale`](#Scale), or [`SRID`](#SRID) can be used as appropriate to +specify value restrictions of the parameter, as well as the +[`Unicode`](#Unicode) facet for 4.01 and greater payloads. + +::: {.varxml .rep} +Element `edm:Parameter` +::: + +::: csdl +The `edm:Parameter` element MUST contain the `Name` and the `Type` +attribute, and it MAY contain the attributes `Nullable`, +[`MaxLength`](#MaxLength), [`Unicode`](#Unicode), +[`Precision`](#Precision), [`Scale`](#Scale), and [`SRID`](#SRID). + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the parameter's name. +::: + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +For single-valued parameters the value of `Type` is the qualified name +of the parameter. + +For collection-valued parameters the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the parameter's +type, followed by a closing parenthesis `)`. +::: + +::: {.varxml .rep} +Attribute `Nullable` +::: + +::: csdl +The value of `Nullable` is one of the Boolean literals `true` or +`false`. Absence of the attribute means `true`. + +The value `true` means that the parameter accepts a `null` value. +::: + +::: {.varxml .example} +Example ##ex: a function returning the top-selling products for a given +year. In this case the year must be specified as a parameter of the +function with the `edm:Parameter` element. +``` +\ +::: + +  \ + +  \ + +\ +``` + +# ##sec Entity Container + +Each metadata document used to describe an OData service MUST define +exactly one entity container. + +The entity container's name is a [simple identifier](#SimpleIdentifier) +that MUST be unique within its schema. + +Entity containers define the entity sets, singletons, function and +action imports exposed by the service. + +Entity set, singleton, action import, and function import names MUST be +unique within an entity container. + +An [*entity set*](#EntitySet) allows access to entity type instances. +Simple entity models frequently have one entity set per entity type. + +::: {.varxml .example} +Example ##ex: one entity set per entity type +``` +[[\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +Other entity models may expose multiple entity sets per type. + +::: {.varxml .example} +Example ##ex: three entity sets referring to the two entity types +``` +[[\\ +]{style="color:black"}]{.Datatype}[  \\ +\ ]{style="color:black"} +::: + +`` + +[  \\ +\\ +\]{style="color:black"} +``` + +There are separate entity sets for standard customers and preferred +customers, but only one entity set for orders. The entity sets for +standard customers and preferred customers both have [navigation +property bindings](#NavigationPropertyBinding) to the orders entity set, +but the orders entity set does not have a navigation property binding +for the Customer navigation property, since it could lead to either set +of customers. + +An entity set can expose instances of the specified entity type as well +as any entity type inherited from the specified entity type. + +A [*singleton*](#Singleton) allows addressing a single entity directly +from the entity container without having to know its key, and without +requiring an entity set. + +A [*function import*](#FunctionImport) or an [*action +import*](#ActionImport) is used to expose a function or action defined +in an entity model as a top level resource. + +::: {.varxml .rep} +Element `edm:EntityContainer` +::: + +::: csdl +The `edm:EntityContainer` MUST contain one or more +[`edm:EntitySet`](#EntitySet), [`edm:Singleton`](#Singleton), +[`edm:ActionImport`](#ActionImport), or +[`edm:FunctionImport`](#FunctionImport) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the entity container's name. +::: + +::: {.varxml .example} +Example ##ex: An entity container aggregates entity sets, singletons, +action imports, and function imports. +``` +[[\\ +  \]{style="color:black"}]{.Datatype} +::: + +`    +    ` + +[[  \\ +    \]{style="color:black"}]{.Datatype} + +`  ` + +[[  \\ +    \]{style="color:black"}]{.Datatype} + +`  ` + +[[  \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Extending an Entity Container + +An entity container MAY specify that it extends another entity container +in scope. All children of the "base" entity container are added to the +"extending" entity container. + +If the "extending" entity container defines an entity set with the same +name as defined in any of its "base" containers, then the entity set's +type MUST specify an entity type derived from the entity type specified +for the identically named entity set in the "base" container. The same +holds for singletons. Action imports and function imports cannot be +redefined, nor can the "extending" container define a child with the +same name as a child of a different kind in a "base" container. + +Note: services should not introduce cycles by extending entity +containers. Clients should be prepared to process cycles introduced by +extending entity containers. + +::: {.varxml .rep} +Attribute `Extends` +::: + +::: csdl +The value of `Extends` is the qualified name of the entity container to +be extended. +::: + +::: {.varxml .example} +Example ##ex: the entity container `Extending` will contain all child +elements that it defines itself, plus all child elements of the `Base` +entity container located in `SomeOtherSchema` +``` +\ +::: + +   `…` + +\ +``` + +## ##subsec Entity Set + +Entity sets are top-level collection-valued resources. + +An entity set is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An entity set MUST specify a type that MUST be an entity type in scope. + +An entity set MUST contain only instances of its specified entity type +or its subtypes. The entity type MAY be [abstract](#AbstractEntityType) +but MUST have a [key](#Key) defined. + +An entity set MAY indicate whether it is included in the service +document. If not explicitly indicated, it is included. + +Entity sets that cannot be queried without specifying additional query +options SHOULD NOT be included in the service document. + +::: {.varxml .rep} +Element `edm:EntitySet` +::: + +::: csdl +The `edm:EntitySet` element MUST contain the attributes `Name` and +`EntityType`, and it MAY contain the `IncludeInServiceDocument` +attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the entity set's name. +::: + +::: {.varxml .rep} +Attribute `EntityType` +::: + +::: csdl +The value of `EntityType` is the qualified name of an entity type in +scope. +::: + +::: {.varxml .rep} +Attribute `IncludeInServiceDocument` +::: + +::: csdl +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `true`. +::: + +## ##subsec Singleton + +Singletons are top-level single-valued resources. + +A singleton is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A singleton MUST specify a type that MUST be an entity type in scope. + +A singleton MUST reference an instance its entity type. + +::: {.varxml .rep} +Element `edm:Singleton` +::: + +::: csdl +The `edm:Singleton` element MUST include the attributes `Name` and +`Type`, and it MAY contain the `Nullable` attribute. + +It MAY contain +[`edm:NavigationPropertyBinding`](#NavigationPropertyBinding) elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the singleton's name. +::: + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +The value of `Type` is whose value is the [qualified +name](#QualifiedName) of an entity type in scope. +::: + +::: {.varxml .rep} +Attribute `Nullable` +::: + +::: csdl +The value of `Nullable` is one of the Boolean literals `true` or +`false`. + +If no value is specified, the `Nullable` attribute defaults to `false`. + +In OData 4.0 responses this attribute MUST NOT be specified. +::: + +## ##subsec Navigation Property Binding + +If the entity type of an entity set or singleton declares navigation +properties, a navigation property binding allows describing which entity +set or singleton will contain the related entities. + +An [entity set](#EntitySet) or a [singleton](#Singleton) SHOULD contain +a navigation property binding for each [navigation +property](#NavigationProperty) of its entity type, including navigation +properties defined on complex typed properties. + +If omitted, clients MUST assume that the target entity set or singleton +can vary per related entity. + +### ##subsubsec Navigation Property Path Binding + +A navigation property binding MUST specify a path to a navigation +property of the entity set's or singleton\'s declared entity type, or a +navigation property reached through a chain of type casts, complex +properties, or containment navigation properties. If the navigation +property is defined on a subtype, the path MUST contain the [qualified +name](#QualifiedName) of the subtype, followed by a forward slash, +followed by the navigation property name. If the navigation property is +defined on a complex type used in the definition of the entity set's +entity type, the path attribute MUST contain a forward-slash separated +list of complex property names and qualified type names that describe +the path leading to the navigation property. + +The path can traverse one or more containment navigation properties but +the last navigation property segment MUST be a non-containment +navigation property and there MUST NOT be any non-containment navigation +properties prior to the final navigation property segment. + +If the path traverses collection-valued complex properties or +collection-valued containment navigation properties, the binding applies +to all items of these collections. + +If the path contains a recursive sub-path (i.e. a path leading back to +the same structured type, the binding applies recursively to any +positive number of cycles through that sub-path. + +OData 4.01 services MAY have a type-cast segment as the last path +segment, allowing to bind instances of different sub-types to different +targets. + +The same navigation property path MUST NOT be specified in more than one +navigation property binding; navigation property bindings are only used +when all related entities are known to come from a single entity set. +Note that it is possible to have navigation property bindings for paths +that differ only in a type-cast segment, allowing to bind instances of +different sub-types to different targets. If paths differ only in +type-cast segments, the most specific path applies. + +### ##subsubsec Binding Target + +A navigation property binding MUST specify a target via a [simple +identifier](#SimpleIdentifier) or [target path](#TargetPath). It +specifies the entity set, singleton, or containment navigation property +that contains the entities. + +If the target is a [simple identifier](#SimpleIdentifier), it MUST +resolve to an entity set or singleton defined in the same entity +container as the enclosing element. + +If the target is a [target path](#TargetPath), it MUST resolve to an +entity set, singleton, or direct or indirect containment navigation +property of a singleton in scope. The path can traverse single-valued +containment navigation properties or single-valued complex properties +before ending in a containment navigation property, and there MUST NOT +be any non-containment navigation properties prior to the final segment. + +::: {.varxml .rep} +Element `edm:NavigationPropertyBinding` +::: + +::: csdl +The `edm:NavigationPropertyBinding` element MUST contain the attributes +`Path` and `Target`. +::: + +::: {.varxml .rep} +Attribute `Path` +::: + +::: csdl +The value of `Path` is a path expression. +::: + +::: {.varxml .rep} +Attribute `Target` +::: + +::: csdl +The value of `Target` is a [target path](#TargetPath). +::: + +::: {.varxml .example} +Example ##ex: for an entity set in the same container as the enclosing +entity set `Categories` +``` +[[\\ +  \ + +``` + +::: {.varxml .example} +Example ##ex: for an entity set in any container in scope +``` +[[\\ +  \ + +``` + +::: {.varxml .example} +Example ##ex: binding `Supplier` on `Products` contained within +`Categories – binding applies to all suppliers of all products of all categories` +``` +[[\\ +  \ + +``` + +## ##subsec Action Import + +Action imports sets are top-level resources that are never included in +the service document. + +An action import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +An action import MUST specify the name of an unbound action in scope. + +If the imported action returns an entity or a collection of entities, a +[simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +::: {.varxml .rep} +Element `edm:ActionImport` +::: + +::: csdl +The `edm:ActionImport` element MUST contain the attributes `Name` and +`Action`, and it MAY contain the `EntitySet` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the action import's name. +::: + +::: {.varxml .rep} +Attribute `Action` +::: + +::: csdl +The value of `Action` is the qualified name of an unbound action. +::: + +::: {.varxml .rep} +Attribute `EntitySet` +::: + +::: csdl +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. +::: + +## ##subsec Function Import + +Function imports sets are top-level resources. + +A function import is identified by its name, a [simple +identifier](#SimpleIdentifier) that MUST be unique within its entity +container. + +A function import MUST specify the name of an unbound function in scope. +All unbound [overloads](#FunctionOverloads) of an imported function can +be invoked from the entity container. + +If the imported function returns an entity or a collection of entities, +a [simple identifier](#SimpleIdentifier) or [target path](#TargetPath) +value MAY be specified to identify the entity set that contains the +returned entities. If a [simple identifier](#SimpleIdentifier) is +specified, it MUST resolve to an entity set defined in the same entity +container. If a [target path](#TargetPath) is specified, it MUST resolve +to an entity set in scope. + +A function import for a parameterless function MAY indicate whether it +is included in the service document. If not explicitly indicated, it is +not included. + +::: {.varxml .rep} +Element `edm:FunctionImport` +::: + +::: csdl +The `edm:FunctionImport` element MUST contain the attributes `Name` and +`Function`, and it MAY contain the attributes `EntitySet` and +`IncludeInServiceDocument`. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the function import's name. +::: + +::: {.varxml .rep} +Attribute `Function` +::: + +::: csdl +The value of `Function` is the qualified name of an unbound function. +::: + +::: {.varxml .rep} +Attribute `EntitySet` +::: + +::: csdl +The value of `EntitySet` is either the unqualified name of an entity set +in the same entity container or a path to an entity set in a different +entity container. +::: + +::: {.varxml .rep} +Attribute `IncludeInServiceDocument` +::: + +::: csdl +The value of `IncludeInServiceDocument` is one of the Boolean literals +`true` or `false`. Absence of the attribute means `false`. +::: + +# ##sec Vocabulary and Annotation + +Vocabularies and annotations provide the ability to annotate metadata as +well as instance data, and define a powerful extensibility point for +OData. An [*annotation*](#Annotation) applies a [*term*](#Term) to a +model element and defines how to calculate a value for the applied term. + +*Metadata annotations* are terms applied to model elements. Behaviors or +constraints described by a metadata annotation must be consistent with +the annotated model element. Such annotations define additional +behaviors or constraints on the model element, such as a service, entity +type, property, function, action, or parameter. For example, a metadata +annotation may define ranges of valid values for a particular property. +Metadata annotations are applied in CSDL documents describing or +referencing an entity model. + +*Instance annotations* are terms applied to a particular instance within +an OData payload, such as described in [OData‑JSON](#ODataJSON). An +instance annotation can be used to define additional information +associated with a particular result, entity, property, or error. For +example, whether a property is read-only for a particular instance. +Where the same annotation is defined at both the metadata and instance +level, the instance-level annotation overrides the annotation specified +at the metadata level. Annotations that apply across instances should be +specified as metadata annotations. + +A *vocabulary* is a schema containing a set of terms where each +[term](#Term) is a named metadata extension. Anyone can define a +vocabulary (a set of terms) that is scenario-specific or +company-specific; more commonly used terms can be published as shared +vocabularies such as the OData Core vocabulary +[OData‑VocCore](#ODataVocCore). + +A [term](#Term) can be used to: +- Extend model elements and type instances +with additional information. +- Map instances of annotated structured +types to an interface defined by the term type; i.e. annotations allow +viewing instances of a structured type as instances of a differently +structured type specified by the applied term. + +A service SHOULD NOT require a client to interpret annotations. Clients +SHOULD ignore invalid or unknown terms and silently treat unexpected or +invalid values (including invalid type, invalid literal expression, +invalid targets, etc.) as an unknown value for the term. Unknown or +invalid annotations should never result in an error, as long as the +payload remains well-formed. + +::: {.varxml .example} +Example ##ex: the `Product` entity type is extended with a `DisplayName` +by a metadata annotation that binds the term `DisplayName` to the value +of the property `Name`. The `Product` entity type also includes an +annotation that allows its instances to be viewed as instances of the +type specified by the term `SearchResult` +``` +[[\\ +  \]{style="color:black"}]{.Datatype} +::: + +`    ` + +[[  \\ +  \\ +  \\ +  \\ +  ...  ]{style="color:black"}]{.Datatype} + +[[  \\ +  \]{style="color:black"}]{.Datatype} + +[[    \\ +      \\ +      \\ +      \\ +        \\ +          \Products(\\ +          \ID\\ +          \)\\ +        \\ +      \]{style="color:black"}]{.Datatype} + +[[    \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec Term + +A term allows annotating a CSDL element or OData resource representation +with additional data. + +The term's name is a [simple identifier](#SimpleIdentifier) that MUST be +unique within its schema. + +The term's type MUST be a type in scope, or a collection of a type in +scope. + +::: {.varxml .rep} +Element `edm:Term` +::: + +::: csdl +The `edm:Term` element MUST contain the attributes `Name` and `Type`. It +MAY contain the attributes `BaseTerm` and `AppliesTo`. + +It MAY specify values for the [`Nullable`](#Nullable), +[ ]{.apple-converted-space}[`MaxLength`](#MaxLength), +[`Precision`](#Precision), [`Scale`](#Scale), or [`SRID`](#SRID) facet +attributes, as well as the [`Unicode`](#Unicode) facet attribute for +4.01 and greater payloads. These facets and their implications are +described in section 7.2. + +A `edm:Term` element whose `Type` attribute specifies a primitive or +enumeration type MAY define a value for the `DefaultValue` attribute. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the term's name. +::: + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +For single-valued properties the value of `Type` is the qualified name +of the property's type. + +For collection-valued properties the value of `Type` is the character +sequence `Collection(` followed by the qualified name of the property's +item type, followed by a closing parenthesis `)`. +::: + +::: {.varxml .rep} +Attribute `DefaultValue` +::: + +::: csdl +The value of this attribute determines the value of the term when +applied in an [`edm:Annotation`](#Annotation) without providing an +expression. + +Default values of type `Edm.String` MUST be represented according to the +XML escaping rules for character data in attribute values. Values of +other primitive types MUST be represented according to the appropriate +alternative in the `primitiveValue` rule defined in +[OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as `binaryValue`, +`Edm.Boolean` as `booleanValue` etc. + +If no value is specified, the `DefaultValue` attribute defaults to +`null`. +::: + +### ##subsubsec Specialized Term + +A term MAY specialize another term in scope by specifying it as its base +type. + +When applying a term with a base term, the base term MUST also be +applied with the same qualifier, and so on until a term without a base +term is reached. + +::: {.varxml .rep} +Attribute `BaseTerm` +::: + +::: csdl +The value of `BaseTerm` is the qualified name of the base term. +::: + +### ##subsubsec Applicability + +The applicability of a term MAY be restricted to a list of model +elements. If no list is supplied, the term is not intended to be +restricted in its application. The list of model elements MAY be +extended in future versions of the vocabulary. As the intended usage may +evolve over time, clients SHOULD be prepared for any term to be applied +to any model element and SHOULD be prepared to handle unknown values +within the `AppliesTo` attribute. Applicability is expressed using the +following symbolic values: + + **Symbolic Value** **Model Element** + ------------------------- ----------------------------------------------------------------- + `Action` Action + `ActionImport` Action Import + `Annotation` Annotation + `Apply` Application of a client-side function in an annotation + `Cast` Type Cast annotation expression + `Collection` Entity Set or collection-valued Property or Navigation Property + `ComplexType` Complex Type + `EntityContainer` Entity Container + `EntitySet` Entity Set + `EntityType` Entity Type + `EnumType` Enumeration Type + `Function` Function + `FunctionImport` Function Import + `If` Conditional annotation expression + `Include` Reference to an Included Schema + `IsOf` Type Check annotation expression + `LabeledElement` Labeled Element expression + `Member` Enumeration Member + `NavigationProperty` Navigation Property + `Null` Null annotation expression + `OnDelete` On-Delete Action of a navigation property + `Parameter` Action of Function Parameter + `Property` Property of a structured type + `PropertyValue` Property value of a Record annotation expression + `Record` Record annotation expression + `Reference` Reference to another CSDL document + `ReferentialConstraint` Referential Constraint of a navigation property + `ReturnType` Return Type of an Action or Function + `Schema` Schema + `Singleton` Singleton + `Term` Term + `TypeDefinition` Type Definition + `UrlRef` UrlRef annotation expression + +::: {.varxml .rep} +Attribute `AppliesTo` +::: + +::: csdl +The value of `AppliesTo` is a whitespace-separated list of symbolic +values from the table above that identify model elements the term is +intended to be applied to. +::: + +::: {.varxml .example} +Example ##ex: the `IsURL` term can be applied to properties and terms that +are of type `Edm.String` (the `Core.Tag` type and the two `Core` terms +are defined in [OData‑VocCore](#ODataVocCore)) +``` +[\\ +  \\ +    \\ +      Properties and terms annotated with this term MUST contain a valid +URL]{style="color:black"} +::: + +[    \\ +  \]{style="color:black"} + +  \ + +\ +``` + +## ##subsec Annotation + +An annotation applies a [term](#Term) to a model element and defines how +to calculate a value for the term application. Both term and model +element MUST be in scope. Section 14.1.2 specifies which model elements +MAY be annotated with a term. + +The value of an annotation is specified as an *annotation expression*, +which is either a [constant expression](#ConstantExpression) +representing a constant value, or a [dynamic +expression](#DynamicExpression). The most common construct for assigning +an annotation value is a [path expression](#ValuePath) that refers to a +property of the same or a related structured type. + +::: {.varxml .rep} +Element `edm:Annotation` +::: + +::: csdl +The `edm:Annotation` element MUST contain the attribute `Term`, and it +MAY contain the attribute [`Qualifier`](#Qualifier). + +The value of the annotation MAY be a [constant +expression](#ConstantExpression) or [dynamic +expression](#DynamicExpression). + +If no expression is specified for a term with a primitive type, the +annotation evaluates to the [default value](#DefaultValue) of the term +definition. If no expression is specified for a term with a complex +type, the annotation evaluates to a complex instance with default values +for its properties. If no expression is specified for a +collection-valued term, the annotation evaluates to an empty collection. + +An `edm:Annotation` element can be used as a child of the model element +it annotates, or as the child of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element that +targets the model element to be annotated. + +An `edm:Annotation` element MAY contain [`edm:Annotation`](#Annotation) +elements that annotate the annotation. +::: + +::: {.varxml .rep} +Attribute `Term` +::: + +::: csdl +The value of `Term` is the qualified name of a [term](#Term) in scope. +::: + +::: {.varxml .example} +Example ##ex: term `Measures.ISOCurrency`, once applied with a constant +value, once with a path value +``` +[[\\ +  \]{style="color:black"}]{.Datatype} +::: + +[[    \]{style="color:black"}]{.Datatype} + +`  +` + +[[\\ +  \]{style="color:black"}]{.Datatype} + +` + +``` + +If an entity type or complex type is annotated with a term that itself +has a structured type, an instance of the annotated type may be viewed +as an "instance" of the term, and the qualified term name may be used as +a [term-cast segment](#ref_TermCast) in path expressions. + +Structured types "inherit" annotations from their direct or indirect +base types. If both the type and one of its base types is annotated with +the same term and qualifier, the annotation on the type completely +replaces the annotation on the base type; structured or +collection-valued annotation values are not merged. Similarly, +properties of a structured type inherit annotations from identically +named properties of a base type. + +It is up to the definition of a term to specify whether and how +annotations with this term propagate to places where the annotated model +element is used, and whether they can be overridden. E.g. a \"Label\" +annotation for a UI can propagate from a type definition to all +properties using that type definition and may be overridden at each +property with a more specific label, whereas an annotation marking a +type definition as containing a phone number will propagate to all using +properties but may not be overridden. + +### ##subsubsec Qualifier + +A term can be applied multiple times to the same model element by +providing a qualifier to distinguish the annotations. The qualifier is a +[simple identifier](#SimpleIdentifier). + +The combination of target model element, term, and qualifier uniquely +identifies an annotation. + +::: {.varxml .rep} +Attribute `Qualifier` +::: + +::: csdl +Annotation elements that are children of an +[`edm:Annotations`](#AnnotationswithExternalTargeting) element MUST NOT +provide a value for the qualifier attribute if the parent +[`edm:Annotations`](#AnnotationswithExternalTargeting) element provides +a value for the qualifier attribute. +::: + +::: {.varxml .example} +Example ##ex: annotation should only be applied to tablet devices +``` +[[\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Target + +The target of an annotation is the model element the term is applied to. + +The target of an annotation MAY be specified indirectly by "nesting" the +annotation within the model element. Whether and how this is possible is +described per model element in this specification. + +The target of an annotation MAY also be specified directly; this allows +defining an annotation in a different schema than the targeted model +element. + +This external targeting is only possible for model elements that are +uniquely identified within their parent, and all their ancestor elements +are uniquely identified within their parent: + +- [Action](#Action)[ (single or all overloads)]{style="color:black; + background:white"} +- [Action Import](#ActionImport) +- [Annotation](#Annotation) +- [Complex Type](#ComplexType) +- [Entity Container](#EntityContainer) +- [Entity Set](#EntitySet) +- [Entity Type](#EntityType) +- [Enumeration Type](#EnumerationType) +- [Enumeration Type Member](#EnumerationTypeMember) +- [Function](#Function)[ (single or all + overloads)]{style="color:black;background:white"} +- [Function Import](#FunctionImport) +- [Navigation Property](#NavigationProperty) (via type, entity set, or + singleton) +- [Parameter](#Parameter)[ of an action or function (single overload + or all overloads defining the + parameter)]{style="color:black;background:white"} +- [Property](#StructuralProperty) (via type, entity set, or singleton) +- [Return Type](#ReturnType)[ of an action or function + ([single]{#_Hlk523392241} or all + overloads)]{style="color:black;background:white"} +- [Singleton](#Singleton) +- [Type Definition](#TypeDefinition) + +These are the direct children of a schema with a unique name (i.e. +except actions and functions whose overloads to not possess a natural +identifier), and all direct children of an entity container. + +External targeting is possible for actions, functions, their parameters, +and their return type, either in a way that applies to all overloads of +the action or function or all parameters of that name across all +overloads, or in a way that identifies a single overload. + +External targeting is also possible for properties and navigation +properties of singletons or entities in a particular entity set. These +annotations override annotations on the properties or navigation +properties targeted via the declaring structured type. + +The allowed path expressions are: +- [qualified name](#QualifiedName) +of schema child +- [qualified +name](#QualifiedName) of schema child followed by a forward slash and +name of child element +- [qualified +name](#QualifiedName) of structured type followed by zero or more +property, navigation property, or type-cast segments, each segment +starting with a forward slash +- [qualified +name](#QualifiedName) of an entity container followed by a segment +containing a singleton or entity set name and zero or more property, +navigation property, or type-cast segments +- [qualified +name](#QualifiedName)[ of an action followed by parentheses containing +the binding parameter *type* of a bound action overload to identify that +bound overload, or by empty parentheses to identify the unbound +overload]{style="color:black;background:white"} +- [qualified +name](#QualifiedName)[ of a function followed by parentheses containing +the comma-separated list of the parameter *types* of a bound or unbound +function overload in the order of their definition in the function +overload]{style="color:black;background:white"} +- [qualified +name](#QualifiedName) of an action or function, optionally followed by +parentheses as described in the two previous bullet points to identify a +single overload, followed by a forward slash and either a parameter name +or `$ReturnType` +- [qualified +name](#QualifiedName) of an entity container followed by a segment +containing an action or function import name, optionally followed by a +forward slash and either a parameter name or `$ReturnType` + +- One of the preceding, followed by a forward slash, an at (`@`), the + [qualified name](#QualifiedName)[ of a term, and optionally a hash + (]{style="color:black;background:white"}`#`) and the qualifier of an + annotation + +All [qualified names](#QualifiedName) used in a target path MUST be in +scope. + +::: {.varxml .example} +Example ##ex: Target expressions +``` +MySchema.MyEntityType +::: + +MySchema.MyEntityType/MyProperty + +MySchema.MyEntityType/MyNavigationProperty + +MySchema.MyComplexType + +MySchema.MyComplexType/MyProperty + +MySchema.MyComplexType/MyNavigationProperty + +MySchema.MyEnumType + +MySchema.MyEnumType/MyMember + +MySchema.MyTypeDefinition + +MySchema.MyTerm + +MySchema.MyEntityContainer + +MySchema.MyEntityContainer/MyEntitySet + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MyActionImport + +MySchema.MyEntityContainer/MyFunctionImport + +MySchema.MyAction + +MySchema.MyAction(MySchema.MyBindingType) + +MySchema.MyAction(Collection(MySchema.MyBindingType)) + +MySchema.MyAction() + +MySchema.MyFunction + +MySchema.MyFunction(MySchema.MyBindingParamType,First.NonBinding.ParamType) + +MySchema.MyFunction(First.NonBinding.ParamType,Second.NonBinding.ParamType) + +MySchema.MyFunction/MyParameter + +MySchema.MyEntityContainer/MyEntitySet/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyNavProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty + +MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyNavigationProperty +``` + +## ##subsec Constant Expression + +Constant expressions allow assigning a constant value to an applied +term. + +### ##subsubsec Binary + +::: {.varxml .rep} +Expression `edm:Binary` +::: + +::: csdl +The `edm:Binary` expression evaluates to a primitive binary value. A +binary expression MUST be assigned a value conforming to the rule +`binaryValue` in [OData‑ABNF](#ODataABNF). + +The binary expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: base64url-encoded binary value (OData) +``` +[[\\ +\ +\\ +  \T0RhdGE\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Boolean + +::: {.varxml .rep} +Expression `edm:Bool` +::: + +::: csdl +The `edm:Bool` expression evaluates to a primitive Boolean value. A +Boolean expression MUST be assigned a Boolean value. + +The Boolean expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +\ +\\ +  \true\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Date + +::: {.varxml .rep} +Expression `edm:Date` +::: + +::: csdl +The `edm:Date` expression evaluates to a primitive date value. A date +expression MUST be assigned a value of type `xs:date`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.3.9](http://www.w3.org/TR/xmlschema11-2/#date). The value MUST also +conform to rule `dateValue` in [OData‑ABNF](#ODataABNF), i.e. it MUST +NOT contain a time-zone offset. + +The date expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +\ +\\ +  \2000-01-01\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec DateTimeOffset + +::: {.varxml .rep} +Expression `edm:DateTimeOffset` +::: + +::: csdl +The `edm:DateTimeOffset` expression evaluates to a primitive +datetimestamp value with a time-zone offset. A datetimestamp expression +MUST be assigned a value of type `xs:dateTimeStamp`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.4.28](http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp). The value +MUST also conform to rule `dateTimeOffsetValue` in +[OData‑ABNF](#ODataABNF), i.e. it MUST NOT contain an end-of-day +fragment (24:00:00). + +The datetimestamp expression MAY be provided using element notation or +attribute notation`.` +::: + +::: {.varxml .example} +Example ##ex: +``` +\ +\ +\\ +  \2000-01-01T16:00:00.000-09:00\\ +\]{style="color:black"}]{.Datatype} +``` + +### ##subsubsec Decimal + +::: {.varxml .rep} +Expression `edm:Decimal` +::: + +::: csdl +The `edm:Decimal` expression evaluates to a primitive decimal value. A +decimal expression MUST be assigned a value conforming to the rule +`decimalValue` in [OData‑ABNF](#ODataABNF). + +The decimal expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: attribute notation +``` + +``` +::: + +::: {.varxml .example} +Example ##ex: element notation +``` +[[\\ +  \3.14\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Duration + +::: {.varxml .rep} +Expression `edm:Duration` +::: + +::: csdl +The `edm:Duration` expression evaluates to a primitive duration value. A +duration expression MUST be assigned a value of type +`xs:dayTimeDuration`, see [**\[XML‑Schema‑2\]**](#BMXMLSchema2), +[section 3.4.27](http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration). + +The duration expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +\ +\\ +  \P11DT23H59M59.999999999999S\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Enumeration Member + +::: {.varxml .rep} +Expression `edm:EnumMember  ` +::: + +::: csdl +The `edm:EnumMember` expression references a +[member](#EnumerationTypeMember) of an [enumeration +type](#EnumerationType). An enumeration member expression MUST be +assigned a value that consists of the qualified name of the enumeration +type, followed by a forward slash and the name of the enumeration +member. If the enumeration type specifies an `IsFlags` attribute with +value `true`, the expression MAY also be assigned a whitespace-separated +list of values. Each of these values MUST resolve to the name of a +member of the enumeration type of the specified term. + +The enumeration member expression MAY be provided using element notation +or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: single value +``` +[[\\ +\ +\\ +  \org.example.Pattern/Red\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +::: {.varxml .example} +Example ##ex: combined value for `IsFlags` enumeration type +``` +[[\\ +\ +\\ +  \org.example.Pattern/Red +org.example.Pattern/Striped\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Floating-Point Number + +::: {.varxml .rep} +Expression `edm:Float` +::: + +::: csdl +The `edm:Float` expression evaluates to a primitive floating point (or +double) value. A float expression MUST be assigned a value conforming to +the rule `doubleValue` in [OData‑ABNF](#ODataABNF). + +The float expression MAY be provided using element notation or attribute +notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +\ +\\ +  \3.14\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Guid + +::: {.varxml .rep} +Expression `edm:Guid` +::: + +::: csdl +The `edm:Guid` expression evaluates to a primitive guid value. A guid +expression MUST be assigned a value conforming to the rule `guidValue` +in [OData‑ABNF](#ODataABNF). + +The guid expression MAY be provided using element notation or attribute +notation`.` +::: + +::: {.varxml .example} +Example ##ex: +``` +\ +\ +\\ +  \21EC2020-3AEA-1069-A2DD-08002B30309D\\ +\]{style="color:black"}]{.Datatype} +``` + +### ##subsubsec Integer + +::: {.varxml .rep} +Expression `edm:Int` +::: + +::: csdl +The `edm:Int` expression evaluates to a primitive integer value. An +integer MUST be assigned a value conforming to the rule `int64Value` in +[OData‑ABNF](#ODataABNF). + +The integer expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: attribute notation +``` + +``` +::: + +::: {.varxml .example} +Example ##ex: element notation +``` +[[\\ +  \42\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec String + +::: {.varxml .rep} +Expression `edm:String` +::: + +::: csdl +The `edm:String` expression evaluates to a primitive string value. A +string expression MUST be assigned a value of the type `xs:string`, see +[**\[XML‑Schema‑2\]**](#BMXMLSchema2), [section +3.3.1](http://www.w3.org/TR/xmlschema11-2/#string). + +The string expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +\ +\\ +  \Product Catalog\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Time of Day + +::: {.varxml .rep} +Expression `edm:TimeOfDay` +::: + +::: csdl +The `edm:TimeOfDay` expression evaluates to a primitive time value. A +time-of-day expression MUST be assigned a value conforming to the rule +`timeOfDayValue` in [OData‑ABNF](#ODataABNF). + +The time-of-day expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +\ +\\ +  \21:45:00\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +## ##subsec Dynamic Expression + +Dynamic expressions allow assigning a calculated value to an applied +term. + +### ##subsubsec Path Expressions + +Path expressions allow assigning a value to an applied term or term +component. There are two kinds of path expressions: +- [[A *model path* is used within +]{style="font-family:\"Arial\",sans-serif"}]{.Datatype}[Annotation +Path](#AnnotationPath), [Model Element Path](#ModelElementPath), +[Navigation Property Path](#NavigationPropertyPath), and [Property +Path](#PropertyPath) expressions to traverse the model of a service and +resolves to the model element identified by the path. It allows +assigning values to terms or term properties of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) `Edm.AnnotationPath`, +`Edm.NavigationPropertyPath`, `Edm.PropertyPath`, and their base types +`Edm.AnyPropertyPath` and `Edm.ModelElementPath`. +- An *instance path* is used within a +[Value Path](#ValuePath) expression to traverse a graph of type +instances and resolves to the value identified by the path. It allows +assigning values to terms or term properties of built-in types other +than the `Edm.*Path` types, or of any model-defined type. + +#### ##subsubsubsec Path Syntax + +Model paths and instance paths share a common syntax which is derived +from the path expression syntax of URLs, see [OData‑URL](#ODataURL). + +A path MUST be composed of zero or more path segments joined together by +forward slashes (`/`). + +Paths starting with a forward slash (`/`) are absolute paths, and the +first path segment MUST be the qualified name of a model element, e.g. +an entity container. The remaining path after the second forward slash +is interpreted relative to that model element. + +::: {.varxml .example} +Example ##ex: absolute path to an entity set +``` +/self.MyEntityContainer/MyEntitySet +``` +::: + +Paths not starting with a forward slash are interpreted relative to the +annotation target, following the rules specified in section "[Path +Evaluation](#PathEvaluation)". + +::: {.varxml .example} +Example ##ex: relative path to a property +``` +Address/City +``` +::: + +If a path segment is a [qualified name](#QualifiedName), it represents a +[*type cast*]{#ref_TypeCast}, and the segment MUST be the name of a type +in scope. If the type or instance identified by the preceding path part +cannot be cast to the specified type, the path expression evaluates to +the null value. + +::: {.varxml .example} +Example ##ex: type-cast segment +``` +.../self.Manager/... +``` +::: + +If a path segment starts with an at (`@`) character, it represents a +[*term cast*]{#ref_TermCast}. The at (`@`) character MUST be followed by +a [qualified name](#QualifiedName) that MAY be followed by a hash (`#`) +character and a [simple identifier](#SimpleIdentifier). The [qualified +name](#QualifiedName) preceding the hash character MUST resolve to a +term that is in scope, the [simple identifier](#SimpleIdentifier) +following the hash sign is interpreted as a [qualifier](#Qualifier) for +the term. If the model element or instance identified by the preceding +path part has not been annotated with that term (and if present, with +that qualifier), the term cast evaluates to the null value. Four special +terms are implicitly "annotated" for media entities and stream +properties: + +- `odata.mediaEditLink` +- `odata.mediaReadLink` +- `odata.mediaContentType` +- `odata.mediaEtag` + +::: {.varxml .example} +Example ##ex: term-cast segment +``` +.../@Capabilities.SortRestrictions/... +``` +::: + +If a path segment is a [simple identifier](#SimpleIdentifier), it MUST +be the name of a child model element of the model element identified by +the preceding path part, or a structural or navigation property of the +instance identified by the preceding path part. A sequence of navigation +segments can traverse multiple CSDL documents. The document containing +the path expression only needs to reference the next traversed document +to bring the navigation target type into scope, and each traversed +document in turn needs to reference only its next document. + +A model path MAY contain any number of segments representing +collection-valued structural or navigation properties. The result of the +expression is the model element reached via this path. + +::: {.varxml .example} +Example ##ex: property segment in model path +``` +.../Orders/Items/Product/... +``` +::: + +An instance path MUST NOT contain more than one segment representing a +collection-valued construct, e.g. an entity set or a collection-valued +navigation property that is not followed by a key predicate, or a +collection-valued structural property that is not followed by an index +segment. The result of the expression is the collection of instances +resulting from applying any remaining segments that operate on a +single-valued expression to each instance in the collection-valued +segment. + +An instance path MAY terminate in a `$count` segment if the previous +segment is collection-valued, in which case the path evaluates to the +number of items in the collection identified by the preceding segment. + +::: {.varxml .example} +Example ##ex: property segments in instance path +``` +.../Addresses/Street +::: + +.../Addresses/\$count +``` + +A model path MAY contain path segments starting with a navigation +property, then followed by an at (`@`) character, then followed by the +[qualified name](#QualifiedName) of a term in scope, and optionally +followed by a hash (`#`) character and a [simple +identifier](#SimpleIdentifier) which is interpreted as a +[qualifier](#Qualifier) for the term. If the navigation property has not +been annotated with that term (and if present, with that qualifier), the +path segment evaluates to the null value. This allows addressing +annotations on the navigation property itself; annotations on the entity +type specified by the navigation property are addressed via a [term-cast +segment](#ref_TermCast). + +::: {.varxml .example} +Example ##ex: model path addressing an annotation on a navigation property +``` +.../Items@Capabilities.InsertRestrictions/Insertable +``` +::: + +An instance path MAY contain path segments starting with an entity set +or a collection-valued navigation property, then followed by a key +predicate using parentheses-style convention, see +[OData‑URL](#ODataURL). The key values are either primitive literals or +instance paths. If the key value is a relative instance path, it is +interpreted according to the same rule below as the instance path it is +part of, *not* relative to the instance identified by the preceding path +part. + +::: {.varxml .example} +Example ##ex: instance path with entity set and key predicate +``` +/self.container/SettingsCollection(\'FeatureXxx\')/IsAvailable +::: + +/self.container/Products(ID=ProductID)/Name +``` + +An instance path MAY contain an index segment immediately following a +path segment representing an ordered collection-valued structural +property. The index is zero-based and MUST be an integer literal. +Negative integers count from the end of the collection, with -1 +representing the last item in the collection. Remaining path segments +are evaluated relative to the identified item of the collection. + +::: {.varxml .example} +Example ##ex: instance path with collection-valued structural property and +index segment +``` +Addresses/1 +::: + +Addresses/-1/Street +``` + +#### ##subsubsubsec Path Evaluation + +Annotations MAY be embedded within their target, or specified +separately, e.g. as part of a different schema, and specify a path to +their target model element. The latter situation is referred to as +*targeting* in the remainder of this section. + +For annotations embedded within or targeting an entity container, the +path is evaluated starting at the entity container, i.e. an empty path +resolves to the entity container, and non-empty paths MUST start with a +segment identifying a container child (entity set, function import, +action import, or singleton). The subsequent segments follow the rules +for path expressions targeting the corresponding child element. + +For annotations embedded within or targeting an entity set or a +singleton, the path is evaluated starting at the entity set or +singleton, i.e. an empty path resolves to the entity set or singleton, +and non-empty paths MUST follow the rules for annotations targeting the +declared entity type of the entity set or singleton. + +For annotations embedded within or targeting an entity type or complex +type, the path is evaluated starting at the type, i.e. an empty path +resolves to the type, and the first segment of a non-empty path MUST be +a structural or navigation property of the type, a [type +cast](#ref_TypeCast), or a [term cast](#ref_TermCast). + +For annotations embedded within a structural or navigation property of +an entity type or complex type, the path is evaluated starting at the +directly enclosing type. This allows e.g. specifying the value of an +annotation on one property to be calculated from values of other +properties of the same type. An empty path resolves to the enclosing +type, and non-empty paths MUST follow the rules for annotations +targeting the directly enclosing type. + +For annotations targeting a structural or navigation property of an +entity type or complex type, the path is evaluated starting at the +*outermost* entity type or complex type named in the target of the +annotation, i.e. an empty path resolves to the outermost type, and the +first segment of a non-empty path MUST be a structural or navigation +property of the outermost type, a [type cast](#ref_TypeCast), or a [term +cast](#ref_TermCast). + +For annotations embedded within or targeting an action, action import, +function, function import, parameter, or return type, the first segment +of the path MUST be a parameter name or `$ReturnType`. + +#### ##subsubsubsec Annotation Path + +The annotation path expression provides a value for terms or term +properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.AnnotationPath or Edm.ModelElementPath`. Its argument is a [model +path](#PathExpressions) with the following restriction: +- `A non-null path MUST resolve to an annotation. ` + +A term or term property of type `Edm.AnnotationPath` can be annotated +with term `Validation.AllowedTerms` (see +[OData-VocValidation](#ODataVocValidation)) if its intended value is an +annotation path that ends in a term cast with one of the listed terms. + +The value of the annotation path expression is the path itself, not the +value of the annotation identified by the path. This is useful for terms +that reuse or refer to other terms. + +::: {.varxml .rep} +Expression `edm:AnnotationPath` +::: + +::: csdl +The `edm:AnnotationPath` expression MAY be provided using element +notation or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[\ +]{style="color:black"} +::: + +  + +\ + +  \ + +    \Supplier/@Communication.Contact\ + +    \Customer/@Communication.Contact\ + +  \ + +\ +``` + +#### ##subsubsubsec Model Element Path + +The model element path expression provides a value for terms or term +properties that specify the [built-in +type](#BuiltInTypesfordefiningVocabularyTer)` Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions). + +The value of the model element path expression is the path itself, not +the instance(s) identified by the path. + +::: {.varxml .rep} +Expression `edm:ModelElementPath` +::: + +::: csdl +The `edm:ModelElementPath` expression MAY be provided using element +notation or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` + +  +/org.example.someAction + +``` +::: + +#### ##subsubsubsec Navigation Property Path + +The navigation property path expression provides a value for terms or +term properties that specify the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.NavigationPropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. +Its argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is an entity type, or a collection of entity types, +e.g. a navigation property. + +The value of the navigation property path expression is the path itself, +not the instance(s) identified by the path. + +::: {.varxml .rep} +Expression `edm:NavigationPropertyPath` +::: + +::: csdl +The `edm:NavigationPropertyPath` expression MAY be provided using +element notation or attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` + +  +` +::: + +[[  \\ +    \]{style="color:black"}]{.Datatype} + +`       +        Supplier +        Category +       +    +  + +``` + +#### ##subsubsubsec Property Path + +The property path expression provides a value for terms or term +properties that specify one of the [built-in +types](#BuiltInTypesfordefiningVocabularyTer) +`Edm.PropertyPath, Edm.AnyPropertyPath, or Edm.ModelElementPath`. Its +argument is a [model path](#PathExpressions) with the following +restriction: +- A non-null path MUST resolve to a model +element whose type is a primitive or complex type, an enumeration type, +a type definition, or a collection of one of these types. + +The value of the property path expression is the path itself, not the +value of the property or the value of the term cast identified by the +path. + +::: {.varxml .rep} +Expression `edm:PropertyPath` +::: + +::: csdl +The `edm:PropertyPath` MAY be provided using either element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` + + ` +::: + +[[\\ +  \\ +    \]{style="color:black"}]{.Datatype} + +`       +        CreatedAt +        ChangedAt +       +    +  + +``` + +#### ##subsubsubsec Value Path + +The` value path` expression allows assigning a value by traversing an +object graph. It can be used in annotations that target entity +containers, entity sets, entity types, complex types, navigation +properties of structured types, and properties of structured types. Its +argument is an [instance path](#PathExpressions). + +The value of the path expression is the instance or collection of +instances identified by the path. + +::: {.varxml .rep} +Expression `edm:Path` +::: + +::: csdl +The `edm:Path` expression MAY be provided using element notation or +attribute notation. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +\ +\\ +  \@vCard.Address#work/FullName\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Comparison and Logical Operators + +Annotations MAY use the following logical and comparison expressions +which evaluate to a Boolean value. These expressions MAY be combined and +they MAY be used anywhere instead of a Boolean expression. + + **Operator** **Description** + -------------------------- ------------------------------- + **Logical Operators** + `And` `Logical and` + `Or` `Logical or` + `Not` `Logical negation` + **Comparison Operators** + `Eq` `Equal` + `Ne` `Not equal` + `Gt` `Greater than` + `Ge` `Greater than or equal` + `Lt` Less than + `Le` `Less than or equal` + `Has` `Has enumeration flag(s) set` + `In` `Is in collection` + +The `And` and `Or` operators require two operand expressions that +evaluate to Boolean values. The `Not` operator requires a single operand +expression that evaluates to a Boolean value. For details on null +handling for comparison operators see [OData‑URL](#ODataURL). + +The other comparison operators require two operand expressions that +evaluate to comparable values. + +::: {.varxml .rep} +`Expressions edm:And and edm:Or` +::: + +::: csdl +The `And` and `Or` logical expressions are represented as elements +`edm:And` and `edm:Or` that MUST contain two annotation expressions. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +`Expression ``edm:Not` +::: + +::: csdl +Negation expressions are represented as an element `edm:Not` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +`Expressions ``edm:Eq, edm:Ne, edm:Gt, edm:Ge, edm:Lt, edm:Le, edm:Has, and edm:In` +::: + +::: csdl +All comparison expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example ##ex: +``` +IsMaleIsMarried + +IsMaleIsMarried + +IsMale + +IsMale + +IsMale + +Price20 + +Price10 + +Price20 + +Price100 + +Fabricorg.example.Pattern/Red + +Size +    XS +    S + +``` +::: + +### ##subsubsec Arithmetic Operators + +Annotations MAY use the following arithmetic expressions which evaluate +to a numeric value. These expressions MAY be combined, and they MAY be +used anywhere instead of a numeric expression of the appropriate type. +The semantics and evaluation rules for each arithmetic expression is +identical to the corresponding arithmetic operator defined in +[OData‑URL](#ODataURL). + + **Operator** **Description** + -------------- --------------------------------------------------------------- + `Add` `Addition` + `Sub` `Subtraction` + `Neg` `Negation` + `Mul` `Multiplication` + `Div` `Division (with integer result for integer operands)` + `DivBy` `Division (with fractional result also for integer operands)` + `Mod` `Modulo` + +The `Neg` operator requires a single operand expression that evaluates +to a numeric value. The other arithmetic operators require two operand +expressions that evaluate to numeric values. + +::: {.varxml .rep} +`Expression ``edm:Neg` +::: + +::: csdl +Negation expressions are represented as an element `edm:Neg` that MUST +contain a single annotation expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +`Expressions ``edm:Add, edm:Sub, edm:Mul, edm:Div, edm:DivBy, and edm:Mod` +::: + +::: csdl +These arithmetic expressions are represented as an element that MUST +contain two annotation expressions. + +They MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example ##ex: +``` +StartDateDuration + +RevenueCost + +Height + +NetPriceTaxRate + +
    QuantityQuantityPerParcel +
    +QuantityQuantityPerParcel + +QuantityQuantityPerParcel + +``` +::: + +### ##subsubsec Apply Client-Side Function + +The apply expression enables a value to be obtained by applying a +client-side function. The apply expression MAY have operand expressions. +The operand expressions are used as parameters to the function. + +::: {.varxml .rep} +Expression `edm:Apply` +::: + +::: csdl +The `edm:Apply` element MUST contain the `Function` attribute and MAY +contain annotation expressions as operands for the applied function. + +It MAY contain more [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Function` +::: + +::: csdl +The value of `Function` is the [qualified name](#QualifiedName) of the +client-side function to apply. +::: + +OData defines the following functions. Services MAY support additional +functions that MUST be qualified with a namespace or alias other than +`odata`. Function names qualified with `odata` are reserved for this +specification and its future versions. + +#### ##subsubsubsec Canonical Functions + +All canonical functions defined in [OData‑URL](#ODataURL) can be used as +client-side functions, qualified with the namespace `odata`. The +semantics of these client-side functions is identical to their +counterpart function defined in [OData‑URL](#ODataURL). + +For example, the `odata.concat` client-side function takes two or more +expressions as arguments. Each argument MUST evaluate to a primitive or +enumeration type. It returns a value of type `Edm.String` that is the +concatenation of the literal representations of the results of the +argument expressions. Values of primitive types other than `Edm.String` +are represented according to the appropriate alternative in the +`primitiveValue` rule of [OData‑ABNF](#ODataABNF), i.e. `Edm.Binary` as +`binaryValue`, `Edm.Boolean` as `booleanValue` etc. + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +    \Product: \\ +    \ProductName\\ +    \ (\\ +    +\Available/Quantity\]{style="color:black"}]{.Datatype} +::: + +[[    \ \\ +    \Available/Unit\]{style="color:black"}]{.Datatype} + +`    available)` + +[[  \\ +\]{style="color:black"}]{.Datatype} +``` + +`ProductName` is of type `String`, `Quantity` in complex type +`Available` is of type `Decimal`, and `Unit` in `Available` is of type +enumeration, so the result of the `Path` expression is represented as +the member name of the enumeration value. + +#### ##subsubsubsec [Function `odata.fillUriTemplate`](#FunctionodatafillUriTemplate) + +The `odata.fillUriTemplate` client-side function takes two or more +expressions as arguments and returns a value of type `Edm.String.` + +The first argument MUST be of type `Edm.String` and specifies a URI +template according to [RFC6570](#rfc6570), the other arguments MUST be +[labeled element expressions](#LabeledElement). Each [labeled element +expression](#LabeledElement) specifies the template parameter name in +its `Name` attribute and evaluates to the template parameter value. + +[RFC6570](#rfc6570) defines three kinds of template parameters: simple +values, lists of values, and key-value maps. + +Simple values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a single primitive value. +The literal representation of this value according to +[OData‑ABNF](#ODataABNF) is used to fill the corresponding template +parameter. + +Lists of values are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of primitive +values. + +Key-value maps are represented as [labeled element +expressions](#LabeledElement) that evaluate to a collection of complex +types with two properties that are used in lexicographic order. The +first property is used as key, the second property as value. + +::: {.varxml .example} +Example ##ex: assuming there are no special characters in values of the +`Name property of the Actor` entity +``` +\ +::: + +  \http://host/someAPI/Actors/{actorName}/CV\ + +  \ + +\ +``` + +#### ##subsubsubsec [Function `odata.matchesPattern`](#FunctionodatamatchesPattern) + +The `odata.matchesPattern` client-side function takes two string +expressions as arguments and returns a Boolean value`.` + +The function returns true if the second expression evaluates to an +[**\[ECMAScript\]**](#ECMAScript) (JavaScript) regular expression and +the result of the first argument expression matches that regular +expression, using syntax and semantics of +[**\[ECMAScript\]**](#ECMAScript) regular expressions. + +::: {.varxml .example} +Example ##ex: all non-empty `FirstName` values not containing the letters +`b`, `c`, or `d` evaluate to `true` +``` +\ +::: + +  \FirstName\ + +  \\^\[\^b-d\]+\$\ + +\ +``` + +#### ##subsubsubsec [Function `odata.uriEncode`](#FunctionodatauriEncode) + +The `odata.uriEncode `client-side function takes one argument of +primitive type and returns the URL-encoded OData literal that can be +used as a key value in OData URLs or in the query part of OData URLs. + +Note: string literals are surrounded by single quotes as required by the +paren-style key syntax. + +::: {.varxml .example} +Example ##ex: +``` +\ +::: + +  \http://host/service/Genres({genreName})\ + +  \ + +    \ + +      \NameOfMovieGenre\ + +    \ + +  \ + +\ +``` + +### ##subsubsec Cast + +The cast expression casts the value obtained from its single child +expression to the specified type. The cast expression follows the same +rules as the `cast` canonical function defined in +[OData‑URL](#ODataURL). + +::: {.varxml .rep} +Expression `edm:Cast` +::: + +::: csdl +The `edm:Cast` element MUST contain the `Type` attribute and MUST +contain exactly one expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +The value of `Type` is a qualified type name in scope, or the character +sequence `Collection(` followed by the qualified name of a type in +scope, followed by a closing parenthesis `)`. + +If the specified type is a primitive type or a collection of a primitive +type, the facet attributes [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet attributes are not specified, their values +are considered unspecified. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +    \Average\\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Collection + +The collection expression enables a value to be obtained from zero or +more item expressions. The value calculated by the collection expression +is the collection of the values calculated by each of the item +expressions. The values of the child expressions MUST all be type +compatible. + +::: {.varxml .rep} +Expression `edm:Collection` +::: + +::: csdl +The `edm:Collection` element contains zero or more child expressions. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +    \Product\\ +    \Supplier\\ +    \Customer\\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec If-Then-Else + +The if-then-else expression enables a value to be obtained by evaluating +a *condition expression*. It MUST contain exactly three child +expressions. There is one exception to this rule: if and only if the +if-then-else expression is a direct child of a collection expression`,` +the third child expression MAY be omitted, reducing it to an if-then +expression. This can be used to conditionally add an element to a +collection. + +The first child element is the condition and MUST evaluate to a Boolean +result, e.g. the [comparison and logical +operators](#ComparisonandLogicalOperators) can be used. + +The second and third child elements are evaluated conditionally. The +result MUST be type compatible with the type expected by the surrounding +expression. + +If the first expression evaluates to `true`, the second expression MUST +be evaluated and its value MUST be returned as the result of the +if-then-else expression. If the first expression evaluates to `false` +and a third child element is present, it MUST be evaluated and its value +MUST be returned as the result of the if-then-else expression. If no +third child element is present, nothing is added to the surrounding +collection. + +::: {.varxml .rep} +Expression `edm:If` +::: + +::: csdl +The `edm:If` element MUST contain two or three child expressions that +MUST use element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .example} +Example ##ex: the condition is a [value path expression](#ValuePath) +referencing the Boolean property `IsFemale` ,whose value then determines +the value of the `edm:If` expression +``` +[[\\ +  \\ +    \IsFemale\\ +    \Female\\ +    \Male\\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Is-Of + +The is-of expression checks whether the value obtained from its single +child expression is compatible with the specified type. It returns +`true` if the child expression returns a type that is compatible with +the specified type, and `false` otherwise. + +::: {.varxml .rep} +Expression `edm:IsOf` +::: + +::: csdl +The `edm:IsOf` element MUST contain the `Type` attribute and MUST +contain exactly one child expression. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +The value of `Type` is the qualified name of a type in scope, or the +character sequence `Collection(` followed by the qualified name of a +type in scope, followed by a closing parenthesis `)`. + +If the specified type is a primitive type or a collection of a primitive +type, the facet attributes [`MaxLength`](#MaxLength), +[`Unicode`](#Unicode), [`Precision`](#Precision), [`Scale`](#Scale), and +[`SRID`](#SRID) MAY be specified if applicable to the specified +primitive type. If the facet attributes are not specified, their values +are considered unspecified. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +    \Customer\\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec [Labeled Element](#LabeledElement) + +The labeled element expression assigns a name to its single child +expression. The value of the child expression can then be reused +elsewhere with a [labeled element reference +expression](#LabeledElementReference). + +A labeled element expression MUST contain exactly one child expression. +The value of the child expression is also the value of the labeled +element expression. + +A labeled element expression MUST provide a [simple +identifier](#SimpleIdentifier) value as its name that MUST be unique +within the schema containing the expression. + +::: {.varxml .rep} +Expression `edm:LabeledElement` +::: + +::: csdl +The `edm:LabeledElement` element MUST contain the Name attribute. + +It MUST contain a child expression written either in attribute notation +or element notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Name` +::: + +::: csdl +The value of `Name` is the labeled element's name. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +` ` + +[[\\ +  \\ +    \FirstName\\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +### ##subsubsec Labeled Element Reference + +The labeled element reference expression MUST specify the [qualified +name](#QualifiedName) of a [labeled element expression](#LabeledElement) +in scope and returns the value of the identified labeled element +expression as its value. + +::: {.varxml .rep} +Expression `edm:LabeledElementReference` +::: + +::: csdl +The edm:LabeledElementReference element MUST contain the qualified name +of a labeled element expression in its body. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  +\Model.CustomerFirstName\\ +\]{style="color:black"}]{.Datatype} +``` +::: + +### ##subsubsec Null + +The null expression indicates the absence of a value. The null +expression MAY be annotated. + +The null expression MUST be written with element notation. + +::: {.varxml .rep} +Expression `edm:Null` +::: + +::: csdl +The edm:Null element MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +\]{style="color:black"}]{.Datatype} +``` +::: + +::: {.varxml .example} +Example ##ex: +``` + +     + +``` +::: + +### ##subsubsec Record + +The record expression enables a new entity type or complex type instance +to be constructed. + +A record expression MAY specify the structured type of its result, which +MUST resolve to an entity type or complex type in scope. If not +explicitly specified, the type is derived from the expression's context. + +A record expression contains zero or more property value expressions. +For each single-valued structural or navigation property of the record +expression's type that is neither nullable nor specifies a default value +a property value expression MUST be provided. The only exception is if +the record expression is the value of an annotation for a term that has +a [base term](#SpecializedTerm) whose type is structured and directly or +indirectly inherits from the type of its base term. In this case, +property values that already have been specified in the annotation for +the base term or its base term etc. need not be specified again. + +For collection-valued properties the absence of a property value +expression is equivalent to specifying an empty collection as its value. + +::: {.varxml .rep} +Expression `edm:Record` +::: + +::: csdl +The `edm:Record` element MAY contain the `Type` attribute and MAY +contain `edm:PropertyValue` elements. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Type` +::: + +::: csdl +The value of `Type` is the qualified name of a structured type in scope. +::: + +::: {.varxml .rep} +Element `edm:PropertyValue` +::: + +::: csdl +The `edm:PropertyValue` element MUST contain the `Property` attribute, +and it MUST contain exactly one expression that MAY be provided using +either element notation or attribute notation. + +It MAY contain [`edm:Annotation`](#Annotation) elements. +::: + +::: {.varxml .rep} +Attribute `Property` +::: + +::: csdl +The value of `Property` is the name of a property of the type of the +enclosing `edm:Record` expression. +::: + +::: {.varxml .example} +Example ##ex: this annotation "morphs" the entity type from example 8 into +a structured type with two structural properties `GivenName` and +`Surname` and two navigation properties `DirectSupervisor` and +`CostCenter`. The first three properties simply rename properties of the +annotated entity type, the fourth adds a calculated navigation property +that is pointing to a different service +``` +[[\\ +  \\ +    \]{style="color:black"}]{.Datatype} +::: + +`     +      ` + +[[    \\ +    \]{style="color:black"}]{.Datatype} + +`    +     +       +         +          http://host/anotherservice/CostCenters('{ccid}') +           +         +      ` + +[[    \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +### ##subsubsec URL Reference + +The URL reference expression enables a value to be obtained by sending a +`GET` request. + +The URL reference expression MUST contain exactly one expression of type +`Edm.String`. Its value is treated as a URL that MAY be relative or +absolute; relative URIs are relative to the URL of the document +containing the URL reference expression, or relative to a base URL +specified in a format-specific way. + +The response body of the `GET` request MUST be returned as the result of +the` `URL reference expression. The result of the` edm:UrlRef` +expression MUST be type compatible with the type expected by the +surrounding element or expression. + +::: {.varxml .rep} +Expression `edm:UrlRef` +::: + +::: csdl +The `edm:UrlRef` expression MAY be provided using element notation or +attribute notation. + +Relative URLs are relative to the `xml:base` attribute, see +[**\[XML‑Base\]**](#BMXMLBase). + +In element notation it MAY contain [`edm:Annotation`](#Annotation) +elements. +::: + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +    \\ +      \http://host/service/Suppliers({suppID})\\ +      \\ +      \\ +        \SupplierId\\ +      \\ +      \\ +     \\ +  \\ +\]{style="color:black"}]{.Datatype} +::: + +`  +http://host/wiki/HowToUse + +  + +``` + +# ##sec Identifier and Path Values + +## ##subsec Namespace + +A namespace is a dot-separated sequence of [simple +identifier](#SimpleIdentifier)s with a maximum length of 511 Unicode +characters (code points). + +## ##subsec Simple Identifier + +A simple identifier is a Unicode character sequence with the following +restrictions: + +- It consists of at least one and at most 128 Unicode characters (code + points). +- The first character MUST be the underscore character (U+005F) or any + character in the Unicode category "Letter (L)" or "Letter number + (Nl)". +- The remaining characters MUST be the underscore character (U+005F) + or any character in the Unicode category "Letter (L)", "Letter + number (Nl)", "Decimal number (Nd)", "Non-spacing mark (Mn)", + "Combining spacing mark (Mc)", "Connector punctuation (Pc)", and + "Other, format (Cf)". + +Non-normatively speaking it starts with a letter or underscore, followed +by at most 127 letters, underscores or digits. + +## ##subsec Qualified Name + +For model elements that are direct children of a schema: the namespace +or alias of the schema that defines the model element, followed by a dot +and the name of the model element, see rule `qualifiedTypeName` in +[OData‑ABNF](#ODataABNF). + +For built-in [primitive types](#PrimitiveTypes): the name of the type, +prefixed with `Edm` followed by a dot. + +## ##subsec Target Path + +Target paths are used in attributes of CSDL elements to refer to other +CSDL elements or their nested child elements. + +The allowed path expressions are: +- The [qualified +name](#QualifiedName) of an entity container, followed by a forward +slash and the name of a container child element +- The target +path of a container child followed by a forward slash and one or more +forward-slash separated property, navigation property, or type-cast +segments + +::: {.varxml .example} +Example ##ex: Target expressions +``` +MySchema.MyEntityContainer/MyEntitySet +::: + +MySchema.MyEntityContainer/MySingleton + +MySchema.MyEntityContainer/MySingleton/MyContainmentNavigationProperty + +MySchema.MyEntityContainer/MySingleton/My.EntityType/MyContainmentNavProperty + +MySchema.MyEntityContainer/MySingleton/MyComplexProperty/MyContainmentNavProp +``` + +# ##sec CSDL Examples + +Following are two basic examples of valid EDM models as represented in +CSDL. These examples demonstrate many of the topics covered above. + +## ##subsec [Products and Categories Example](#ProductsandCategoriesExample) + +::: {.varxml .example} +Example ##ex: +``` +\ +  \]{style="color:black"}]{.Datatype} + +`    +      +    +    ` + +[[  \\ +    \\ +      \\ +        \\ +          \\ +        \\ +        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`        ` + +[[        \\ +        \\ +        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`        +        +        +        \ +      \\ +      \\ +        \\ +         \\ +        \\ +        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`        +        \ +          \]{style="color:black"}]{.Datatype} + +[[        \\ +      \\ +      \\ +        \\ +          \\ +        \\ +        \\ +        \\ +        \\ +        \\ +        \` + +[[      \\ +      \]{style="color:black"}]{.Datatype} + +`        +          +        +        +        +      ` + +[[      \\ +        \\ +        \\ +        \\ +        \\ +        \\ +        \]{style="color:black"}]{.Datatype} + +`          +        ` + +[[      \\ +      \\ +        \]{style="color:black"}]{.Datatype} + +[[        \\ +      \\ +      \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +[[        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`          ` + +[[        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`          +          +            +              Concurrency +            +          ` + +[[        \\ +        \\ +          \]{style="color:black"}]{.Datatype} + +`          +        +        +        \ +      \\ +    \\ +  \\ +\]{style="color:black"}]{.Datatype} +``` + +## ##subsec [Annotations for Products and Categories Example](#AnnotationsforProductsandCategoriesE) + +::: {.varxml .example} +Example ##ex: +``` +[[\\ +  \\ +    \]{style="color:black"}]{.Datatype} +::: + +`  +    ` + +[[  \\ +    \\ +      \\ +        \\ +          \\ +        \\ +        \\ +        \\ +        \\ +        \\ +            \Name\\ +            \ in \\ +            \Address/CountryName\\ +          \\ +        \\ +      \\ +      \]{style="color:black"}]{.Datatype} + +`        +          +            MasterData +          +        +      ` + +[[  \\ +\]{style="color:black"}]{.Datatype} +``` + +# ##sec Conformance + +Conforming services MUST follow all rules of this specification document +for the types, sets, functions, actions, containers and annotations they +expose. + +In addition, conforming services MUST NOT return 4.01 CSDL constructs +for requests made with `OData-MaxVersion:4.0`. + +Specifically, they + +1\. MUST NOT include properties in derived types that overwrite a +property defined in the base type + +2\. MUST NOT include [[Edm.Untyped]{style="font-family: +\"Courier New\";color:windowtext"}](#EntityModel) + +3\. MUST NOT use [path syntax](#PathSyntax) added with 4.01 + +4\. MUST NOT use +[[Edm.ModelElementPath]{style="font-family:\"Courier New\"; +color:windowtext"}](#EntityModel) and +[[Edm.AnyPropertyPath]{style="font-family:\"Courier New\";color:windowtext"}](#EntityModel) + +5\. MUST NOT specify [referential constraints](#ReferentialConstraint) +to complex types and navigation properties + +6\. MUST NOT include a non-abstract entity type with no inherited or +defined [entity key](#Key) + +7\. MUST NOT include the +[`Core.DefaultNamespace`](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#DefaultNamespace) +annotation on [included schemas](#IncludedSchema) + +8\. MUST NOT return the Unicode facet for terms, parameters, and return +types + +9\. MUST NOT include collections of +[[Edm.ComplexType]{style="font-family:\"Courier New\";color:windowtext"}](#EntityModel) +or +[[Edm.Untyped]{style="font-family:\"Courier New\";color:windowtext"}](#EntityModel) + +10\. MUST NOT specify a key as a property of a related entity + +11\. SHOULD NOT include new/unknown values for the +[`AppliesTo`](#Applicability) attribute + +12\. SHOULD specify the [Nullable](#Nullable) facet for collections + +13\. MAY include new CSDL annotations + +In addition, OData 4.01 services: + +14\. MUST specify the [Nullable](#Nullable) facet for collections + +15\. SHOULD NOT have identifiers within a uniqueness scope (e.g. a +schema, a structural type or an entity container) that differ only by +case + +Conforming clients MUST be prepared to consume a model that uses any or +all constructs defined in this specification, including custom +annotations, and MUST ignore any elements or attributes not defined in +this version of the specification. + +Appendix A. [Acknowledgments](#Acknowledgments) + +The contributions of the OASIS OData Technical Committee members, +enumerated in [OData‑Protocol](#ODataProtocol), are gratefully +acknowledged. + +Appendix B. [Table of XML Elements and +Attributes](#TableofXMLElementsandAttributes) + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection3 +[Element `edmx:Edmx`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318837) + +[Attribute `Version`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318838) + +[Element `edmx:DataServices`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318839) + +[Element `edmx:Reference`[. +]{style="color:windowtext;display:none"}[15]{style="color:windowtext;display:none"}](#_Toc37318840) + +[Attribute `Uri`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37318841) + +[Element `edmx:Include`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37318842) + +[Attribute `Namespace`[. +]{style="color:windowtext;display:none"}[16]{style="color:windowtext;display:none"}](#_Toc37318843) + +[Attribute `Alias`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37318844) + +[Element `edmx:IncludeAnnotations`[. +]{style="color:windowtext;display:none"}[17]{style="color:windowtext;display:none"}](#_Toc37318845) + +[Attribute `TermNamespace`[. +]{style="color:windowtext;display:none"}[18]{style="color:windowtext;display:none"}](#_Toc37318846) + +[Attribute `Qualifier`[. +]{style="color:windowtext;display:none"}[18]{style="color:windowtext;display:none"}](#_Toc37318847) + +[Attribute `TargetNamespace`[. ]{style="color:windowtext;display: +none"}[18]{style="color:windowtext;display:none"}](#_Toc37318848) + +[[Element ]{lang="DE"}[edm:Schema]{lang="DE" +style="font-family:\"Courier New\""}[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37318849) + +[Attribute `Namespace`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37318850) + +[Attribute `Alias`[. +]{style="color:windowtext;display:none"}[19]{style="color:windowtext;display:none"}](#_Toc37318851) + +[Element `edm:Annotations`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37318852) + +[Attribute `Target`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37318853) + +[Attribute `Qualifier`[. +]{style="color:windowtext;display:none"}[20]{style="color:windowtext;display:none"}](#_Toc37318854) + +[Element `edm:EntityType`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37318855) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37318856) + +[Attribute `BaseType`[. +]{style="color:windowtext;display:none"}[21]{style="color:windowtext;display:none"}](#_Toc37318857) + +[Attribute `Abstract`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37318858) + +[Attribute `OpenType`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37318859) + +[Attribute `HasStream`[. +]{style="color:windowtext;display:none"}[22]{style="color:windowtext;display:none"}](#_Toc37318860) + +[Element `edm:Key`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37318861) + +[Element `edm:PropertyRef`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37318862) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[23]{style="color:windowtext;display:none"}](#_Toc37318863) + +[Attribute `Alias`[. +]{style="color:windowtext;display:none"}[24]{style="color:windowtext;display:none"}](#_Toc37318864) + +[Element `edm:Property`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37318865) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37318866) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[25]{style="color:windowtext;display:none"}](#_Toc37318867) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[26]{style="color:windowtext;display:none"}](#_Toc37318868) + +[Attribute `MaxLength`[. +]{style="color:windowtext;display:none"}[26]{style="color:windowtext;display:none"}](#_Toc37318869) + +[Attribute `Precision`[. +]{style="color:windowtext;display:none"}[27]{style="color:windowtext;display:none"}](#_Toc37318870) + +[Attribute `Scale`[. +]{style="color:windowtext;display:none"}[27]{style="color:windowtext;display:none"}](#_Toc37318871) + +[Attribute `Unicode`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37318872) + +[Attribute `SRID`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37318873) + +[Attribute `DefaultValue`[. +]{style="color:windowtext;display:none"}[28]{style="color:windowtext;display:none"}](#_Toc37318874) + +[Element `edm:NavigationProperty`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37318875) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[29]{style="color:windowtext;display:none"}](#_Toc37318876) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37318877) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37318878) + +[Attribute `Partner`[. +]{style="color:windowtext;display:none"}[30]{style="color:windowtext;display:none"}](#_Toc37318879) + +[Attribute `ContainsTarget`[. +]{style="color:windowtext;display:none"}[31]{style="color:windowtext;display:none"}](#_Toc37318880) + +[Element `edm:ReferentialConstraint`[. +]{style="color:windowtext;display:none"}[31]{style="color:windowtext;display:none"}](#_Toc37318881) + +[Attribute `Property`[. +]{style="color:windowtext;display:none"}[32]{style="color:windowtext;display:none"}](#_Toc37318882) + +[Attribute `ReferencedProperty`[. ]{style="color:windowtext; +display:none"}[32]{style="color:windowtext;display:none"}](#_Toc37318883) + +[Element `edm:OnDelete`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37318884) + +[Attribute `Action`[. +]{style="color:windowtext;display:none"}[33]{style="color:windowtext;display:none"}](#_Toc37318885) + +[Element `edm:ComplexType`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37318886) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37318887) + +[Attribute `BaseType`[. +]{style="color:windowtext;display:none"}[34]{style="color:windowtext;display:none"}](#_Toc37318888) + +[Attribute `Abstract`[. +]{style="color:windowtext;display:none"}[35]{style="color:windowtext;display:none"}](#_Toc37318889) + +[Attribute `OpenType`[. +]{style="color:windowtext;display:none"}[35]{style="color:windowtext;display:none"}](#_Toc37318890) + +[Element `edm:EnumType`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318891) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318892) + +[Attribute `UnderlyingType`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318893) + +[Attribute `IsFlags`[. +]{style="color:windowtext;display:none"}[36]{style="color:windowtext;display:none"}](#_Toc37318894) + +[Element `edm:Member`[. +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37318895) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37318896) + +[Attribute `Value`[. +]{style="color:windowtext;display:none"}[37]{style="color:windowtext;display:none"}](#_Toc37318897) + +[Element `edm:TypeDefinition`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37318898) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37318899) + +[Attribute `UnderlyingType`[. +]{style="color:windowtext;display:none"}[39]{style="color:windowtext;display:none"}](#_Toc37318900) + +[Element `edm:Action`[. +]{style="color:windowtext;display:none"}[40]{style="color:windowtext;display:none"}](#_Toc37318901) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[40]{style="color:windowtext;display:none"}](#_Toc37318902) + +[Element `edm:Function`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318903) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318904) + +[Attribute `IsBound`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318905) + +[Attribute `EntitySetPath`[. +]{style="color:windowtext;display:none"}[41]{style="color:windowtext;display:none"}](#_Toc37318906) + +[Attribute `IsComposable`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318907) + +[Element `edm:ReturnType`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318908) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318909) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[42]{style="color:windowtext;display:none"}](#_Toc37318910) + +[Element `edm:Parameter`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318911) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318912) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318913) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[43]{style="color:windowtext;display:none"}](#_Toc37318914) + +[Element `edm:EntityContainer`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37318915) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[44]{style="color:windowtext;display:none"}](#_Toc37318916) + +[Attribute `Extends`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318917) + +[Element `edm:EntitySet`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318918) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318919) + +[Attribute `EntityType`[. +]{style="color:windowtext;display:none"}[45]{style="color:windowtext;display:none"}](#_Toc37318920) + +[Attribute `IncludeInServiceDocument`[. ]{style="color:windowtext; +display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318921) + +[Element `edm:Singleton`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318922) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318923) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318924) + +[Attribute `Nullable`[. +]{style="color:windowtext;display:none"}[46]{style="color:windowtext;display:none"}](#_Toc37318925) + +[Element `edm:NavigationPropertyBinding`[. +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37318926) + +[Attribute `Path`[. +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37318927) + +[Attribute `Target`[. +]{style="color:windowtext;display:none"}[47]{style="color:windowtext;display:none"}](#_Toc37318928) + +[Element `edm:ActionImport`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318929) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318930) + +[Attribute `Action`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318931) + +[Attribute `EntitySet`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318932) + +[Element `edm:FunctionImport`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318933) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318934) + +[Attribute `Function`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318935) + +[Attribute `EntitySet`[. +]{style="color:windowtext;display:none"}[48]{style="color:windowtext;display:none"}](#_Toc37318936) + +[Attribute `IncludeInServiceDocument`[. ]{style="color:windowtext; +display:none"}[49]{style="color:windowtext;display:none"}](#_Toc37318937) + +[Element `edm:Term`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318938) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318939) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318940) + +[Attribute `DefaultValue`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318941) + +[Attribute `BaseTerm`[. +]{style="color:windowtext;display:none"}[51]{style="color:windowtext;display:none"}](#_Toc37318942) + +[Attribute `AppliesTo`[. +]{style="color:windowtext;display:none"}[53]{style="color:windowtext;display:none"}](#_Toc37318943) + +[Element `edm:Annotation`[. +]{style="color:windowtext;display:none"}[53]{style="color:windowtext;display:none"}](#_Toc37318944) + +[Attribute `Term`[. +]{style="color:windowtext;display:none"}[53]{style="color:windowtext;display:none"}](#_Toc37318945) + +[Attribute `Qualifier`[. +]{style="color:windowtext;display:none"}[54]{style="color:windowtext;display:none"}](#_Toc37318946) + +[Expression `edm:Binary`[. +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37318947) + +[Expression `edm:Bool`[. +]{style="color:windowtext;display:none"}[56]{style="color:windowtext;display:none"}](#_Toc37318948) + +[Expression `edm:Date`[. +]{style="color:windowtext;display:none"}[57]{style="color:windowtext;display:none"}](#_Toc37318949) + +[Expression `edm:DateTimeOffset`[. ]{style="color:windowtext; +display:none"}[57]{style="color:windowtext;display:none"}](#_Toc37318950) + +[Expression `edm:Decimal`[. +]{style="color:windowtext;display:none"}[57]{style="color:windowtext;display:none"}](#_Toc37318951) + +[Expression `edm:Duration`[. +]{style="color:windowtext;display:none"}[58]{style="color:windowtext;display:none"}](#_Toc37318952) + +[Expression `edm:EnumMember`[. +]{style="color:windowtext;display:none"}[58]{style="color:windowtext;display:none"}](#_Toc37318953) + +[Expression `edm:Float`[. +]{style="color:windowtext;display:none"}[58]{style="color:windowtext;display:none"}](#_Toc37318954) + +[Expression `edm:Guid`[. +]{style="color:windowtext;display:none"}[59]{style="color:windowtext;display:none"}](#_Toc37318955) + +[Expression `edm:Int`[. +]{style="color:windowtext;display:none"}[59]{style="color:windowtext;display:none"}](#_Toc37318956) + +[Expression `edm:String`[. +]{style="color:windowtext;display:none"}[59]{style="color:windowtext;display:none"}](#_Toc37318957) + +[Expression `edm:TimeOfDay`[. +]{style="color:windowtext;display:none"}[60]{style="color:windowtext;display:none"}](#_Toc37318958) + +[Expression `edm:AnnotationPath`[. ]{style="color:windowtext; +display:none"}[63]{style="color:windowtext;display:none"}](#_Toc37318959) + +[Expression `edm:ModelElementPath`[. ]{style="color:windowtext; +display:none"}[63]{style="color:windowtext;display:none"}](#_Toc37318960) + +[Expression `edm:NavigationPropertyPath`[. ]{style="color:windowtext; +display:none"}[63]{style="color:windowtext;display:none"}](#_Toc37318961) + +[Expression `edm:PropertyPath`[. ]{style="color:windowtext;display: +none"}[64]{style="color:windowtext;display:none"}](#_Toc37318962) + +[Expression `edm:Path`[. +]{style="color:windowtext;display:none"}[64]{style="color:windowtext;display:none"}](#_Toc37318963) + +[Expressions `edm:And` and `edm:Or`[. +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37318964) + +[Expression `edm:Not`[. +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37318965) + +[Expressions `edm:Eq`, `edm:Ne`, `edm:Gt`, `edm:Ge`, `edm:Lt`, `edm:Le`, +`edm:Has`, and `edm:In`[  +]{style="color:windowtext;display:none"}[65]{style="color:windowtext;display:none"}](#_Toc37318966) + +[Expression `edm:Neg`[. +]{style="color:windowtext;display:none"}[67]{style="color:windowtext;display:none"}](#_Toc37318967) + +[Expressions `edm:Add`, `edm:Sub`, `edm:Mul`, `edm:Div`, `edm:DivBy`, +and `edm:Mod`[  +]{style="color:windowtext;display:none"}[67]{style="color:windowtext;display:none"}](#_Toc37318968) + +[Expression `edm:Apply`[. +]{style="color:windowtext;display:none"}[68]{style="color:windowtext;display:none"}](#_Toc37318969) + +[Attribute `Function`[. +]{style="color:windowtext;display:none"}[68]{style="color:windowtext;display:none"}](#_Toc37318970) + +[Expression `edm:Cast`[. +]{style="color:windowtext;display:none"}[69]{style="color:windowtext;display:none"}](#_Toc37318971) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[69]{style="color:windowtext;display:none"}](#_Toc37318972) + +[Expression `edm:Collection`[. +]{style="color:windowtext;display:none"}[70]{style="color:windowtext;display:none"}](#_Toc37318973) + +[Expression `edm:If`[. +]{style="color:windowtext;display:none"}[70]{style="color:windowtext;display:none"}](#_Toc37318974) + +[Expression `edm:IsOf`[. +]{style="color:windowtext;display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318975) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318976) + +[Expression `edm:LabeledElement`[. ]{style="color:windowtext; +display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318977) + +[Attribute `Name`[. +]{style="color:windowtext;display:none"}[71]{style="color:windowtext;display:none"}](#_Toc37318978) + +[Expression `edm:LabeledElementReference`[. ]{style="color:windowtext; +display:none"}[72]{style="color:windowtext;display:none"}](#_Toc37318979) + +[Expression `edm:Null`[. +]{style="color:windowtext;display:none"}[72]{style="color:windowtext;display:none"}](#_Toc37318980) + +[Expression `edm:Record`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318981) + +[Attribute `Type`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318982) + +[Element `edm:PropertyValue`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318983) + +[Attribute `Property`[. +]{style="color:windowtext;display:none"}[73]{style="color:windowtext;display:none"}](#_Toc37318984) + +[Expression `edm:UrlRef`[. +]{style="color:windowtext;display:none"}[74]{style="color:windowtext;display:none"}](#_Toc37318985) + +  +::: + +[\ +]{style="font-size:10.0pt;font-family:\"Liberation Sans\",sans-serif"} + +::: WordSection4 +Appendix C. [Revision History](#RevisionHistory) + +  + ++-----------------+-----------------+-----------------+-----------------+ +| **Revision** | **Date** | **Editor** | **Changes | +| | | | Made** | ++-----------------+-----------------+-----------------+-----------------+ +| Working Draft | 2016-09-07 | Michael Pizzo | Imported | +| 01 | | | content from | +| | | Ralf Handl | 4.0 Errata 3 | +| | | | specification | +| | | | and integrated | +| | | | initial 4.01 | +| | | | features | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2016-12-08 | Michael Pizzo | Integrated 4.01 | +| Specification | | | features | +| Draft 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-06-08 | Michael Pizzo | Incorporated | +| Specification | | | normative text | +| Draft 02 | | Ralf Handl | from former | +| | | | OData Part 3: | +| | | | CSDL | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-09-22 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 03 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-11-10 | Michael Pizzo | Incorporated | +| Specification | | | review feedback | +| Draft 04 | | Ralf Handl | | +| | | | Stable order of | +| | | | action and | +| | | | function | +| | | | parameters | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2017-12-19 | Michael Pizzo | Non-Material | +| Specification | | | Changes | +| 01 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-06-21 | Michael Pizzo | External | +| Specification | | | targeting for | +| Draft 05 | | Ralf Handl | annotations on | +| | | | action/function | +| | | | overloads, | +| | | | parameters, and | +| | | | return types | +| | | | | +| | | | Key and index | +| | | | segments for | +| | | | path | +| | | | expressions in | +| | | | annotations | +| | | | | +| | | | Nullable | +| | | | singletons | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-09-20 | Michael Pizzo | Redefining | +| Specification | | | entity sets and | +| Draft 06 | | Ralf Handl | singletons when | +| | | | extending | +| | | | entity | +| | | | containers | ++-----------------+-----------------+-----------------+-----------------+ +| Committee | 2019-11-05 | Michael Pizzo | Non-material | +| Specification | | | changes | +| 02 | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Candidate OASIS | 2020-01-15 | Michael Pizzo | Non-material | +| Standard 01 | | | changes | +| | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ +| Candidate OASIS | 2020-04-09 | Michael Pizzo | Non-material | +| Standard 02 | | | changes | +| | | Ralf Handl | | ++-----------------+-----------------+-----------------+-----------------+ + +  +::: diff --git a/odata-csdl-xml/meta.yaml b/odata-csdl/xml.yaml similarity index 92% rename from odata-csdl-xml/meta.yaml rename to odata-csdl/xml.yaml index 9e27116dd..db04b8481 100644 --- a/odata-csdl-xml/meta.yaml +++ b/odata-csdl/xml.yaml @@ -1,5 +1,6 @@ pagetitle: OData Common Schema Definition Language (CSDL) XML Representation Version 4.02 subtitle: Committee Specification Draft 01 +dirname: odata-csdl-xml filename: odata-csdl-xml-v4.02-csd01 stage: csd01 previousStage: n/a diff --git a/odata-protocol/temp/odata-v4.01-os-part1-protocol-clean.html b/odata-protocol/temp/odata-v4.01-os-part1-protocol-clean.html index 25e698211..25ab5197f 100644 --- a/odata-protocol/temp/odata-v4.01-os-part1-protocol-clean.html +++ b/odata-protocol/temp/odata-v4.01-os-part1-protocol-clean.html @@ -4544,7 +4544,7 @@

    ##subsubsec Requesting the Number of Items or $search system query options, formatted as a simple primitive integer value with media type text/plain. Clients SHOULD NOT combine the system -query options $top, $skip, $orderby, @@ -5337,11 +5337,9 @@

    ##subsubsubsec Update Related Entities that relationship and MUST NOT include added links, deleted links, or deleted entities.

    -

    Example 78: using the JSON format, a 4.01 PATCH request can +

    Example 78: using the JSON format, a 4.01 PATCH request can update a manager entity. Following the update, the manager has three direct -reports; two existing employees and one new employee named Suzanne Brown. The LastName of employee 6 is updated to Smith.

    +reports; two existing employees and one new employee named Suzanne Brown. The LastName of employee 6 is updated to Smith.

    PATCH +using the JSON format, a 4.01 PATCH request can specify a nested delta representation to:

    Each body +class=MsoCommentReference>Each body part representing an operation in the change set MUST specify a Content-ID header with a request identifier that is unique within the batch request.

    diff --git a/odata-protocol/temp/odata-v4.01-os-part1-protocol-raw.md b/odata-protocol/temp/odata-v4.01-os-part1-protocol-raw.md index 3f9f33b92..44460e555 100644 --- a/odata-protocol/temp/odata-v4.01-os-part1-protocol-raw.md +++ b/odata-protocol/temp/odata-v4.01-os-part1-protocol-raw.md @@ -3591,7 +3591,7 @@ matching the request after applying any [`$search`](#SystemQueryOptionsearch) system query options, formatted as a simple primitive integer value with media type `text/plain`. Clients SHOULD NOT combine the system query options -[[ ]{style="font-size:8.0pt"}]{.MsoCommentReference}[`$top`](#SystemQueryOptiontop), +[ ]{.MsoCommentReference}[`$top`](#SystemQueryOptiontop), [`$skip`](#SystemQueryOptionskip), [`$orderby`](#SystemQueryOptionorderby), [`$expand`](#SystemQueryOptionexpand), and @@ -4331,12 +4331,10 @@ references specified in a successful update request represents the full set of entities to be related according to that relationship and MUST NOT include added links, deleted links, or deleted entities. -Example 78: using the JSON format, a 4.01 -[[PATCH]{style="font-size:10.0pt"}]{.Keyword} request can update a +Example 78: using the JSON format, a 4.01 `PATCH` request can update a manager entity. Following the update, the manager has three direct reports; two existing employees and one new employee named -`Suzanne Brown`. The `LastName` of employee -[[6]{style="font-size:10.0pt"}]{.Keyword} is updated to `Smith.` +`Suzanne Brown`. The `LastName` of employee `6` is updated to `Smith.` ::: {style="border-top:solid windowtext 1.0pt;border-left:none;border-bottom: solid windowtext 1.0pt;border-right:none;padding:3.0pt 0in 3.0pt 0in; @@ -4398,8 +4396,7 @@ MUST include a context URL specifying the entity set in which the new entity is to be created. If any nested entities contain both id and key fields, they MUST identify the same entity, or the request is invalid. -Example 79: using the JSON format, a 4.01 -[[PATCH]{style="font-size:10.0pt"}]{.Keyword} request can specify a +Example 79: using the JSON format, a 4.01 `PATCH` request can specify a nested delta representation to: [· ]{style="font-family:Symbol;font-style:normal"}delete employee 3 and @@ -5822,8 +5819,7 @@ A body part representing an individual request MUST include a The contents of a body part representing a change set MUST itself be a multipart document (see [RFC2046](#rfc2046)) with one body part for each -operation in the change set. -[[E]{style="font-size:8.0pt"}]{.MsoCommentReference}ach body part +operation in the change set. [E]{.MsoCommentReference}ach body part representing an operation in the change set MUST specify a `Content-ID` header with a [request identifier](#IdentifyingIndividualRequests) that is unique within the batch request. diff --git a/odata-protocol/temp/odata-v4.01-os-part1-protocol.md b/odata-protocol/temp/odata-v4.01-os-part1-protocol.md index 148796cfc..5366828a6 100644 --- a/odata-protocol/temp/odata-v4.01-os-part1-protocol.md +++ b/odata-protocol/temp/odata-v4.01-os-part1-protocol.md @@ -105,7 +105,7 @@ Ed., "Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests"[, ]{style="font-size:10.5pt;color:#333333"}RFC 7232, June 2014. . -[**\[**]{#_Toc370125980}[**RFC7240**]{#HTTPPREFER}**\]**                      +**\[**[**RFC7240**]{#HTTPPREFER}**\]**                      Snell, J., \"Prefer Header for HTTP\",[ ]{style="font-size:10.5pt;color:#333333"}RFC 7240, June 2014.https://tools.ietf.org/html/rfc7240. @@ -1607,10 +1607,10 @@ request methods for the requested resource as defined in ### ##subsubsec Response Code `406 Not Acceptable` -[`406 Not Acceptable` indicates that the resource specified by the +`406 Not Acceptable` indicates that the resource specified by the request URL does not have a current representation that would be acceptable for the client according to the request -headers]{#_Toc477876608} [`Accept`](#HeaderAccept), +headers [`Accept`](#HeaderAccept), [`Accept-Charset`](#HeaderAcceptCharset), and [`Accept-Language`](#HeaderAcceptLanguage), and that the service is unwilling to supply a default representation. @@ -1738,7 +1738,7 @@ the service. ::: example Example ##ex: resource URL and corresponding context URL ``` -`http://host/service/` +http://host/service/` ::: http://host/service/\$metadata @@ -1798,7 +1798,7 @@ of an entity set, `/$entity` is appended to the context URL. ::: example Example ##ex: resource URL and corresponding context URL ``` -`http://host/service/Customers(1)` +http://host/service/Customers(1)` ::: http://host/service/\$metadata#Customers/\$entity @@ -1836,10 +1836,10 @@ URL fragment. ::: example Example ##ex: resource URL and corresponding context URL ``` -`http://host/service/MainSupplier` +http://host/service/MainSupplier` ::: -http://host/service/\$metadata#`MainSupplier` +http://host/service/\$metadata#`MainSupplier ``` ## ##subsec Collection of Derived Entities @@ -1873,7 +1873,7 @@ the entity set name. ::: example Example ##ex: resource URL and corresponding context URL ``` -`http://host/service/Customers(2)/Model.VipCustomer` +http://host/service/Customers(2)/Model.VipCustomer` ::: http://host/service/\$metadata#Customers/Model.VipCustomer/\$entity @@ -2112,11 +2112,10 @@ not contain the type of the referenced entities. Example ##ex: resource URL and corresponding context URL for a collection of entity references ``` -`http://host/service/Customers('ALFKI')/Orders/$ref` -::: - -`http://host/service/$metadata#Collection($ref)` +http://host/service/Customers('ALFKI')/Orders/$ref +http://host/service/$metadata#Collection($ref) ``` +::: ## ##subsec Entity Reference @@ -2131,11 +2130,10 @@ fragment. Example ##ex: resource URL and corresponding context URL for a single entity reference ``` -`http://host/service/Orders(10643)/Customer/$ref` -::: - -`http://host/service/$metadata#$ref` +http://host/service/Orders(10643)/Customer/$ref +http://host/service/$metadata#$ref ``` +::: ## ##subsec Property Value @@ -2162,7 +2160,7 @@ Example ##ex: resource URL and corresponding context URL http://host/service/Customers(1)/Addresses ::: -`http://host/service/$metadata#Customers(1)/Addresses` +`http://host/service/$metadata#Customers(1)/Addresses ``` ## ##subsec Collection of Complex or Primitive Types @@ -2182,7 +2180,7 @@ Example ##ex: resource URL and corresponding context URL http://host/service/TopFiveHobbies() ::: -`http://host/service/$metadata#Collection(Edm.String)` +`http://host/service/$metadata#Collection(Edm.String) ``` ## ##subsec Complex or Primitive Type @@ -2198,11 +2196,10 @@ context URL specifies the fully qualified type of the result. ::: example Example ##ex: resource URL and corresponding context URL ``` -`http://host/service/MostPopularName()` -::: - -`http://host/service/$metadata#Edm.String` +http://host/service/MostPopularName() +http://host/service/$metadata#Edm.String ``` +::: ## ##subsec Operation Result @@ -2259,11 +2256,10 @@ of the containing entity. ::: example Example ##ex: resource URL and corresponding context URL ``` -http://host/service/Customers`?$deltatoken=1234` -::: - -`http://host/service/$metadata#Customers/$delta` +http://host/service/Customers`?$deltatoken=1234 +http://host/service/$metadata#Customers/$delta ``` +::: The context URL of an update request body for a collection of entities is simply the fragment `#$delta`. @@ -2452,9 +2448,7 @@ and specify the `$` prefix. The result of the request MUST be as if the system query options were evaluated in the following order. - -[· ]{style="font-family: -Symbol;color:black"}[`$schemaversion`](#SystemQueryOptionschemaversion) +- [`$schemaversion`](#SystemQueryOptionschemaversion) MUST be evaluated first, because it may influence any further processing. @@ -3023,7 +3017,7 @@ specified parameter alias. Example ##ex: returns all employees whose Region property matches the string parameter value \"WA\" ``` -GET `http://host/service.svc/Employees?$filter=Region eq @p1&@p1='WA'` +GET `http://host/service.svc/Employees?$filter=Region eq @p1&@p1='WA' ``` ::: @@ -3054,7 +3048,7 @@ parameter alias for `$this` to pass the manager into the filter on the expanded direct reports ``` GET -`http://host/service.svc/Employees?$expand=Manager(@m=$this;$expand=DirectReports($filter=@m/FirstName eq FirstName))` +`http://host/service.svc/Employees?$expand=Manager(@m=$this;$expand=DirectReports($filter=@m/FirstName eq FirstName)) ``` ::: @@ -3460,7 +3454,7 @@ matching the request after applying any [`$search`](#SystemQueryOptionsearch) system query options, formatted as a simple primitive integer value with media type `text/plain`. Clients SHOULD NOT combine the system query options -[[ ]{style="font-size:8.0pt"}]{.MsoCommentReference}[`$top`](#SystemQueryOptiontop), +[ ]{.MsoCommentReference}[`$top`](#SystemQueryOptiontop), [`$skip`](#SystemQueryOptionskip), [`$orderby`](#SystemQueryOptionorderby), [`$expand`](#SystemQueryOptionexpand), and @@ -4192,12 +4186,10 @@ set of entities to be related according to that relationship and MUST NOT include added links, deleted links, or deleted entities. ::: example -Example ##ex: using the JSON format, a 4.01 -[[PATCH]{style="font-size:10.0pt"}]{.Keyword} request can update a +Example ##ex: using the JSON format, a 4.01 `PATCH` request can update a manager entity. Following the update, the manager has three direct reports; two existing employees and one new employee named -`Suzanne Brown`. The `LastName` of employee -[[6]{style="font-size:10.0pt"}]{.Keyword} is updated to `Smith.` +`Suzanne Brown`. The `LastName` of employee `6` is updated to `Smith.` ``` { ::: @@ -4258,8 +4250,7 @@ entity is to be created. If any nested entities contain both id and key fields, they MUST identify the same entity, or the request is invalid. ::: example -Example ##ex: using the JSON format, a 4.01 -[[PATCH]{style="font-size:10.0pt"}]{.Keyword} request can specify a +Example ##ex: using the JSON format, a 4.01 `PATCH` request can specify a nested delta representation to: - delete employee 3 and remove link to it @@ -5144,13 +5135,11 @@ used to create a new entity in the identified collection. Example ##ex: add a new item to the list of items of the shopping cart returned by the composable `MyShoppingCart` function import ``` -`POST `http://host/service/MyShoppingCart()`/Items` -::: - -` ` - -`...` +POST `http://host/service/MyShoppingCart()`/Items +  +... ``` +::: Parameter values passed to functions MUST be specified either as a URL literal (for primitive values) or as a JSON formatted OData object (for @@ -5192,7 +5181,7 @@ Example ##ex: invoke a `Sales.EmployeesByManager` function which takes a single `ManagerID` parameter via the function import `EmployeesByManager` ``` -`GET http://host/service/EmployeesByManager(ManagerID=3)` +GET http://host/service/EmployeesByManager(ManagerID=3) ``` ::: @@ -5215,7 +5204,7 @@ Example ##ex: invoke a `Sales.EmployeesByManager` function via the function import `EmployeesByManager`, passing 3 for the `ManagerID` parameter ``` -`GET http://host/service/EmployeesByManager(ManagerID=@p1)?@p1=3` +GET http://host/service/EmployeesByManager(ManagerID=@p1)?@p1=3 ``` ::: @@ -5235,7 +5224,7 @@ Example ##ex: invoke a `Sales.EmployeesByManager` function via the function import `EmployeesByManager`, passing 3 for the `ManagerID` parameter using the implicit parameter alias ``` -`GET http://host/service/EmployeesByManager?ManagerID=3` +GET http://host/service/EmployeesByManager?ManagerID=3 ``` ::: @@ -5368,11 +5357,10 @@ Example ##ex: invoke the `SampleEntities.CreateOrder` action using `discountCode` parameter are passed in the body of the request. Invoke the action only if the customer's ETag still matches. ``` -`POST http://host/service/Customers('ALFKI')/SampleEntities.CreateOrder` +POST http://host/service/Customers('ALFKI')/SampleEntities.CreateOrder +If-Match: W/"MjAxOS0wMy0yMVQxMzowNVo="` ::: -`If-Match: W/"MjAxOS0wMy0yMVQxMzowNVo="` - [[\ {\    \"items\": \[]{style="color:black"}]{.VerbatimChar} @@ -5506,12 +5494,12 @@ format](#MultipartBatchFormat) MUST contain a ::: example Example ##ex: multipart batch request ``` -`POST /service/$batch HTTP/1.1`[\ +POST /service/$batch HTTP/1.1`[\ ]{style="font-size:6.0pt;color:black"}`Host: odata.org`[\ ]{style="font-size:6.0pt;color:black"}`OData-Version: 4.0 `[\ ]{style="font-size:6.0pt;color:black"}`Content-Type: multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b`[\ \ -]{style="font-size:6.0pt;color:black"}`` +]{style="font-size:6.0pt;color:black"}` ``` ::: @@ -5521,12 +5509,12 @@ A batch request using the JSON batch format MUST contain a ::: example Example ##ex: JSON batch request ``` -`POST /service/$batch HTTP/1.1`[\ +POST /service/$batch HTTP/1.1`[\ ]{style="font-size:6.0pt;color:black"}`Host: odata.org`[\ ]{style="font-size:6.0pt;color:black"}`OData-Version: 4.01 `[\ ]{style="font-size:6.0pt;color:black"}`Content-Type: application/json`[\ \ -]{style="font-size:6.0pt;color:black"}`` +]{style="font-size:6.0pt;color:black"}` ``` ::: @@ -5649,8 +5637,7 @@ A body part representing an individual request MUST include a The contents of a body part representing a change set MUST itself be a multipart document (see [RFC2046](#rfc2046)) with one body part for each -operation in the change set. -[[E]{style="font-size:8.0pt"}]{.MsoCommentReference}ach body part +operation in the change set. [E]{.MsoCommentReference}ach body part representing an operation in the change set MUST specify a `Content-ID` header with a [request identifier](#IdentifyingIndividualRequests) that is unique within the batch request. diff --git a/odata-url-conventions/temp/odata-v4.01-os-part2-url-conventions-clean.html b/odata-url-conventions/temp/odata-v4.01-os-part2-url-conventions-clean.html index e0b99d7bb..fb6f5afde 100644 --- a/odata-url-conventions/temp/odata-v4.01-os-part2-url-conventions-clean.html +++ b/odata-url-conventions/temp/odata-v4.01-os-part2-url-conventions-clean.html @@ -1012,15 +1012,13 @@

    ##subsec Addressing

    The /$count path suffix identifies the integer count of records in the collection and SHOULD NOT be -combined with the system query options $top, $skip, $orderby, $expand, and $format. -The count MUST NOT be affected by $top, +The count MUST NOT be affected by $top, $skip, $orderby, or $expand.

    The count is calculated after applying any code { font-family: MJXZERO, MJXTEX-T; font-size: 1em; line-height: 0; @@ -133,7 +145,8 @@ h6 code { font-style: initial; } -.example pre { +.example pre, +.rep { margin-left: 40px; }