From e6079da3685d3705e6bd6372073ec500567c26d3 Mon Sep 17 00:00:00 2001 From: "A.J. Stein" Date: Fri, 18 Aug 2023 14:59:54 -0400 Subject: [PATCH] Adding more examples and other touch-ups. --- .../specification/syntax/constraints.md | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/website/content/specification/syntax/constraints.md b/website/content/specification/syntax/constraints.md index 8dc50f7f..82e0774d 100644 --- a/website/content/specification/syntax/constraints.md +++ b/website/content/specification/syntax/constraints.md @@ -22,14 +22,14 @@ One kind of Metaschema constraint is restricting assembly, field, or flag value( ### `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. +A flag 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 Computer Form Factor - The type of computer in the example application's data model. + The type of computer in the example application's data model - + this text value documents the domain and information model's meaning of a laptop this text value documents the domain and information model's meaning of a desktop @@ -44,9 +44,9 @@ A field `allowed-values` constraint is syntactically equivalent to such a constr ```xml Computer Form Factor - The type of computer in the example application's data model. + The type of computer in the example application's data model - + this text value documents the domain and information model's meaning of a laptop this text value documents the domain and information model's meaning of a desktop @@ -58,9 +58,51 @@ A field `allowed-values` constraint is syntactically equivalent to such a constr 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. +```xml + + Employee Computer + A computer for an employee + + + Computer Form Factor + The type of computer in the example application's data model + + + + + this text value documents the domain and information model's meaning of an employee server + + + +``` + ### Multiple allowed value constraints for the same target A Metaschema processor MUST process and support validation of content instances of Metaschema modules with multiple `allowed-values` constraints for the same targets with an implicit or explicit `allow-other="no"` directive. Fields and flags may have their own internal enumerations, and assemblies themselves can define additional `allowed-values` constraints with `target` attributes for context-sensitive constraints to the same fields and flags, the result is compositional. A Metaschema processor MUST validate content instances with these constraints when there is an explicit or implicit `allow-other="no"` as a union of all enumerations applicable to the context-sensitive target. Below is an example. ```xml -``` \ No newline at end of file + + Computer Form Factor + The type of computer in the example application's data model + + + this text value documents the domain and information model's meaning of a laptop + this text value documents the domain and information model's meaning of a desktop + + + + + Employee Computer + A computer for an employee + + + + + + this text value documents the domain and information model's meaning of an employee server + + + +``` + +When multiple `allowed-constraints` apply to an element where one defines a constraint `allow-other="yes"` and another that defines a constraint with `allow-other="no"`, the latter takes precedence and a Metaschema processor MUST perform strict validation content instances for a given Metaschema module on the enumerated allowed-values in the `allow-other="no"` constraint.