From 74a7d6de7ee2e7610d6eed070d66564201e24b1f Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Wed, 29 Apr 2020 17:46:50 -0400 Subject: [PATCH] Initial cut at XSLT to produce XML->supermodel converter XSLT see #51; also more worked examples / problem cases --- support/lib/metaschema-supermodel.xsd | 66 +++++++++++++ .../allowed-values-confusion-metaschema.xml | 20 ++-- ...d-values-confusion-metaschema_METATRON.sch | 19 ++++ ...s-confusion-metaschema_declaration-map.xml | 4 +- .../models-definition-map.xml | 92 +++++++++++++++++++ .../everything-metaschema/models-testdata.xml | 89 ++++++++++++++++++ .../models_metaschema.xml | 16 +++- .../models_metaschema_JSON-SCHEMA.json | 10 +- .../models_metaschema_XML-SCHEMA.xsd | 37 +++++--- .../xslt-proto-v04/compose/make-model-map.xsl | 54 ++++++++--- .../xslt-proto-v04/compose/reduce-map.xsl | 4 +- .../make-metaschema-model-maps.xpl | 8 +- .../schema_gen/make-metaschema-metatron.xsl | 3 +- .../validate/metaschema-check.sch | 6 +- 14 files changed, 373 insertions(+), 55 deletions(-) create mode 100644 support/lib/metaschema-supermodel.xsd create mode 100644 test-suite/worked-examples/everything-metaschema/models-definition-map.xml create mode 100644 test-suite/worked-examples/everything-metaschema/models-testdata.xml diff --git a/support/lib/metaschema-supermodel.xsd b/support/lib/metaschema-supermodel.xsd new file mode 100644 index 000000000..4dfaff3dc --- /dev/null +++ b/support/lib/metaschema-supermodel.xsd @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-suite/broken/allowed-values-confusion-metaschema.xml b/test-suite/broken/allowed-values-confusion-metaschema.xml index 0b3bd4769..063ad1427 100644 --- a/test-suite/broken/allowed-values-confusion-metaschema.xml +++ b/test-suite/broken/allowed-values-confusion-metaschema.xml @@ -73,17 +73,14 @@ o umlaut u umlaut - + + + + pink + orange + purple + @@ -112,7 +109,6 @@ - Item type Characterizes the type of item diff --git a/test-suite/broken/allowed-values-confusion-metaschema_METATRON.sch b/test-suite/broken/allowed-values-confusion-metaschema_METATRON.sch index 48d7edb80..9225389d4 100644 --- a/test-suite/broken/allowed-values-confusion-metaschema_METATRON.sch +++ b/test-suite/broken/allowed-values-confusion-metaschema_METATRON.sch @@ -7,7 +7,15 @@ + + + + + + Where @type='hex', is expected to match regular expression '^[\dabcdef]+$' + + Where exists(self::anthology:item[@type='german']), is expected to be (one of) 'Ä', 'Ö', 'Ü', not '' + + + Where exists(self::anthology:item/ancestor::anthology:subsequence), is expected to be (one of) 'pink', 'orange', 'purple', not '' + + is expected to be (one of) 'A', 'B', 'C', not '' [[See id#global-item-allowed-values]] + + + + is expected to be unique. + + diff --git a/test-suite/broken/allowed-values-confusion-metaschema_declaration-map.xml b/test-suite/broken/allowed-values-confusion-metaschema_declaration-map.xml index 16bc1b01e..85ca429ab 100644 --- a/test-suite/broken/allowed-values-confusion-metaschema_declaration-map.xml +++ b/test-suite/broken/allowed-values-confusion-metaschema_declaration-map.xml @@ -6,7 +6,7 @@ - + a b @@ -39,7 +39,7 @@ - + one two diff --git a/test-suite/worked-examples/everything-metaschema/models-definition-map.xml b/test-suite/worked-examples/everything-metaschema/models-definition-map.xml new file mode 100644 index 000000000..e03ca98b2 --- /dev/null +++ b/test-suite/worked-examples/everything-metaschema/models-definition-map.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-suite/worked-examples/everything-metaschema/models-testdata.xml b/test-suite/worked-examples/everything-metaschema/models-testdata.xml new file mode 100644 index 000000000..da66e2185 --- /dev/null +++ b/test-suite/worked-examples/everything-metaschema/models-testdata.xml @@ -0,0 +1,89 @@ + + + + FIELD-1-ONLY + 1234abcd + FIELD-NAMED-VALUE + field-groupable 1 + field-groupable 2 + field-groupable 3 + + field-wrappable 1 + field-wrappable 2 + field-wrappable 3 + + field-by-key 1 + field-by-key 2 + field-by-key 3 + field-dynamic-value-key 1 + field-dynamic-value-key 2 + field-dynamic-value-key 3 + + +

