From 7f0f2c493a34fdd116697cfd58c74ca994553ef5 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 15 Aug 2019 16:07:33 -0400 Subject: [PATCH 1/4] Several small corrections and enhancements to schema docs --- build/metaschema/lib/metaschema-check.sch | 14 ++++++++------ build/metaschema/lib/metaschema-docs-util.xsl | 8 ++++---- .../lib/metaschema-jsondocs-jekyll-uswds.xsl | 6 +++--- build/metaschema/lib/metaschema-jsonobject-map.xsl | 1 - .../lib/metaschema-xmldocs-jekyll-uswds.xsl | 7 +++---- .../xml/produce-and-run-either-documentor.xsl | 3 +++ 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/build/metaschema/lib/metaschema-check.sch b/build/metaschema/lib/metaschema-check.sch index 481d9daa86..b991fa5d41 100644 --- a/build/metaschema/lib/metaschema-check.sch +++ b/build/metaschema/lib/metaschema-check.sch @@ -18,6 +18,8 @@ + + @@ -41,10 +43,11 @@ formal-name missing from description missing from model missing from - Definition set to address by '', but no flag with that name is declared. Property defined as boolean may not have flags. is assigned a json key, but no 'json-key' is given + Names "STRVALUE", "RICHTEXT" or "PROSE" (reserved names) + @@ -84,12 +87,10 @@ No definition found for '' Flag data type doesn't match: the definition has '' Flag should not be named "STRVALUE", "RICHTEXT" or "PROSE" (reserved names) + Flag is declared with datatype '' while other flags with that name show datatype + - - Prose may not appear in more than once in a model - - @@ -118,7 +119,8 @@ --> - + Only one field may be marked + as 'markup-multiline' (without xml wrapping) within a model. diff --git a/build/metaschema/lib/metaschema-docs-util.xsl b/build/metaschema/lib/metaschema-docs-util.xsl index b7aced3db7..f0a09dc06e 100644 --- a/build/metaschema/lib/metaschema-docs-util.xsl +++ b/build/metaschema/lib/metaschema-docs-util.xsl @@ -91,17 +91,17 @@ function switch_view(who,flag) { - + -
+
diff --git a/build/metaschema/lib/metaschema-jsondocs-jekyll-uswds.xsl b/build/metaschema/lib/metaschema-jsondocs-jekyll-uswds.xsl index 25820325c7..07665bba4b 100644 --- a/build/metaschema/lib/metaschema-jsondocs-jekyll-uswds.xsl +++ b/build/metaschema/lib/metaschema-jsondocs-jekyll-uswds.xsl @@ -112,9 +112,9 @@ @@ -339,7 +339,7 @@
  • - + property diff --git a/build/metaschema/lib/metaschema-jsonobject-map.xsl b/build/metaschema/lib/metaschema-jsonobject-map.xsl index 46019d746e..b01dcdfe90 100644 --- a/build/metaschema/lib/metaschema-jsonobject-map.xsl +++ b/build/metaschema/lib/metaschema-jsonobject-map.xsl @@ -22,7 +22,6 @@ - - +
  • @@ -232,8 +232,7 @@
  • - - + attribute (optional) diff --git a/build/metaschema/xml/produce-and-run-either-documentor.xsl b/build/metaschema/xml/produce-and-run-either-documentor.xsl index 383aa7898d..c820a35049 100644 --- a/build/metaschema/xml/produce-and-run-either-documentor.xsl +++ b/build/metaschema/xml/produce-and-run-either-documentor.xsl @@ -117,6 +117,7 @@ + @@ -127,6 +128,7 @@ + --- title: Schema Documentation - { $metaschema-code }{ $tagname ! (' - ' || .) } description: { $metaschema-code } schema documentation{ $tagname ! (' - ' || .) } @@ -139,6 +141,7 @@ model: { $metaschema-code }-{ $target-format } root: true overview: true + model-type: { $model-type } --- From 5f6f1e3e65b65ddcc7b8692e0369f50579785b8f Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 15 Aug 2019 16:35:25 -0400 Subject: [PATCH 2/4] Corrected erroneous error check in Schematron --- build/metaschema/lib/metaschema-check.sch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/metaschema/lib/metaschema-check.sch b/build/metaschema/lib/metaschema-check.sch index b991fa5d41..e07aef8f91 100644 --- a/build/metaschema/lib/metaschema-check.sch +++ b/build/metaschema/lib/metaschema-check.sch @@ -87,7 +87,7 @@ No definition found for '' Flag data type doesn't match: the definition has '' Flag should not be named "STRVALUE", "RICHTEXT" or "PROSE" (reserved names) - Flag is declared with datatype '' while other flags with that name show datatype + Flag is declared with datatype '' while other flags with that name show datatype From f5788a10de945067eaf0f20e33bf88def8082680 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 16 Aug 2019 15:39:07 -0400 Subject: [PATCH 3/4] Corrections to unit tests --- .../datatypes-prose_json-schema.json | 50 ++++++++----------- .../datatypes-prose_test-valid-PASS.json | 8 +-- .../flag/flag-basic_json-schema.json | 2 +- .../flag/flag-basic_metaschema.xml | 2 +- .../group-as-by-key_test_valid_PASS.json | 2 +- 5 files changed, 28 insertions(+), 36 deletions(-) diff --git a/build/metaschema/unit-testing/datatypes/datatypes-prose_json-schema.json b/build/metaschema/unit-testing/datatypes/datatypes-prose_json-schema.json index 264e19e554..29266484ec 100644 --- a/build/metaschema/unit-testing/datatypes/datatypes-prose_json-schema.json +++ b/build/metaschema/unit-testing/datatypes/datatypes-prose_json-schema.json @@ -37,17 +37,19 @@ "title": "Plain text", "description": "plain text, no markup", "$id": "#/definitions/field-flag-plaintext", + "type": "object", "properties": { "length": { "title": "Length", "description": "The length.", "type": "integer", - "minimum": 1 + "minimum": 1, + "multipleOf": 1.0 }, - "STRVALUE": { - "type": "string" - } - } + "STRVALUE": {"type": "string"} + }, + "required": ["STRVALUE"], + "additionalProperties": false }, "field-richtext": { "title": "Rich text", @@ -59,56 +61,46 @@ "title": "Rich text", "description": "Rich text supports markup", "$id": "#/definitions/field-flag-richtext", + "type": "object", "properties": { "length": { "title": "Length", "description": "The length.", "type": "integer", + "multipleOf": 1.0, "minimum": 1 }, - "RICHTEXT": { - "type": "string" - } - } + "RICHTEXT": {"type": "string"} + }, + "required": ["RICHTEXT"], + "additionalProperties": false }, "field-prose": { "title": "Prose", "description": "Prose permits multiple paragraphs, lists, tables etc.", "$id": "#/definitions/field-prose", - "oneOf": [ - {"type": "string"}, - { - "type": "array", - "items": {"type": "string"}, - "minItems": 2 - } - ] + "type": "string" }, "field-flag-prose": { "title": "Prose", "description": "Prose permits multiple paragraphs, lists, tables etc.", "$id": "#/definitions/field-flag-prose", + "type" : "object", "properties": { "length": { "title": "Length", "description": "The length.", "type": "integer", + "multipleOf": 1.0, "minimum": 1 }, - "PROSE": { - "oneOf": [ - {"type": "string"}, - { - "type": "array", - "items": {"type": "string"}, - "minItems": 2 - } - ] - } - } + "PROSE": {"type": "string"} + }, + "required": ["PROSE"], + "additionalProperties": false } }, "properties": { "parent": {"$ref": "#/definitions/parent"} } -} +} \ No newline at end of file diff --git a/build/metaschema/unit-testing/datatypes/datatypes-prose_test-valid-PASS.json b/build/metaschema/unit-testing/datatypes/datatypes-prose_test-valid-PASS.json index 4f01abbb37..33f2d30750 100644 --- a/build/metaschema/unit-testing/datatypes/datatypes-prose_test-valid-PASS.json +++ b/build/metaschema/unit-testing/datatypes/datatypes-prose_test-valid-PASS.json @@ -1,8 +1,8 @@ { "parent": { - "date": "2019-07-08TZ", - "plaintext": "Some *plain* text", - "richtext": "Some *rich* text", - "prose": [ "Here's some *extra prose*" ] + "field-date": "2019-07-08TZ", + "field-plaintext": "Some *plain* text", + "field-richtext": "Some *rich* text", + "field-prose": "Here's some *extra prose*" } } \ No newline at end of file diff --git a/build/metaschema/unit-testing/flag/flag-basic_json-schema.json b/build/metaschema/unit-testing/flag/flag-basic_json-schema.json index 0f96aedfc3..2b29163d56 100644 --- a/build/metaschema/unit-testing/flag/flag-basic_json-schema.json +++ b/build/metaschema/unit-testing/flag/flag-basic_json-schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://csrc.nist.gov/ns/oscal/unit-testing/flag-basic-schema.json", - "$comment": "Metaschema Unit Test: flag: basic flag", + "$comment": "Metaschema Unit Test: flag: basic flag: JSON Schema", "type": "object", "definitions": { "parent": { diff --git a/build/metaschema/unit-testing/flag/flag-basic_metaschema.xml b/build/metaschema/unit-testing/flag/flag-basic_metaschema.xml index 91765282ee..087aaeef4f 100644 --- a/build/metaschema/unit-testing/flag/flag-basic_metaschema.xml +++ b/build/metaschema/unit-testing/flag/flag-basic_metaschema.xml @@ -8,7 +8,7 @@ xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" xmlns:o="http://csrc.nist.gov/ns/oscal/example" root="parent"> - Metaschema Unit Test: group-as + Metaschema Unit Test: flag: basic flag 1.0-milestone1 metaschema-group-as http://csrc.nist.gov/ns/oscal/unit-testing/flag-basic diff --git a/build/metaschema/unit-testing/group-as/group-as-by-key_test_valid_PASS.json b/build/metaschema/unit-testing/group-as/group-as-by-key_test_valid_PASS.json index 34aa7736b7..f0b784ed32 100644 --- a/build/metaschema/unit-testing/group-as/group-as-by-key_test_valid_PASS.json +++ b/build/metaschema/unit-testing/group-as/group-as-by-key_test_valid_PASS.json @@ -2,7 +2,7 @@ "parent": { "props": { "id3": {"STRVALUE": "test3"}, - "id3": {"STRVALUE": ""}, + "id2": {"STRVALUE": ""}, "id1": {"STRVALUE": "test1"} } } From e269a1c8f441a37075d4f21687e1b423c6096c03 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 16 Aug 2019 15:39:49 -0400 Subject: [PATCH 4/4] Corrections to JSON Schema production now correct to current unit tests --- build/metaschema/json/json-schema-metamap.xsl | 80 ++++++++++++++++--- build/metaschema/json/pull-datatypes.xsl | 6 ++ 2 files changed, 74 insertions(+), 12 deletions(-) diff --git a/build/metaschema/json/json-schema-metamap.xsl b/build/metaschema/json/json-schema-metamap.xsl index 460b039366..7119cd3402 100644 --- a/build/metaschema/json/json-schema-metamap.xsl +++ b/build/metaschema/json/json-schema-metamap.xsl @@ -37,7 +37,7 @@ http://json-schema.org/draft-07/schema# - http://csrc.nist.gov/ns/oscal/{ $composed-metaschema/METASCHEMA/schema-version }/{ short-name }-schema.json + { $composed-metaschema/METASCHEMA/namespace }-schema.json { . }: JSON Schema @@ -66,6 +66,39 @@ + + + + http://json-schema.org/draft-07/schema# + { namespace }-schema.json + + { . }: JSON Schema + + + + object + + + + + + + + + #/definitions/{ @root } + + + + + + + + + + + + + + + @@ -220,18 +261,18 @@ - + - + @@ -245,8 +286,6 @@ string - @@ -314,7 +353,7 @@ match="assembly[empty(@max-occurs) or number(@max-occurs) = 1 ] | field[empty(@max-occurs) or number(@max-occurs)= 1 ]"> - + #/definitions/{ @ref } @@ -376,6 +415,23 @@ string + + + + string + + + array + + + string + + + 2 + + + + @@ -397,7 +453,7 @@ integer - 1.0 + @@ -434,9 +490,9 @@ string - date + - + ((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 diff --git a/build/metaschema/json/pull-datatypes.xsl b/build/metaschema/json/pull-datatypes.xsl index 5f7f22b2af..76e78f5d49 100644 --- a/build/metaschema/json/pull-datatypes.xsl +++ b/build/metaschema/json/pull-datatypes.xsl @@ -11,6 +11,8 @@ + + @@ -68,4 +70,8 @@ { @value } + + \ No newline at end of file