Commit 25ac5aaf authored by Martin Bauer's avatar Martin Bauer
Browse files

Clarified the matching algorithm as described in Issue 34:...

Clarified the matching algorithm as described in Issue 34: #34, splitting the clause into 9.4.1 Introduction and 9.4.2 Algorithm
parent 01d080fb
Loading
Loading
Loading
Loading
+53 −41
Original line number Diff line number Diff line
@@ -375,6 +375,8 @@ exhausted.

## 9.4 Matching Context Source registrations

### 9.4.1 Introduction

When querying [Context Source Registrations]{.HTML-Keyboard} as described in
Clause+++clause-12+++12.3.3 and subscribing to [Context Source
Registrations]{.HTML-Keyboard} as described in Clause+++clause-12+++12.4.2, the
@@ -409,48 +411,58 @@ b. list of Attribute names.

<!-- prettier-ignore-end -->

### 9.4.2 Matching algorithm

A specification of Entity Types or Attributes matches a [Context Source 
Registration]{.HTML-Keyboard} if at least one of the _RegistrationInfo_ elements
(defined in Clause 5.2.6.6.4) in the _`information`_ element matches. An Entity
specification matches a _RegistrationInfo_ if the following conditions hold:

- If present, the selector of Entity Types, Entity identifiers and id pattern
  match at least one of the _EntityInfo_ elements of the _RegistrationInfo_ (see
  below).
- If present, the Attribute identifiers match the combination of Properties and
  Relationships specified in the _RegistrationInfo_ (see below).

An Entity specification consisting of selector of Entity Types, Entity
identifiers and id pattern matches an _EntityInfo_ element of the
_RegistrationInfo_ if the type selector matches the entity types in the
_EntityInfo_ element (defined in clause 5.2.6.6.2) and one of the following
conditions holds:

- The _EntityInfo_ contains neither an _`id`_ nor an _`idPattern`_.
- One of the specified Entity identifiers matches the _`id`_ in the
  _EntityInfo_.
- At least one of the specified Entity identifiers matches the _`idPattern`_ in
  the _EntityInfo_.
- The specified id pattern matches the _`id`_ in the _EntityInfo_.
- Both a specified id pattern and an _`idPattern`_ in the _Entity Info_ are
  present (since in the general case it is not easily feasible to determine if
  there can be identifiers matching both patterns).

Attribute names match the combination of Properties and Relationships if one of
the following conditions hold:

- No Attribute names have been specified (as this means all Attributes are
  requested).
- The combination of Properties and Relationships is empty (as this means only
  Entities have been registered and the [Context Sources]{.HTML-Keyboard} may
  have matching Property or Relationship instances).
- If at least one of the specified attribute names matches a Property or
  Relationship specified in the _RegistrationInfo_.

If the request that triggered the matching includes a _`datasetId`_ parameter
and the CSourceRegistration to be matched contains a _`datasetId`_ element, the
CSourceRegistration should only be considered matching, if both have at least
one value in common. If only one of them specifies a _`datasetId`_, it is
(defined in clause 5.2.6.6.5) inside the _`information`_ element matches.

A RegistrationInfo shall match the Entity specification when the following conditions 
apply:

1. Matching Entity Types / Entity Identifiers / idPattern

   If present, the selector of Entity Types, Entity identifiers, and _`idPattern`_ shall match
   at least one of the _`EntityInfo`_ elements contained in the _RegistrationInfo_
   (see "Entity matching" details below).

2. Matching Attributes

   If present, the specified Attribute identifiers shall match the _`attributeNames`_ (or
   the combination of _`propertyNames`_ and _`relationshipNames`_) in the _RegistrationInfo_
  (see "Attribute matching" details below).

**Entity matching**

An Entity specification containing a selector of Entity Types, Entity identifiers, and/or 
an _`idPattern`_ shall match an _`EntityInfo`_ element of a _RegistrationInfo_ if:
- The Entity Type selector matches the Entity Types in the EntityInfo (see clause 5.2.6.6.2),
and
- One of the following identifier conditions shall hold:
  - The EntityInfo contains neither an _`id`_ nor an _`idPattern`_.
  - A specified Entity identifier matches the _`id`_ in the _EntityInfo_.
  - A specified Entity identifier matches the _`idPattern`_ in the _EntityInfo_.
  - The specified _`idPattern`_ matches the _`id`_ in the _EntityInfo_.
  - Both a specified _`idPattern`_ and an _`idPattern`_ in the _EntityInfo_ are present 
  (because, in general, determining whether their sets of possible identifiers overlap is not
  feasible).

**Attribute matching**

Specified Attribute names shall match the _`attributeNames`_ or the combination of 
_`propertyNames`_ and _`relationshipNames`_ defined in a _RegistrationInfo_ when any of the
following holds:
- No Attribute names are specified in the request (meaning: all attributes are requested).
- The _RegistrationInfo_ defines no _`attributeNames`_ (or combination of _`propertyNames`_ and
  _`relationshipNames`_ (meaning: only Entities are registered, and the Context Source may still
  provide matching Properties or Relationships).
- At least one specified Attribute name matches an _`attributeName`_ (or _`propertyName`_ or 
  _`relationshipName`_ listed in the _RegistrationInfo_.

If the incoming request that triggered the matching includes a _`datasetId`_ parameter
and the [Context Source Registration]{.HTML-Keyboard} to be matched contains a _`datasetId`_ 
element, the [Context Source Registration]{.HTML-Keyboard} should only be considered matching,
if both have at least one value in common. If only one of them specifies a _`datasetId`_, it is
considered a match.

In the case of distributed operations (see Clause+++clause-9+++9.7), where a