Wrapped up prose

+

This is prose. All wrapped up.

+
+

Unwrapped prose

+

Here we have unwrapped prose....

+ + ASSEMBLY-1-ONLY / FIELD-1-ONLY + + + assembly-groupable 1 / field-groupable 1 + assembly-groupable 1 / field-groupable 2 + assembly-groupable 1 / field-groupable 3 + + + assembly-groupable 2 / field-groupable 1 + assembly-groupable 2 / field-groupable 2 + assembly-groupable 2 / field-groupable 3 + + + assembly-groupable 3 / field-groupable 1 + assembly-groupable 3 / field-groupable 2 + assembly-groupable 3 / field-groupable 3 + + + + + assembly-wrappable 1 / field-wrappable 1 + assembly-wrappable 1 / field-wrappable 2 + assembly-wrappable 1 / field-wrappable 3 + + + + + assembly-wrappable 2 / field-wrappable 1 + assembly-wrappable 2 / field-wrappable 2 + assembly-wrappable 2 / field-wrappable 3 + + + + + assembly-wrappable 3 / field-wrappable 1 + assembly-wrappable 3 / field-wrappable 2 + assembly-wrappable 3 / field-wrappable 3 + + + + + assembly-by-key 1 / field-by-key 1 + assembly-by-key 1 / field-by-key 2 + assembly-by-key 1 / field-by-key 3 + + + assembly-by-key 1 / field-by-key 1 + assembly-by-key 1 / field-by-key 2 + assembly-by-key 1 / field-by-key 3 + + + assembly-by-key 1 / field-by-key 1 + assembly-by-key 1 / field-by-key 2 + assembly-by-key 1 / field-by-key 3 + + + nested FIELD-1-ONLY + +
\ No newline at end of file diff --git a/test-suite/worked-examples/everything-metaschema/models_metaschema.xml b/test-suite/worked-examples/everything-metaschema/models_metaschema.xml index 3994b5f73..0c5c43a8a 100644 --- a/test-suite/worked-examples/everything-metaschema/models_metaschema.xml +++ b/test-suite/worked-examples/everything-metaschema/models_metaschema.xml @@ -11,9 +11,11 @@

A mini metaschema produced for conversion testing purposes.

-

Exercises Metaschema modeling with global declarations. Does not exercise +

This metaschema exercises modeling with global definitions. It does not exercise datatypes, constraints, or cardinality except as reflected in models (where grouping must be explicit).

+

When this is stable and working, extend to include local definitions.

+

Also cover use-name as appropriate.

@@ -29,6 +31,7 @@ + @@ -44,7 +47,7 @@ - + @@ -67,6 +70,11 @@ + + + + + @@ -81,13 +89,13 @@ - + - VALUE + CUSTOM-VALUE-KEY diff --git a/test-suite/worked-examples/everything-metaschema/models_metaschema_JSON-SCHEMA.json b/test-suite/worked-examples/everything-metaschema/models_metaschema_JSON-SCHEMA.json index 1de2d15b0..2917ee1d4 100644 --- a/test-suite/worked-examples/everything-metaschema/models_metaschema_JSON-SCHEMA.json +++ b/test-suite/worked-examples/everything-metaschema/models_metaschema_JSON-SCHEMA.json @@ -15,6 +15,8 @@ "type" : "string" }, "field-1only" : { "$ref" : "#/definitions/field-1only" }, + "field-base64" : + { "$ref" : "#/definitions/field-base64" }, "field-named-value" : { "$ref" : "#/definitions/field-named-value" }, "groupable-fields" : @@ -101,6 +103,10 @@ { "$ref" : "#/definitions/EVERYTHING" } } ] } }, "additionalProperties" : false }, "field-1only" : + { "title" : "", + "description" : "", + "type" : "string" }, + "field-base64" : { "title" : "", "description" : "", "type" : "string" }, @@ -131,10 +137,10 @@ { "title" : "", "description" : "", "type" : "string" }, - "VALUE" : + "CUSTOM-VALUE-KEY" : { "type" : "string" } }, "required" : - [ "VALUE", + [ "CUSTOM-VALUE-KEY", "id" ], "additionalProperties" : false }, "field-dynamic-value-key" : diff --git a/test-suite/worked-examples/everything-metaschema/models_metaschema_XML-SCHEMA.xsd b/test-suite/worked-examples/everything-metaschema/models_metaschema_XML-SCHEMA.xsd index 920f70866..c1a349b9b 100644 --- a/test-suite/worked-examples/everything-metaschema/models_metaschema_XML-SCHEMA.xsd +++ b/test-suite/worked-examples/everything-metaschema/models_metaschema_XML-SCHEMA.xsd @@ -13,7 +13,9 @@ everything

