Skip to content

Commit

Permalink
Document index, index-has-key constraint for usnistgov#490.
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-nist committed Jan 5, 2024
1 parent fd6d730 commit 3b36dcc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions website/content/specification/syntax/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,30 @@ And the following document.
The expect constraint would pass for each `sibling` in the `parent` named "p1", and would fail for each `sibling` in the `parent` named "p2".


## `index` constraints

The `index` constraint is a type of Metaschema constraint that defines an index of document instance nodes addressable by key.

The `@name` attribute of an `<index>` constraint specifies the identity of the index. The constraint MUST define the name.

The `@target` attribute of an `<index>` constraint defines the node(s) in a document instance to index. The index MUST define a [`@target`](#target) with a Metapath expression. The processor MUST index only The document instance node(s) resulting from its evaluation.

The `<key-field>` child element of an `<index>` constraint defines the attribute or element value that is the key for each entry in the index. The `<key-field>` element MUST define a [`@target`](#target) attribute with a Metapath expression evaluated relative to [the evaluation focus](#constraint-processing) of each entry of the matches of the constraint's `@target`.

An `index` constraint MAY define more than one `<key-field>` child element. The composite key for each entry in the index is the combination of values for the `@target` of every `<key-field/>`. The composite values of the key are the discriminator for the uniqueness of the index entry.

An `index` constraint requires the each member entry be unique based upon this composite key.

If the evaluation of the Metapath `@target` of the `<key-field/>` does not result in a value, its value for that key in the index is null.

## `index-has-key` constraints

The `index-has-key` constraint is a type of Metaschema constraint that cross-references values an existing `index` constraint` with a separate `@target` and `<key-field/>`.

The `@name` attribute of an `<index>` constraint MUST specify the name of a previously defined `index` constraint.

The `index-has-key` constraint has the same attributes and child elements as a [`index`](#index-constraints) constraint.

## Enumerated values

The `allowed-values` constraint is a type of Metaschema constraint that restricts field or flag value(s) based on an enumerated set of permitted values.
Expand Down

0 comments on commit 3b36dcc

Please sign in to comment.