diff --git a/test-suite/schema-generation/token/datatype-token-test-FAIL.xml b/test-suite/schema-generation/token/datatype-token-test-FAIL.xml new file mode 100644 index 000000000..dbfbf9917 --- /dev/null +++ b/test-suite/schema-generation/token/datatype-token-test-FAIL.xml @@ -0,0 +1,6 @@ + + + + 7b5d9713-4488-4d71-8e77-85b0b185d71a + :xyz + \ No newline at end of file diff --git a/test-suite/schema-generation/token/datatypes-token_metaschema.xml b/test-suite/schema-generation/token/datatypes-token_metaschema.xml new file mode 100644 index 000000000..4e373a222 --- /dev/null +++ b/test-suite/schema-generation/token/datatypes-token_metaschema.xml @@ -0,0 +1,35 @@ + + + + + + + Metaschema Unit Test: Token Datatype + 1.0-milestone2 + metaschema-datatypes-token + http://csrc.nist.gov/ns/metaschema/unit-test/datatypes-uri + http://csrc.nist.gov/ns/metaschema/unit-test/datatypes-uri + + + parent + parent assembly + parent + + A metaschema 'token', a string without spaces suitable for use as a key value) + Corresponds to XML NCName (no-colon name). + + + + + + + + + + A metaschema 'token', a string without spaces for use as a key value + Corresponds to XML NCName (no-colon name). + + + diff --git a/test-suite/schema-generation/token/datatypes-token_metaschema_JSON-SCHEMA.json b/test-suite/schema-generation/token/datatypes-token_metaschema_JSON-SCHEMA.json new file mode 100644 index 000000000..37aefbf44 --- /dev/null +++ b/test-suite/schema-generation/token/datatypes-token_metaschema_JSON-SCHEMA.json @@ -0,0 +1,42 @@ + + { "$schema" : "http://json-schema.org/draft-07/schema#", + "$id" : "http://csrc.nist.gov/ns/metaschema/unit-test/datatypes-uri/1.0-milestone2/metaschema-datatypes-token-schema.json", + "$comment" : "Metaschema Unit Test: Token Datatype: JSON Schema", + "type" : "object", + "definitions" : + { "metaschema-datatypes-token-metaschema-datatypes-token:parent" : + { "title" : "parent", + "description" : "parent assembly", + "$id" : "#assembly_metaschema-datatypes-token_parent", + "type" : "object", + "properties" : + { "token-flag" : + { "title" : "A metaschema 'token', a string without spaces suitable for use as a key value)", + "description" : "Corresponds to XML NCName (no-colon name).", + "type" : "string", + "pattern" : "^[_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-\\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$" }, + "token-fields" : + { "anyOf" : + [ + { "$ref" : "#field_metaschema-datatypes-token_token-field" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#field_metaschema-datatypes-token_token-field" } } ] } }, + "required" : + [ "token-flag" ], + "additionalProperties" : false }, + "metaschema-datatypes-token-metaschema-datatypes-token:token-field" : + { "title" : "A metaschema 'token', a string without spaces for use as a key value", + "description" : "Corresponds to XML NCName (no-colon name).", + "$id" : "#field_metaschema-datatypes-token_token-field", + "type" : "string", + "pattern" : "^[_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-\\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$" } }, + "properties" : + { "parent" : + { "$ref" : "#assembly_metaschema-datatypes-token_parent" } }, + "required" : + [ "parent" ], + "additionalProperties" : false, + "maxProperties" : 1 } \ No newline at end of file diff --git a/test-suite/schema-generation/token/datatypes-token_metaschema_XML-SCHEMA.xsd b/test-suite/schema-generation/token/datatypes-token_metaschema_XML-SCHEMA.xsd new file mode 100644 index 000000000..5a555deb9 --- /dev/null +++ b/test-suite/schema-generation/token/datatypes-token_metaschema_XML-SCHEMA.xsd @@ -0,0 +1,72 @@ + + + + + Metaschema Unit Test: Token Datatype + 1.0-milestone2 + metaschema-datatypes-token + parent + + + + + + + parent + parent assembly + + + parent: parent assembly + + + + + + + + A metaschema 'token', a string without spaces suitable for use as a key value) + Corresponds to XML NCName (no-colon name). + + + A metaschema 'token', a string without spaces suitable for use as a key value): Corresponds to XML NCName (no-colon name). + + + + + + + A metaschema 'token', a string without spaces for use as a key value + Corresponds to XML NCName (no-colon name). + + + A metaschema 'token', a string without spaces for use as a key value: Corresponds to XML NCName (no-colon name). + + + + + + A string token following the rules of XML "no colon" names, with no whitespace. (XML names are single alphabetic characters + followed by alphanumeric characters, periods, underscores or dashes.) + + + + + + A single token may not contain whitespace. + + + + + diff --git a/test-suite/schema-generation/token/datatypes-token_test_invalid_FAIL.json b/test-suite/schema-generation/token/datatypes-token_test_invalid_FAIL.json new file mode 100644 index 000000000..90ee64948 --- /dev/null +++ b/test-suite/schema-generation/token/datatypes-token_test_invalid_FAIL.json @@ -0,0 +1,5 @@ +{ + "parent": { + "token-flag": ":::" + } +} \ No newline at end of file diff --git a/test-suite/schema-generation/token/datatypes-token_test_valid_PASS.json b/test-suite/schema-generation/token/datatypes-token_test_valid_PASS.json new file mode 100644 index 000000000..6f733818b --- /dev/null +++ b/test-suite/schema-generation/token/datatypes-token_test_valid_PASS.json @@ -0,0 +1,11 @@ +{ + "parent": { + "token-flag": "F22", + "token-fields": [ + "Af70e7c83", + "B4b1344c3", + "C398f9ba5", + "Ω" + ] + } +} \ No newline at end of file diff --git a/toolchains/xslt-M4/make-metaschema-xsd.xpl b/toolchains/xslt-M4/make-metaschema-xsd.xpl index a256246f6..20ef8aaad 100644 --- a/toolchains/xslt-M4/make-metaschema-xsd.xpl +++ b/toolchains/xslt-M4/make-metaschema-xsd.xpl @@ -31,7 +31,7 @@ - + diff --git a/toolchains/xslt-M4/nist-metaschema-MAKE-JSON-SCHEMA-debug.xsl b/toolchains/xslt-M4/nist-metaschema-MAKE-JSON-SCHEMA-debug.xsl new file mode 100644 index 000000000..64b5715bc --- /dev/null +++ b/toolchains/xslt-M4/nist-metaschema-MAKE-JSON-SCHEMA-debug.xsl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + off + + + + + + + + + compose/metaschema-collect.xsl + compose/metaschema-build-refs.xsl + compose/metaschema-trim-extra-modules.xsl + compose/metaschema-prune-unused-definitions.xsl + compose/metaschema-resolve-use-names.xsl + compose/metaschema-resolve-sibling-names.xsl + compose/metaschema-digest.xsl + compose/annotate-composition.xsl + + schema-gen/make-json-schema-metamap.xsl + + + + \ No newline at end of file diff --git a/toolchains/xslt-M4/nist-metaschema-MAKE-XSD.xsl b/toolchains/xslt-M4/nist-metaschema-MAKE-XSD.xsl index 3adb6e3fe..6a8da2c61 100644 --- a/toolchains/xslt-M4/nist-metaschema-MAKE-XSD.xsl +++ b/toolchains/xslt-M4/nist-metaschema-MAKE-XSD.xsl @@ -11,7 +11,7 @@ - + \ No newline at end of file diff --git a/toolchains/xslt-M4/schema-gen/datatypes-query.xsl b/toolchains/xslt-M4/schema-gen/datatypes-query.xsl new file mode 100644 index 000000000..bd74be25f --- /dev/null +++ b/toolchains/xslt-M4/schema-gen/datatypes-query.xsl @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + Copies of simpleType declarations for querying by + routines that need to know about XSD simple types we may use. Any simpleType + we support should be listed here for propagation in tools e.g. Metaschema Schematron. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { @key }: {.} + + + \ No newline at end of file diff --git a/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl b/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl index a6f49ff02..217987c13 100644 --- a/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl +++ b/toolchains/xslt-M4/schema-gen/make-json-schema-metamap.xsl @@ -620,7 +620,15 @@ - + + + + + + + --> - - - + + + + + + + number - ^(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)$ + - + string - ^((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30))(Z|[+-][0-9]{2}:[0-9]{2})?$ - + string - ^((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})?$ - + string - ^((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30))(Z|[+-][0-9]{2}:[0-9]{2})$ - + string date-time - ^((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$ - + string email - - ^.+@.+ + ^.+@.+$ - + string ipv4 - ^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]).){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$ - + string ipv6 - ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|[fF][eE]80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::([fF]{4}(:0{1,4}){0,1}:){0,1}((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]).){3,3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]).){3,3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))$ - - string + + #/definitions/StringDatatype idn-hostname - - ^.+$ - + string uri - + ^[a-zA-Z][a-zA-Z0-9+\-.]+:.+$ - + string uri-reference - - - + string - - ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$ + A type 4 ('random' or 'pseudorandom') or type 5 UUID per RFC 4122. + ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[45][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$ - - Javascript regex NameStartChar (no colon) [_A-Za-z\uC0-\uD6\uD8-\uF6\uF8-\u2FF\u370-\u37D\u37F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD] - -PRODUCTION 4a NameChar ::= - NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] - --> Javascript regex NameChar (no colon) -[_\-\.\u00B7\u0300-\u036F\u203F-\u2040 + NameStartChar ] - - --> + string - - - _A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD - { $initial-name-chars }\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040 - - ^[{ $initial-name-chars }][{ $name-chars }]*$ - + ^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$ + string ^\S(.*\S)?$ diff --git a/toolchains/xslt-M4/schema-gen/make-metaschema-xsd.xsl b/toolchains/xslt-M4/schema-gen/make-metaschema-xsd.xsl index db384e040..6ae0e7b45 100644 --- a/toolchains/xslt-M4/schema-gen/make-metaschema-xsd.xsl +++ b/toolchains/xslt-M4/schema-gen/make-metaschema-xsd.xsl @@ -78,9 +78,8 @@ --> - - + diff --git a/toolchains/xslt-M4/schema-gen/oscal-auto-datatypes.xsd b/toolchains/xslt-M4/schema-gen/oscal-auto-datatypes.xsd new file mode 100644 index 000000000..f3316f806 --- /dev/null +++ b/toolchains/xslt-M4/schema-gen/oscal-auto-datatypes.xsd @@ -0,0 +1,293 @@ + + + + Copies of simpleType declarations for querying by + routines that need to know about XSD simple types we may use. Any simpleType + we support should be listed here for propagation in tools e.g. Metaschema Schematron. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A type 4 ('random' or 'pseudorandom') or type 5 UUID per RFC 4122. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A type 4 ('random' or 'pseudorandom') or type 5 UUID per RFC 4122. + + + + + + + + + + + + + + + + + + + + + + diff --git a/toolchains/xslt-M4/schema-gen/oscal-datatypes.xsd b/toolchains/xslt-M4/schema-gen/oscal-datatypes.xsd index 8991d5b9d..079f0daf4 100644 --- a/toolchains/xslt-M4/schema-gen/oscal-datatypes.xsd +++ b/toolchains/xslt-M4/schema-gen/oscal-datatypes.xsd @@ -1,9 +1,9 @@ @@ -31,31 +31,50 @@ + + + OSCAL reference for native type + + + + + + + OSCAL reference for native type + + + + + + + OSCAL reference for native type + + + + + + + OSCAL reference for native type + + + + + + A string, but not empty and not whitespace-only (whitespace is U+9, U+10, U+32 or [ \n\t]+ ) - - - - - A trimmed string, at least one character with no leading or trailing whitespace. - - - + - The ip-v4-address type specifies an IPv4 address in dot decimal notation. - - - - + @@ -63,93 +82,57 @@ The ip-v6-address type specifies an IPv6 address represented in 8 hextets separated by colons. This is based on the pattern provided here: https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses with some customizations. - - - - + The xs:dateTime with a required timezone. - - - + The xs:date with a required timezone. - - - + + An email address - - - - - Need a better pattern. - - - + A host name - - - - - Need a better pattern - - - + A URI - - - - - Requires a scheme with colon per RFC 3986 - - - + A URI reference, such as a relative URL - - - + A Type 4 ('random' or 'pseudorandom' UUID per RFC 4122 - - - - - A sequence of 8-4-4-4-12 hex digits, with extra constraints in the 13th and 17-18th places for version 4 - - - + @@ -159,18 +142,246 @@ A string token following the rules of XML "no colon" names, with no whitespace. (XML names are single alphabetic characters followed by alphanumeric characters, periods, underscores or dashes.) - - - - - - A single token may not contain whitespace. - - - + + + + + + + A trimmed string, at least one character with no + leading or trailing whitespace. + + + + + + + + + + A trimmed string, at least one character with no + leading or trailing whitespace. + + + + + + + + + + + + + + The xs:date with a required timezone. + + + + + + + + + + + + + + + The xs:dateTime with a required timezone. + + + + + + + + + + + + + + + + + A trimmed string, at least one character with no + leading or trailing whitespace. + + + + + + + + An email address + + + + + Need a better pattern. + + + + + + + + A host name + + + + + + + + + + + A trimmed string, at least one character with no + leading or trailing whitespace. + + + + + + + + The ip-v4-address type specifies an IPv4 address in + dot decimal notation. + + + + + + + + + The ip-v6-address type specifies an IPv6 address + represented in 8 hextets separated by colons. + This is based on the pattern provided here: + https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses + with some customizations. + + + + + + + + + + + + A trimmed string, at least one character with no + leading or trailing whitespace. + + + + + + + + + + A trimmed string, at least one character with no + leading or trailing whitespace. + + + + + + + + A string, but not empty and not whitespace-only + (whitespace is U+9, U+10, U+32 or [ \n\t]+ ) + + + + The OSCAL 'string' datatype restricts the XSD type by prohibiting leading + and trailing whitespace, and something (not only whitespace) is required. + + + + + A trimmed string, at least one character with no + leading or trailing whitespace. + + + + + + + + + A string token following the rules of XML "no + colon" names, with no whitespace. (XML names are single alphabetic + characters followed by alphanumeric characters, periods, underscores or dashes.) + + + + + + + + A single token may not contain whitespace. + + + + + + + + + A URI + + + + + Requires a scheme with colon per RFC 3986. + + + + + + + + A URI reference, such as a relative URL + + + + + + A trimmed URI, at least one character with no + leading or trailing whitespace. + + + + + + + + A type 4 ('random' or 'pseudorandom') or type 5 UUID per RFC + 4122. + + + + + A sequence of 8-4-4-4-12 hex digits, with extra + constraints in the 13th and 17-18th places for version 4 and 5 + + + + + diff --git a/toolchains/xslt-M4/validate/metaschema-composition-check.sch b/toolchains/xslt-M4/validate/metaschema-composition-check.sch index 7b2ebe42d..a116a96d1 100644 --- a/toolchains/xslt-M4/validate/metaschema-composition-check.sch +++ b/toolchains/xslt-M4/validate/metaschema-composition-check.sch @@ -63,7 +63,7 @@ --> - + Ambiguous reference to '' found in . The reference resolved to define- with the name '' in: . Is this due to a duplicated METASCHEMA/short-name in a module?