A mini metaschema produced for conversion testing purposes.

-

Exercises Metaschema modeling with global declarations. Does not exercise datatypes, constraints, or cardinality except as reflected in models (where grouping must be explicit).

+

This metaschema exercises modeling with global definitions. It does not exercise datatypes, constraints, or cardinality except as reflected in models (where grouping must be explicit).

+

When this is stable and working, extend to include local definitions.

+

Also cover use-name as appropriate.

EVERYTHING @@ -33,6 +35,10 @@ type="everything:field-1only-FIELD" minOccurs="0" maxOccurs="1"/> + - - - - - - - - : - - - - - + + + + + + + + + : + + + + + @@ -173,7 +180,7 @@ - + diff --git a/toolchains/xslt-proto-v04/compose/make-model-map.xsl b/toolchains/xslt-proto-v04/compose/make-model-map.xsl index b843a5536..2e4116f11 100644 --- a/toolchains/xslt-proto-v04/compose/make-model-map.xsl +++ b/toolchains/xslt-proto-v04/compose/make-model-map.xsl @@ -12,7 +12,8 @@ - + @@ -32,9 +33,7 @@ - - string - + @@ -47,11 +46,10 @@ - + - - + @@ -60,6 +58,11 @@ + + + + + @@ -69,9 +72,9 @@ - + @@ -83,6 +86,9 @@ + + + @@ -113,6 +119,9 @@ + + global + string @@ -124,13 +133,34 @@ - - global - + STRVALUE + RICHTEXT + PROSE + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/toolchains/xslt-proto-v04/compose/reduce-map.xsl b/toolchains/xslt-proto-v04/compose/reduce-map.xsl index c9fa7a6b9..bdfaff72b 100644 --- a/toolchains/xslt-proto-v04/compose/reduce-map.xsl +++ b/toolchains/xslt-proto-v04/compose/reduce-map.xsl @@ -11,14 +11,14 @@ - + - + diff --git a/toolchains/xslt-proto-v04/make-metaschema-model-maps.xpl b/toolchains/xslt-proto-v04/make-metaschema-model-maps.xpl index 147863a37..ffb292927 100644 --- a/toolchains/xslt-proto-v04/make-metaschema-model-maps.xpl +++ b/toolchains/xslt-proto-v04/make-metaschema-model-maps.xpl @@ -31,9 +31,9 @@ - - - + + + @@ -86,7 +86,7 @@ - + diff --git a/toolchains/xslt-proto-v04/schema_gen/make-metaschema-metatron.xsl b/toolchains/xslt-proto-v04/schema_gen/make-metaschema-metatron.xsl index 002ba6f63..011572595 100644 --- a/toolchains/xslt-proto-v04/schema_gen/make-metaschema-metatron.xsl +++ b/toolchains/xslt-proto-v04/schema_gen/make-metaschema-metatron.xsl @@ -58,6 +58,7 @@ + + RULES diff --git a/toolchains/xslt-proto-v04/validate/metaschema-check.sch b/toolchains/xslt-proto-v04/validate/metaschema-check.sch index 721a382ba..577963d1a 100644 --- a/toolchains/xslt-proto-v04/validate/metaschema-check.sch +++ b/toolchains/xslt-proto-v04/validate/metaschema-check.sch @@ -110,13 +110,17 @@ A flag declared as a value key must be required (@required='yes') + A flag declared as a key must be required (@required='yes') Multiline markup fields must have no flags, unless always used with a wrapper - put your flags on an assembly with an unwrapped multiline field - JSON key indicates no flag on this Should be (one of) + + + JSON key indicates no flag on this Should be (one of)