Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore legacy datatypes #698

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions schema/metaschema/metaschema-module-constraints.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,81 @@
<metaschema-meta-constraints xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../xml/metaschema-meta-constraints.xsd">
<context>
<metapath target="/METASCHEMA"/>
<constraints>
<let var="all-imports" expression="recurse-depth('for $import in ./import return doc(resolve-uri($import/@href))/METASCHEMA')"/>
<index id="module-short-name-unique" target="(.|$all-imports)" name="metaschema-metadata-short-name-index">
<formal-name>Index Module Short Names</formal-name>
<description>Ensures that the current and all imported modules have a unique short name.</description>
<key-field target="@short-name"/>
</index>
<expect id="module-top-level-version-required" level="WARNING"
target=".[not(@abstract) or @abstract='no']"
test="schema-version">
<formal-name>Require Schema Version for Top-Level Modules</formal-name>
<description>A top-level module, a module that is not marked as @abstract='yes', must have a schema version specified.</description>
<message>Unless marked as @abstract='yes', a Metaschema module (or an imported module) should have a schema version.</message>
</expect>
<expect id="module-top-level-root-required" level="WARNING"
target=".[not(@abstract) or @abstract='no']"
test="exists($all-imports/define-assembly/root-name)">
<formal-name>Require Root Assembly for Top-Level Modules</formal-name>
<description>A top-level module, a module that is not marked as @abstract='yes', must have at least one assembly with a root-name.</description>
<message>Unless marked as @abstract='yes', a Metaschema module (or an imported module) should have at least one assembly with a root-name.</message>
</expect>
<is-unique id="module-namespace-unique-entry" target="namespace-binding">
<formal-name>Require Unique Namespace Entries</formal-name>
<description>Ensures that all declared namespace entries are unique.</description>
<key-field target="@prefix"/>
<key-field target="@uri"/>
</is-unique>
<is-unique id="module-namespace-unique-prefix" target="namespace-binding">
<formal-name>Require Unique Namespace Entry Prefixes</formal-name>
<description>Ensures that all declared namespace entries have a unique prefix.</description>
<key-field target="@prefix"/>
</is-unique>
<expect id="module-import-href-available" target="import" test="doc-available(resolve-uri(@href))">
<formal-name>Import is Resolvable</formal-name>
<description>Ensure each import has a resolvable @href.</description>
<message>Unable to access a Metaschema module at '{{ resolve-uri(@href) }}'.</message>
</expect>
<expect id="module-import-href-is-module" target="import" test="doc(resolve-uri(@href))/METASCHEMA ! exists(.)">
<formal-name>Import is a Metaschema module</formal-name>
<description>Ensure each import is a Metaschema module.</description>
<message>Unable the resource at '{{ resolve-uri(@href) }}' is not a Metaschema module.</message>
</expect>
</constraints>
</context>
<context>
<metapath target="/METASCHEMA"/>
<metapath target="/metaschema-meta-constraints"/>
<metapath target="/metaschema-module-constraints"/>
<constraints>
<let var="deprecated-type-map" expression="map { 'base64Binary':'base64','dateTime':'date-time','dateTime-with-timezone':'date-time-with-timezone','email':'email-address','nonNegativeInteger':'non-negative-integer','positiveInteger':'positive-integer' }"/>
<expect id="metaschema-deprecated-types" level="WARNING"
target=".//matches/@datatype|.//(define-field|define-flag)/@as-type"
test="not(.=('base64Binary','dateTime','dateTime-with-timezone','email','nonNegativeInteger','positiveInteger'))">
<formal-name>Avoid Deprecated Data Type Use</formal-name>
<description>Ensure that the data type specified is not one of the legacy Metaschema data types which have been deprecated (i.e. base64Binary, dateTime, dateTime-with-timezone, email, nonNegativeInteger, positiveInteger).</description>
<message>Use of the type '{ . }' is deprecated. Use '{ $deprecated-type-map(.)}' instead.</message>
</expect>
</constraints>
</context>
<context>
<metapath target="/metaschema-meta-constraints"/>
<constraints>
<is-unique id="meta-constraints-namespace-unique-entry" target="namespace-binding">
<formal-name>Require Unique Namespace Entries</formal-name>
<description>Ensures that all declared namespace entries are unique.</description>
<key-field target="@prefix"/>
<key-field target="@uri"/>
</is-unique>
<is-unique id="meta-constraints-namespace-unique-prefix" target="namespace-binding">
<formal-name>Require Unique Namespace Entry Prefixes</formal-name>
<description>Ensures that all declared namespace entries have a unique prefix.</description>
<key-field target="@prefix"/>
</is-unique>
</constraints>
</context>
</metaschema-meta-constraints>
67 changes: 52 additions & 15 deletions schema/metaschema/metaschema-module-metaschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<description>A relative or absolute URI for retrieving an out-of-line Metaschema definition.</description>
</define-flag>
</define-assembly>
<assembly ref="metapath-namespace" max-occurs="unbounded">
<group-as name="namespace-bindings" />
</assembly>
<choice-group max-occurs="unbounded">
<group-as name="definitions" in-json="ARRAY"/>
<discriminator>object-type</discriminator>
Expand Down Expand Up @@ -178,11 +181,23 @@
</define-assembly>
</choice-group>
</model>
<constraint>
<let var="keywords" expression="'ancestor', 'ancestor-or-self', 'and', 'as', 'attribute', 'cast', 'castable', 'child', 'comment', 'descendant', 'descendant-or-self', 'div', 'document-node', 'element', 'else', 'empty-sequence', 'eq', 'every', 'except', 'following', 'following-sibling', 'for', 'function', 'ge', 'gt', 'idiv', 'if', 'in', 'instance', 'intersect', 'is', 'item', 'le', 'let', 'lt', 'mod', 'namespace', 'namespace-node', 'ne', 'node', 'of', 'or', 'parent', 'preceding', 'preceding-sibling', 'processing-instruction', 'return', 'satisfies', 'schema-attribute', 'schema-element', 'self', 'some', 'text', 'then', 'to', 'treat', 'union'"/>
</constraint>
</define-assembly>

