Skip to content

Commit

Permalink
Updated the constraints documentation to add is-unique (usnistgov#512)
Browse files Browse the repository at this point in the history
* Updated the constraints documentation to add is-unique

* removed dashes and added evalutation statement

* revised the key-field statement

* Updated terminology to reflect that of Metaschema. Added link to id attribute.

* Updated language in @target section.

* Update website/content/specification/syntax/constraints.md

Co-authored-by: A.J. Stein <[email protected]>

* Update website/content/specification/syntax/constraints.md

Co-authored-by: A.J. Stein <[email protected]>

* addressed AJ's concerns on <key-field> and wording of capability.

* adjusted text based on pairing feedback.

* Apply suggestions from code review

Co-authored-by: A.J. Stein <[email protected]>

---------

Co-authored-by: A.J. Stein <[email protected]>
Co-authored-by: David Waltermire <[email protected]>
  • Loading branch information
3 people authored Feb 23, 2024
1 parent 6c519a6 commit 3eb970b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions website/content/specification/syntax/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ The `index` constraint is a type of Metaschema constraint that defines an index

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

The `@target` flag 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 `@target` flag 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 node(s) resulting from evaluating the `@target`.

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

An `index` constraint MAY define more than one `<key-field>` assembly. 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.

Expand All @@ -205,6 +205,20 @@ The `@name` flag of an `<index>` constraint MUST specify the name of a previousl

The `index-has-key` constraint has the same flags and assemblies as a [`index`](#index-constraints) constraint.

## `is-unique` constraints

The `<is-unique>` constraint is a type of Metaschema constraint that checks that a computed key, based on field and flag values, does not occur more than once. Unlike `<index>`, an explicit, named index is not created. Therefore, this constraint MUST NOT define a `@name` flag.

The [`id`](#id) flag of an `<is-unique>` constraint specifies an identifier for the constraint.

The `@target` flag of an `<is-unique>` constraint identifies the node(s) in a document instance to check for uniqueness. The `<is-unique>` MUST define a [`@target`](#target) with a Metapath expression. The processor MUST check uniqueness for only the node(s) resulting from evaluating the `@target`.

A `<key-field>` assembly of an `<is-unique>` constraint identifies the flag or field value that is the key used to determine the uniqueness of each entry based on a computed key. A `<key-field>` element MUST define at least one [`@target`](#target) flag with a Metapath expression evaluated relative to [the evaluation focus](#constraint-processing) using each node that matches the constraint's `@target`.

An `is-unique` constraint MAY define more than one `<key-field>` assembly. 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.

When evaluating a given key relative to other computed keys for the same constraint, if the given key has the same computed key value as another node matching the same constraint, then the target node MUST be considered to not pass the constraint.

## `has-cardinality` constraints

The `has-cardinality` constraint is a type of Metaschema constraint that defines the cardinality of assemblies, flags, and, fields, i.e. the required minimum count of occurrences, the maximum count of occurrences, or both for applicable document instances.
Expand Down

0 comments on commit 3eb970b

Please sign in to comment.