Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-1420

Path evaluation for annotations targeting annotations

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.01_OS
    • Fix Version/s: V4.01_ERRATA01
    • Component/s: CSDL JSON, CSDL XML, Temporal
    • Labels:
      None
    • Environment:

      Closed as applied 2023-10-18.

    • Proposal:
      Hide

      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.

      If the value of an annotation is expressed dynamically with a path expression, the path evaluation rules for this expression depend on the host of the annotation (roughly, the innermost model element other than an annotation) and its hosting kind (roughly, embedded vs. targeting).

      • The host of an annotation embedded within or targeting another annotation or a collection, record or property value of another annotation is the host of that other annotation.
      • The host of an annotation embedded within or targeting another kind of model element is that model element.
      • The hosting kind of an annotation with external targeting whose target path starts with an entity container is "container".
      • The hosting kind of an annotation with external targeting whose target path starts with another kind of schema child is "targeting".
      • The hosting kind of an annotation embedded within another annotation or a collection, record or property value of another annotation is the hosting kind of that other annotation.
      • The hosting kind of an annotation embedded within another kind of model element is "embedded".
      Host of annotation Hosting kind Path evaluation starts at Remark
      Entity Container container or embedded the entity container 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.
      Entity Set or Singleton container or embedded the entity set or singleton 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.
      Entity Type or Complex Type embedded or targeting the type 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.
      Structural or navigation property container the declared type of the property An empty path resolves to the declared type of the property, and non-empty paths MUST follow the rules for annotations targeting the declared type of the property. If the type is primitive, the first segment of a non-empty path MUST be a term cast or type cast.
      Structural or navigation property of an entity type or complex type embedded 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.
      Structural or navigation property of an entity type or complex type targeting the outermost entity type or complex type named in the target 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.
      Action, action import, function, function import, parameter, or return type any the action or function The first segment of the path MUST be a parameter name or $ReturnType.
      Any other kind of model element embedded n/a Path evaluation is not possible.
      Show
      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. If the value of an annotation is expressed dynamically with a path expression, the path evaluation rules for this expression depend on the  host of the annotation  (roughly, the innermost model element other than an annotation) and its  hosting kind  (roughly, embedded vs. targeting). The host of an annotation embedded within or targeting another annotation or a collection, record or property value of another annotation is the host of that other annotation. The host of an annotation embedded within or targeting another kind of model element is that model element. The hosting kind of an annotation with external targeting whose target path starts with an entity container is "container". The hosting kind of an annotation with external targeting whose target path starts with another kind of schema child is "targeting". The hosting kind of an annotation embedded within another annotation or a collection, record or property value of another annotation is the hosting kind of that other annotation. The hosting kind of an annotation embedded within another kind of model element is "embedded". Host of annotation Hosting kind Path evaluation starts at Remark Entity Container container or embedded the entity container 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. Entity Set or Singleton container or embedded the entity set or singleton 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. Entity Type or Complex Type embedded or targeting the type 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 . Structural or navigation property container the declared type of the property An empty path resolves to the declared type of the property, and non-empty paths MUST follow the rules for annotations targeting the declared type of the property. If the type is primitive, the first segment of a non-empty path MUST be a term cast or type cast. Structural or navigation property of an entity type or complex type embedded 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. Structural or navigation property of an entity type or complex type targeting the  outermost  entity type or complex type named in the target 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 . Action, action import, function, function import, parameter, or return type any the action or function The first segment of the path MUST be a parameter name or $ReturnType. Any other kind of model element embedded n/a Path evaluation is not possible.
    • Resolution:
      Show
      OData-CSDL-XML and OData-CSDL-JSON https://github.com/oasis-tcs/odata-specs/pull/58

      Description

      OData-CSDL, section "Path evaluation" does not specify rules for annotations that target another annotation.

      Imagine an annotation term PAngV.PriceSection2 whose value is an amount.

      <EntityType Name="SalesOrderItem">
       <Property Name="Pieces" Type="Edm.Int"/>
       <Property Name="Price" Type="Edm.Decimal"/>
       <Annotation Term="PAngV.PriceSection2">
        <DivBy>
         <Path>Price</Path>
         <Path>Pieces</Path>
        </DivBy>
        <Annotation Term="Measures.ISOCurrency">
         <Path>Price/@Measures.ISOCurrency</Path>
        </Annotation>
       </Annotation>
      </EntityType>
      

      This entity type computes the PAngV.PriceSection2 as an annotation and wants to annotate this annotation with the corresponding currency. I would expect the evaluation of the path Price/@Measures.ISOCurrency to follow the rules for "annotations embedded within a structural or navigation property of an entity type or complex type", because the "outer" annotation has a primitive type and can thus be treated like a structural property.

      This should be clarified in the specification.

        Attachments

          Activity

            People

            • Assignee:
              heiko.theissen Heiko Theissen
              Reporter:
              heiko.theissen Heiko Theissen
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: