Skip to content

Commit

Permalink
Add field and flag a-v constraint explanation.
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-nist committed Aug 18, 2023
1 parent b906d15 commit d4db3d9
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions website/content/specification/syntax/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ One kind of Metaschema constraint is restricting assembly, field, or flag value(
2. When the `allow-other` attribute is defined as `allow-other="yes"`, the processor MUST loosely validate content instances with enumerations: both `enum` values and other values are valid.
3. When the `allow-other` attribute is not explicitly defined, the Metaschema processor MUST strictly validate content instances. The implied default is `allow-other="no"`.

Within `allowed-values` of a `constraint`, a Metaschema processor MUST strictly or loosely validate `enum` values with the `@value` attribute. A Metaschema processor MAY use the text value of the `enum`'s XML element as documentation for a given allowed value enumeration. Below is an example.
### `define-flag` constraints

An assembly can define `allowed-values` constraints. The constraint MUST have an `allowed-values` values element with one or more `enum` elements for each value subject to strict or loose validation. Each `enum` element MUST have a `value` attribute and MAY have a text value for documenting the allowed value. A Metaschema processor MUST strictly or loosely validate `enum` values with the `value` attribute. A Metaschema processor MAY use the text value of the `enum`'s XML element as documentation for a given allowed value enumeration. Below is an example.

```xml
<define-flag name="form-factor">
Expand All @@ -35,10 +37,23 @@ Within `allowed-values` of a `constraint`, a Metaschema processor MUST strictly
</define-flag>
```

### `define-flag` constraints

### `define-field` constraints

A field `allowed-values` constraint is syntactically equivalent to such a constraint for a flag. Syntax and processor requirements are identical. See below for an example.

```xml
<define-field name="form-factor">
<formal>Computer Form Factor</formal-name>
<description>The type of computer in the example application's data model.</description>
<constraint>
<allowed-values allow-other="yes">
<enum value="laptop">this text value documents the domain and information model's meaning of a laptop</enum>
<enum value="desktop">this text value documents the domain and information model's meaning of a desktop</enum>
</allowed-values>
</constraint> ...
</define-field>
```

### `define-assembly` constraints

An assembly can define `allowed-values` constraints. Unlike flag and field constraints, assembly `allowed-vaues` constraints have a `target` attribute to indicate the location of element(s) where the enumerated values are applicable for strict or loose validation. A Metaschema processor MUST parse the right-hand side of the `target` attribute, a Metapath expression, to correctly apply strict or loose validation to the relevant elements that match this expression. Below is an example.
Expand Down

0 comments on commit d4db3d9

Please sign in to comment.