<define-assembly name="metapath-namespace">
<formal-name>Metapath Namespace Declaration</formal-name>
<description>Assigns a Metapath namespace to a prefix for use in a Metapath expression in a lexical qualified name.</description>
<use-name>namespace-binding</use-name>
<define-flag name="uri" as-type="uri" required="yes">
<formal-name>Metapath Namespace URI</formal-name>
<description>The namespace URI to bind to the prefix.</description>
</define-flag>
<define-flag name="prefix" as-type="token" required="yes">
<formal-name>Metapath Namespace Prefix</formal-name>
<description>The prefix that is bound to the namespace.</description>
</define-flag>
</define-assembly>


<define-assembly name="inline-define-assembly">
<formal-name>Inline Assembly Definition</formal-name>
<use-name>define-assembly</use-name>
Expand Down Expand Up @@ -624,11 +639,6 @@
<define-flag name="definition-name" as-type="token">
<formal-name>Definition Name</formal-name>
<use-name>name</use-name>
<constraint>
<expect level="WARNING" test="not(.=$keywords)">
<message>Names cannot be non-delimiting terminal symbols in Metapath syntax.</message>
</expect>
</constraint>
</define-flag>

<define-flag name="definition-reference" as-type="token">
Expand Down Expand Up @@ -684,6 +694,12 @@
<enum value="uri"/>
<enum value="uri-reference"/>
<enum value="uuid"/>
<enum value="base64Binary" deprecated="1.0.0"/>
<enum value="dateTime" deprecated="1.0.0"/>
<enum value="dateTime-with-timezone" deprecated="1.0.0"/>
<enum value="email" deprecated="1.0.0"/>
<enum value="nonNegativeInteger" deprecated="1.0.0"/>
<enum value="positiveInteger" deprecated="1.0.0"/>
</allowed-values>
</constraint>
</define-flag>
Expand Down Expand Up @@ -713,6 +729,13 @@
<enum value="uri"/>
<enum value="uri-reference"/>
<enum value="uuid"/>

<enum value="base64Binary" deprecated="1.0.0"/>
<enum value="dateTime" deprecated="1.0.0"/>
<enum value="dateTime-with-timezone" deprecated="1.0.0"/>
<enum value="email" deprecated="1.0.0"/>
<enum value="nonNegativeInteger" deprecated="1.0.0"/>
<enum value="positiveInteger" deprecated="1.0.0"/>
</allowed-values>
</constraint>
</define-flag>
Expand Down Expand Up @@ -786,11 +809,6 @@
<description>Allows the name of the definition to be overridden.</description>
<json-value-key>name</json-value-key>
<flag ref="alt-name-index"/>
<constraint>
<expect level="WARNING" target="." test="not(.=$keywords)">
<message>Names cannot be non-delimiting terminal symbols in Metapath syntax.</message>
</expect>
</constraint>
</define-field>

<define-flag name="alt-name-index" as-type="non-negative-integer">
Expand Down Expand Up @@ -1238,6 +1256,11 @@
<description>A relative or absolute URI for retrieving an out-of-line Metaschema constraint definition.</description>
</define-flag>
</define-assembly>

<assembly ref="metapath-namespace" max-occurs="unbounded">
<group-as name="namespace-bindings" />
</assembly>

<define-assembly name="scope" min-occurs="1" max-occurs="unbounded">
<group-as name="scopes" in-json="ARRAY"/>
<define-flag name="metaschema-namespace" as-type="uri" required="yes"/>
Expand Down Expand Up @@ -1302,6 +1325,18 @@
<description>Defines constraint rules to be applied to an existing set of Metaschema module-based models.</description>
<root-name>metaschema-meta-constraints</root-name>
<model>
<define-assembly name="import" max-occurs="unbounded">
<description>Declares a set of Metaschema constraints from an out-of-line resource to import, supporting composition of constraint sets.</description>
<group-as name="imports" in-json="ARRAY"/>
<define-flag name="href" as-type="uri-reference" required="yes">
<description>A relative or absolute URI for retrieving an out-of-line Metaschema constraint definition.</description>
</define-flag>
</define-assembly>

<assembly ref="metapath-namespace" max-occurs="unbounded">
<group-as name="namespace-bindings" />
</assembly>

<define-assembly name="definition-context">
<define-flag name="name" as-type="token" required="yes"/>
<define-flag name="namespace" as-type="uri" required="yes"/>
Expand All @@ -1313,7 +1348,8 @@
</model>
</define-assembly>
<assembly ref="metapath-context" min-occurs="1" max-occurs="unbounded">
<group-as name="metapath-contexts" in-json="ARRAY"/>
<use-name>context</use-name>
<group-as name="contexts" in-json="ARRAY"/>
</assembly>
</model>
</define-assembly>
Expand All @@ -1334,7 +1370,8 @@
<use-name>constraints</use-name>
</assembly>
<assembly ref="metapath-context" max-occurs="unbounded">
<group-as name="metapath-contexts" in-json="ARRAY"/>
<use-name>context</use-name>
<group-as name="contexts" in-json="ARRAY"/>
</assembly>
<field ref="remarks"/>
</model>
Expand Down
Loading
Loading