From 1498811b4a785dc72214983bf9a1f00b33c0a7d9 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 7 Jul 2020 17:03:52 -0400 Subject: [PATCH] Building out JSON -> supermodel conversion; bug fixes in Metapath mapping --- issue39-refactor.xpr | 690 +++++++++++++++--- .../converter-gen/produce-json-converter.xsl | 85 +++ .../converter-gen/produce-xml-converter.xsl | 128 ++-- .../xslt-M4/metapath/metapath-jsonize.xsl | 10 +- .../metapath/metapath-jsonizing-result.html | 84 ++- .../xslt-M4/metapath/metapath-jsonizing.xspec | 48 +- ...on-result.xml => models-testdata-json.xml} | 68 +- .../xslt-M4/testing/models-testdata.json | 101 +++ .../xslt-M4/testing/models-testdata.xml | 24 +- .../xslt-M4/testing/models_definition-map.xml | 50 ++ .../xslt-M4/testing/models_metaschema.xml | 24 +- .../models_metaschema_JSON-SCHEMA.json | 118 ++- .../testing/models_metaschema_METATRON.sch | 12 - .../testing/models_metaschema_XML-SCHEMA.xsd | 98 ++- .../xslt-M4/testing/test-json-conversions.xpl | 156 ++++ .../xslt-M4/testing/test-xml-conversions.xpl | 25 +- .../xslt-M4/testing/testdata-supermodel.xml | 80 +- 17 files changed, 1513 insertions(+), 288 deletions(-) create mode 100644 toolchains/xslt-M4/converter-gen/produce-json-converter.xsl rename toolchains/xslt-M4/testing/{testdata-json-result.xml => models-testdata-json.xml} (61%) create mode 100644 toolchains/xslt-M4/testing/models-testdata.json delete mode 100644 toolchains/xslt-M4/testing/models_metaschema_METATRON.sch create mode 100644 toolchains/xslt-M4/testing/test-json-conversions.xpl diff --git a/issue39-refactor.xpr b/issue39-refactor.xpr index 7edc53c2c..da0737fe6 100644 --- a/issue39-refactor.xpr +++ b/issue39-refactor.xpr @@ -24,6 +24,155 @@ scenario.associations + + + toolchains/xslt-M4/converter-gen/produce-json-converter.xsl + + + + Apply XSLT to testdata models definition map + + + + + XML + + + + + 2 + + + + + + toolchains/xslt-M4/converter-gen/produce-xml-converter.xsl + + + + Test XML->JSON conversion on models-testdata.xml + Apply XSLT to testdata models definition map + + + + + XPROC + XML + + + + + 2 + 2 + + + + + + toolchains/xslt-M4/testing/produce-json-converter.xsl + + + + Test XML->JSON conversion on models-testdata.xml + Apply XSLT to testdata models definition map + + + + + XPROC + XML + + + + + 2 + 2 + + + + + + toolchains/xslt-M4/testing/test-xml-conversions.xpl + + + + Test XML->JSON conversion on models-testdata.xml + + + + + XPROC + + + + + 2 + + + + + + toolchains/xslt-M4/testing/test-json-conversions.xpl + + + + Test JSON (XML) -> XML conversion on models-testdata-json.xml + + + + + XPROC + + + + + 2 + + + + + + toolchains/xslt-M4/testing/models-testdata.xml + + + + Test XML->JSON conversion on models-testdata.xml + + + + + XPROC + + + + + 2 + + + + + + toolchains/xslt-M4/testing/models_metaschema.xml + + + + Produce XSD for (this) metaschema (v04 XProc) + Produce JSON Schema for (this) metaschema (v04 XProc) + + + + + XPROC + XPROC + + + + + 2 + 2 + + + test-suite/worked-examples/anthology/anthology_metaschema.xml @@ -1002,86 +1151,6 @@ - - - toolchains/xslt-M4/testing/models-testdata.xml - - - - Test XML->JSON conversion on models-testdata.xml - - - - - XPROC - - - - - 2 - - - - - - toolchains/xslt-M4/testing/models_metaschema.xml - - - - Produce MAPS for this metaschema - - - - - XPROC - - - - - 2 - - - - - - toolchains/xslt-M4/converter-gen/produce-xml-converter.xsl - - - - Test XML->JSON conversion on models-testdata.xml - - - - - XPROC - - - - - 2 - - - - - - toolchains/xslt-M4/testing/test-xml-conversions.xpl - - - - Test XML->JSON conversion on models-testdata.xml - - - - - XPROC - - - - - 2 - - - toolchains/xslt-M4/testing/tiny_metaschema.xml @@ -1739,41 +1808,124 @@ - - - - - - - ${pdu}/test-suite/oscal/oscal_catalog_metaschema.xml - - - - source - - - + + + - - - - - - - - true - - - _0_main-module - - - - - - - - true - + + Apply XSLT to testdata models definition map + + + + + + + + + pdf + + + Apache FOP + + + + + + ${currentFileURL} + + + ${pdu}/toolchains/xslt-M4/testing/models_definition-map.xml + + + false + + + false + + + XML + + + true + + + false + + + + + + false + + + + + + false + + + false + + + true + + + false + + + false + + + true + + + + + + + + + Saxon-PE + + + + + + + + + + + + ${pdu}/test-suite/oscal/oscal_catalog_metaschema.xml + + + + source + + + + + + + + + + + + true + + + _0_main-module + + + + + + + + true + _1_collected @@ -3973,6 +4125,316 @@ + + + + + + + ${pdu}/toolchains/xslt-M4/testing/models_metaschema.xml + + + + metaschema-source + + + + + + ${pdu}/toolchains/xslt-M4/testing/models-testdata-json.xml + + + + testdata-json-xml + + + + + + + + + + + + true + + + a.echo-input + + + + + + + + true + + + b.composed + + + + + + + + true + + + c.abstract-model-map + + + + + + + + true + + + d.unfolded-model-map + + + + + + + + true + + + A.definition-map + + + + + + + + true + + + C.xml-converter + + + + + ${pdu}/toolchains/xslt-M4/testing/testdata-supermodel.xml + + + true + + + S.testdata-supermodel + + + + + + + + true + + + _X1.testdata-xml-result + + + + + + + + true + + + S2.supermodel-with-markdown + + + + + ${pdu}/toolchains/xslt-M4/testing/testdata-json-result.xml + + + true + + + _J1.testdata-xpath-json-result + + + + + + + + true + + + _J2.testdata-json-result + + + + + + + + true + + + Q.testdata-xml-source + + + + + + + + true + + + _J1.testdata-json-xml-result + + + + + + + + true + + + C.json-converter + + + + + + + + true + + + Q.testdata-json-xml-source + + + + + + + + true + + + _J2.testdata-xml-result + + + + + + + + + + + + parameters + + + + + + + + * + + + + + + + + + + + + Test JSON (XML) -> XML conversion on models-testdata-json.xml + + + + + + + + + + + + + + + + + + ${pdu}/toolchains/xslt-M4/testing/test-json-conversions.xpl + + + + + + false + + + false + + + XPROC + + + false + + + false + + + + + + false + + + + + + false + + + false + + + true + + + false + + + false + + + false + + + + + + + + + Add-on for Calabash XProc Engine + + + + + diff --git a/toolchains/xslt-M4/converter-gen/produce-json-converter.xsl b/toolchains/xslt-M4/converter-gen/produce-json-converter.xsl new file mode 100644 index 000000000..329a0abd3 --- /dev/null +++ b/toolchains/xslt-M4/converter-gen/produce-json-converter.xsl @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + j + + + + + + + + + + + + http://www.w3.org/2005/xpath-functions + + + + + + + + METASCHEMA conversion stylesheet supports JSON -> METASCHEMA/SUPERMODEL conversion + + + + + + + + + + + (: { $matching-xml} :) { m:jsonize-path($matching-xml) } + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/toolchains/xslt-M4/converter-gen/produce-xml-converter.xsl b/toolchains/xslt-M4/converter-gen/produce-xml-converter.xsl index e5b0477e9..24df75e35 100644 --- a/toolchains/xslt-M4/converter-gen/produce-xml-converter.xsl +++ b/toolchains/xslt-M4/converter-gen/produce-xml-converter.xsl @@ -21,13 +21,28 @@ + + + + + + + + + + + + + + + - - - + + - METASCHEMA conversion stylesheet supports XML -> METASCHEMA/SUPERMODEL conversion + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,18 +67,38 @@ - + + + + + + + + { $source-namespace } + + + + + + + + METASCHEMA conversion stylesheet supports XML -> METASCHEMA/SUPERMODEL conversion + + + + - + - + - - - + + + @@ -75,7 +110,7 @@ - + @@ -96,12 +131,7 @@ - - - { $source-namespace } - - - + @@ -109,9 +139,20 @@ + + + + + + { $source-namespace } + + + + + - + @@ -121,9 +162,17 @@ - - @ - + + + + / + + + + + + + @@ -134,17 +183,16 @@ - + - / - - + + @@ -153,7 +201,7 @@ p | ul | ol | pre | h1 | h2 | h3 | h4 | h5 | h6 | table - + @@ -165,15 +213,16 @@ - - - - - - + + + + + - + + @@ -186,18 +235,7 @@ - - - - + diff --git a/toolchains/xslt-M4/metapath/metapath-jsonize.xsl b/toolchains/xslt-M4/metapath/metapath-jsonize.xsl index 7677a9eaf..522dd5036 100644 --- a/toolchains/xslt-M4/metapath/metapath-jsonize.xsl +++ b/toolchains/xslt-M4/metapath/metapath-jsonize.xsl @@ -177,7 +177,7 @@ - {$px}:map + {$px}:map{ @key ! ('[@key=''' || . || ''']') } @@ -195,7 +195,7 @@ - + {$px}:{$type}[@key='{value/@key}'] @@ -224,7 +224,7 @@ - OoopsFellThroughOn{ name() } + {$px}:*[@key='{../@key}'] @@ -296,11 +296,9 @@ - (: PARSING '{$metapath}' RETURNS {$path-map => normalize-space() } :) + (: PARSING '{$metapath}' RETURNS { normalize-space($path-map) } :) - - diff --git a/toolchains/xslt-M4/metapath/metapath-jsonizing-result.html b/toolchains/xslt-M4/metapath/metapath-jsonizing-result.html index d1374cc08..4e61188be 100644 --- a/toolchains/xslt-M4/metapath/metapath-jsonizing-result.html +++ b/toolchains/xslt-M4/metapath/metapath-jsonizing-result.html @@ -1,7 +1,7 @@ - Test Report for C:/Users/wap1/Documents/usnistgov/metaschema/toolchains/xslt-M4/metapath/metapath-jsonize.xsl (passed: 11 / pending: 0 / failed: 0 / total: 11) + Test Report for C:/Users/wap1/Documents/usnistgov/metaschema/toolchains/xslt-M4/metapath/metapath-jsonize.xsl (passed: 12 / pending: 0 / failed: 0 / total: 12)