diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ac6e0ee9..8314335d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - submodules: true + submodules: "recursive" fetch-depth: 0 - uses: actions/setup-java@v3 with: diff --git a/.gitignore b/.gitignore index 3cc589cb..73a1e16d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ # test outputs src/**/test_output/ + +# downloaded miscellaneous + +support/lib/* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index c3cb9c7f..8b1c4076 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,13 +1,11 @@ -[submodule "support/xspec"] - path = support/xspec - url = https://github.com/xspec/xspec.git [submodule "support/metaschema"] path = support/metaschema url = https://github.com/usnistgov/metaschema.git branch = develop fetchRecurseSubmodules = false +[submodule "support/xslt3-functions"] + path = support/xslt3-functions + url = https://github.com/usnistgov/xslt3-functions.git [submodule "support/schxslt"] path = support/schxslt url = https://github.com/schxslt/schxslt.git -[submodule "metaschema"] - url = https://github.com/usnistgov/metaschema.git diff --git a/README.md b/README.md index d8129dd6..566d47af 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,9 @@ Additionally, we care about, but do not prioritize: Formerly housed in the [Metaschema repository](https://github.com/usnistgov/metaschema), this code base traces the history of development of the Metaschema concept in the context of the OSCAL project. It was originally conceived as a demonstration and proof of concept, providing a bridge enabling JSON- and XML-based development in parallel over common problem sets and common data. Success in this effort led to a determination that multiple implementations of a platform-independent specification were needed, at which point this implementation was carved out into its own repository. -### Project sunset +### Maturity and project sunset + +Software in this repository remains 'experimental' in status until it can be demonstrated with public conformance testing, which in turn depends on the maturity of the Metaschema initiative. The NIST team has no long-term plan to maintain this project outside the context of the initiatives it supports, [OSCAL](https://pages.nist.gov/OSCAL) and [Metaschema](https://pages.nist.gov/metaschema), while we reserve the right to change and adapt to community needs in alignment with NIST's mission. A project goal is to enable the stabilization and socialization of the Metaschema technology, as evidenced by the use and support of *other* Metaschema implementations. diff --git a/TESTING.md b/TESTING.md index 2b2f7b0a..e165cbf2 100644 --- a/TESTING.md +++ b/TESTING.md @@ -40,7 +40,6 @@ Currently we are emulating and re-engineering some specific XSpec capabilities i These efforts are focused on producing and refining XSpec runtimes for various use cases and scenarios with specialized requirements faced by this project, such as arbitrary batching and iXML support. Tools we develop here are released under the same terms as Metaschema-XSLT (as open-source software). - ## Test-driven development Almost all testing in this repository falls into the category of either XSLT transformations, or runtimes that embed transformations. diff --git a/src/Makefile b/src/Makefile index 71cdcad9..8253a313 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,6 +10,10 @@ dirs:=$(shell find '.' ! -wholename ./Makefile -name 'Makefile' -printf "%h\n") test: ## Run all tests $(call FOREACH_MAKE,$@,$(dirs)) +.PHONY: pre-checks +pre-checks: ## Run all "pre checks", enforcing validation contracts across input artifacts + $(call FOREACH_MAKE_OPTIONAL,$@,$(dirs)) + .PHONY: smoke-test smoke-test: ## Run all "smoke tests", establishing a baseline of sanity across the project $(call FOREACH_MAKE_OPTIONAL,$@,$(dirs)) diff --git a/src/common/metaschema-ws-strip.xsl b/src/common/metaschema-ws-strip.xsl new file mode 100644 index 00000000..8896923e --- /dev/null +++ b/src/common/metaschema-ws-strip.xsl @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/testing/issue_235_regression-metaschema.xml b/src/converter-gen/issue_235_regression-metaschema.xml similarity index 100% rename from src/testing/issue_235_regression-metaschema.xml rename to src/converter-gen/issue_235_regression-metaschema.xml diff --git a/src/testing/issue_235_regression.xspec b/src/converter-gen/issue_235_regression.xspec similarity index 98% rename from src/testing/issue_235_regression.xspec rename to src/converter-gen/issue_235_regression.xspec index a61e54a9..9f818c69 100644 --- a/src/testing/issue_235_regression.xspec +++ b/src/converter-gen/issue_235_regression.xspec @@ -2,7 +2,9 @@ + stylesheet="xml-to-json/supermodel-to-json.xsl"> + + diff --git a/src/schema-gen/InspectorXSLT/Makefile b/src/schema-gen/InspectorXSLT/Makefile index 5a9e87bb..5d7854dc 100644 --- a/src/schema-gen/InspectorXSLT/Makefile +++ b/src/schema-gen/InspectorXSLT/Makefile @@ -10,8 +10,8 @@ include ../../testing/make_common.mk module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) output_folder:=$(module_path)/test_output -xspec_script=$(realpath $(module_path)/../../../support/xspec-dev/mvn-saxon-xspec-batch-quiet.sh) -xspec_ci_script=$(realpath $(module_path)/../../../support/xspec-dev/mvn-saxon-xspec-batch.sh) +xspec_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch-quiet.sh) +xspec_ci_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch.sh) smoketest_script=$(realpath $(module_path)/testing/smoketest-computer-inspector.sh) testing-refresh_script=$(realpath $(module_path)/testing/refresh-test-inspectors.sh) folder=. diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-inspector.xsl index 4865e3aa..f38ee0f5 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-inspector.xsl @@ -1,11 +1,10 @@ - + exclude-result-prefixes="#all"> diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-schema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-schema.xsd index 4fa290d5..193337c0 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-schema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-schema.xsd @@ -1,11 +1,10 @@ - + xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + elementFormDefault="qualified" + targetNamespace="http://example.com/ns/computer" + version="0.0.5"> Computer Model @@ -64,7 +63,7 @@ - + Vendor Identifier @@ -74,6 +73,16 @@ Vendor Identifier: An identifier for classifying a unique computer parts vendor. + + + + Vendor Reference + Instead of an identifier, a reference to another vendor by its @id. + + + Vendor Reference: Instead of an identifier, a reference to another vendor by its @id. + + @@ -122,9 +131,9 @@ + type="computer-vendor-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -150,17 +159,17 @@ + type="computer-vendor-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> + type="computer-product-name-FIELD" + minOccurs="1" + maxOccurs="1"/> + type="computer-cost-FIELD" + minOccurs="0" + maxOccurs="1"/> @@ -188,9 +197,9 @@ + type="computer-property-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -207,17 +216,17 @@ + type="computer-vendor-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> + type="computer-product-name-FIELD" + minOccurs="1" + maxOccurs="1"/> + type="computer-cost-FIELD" + minOccurs="0" + maxOccurs="1"/> @@ -232,9 +241,9 @@ + type="computer-property-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -271,17 +280,17 @@ + type="computer-vendor-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> + type="computer-product-name-FIELD" + minOccurs="1" + maxOccurs="1"/> + type="computer-cost-FIELD" + minOccurs="0" + maxOccurs="1"/> @@ -296,9 +305,9 @@ + type="computer-property-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -314,9 +323,9 @@ + type="computer-cooling-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -329,17 +338,17 @@ + type="computer-vendor-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> + type="computer-product-name-FIELD" + minOccurs="1" + maxOccurs="1"/> + type="computer-cost-FIELD" + minOccurs="0" + maxOccurs="1"/> @@ -354,9 +363,9 @@ + type="computer-property-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -406,21 +415,21 @@ + type="computer-vendor-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> + type="computer-product-name-FIELD" + minOccurs="1" + maxOccurs="1"/> + type="computer-cost-FIELD" + minOccurs="0" + maxOccurs="1"/> + type="computer-property-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -436,9 +445,9 @@ + type="computer-property-ASSEMBLY" + minOccurs="0" + maxOccurs="1"/> @@ -689,9 +698,9 @@ + type="listItemType" + minOccurs="1" + maxOccurs="unbounded"/> diff --git a/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-inspector.xsl index 44cb4883..79fffe88 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-inspector.xsl @@ -1,11 +1,10 @@ - + xmlns:mx="http://csrc.nist.gov/ns/csd/metaschema-xslt" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="3.0" + xpath-default-namespace="http://example.com/ns/tinydata" + exclude-result-prefixes="#all"> @@ -21,29 +20,29 @@ + priority="100" + name="xsl:initial-template" + match="root()"> + priority="101" + match="root()[$format=('mx','mx-report')]"> + priority="101" + match="root()[$format=('html','webpage')]"> + priority="101" + match="root()[$format=('md','markdown')]"> + priority="101" + match="root()[$format=('plaintext','plain','text')]"> @@ -87,9 +86,9 @@ + tunnel="true" + as="xs:string" + select="codepoints-to-string(10)"/> @@ -100,8 +99,8 @@ + on-no-match="fail" + on-multiple-match="use-last"/> @@ -134,14 +133,14 @@ + match="a/@href | a/@title | img/@alt | img/@src | img/@title | code/@class | insert/@id-ref | insert/@type (: other legal attributes :)"/> + match="p/br | li/br | h1/br | h2/br | h3/br | h4/br | h5/br | h6/br | pre/br | tr/br | td/br"/> + match="p/text() | li/text() | h1/text() | h2/text() | h3/text() | h4/text() | h5/text() | h6/text() | pre/text() | blockquote/text() | th/text() | td/text()"/> + match="em/text() | i/text() | strong/text() | b/text() | u/text() | q/text() | code/text() | a/text() | sub/text() | sup/text()"/> @@ -151,7 +150,7 @@ + select=" 'p', 'pre', 'ul', 'ol', 'table', 'h1', 'h2', 'h3', 'h4', 'h5'"/> @@ -161,8 +160,8 @@ + mode="test" + match="@xsi:*"/> @@ -181,10 +180,10 @@ + test="{ $testing }" + class="{$class}" + xpath="{ $xpath }" + level="{ $level }"> @@ -208,7 +207,7 @@ /{ name() } + match="*[node-name() = (../* except current())/node-name()]"> /{ name() }[{ mx:element-position(.)[count($kin) gt 1] }] @@ -271,11 +270,11 @@ + priority="103" + mode="grab-mx"> + select="count(.//mx:report[@level = ('CRITICAL', 'ERROR')])"/> @@ -291,8 +290,8 @@ + priority="102" + mode="grab-mx"> File { replace(@src,'.*/','') } is reported VALID, no issues ... @@ -304,22 +303,22 @@ + select="count(descendant::* except .//mx:*/descendant-or-self::*)"/> + select="count(descendant::*/@* except .//mx:*/descendant-or-self::*/@*)"/> + select="count(.//mx:report[@level = ('CRITICAL', 'ERROR')])"/> + mode="grab-mx"> + mode="grab-mx"> @@ -437,109 +436,109 @@ details p { margin: 0.2em 0em } { codepoints-to-string(10) } + match="html" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> + match="style" + xpath-default-namespace="http://www.w3.org/1999/xhtml"/> + match="body" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> { $lf } + match="div | details" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> { $lf2 }--- + match="body/*[1]/self::h1" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> # + match="h1" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> { $lf2 }# + match="h2" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> { $lf2 }## + match="h3 | details/summary" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> { $lf2 }### + match="p" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> { $lf2 } + match="ul" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> + match="li" + expand-text="true" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> { $lf }- + match="b" + priority="2" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> ** ** + match="i" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> * * + match="code" + priority="2" + xpath-default-namespace="http://www.w3.org/1999/xhtml"> ` ` Computer Model + shortname="computer" + namespace="http://example.com/ns/tinydata">Computer Model @@ -594,7 +593,7 @@ details p { margin: 0.2em 0em } EOOO element-out-of-order exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + select="exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p)"/> Element title is unexpected following term, stuff, part, or notes/note. @@ -608,7 +607,7 @@ details p { margin: 0.2em 0em } EOOO element-out-of-order exists(preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + select="exists(preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p)"/> Element term is unexpected following stuff, part, or notes/note. @@ -636,7 +635,7 @@ details p { margin: 0.2em 0em } EOOO element-out-of-order exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + select="exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p)"/> Element title is unexpected following term, stuff, part, or note. @@ -650,7 +649,7 @@ details p { margin: 0.2em 0em } EOOO element-out-of-order exists(preceding-sibling::part | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + select="exists(preceding-sibling::part | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p)"/> Element term is unexpected following stuff, part, or note. @@ -762,12 +761,12 @@ details p { margin: 0.2em 0em } gix.148 + as="xs:string" + select="($matching[matches(.,'\S')],'*')[1]"/> { $class } not(string(.) castable as xs:string and matches(.,'^\S(.*\S)?$')) + select="not(string(.) castable as xs:string and matches(.,'^\S(.*\S)?$'))"/> Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to string datatype. @@ -779,111 +778,111 @@ details p { margin: 0.2em 0em } gix.148 + as="xs:string" + select="($matching[matches(.,'\S')],'*')[1]"/> { $class } not(string(.) castable as xs:string and matches(.,'^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$') and matches(.,'^\S(.*\S)?$')) + select="not(string(.) castable as xs:string and matches(.,'^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$') and matches(.,'^\S(.*\S)?$'))"/> Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to token datatype. + match="title/a|title/insert|title/br|title/code|title/em|title/i|title/b|title/strong|title/sub|title/sup|title/q|title/img"/> + match="TINY/h1|TINY/h2|TINY/h3|TINY/h4|TINY/h5|TINY/h6|TINY/table|TINY/img|TINY/pre|TINY/hr|TINY/blockquote|TINY/ul|TINY/ol|TINY/p"> gix.390 EOOO element-out-of-order exists(preceding-sibling::part | preceding-sibling::notes) + select="exists(preceding-sibling::part | preceding-sibling::notes)"/> Element stuff is unexpected following part or notes/note. + match="part/h1|part/h2|part/h3|part/h4|part/h5|part/h6|part/table|part/img|part/pre|part/hr|part/blockquote|part/ul|part/ol|part/p"> gix.390 EOOO element-out-of-order exists(preceding-sibling::part | preceding-sibling::note) + select="exists(preceding-sibling::part | preceding-sibling::note)"/> Element stuff is unexpected following part or note. + match="TINY/notes/note/h1|TINY/notes/note/h2|TINY/notes/note/h3|TINY/notes/note/h4|TINY/notes/note/h5|TINY/notes/note/h6|TINY/notes/note/table|TINY/notes/note/img|TINY/notes/note/pre|TINY/notes/note/hr|TINY/notes/note/blockquote|TINY/notes/note/ul|TINY/notes/note/ol|TINY/notes/note/p"/> + match="part/note/h1|part/note/h2|part/note/h3|part/note/h4|part/note/h5|part/note/h6|part/note/table|part/note/img|part/note/pre|part/note/hr|part/note/blockquote|part/note/ul|part/note/ol|part/note/p"/> + match="TINY/title/a|TINY/title/insert|TINY/title/br|TINY/title/code|TINY/title/em|TINY/title/i|TINY/title/b|TINY/title/strong|TINY/title/sub|TINY/title/sup|TINY/title/q|TINY/title/img"> gix.390 EOOO element-out-of-order exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + select="exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p)"/> Element title is unexpected following term, stuff, part, or notes/note. + match="part/title/a|part/title/insert|part/title/br|part/title/code|part/title/em|part/title/i|part/title/b|part/title/strong|part/title/sub|part/title/sup|part/title/q|part/title/img"> gix.390 EOOO element-out-of-order exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + select="exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p)"/> Element title is unexpected following term, stuff, part, or note. + match="h1/a|h2/a|h3/a|h4/a|h5/a|h6/a|table/a|pre/a|blockquote/a|ul/a|ol/a|p/a"/> + match="a/a|insert/a|code/a|em/a|i/a|b/a|strong/a|sub/a|sup/a|q/a"/> + match="h1/insert|h2/insert|h3/insert|h4/insert|h5/insert|h6/insert|table/insert|pre/insert|blockquote/insert|ul/insert|ol/insert|p/insert"/> + match="a/insert|insert/insert|code/insert|em/insert|i/insert|b/insert|strong/insert|sub/insert|sup/insert|q/insert"/> + match="h1/br|h2/br|h3/br|h4/br|h5/br|h6/br|table/br|pre/br|blockquote/br|ul/br|ol/br|p/br"/> + match="a/br|insert/br|code/br|em/br|i/br|b/br|strong/br|sub/br|sup/br|q/br"/> + match="h1/code|h2/code|h3/code|h4/code|h5/code|h6/code|table/code|pre/code|blockquote/code|ul/code|ol/code|p/code"/> + match="a/code|insert/code|code/code|em/code|i/code|b/code|strong/code|sub/code|sup/code|q/code"/> + match="h1/em|h2/em|h3/em|h4/em|h5/em|h6/em|table/em|pre/em|blockquote/em|ul/em|ol/em|p/em"/> + match="a/em|insert/em|code/em|em/em|i/em|b/em|strong/em|sub/em|sup/em|q/em"/> + match="h1/i|h2/i|h3/i|h4/i|h5/i|h6/i|table/i|pre/i|blockquote/i|ul/i|ol/i|p/i"/> + match="a/i|insert/i|code/i|em/i|i/i|b/i|strong/i|sub/i|sup/i|q/i"/> + match="h1/b|h2/b|h3/b|h4/b|h5/b|h6/b|table/b|pre/b|blockquote/b|ul/b|ol/b|p/b"/> + match="a/b|insert/b|code/b|em/b|i/b|b/b|strong/b|sub/b|sup/b|q/b"/> + match="h1/strong|h2/strong|h3/strong|h4/strong|h5/strong|h6/strong|table/strong|pre/strong|blockquote/strong|ul/strong|ol/strong|p/strong"/> + match="a/strong|insert/strong|code/strong|em/strong|i/strong|b/strong|strong/strong|sub/strong|sup/strong|q/strong"/> + match="h1/sub|h2/sub|h3/sub|h4/sub|h5/sub|h6/sub|table/sub|pre/sub|blockquote/sub|ul/sub|ol/sub|p/sub"/> + match="a/sub|insert/sub|code/sub|em/sub|i/sub|b/sub|strong/sub|sub/sub|sup/sub|q/sub"/> + match="h1/sup|h2/sup|h3/sup|h4/sup|h5/sup|h6/sup|table/sup|pre/sup|blockquote/sup|ul/sup|ol/sup|p/sup"/> + match="a/sup|insert/sup|code/sup|em/sup|i/sup|b/sup|strong/sup|sub/sup|sup/sup|q/sup"/> + match="h1/q|h2/q|h3/q|h4/q|h5/q|h6/q|table/q|pre/q|blockquote/q|ul/q|ol/q|p/q"/> + match="a/q|insert/q|code/q|em/q|i/q|b/q|strong/q|sub/q|sup/q|q/q"/> + match="h1/img|h2/img|h3/img|h4/img|h5/img|h6/img|table/img|pre/img|blockquote/img|ul/img|ol/img|p/img"/> + match="a/img|insert/img|code/img|em/img|i/img|b/img|strong/img|sub/img|sup/img|q/img"/> diff --git a/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-schema.xsd b/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-schema.xsd index 8abaa3d5..ee5828b7 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-schema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/tiny_metaschema-schema.xsd @@ -1,11 +1,10 @@ - + xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + elementFormDefault="qualified" + targetNamespace="http://example.com/ns/tinydata" + version="0.0.5"> Computer Model @@ -30,18 +29,18 @@ + type="computer-title-FIELD" + minOccurs="1" + maxOccurs="1"/> + type="computer-term-FIELD" + minOccurs="0" + maxOccurs="unbounded"/> + type="computer-part-ASSEMBLY" + minOccurs="0" + maxOccurs="unbounded"/> @@ -134,18 +133,18 @@ + type="computer-title-FIELD" + minOccurs="1" + maxOccurs="1"/> + type="computer-term-FIELD" + minOccurs="0" + maxOccurs="unbounded"/> + type="computer-part-ASSEMBLY" + minOccurs="0" + maxOccurs="unbounded"/> @@ -208,9 +207,9 @@ + type="listItemType" + minOccurs="1" + maxOccurs="unbounded"/> diff --git a/src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh b/src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh index f010ebbf..533c6788 100644 --- a/src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh +++ b/src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh @@ -28,8 +28,18 @@ ADDITIONAL_ARGS=$(echo "${*// /\\ }") CALABASH_ARGS="-oINSPECTOR-XSLT=\"$XSLT_RESULT\" $ADDITIONAL_ARGS \"${XPROC_FILE}\"" -# echo "${CALABASH_ARGS}" +## show usage if a first argument is '-h', expanding $1 to '' if not set +if [ "${1:-}" = '-h' ] || [ "${1:-}" = '--help' ]; + +then + + usage +else + +# echo "${CALABASH_ARGS}" invoke_calabash "${CALABASH_ARGS}" -echo Computer Model Inspector XSLT refreshed - check - \ No newline at end of file +echo Computer Model Inspector XSLT refreshed - check - + +fi diff --git a/src/schema-gen/InspectorXSLT/testing/refresh-test-inspectors.sh b/src/schema-gen/InspectorXSLT/testing/refresh-test-inspectors.sh index ac4841f1..fc72d481 100644 --- a/src/schema-gen/InspectorXSLT/testing/refresh-test-inspectors.sh +++ b/src/schema-gen/InspectorXSLT/testing/refresh-test-inspectors.sh @@ -26,8 +26,20 @@ ADDITIONAL_ARGS=$(echo "${*// /\\ }") # -iMETASCHEMA=computer_metaschema.xml -iMETASCHEMA=tiny_metaschema.xml CALABASH_ARGS="$ADDITIONAL_ARGS \"${XPROC_FILE}\"" + + +## show usage if a first argument is '-h', expanding $1 to '' if not set +if [ "${1:-}" = '-h' ] || [ "${1:-}" = '--help' ]; + +then + + usage + +else + # echo "${CALABASH_ARGS}" invoke_calabash "${CALABASH_ARGS}" -# invoke_calabash "-iMETASCHEMA=computer_metaschema.xml -iMETASCHEMA=tiny_metaschema.xml "${CALABASH_ARGS}" echo Current test models refreshed - InspectorXSLT and XSD - check 'current' + +fi \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/testing/smoketest-computer-inspector.sh b/src/schema-gen/InspectorXSLT/testing/smoketest-computer-inspector.sh index db1e7d32..ca39ee68 100644 --- a/src/schema-gen/InspectorXSLT/testing/smoketest-computer-inspector.sh +++ b/src/schema-gen/InspectorXSLT/testing/smoketest-computer-inspector.sh @@ -26,7 +26,17 @@ ADDITIONAL_ARGS=$(echo "${*// /\\ }") CALABASH_ARGS="-oINSPECTOR-XSLT=/dev/null $ADDITIONAL_ARGS \"${XPROC_FILE}\"" # echo "${CALABASH_ARGS}" +## show usage if a first argument is '-h', expanding $1 to '' if not set +if [ "${1:-}" = '-h' ] || [ "${1:-}" = '--help' ]; + +then + + usage + +else invoke_calabash "${CALABASH_ARGS}" -echo Computer Model Inspector XSLT produced and run - without apparent error \ No newline at end of file +echo Computer Model Inspector XSLT produced and run - without apparent error + +fi diff --git a/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec index c3fb7592..0185d4a8 100644 --- a/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec @@ -91,6 +91,7 @@ Modes to test: + diff --git a/src/schema-gen/JSON-schema/Makefile b/src/schema-gen/JSON-schema/Makefile new file mode 100644 index 00000000..807f1632 --- /dev/null +++ b/src/schema-gen/JSON-schema/Makefile @@ -0,0 +1,52 @@ +include ../../testing/make_common.mk + +# INCLUDES: +# unit-test - unit testing - XSLT production templates for InspectorXSLT +# spec-test - specification conformance testing - functional runtime tests of the generated XSLT +# xspec - run XSpec tests in designated folder +# clean - clean up designated output folder + +# for smoke testing see ../Makefile + +# tbd - 'field testing' applying result JSON Schema to known 'working and broken' instances + +module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +output_folder:=$(module_path)/test_output +xspec_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch-quiet.sh) +xspec_ci_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch.sh) +folder=. + +.PHONY: test +test: unit-test spec-test ## Run all tests + + +.PHONY: spec-test +spec-test: ## Run all specification tests + LOGFILE="$(output_folder)/jsonschemagen-mapping.log" $(xspec_ci_script) \ + "folder=$(module_path)/testing/tests/jsonschemagen-mapping-xspec/" \ + "report-to=$(output_folder)/jsonschemagen-mapping_report.html" \ + "junit-to=$(output_folder)/jsonschemagen-mapping_junit-report.xml" \ + "stop-on-error=yes" \ + "recurse=yes" + +.PHONY: unit-test +unit-test: ## Run all unit tests + LOGFILE="$(output_folder)/jsonschemagen-runtime.log" $(xspec_ci_script) \ + "folder=$(module_path)/testing/tests/jsonschemagen-runtime-xspec" \ + "report-to=$(output_folder)/jsonschemagen-runtime_report.html" \ + "junit-to=$(output_folder)/jsonschemagen-runtime_junit-report.xml" \ + "stop-on-error=yes" \ + "recurse=yes" + +.PHONY: xspec +xspec: ## Run all *.xspec in a designated folder, quietly - use folder=[folder] + LOGFILE="$(output_folder)/$(folder)-xspec-tests.log" $(xspec_script) \ + "baseURI=file:$(module_path)/" \ + "folder=$(folder)" \ + "report-to=$(output_folder)/inspector-$(folder)-tests_report.html" \ + "stop-on-error=no" \ + "recurse=yes" + +.PHONY: clean +clean: ## Remove test output + rm -fr $(output_folder)/* \ No newline at end of file diff --git a/src/schema-gen/JSON-schema/choice-split.xsl b/src/schema-gen/JSON-schema/choice-split.xsl new file mode 100644 index 00000000..6c2b618a --- /dev/null +++ b/src/schema-gen/JSON-schema/choice-split.xsl @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/JSON-schema/make-json-schema-metamap.xsl b/src/schema-gen/JSON-schema/make-json-schema-metamap.xsl index c0c54878..d022c957 100644 --- a/src/schema-gen/JSON-schema/make-json-schema-metamap.xsl +++ b/src/schema-gen/JSON-schema/make-json-schema-metamap.xsl @@ -145,8 +145,11 @@ - - + + + object @@ -156,7 +159,59 @@ - + + + + + + + + + + + + + object + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -167,6 +222,7 @@ + @@ -199,8 +255,6 @@ - - @@ -216,6 +270,7 @@ + @@ -281,6 +336,8 @@ + + @@ -296,7 +353,7 @@ + $with-model/(field|define-field|assembly|define-assembly)[@min-occurs > 0]"/> @@ -305,7 +362,7 @@ - true + true false @@ -425,8 +482,8 @@ + assembly[group-as/@in-json='BY_KEY'][exists(key('assembly-definition-by-name',@_key-ref, $composed-metaschema)/json-key)] | + field[group-as/@in-json='BY_KEY'][exists(key('field-definition-by-name', @_key-ref, $composed-metaschema)/json-key)]"> object @@ -444,7 +501,7 @@ - + @@ -453,7 +510,7 @@ - + @@ -509,17 +566,17 @@ - + - + - + @@ -550,8 +607,8 @@ - - + + string diff --git a/src/schema-gen/JSON-schema/testing.md b/src/schema-gen/JSON-schema/testing.md new file mode 100644 index 00000000..9e90c370 --- /dev/null +++ b/src/schema-gen/JSON-schema/testing.md @@ -0,0 +1,73 @@ +# Testing Metaschema-XSLT JSON Schema production + +**Currently only JSON Schema v7 is supported.** + +At a future date we aim to support other forms. + +## Smoke testing + +A JSON Schema, with other schemas, is produced by a pipeline in the parent directory, ../METASCHEMA-ALL-SCHEMAS.xpl, which is also run as a smoke test. + +``` +pushd .. +make smoke-test +popd +``` + +The smoke test outputs including a JSON Schema are found in the `test_output` folder (until/unless cleaned out). If a JSON instance cannot be produced, the process will fail. +The smoke test does *not* currently + +- test that the JSON functions as a JSON Schema +- test that it conforms to an idea of a JSON Schema ('the standard') or JSON Schema usage patterns + +It does, however, confirm that the process terminated successfully with a file output in the expected location. + + +## Spec testing + +In this case, 'spec testing' is testing to see whether the resulting JSON Schema looks like what we think it should look like, in detail. + +## Unit testing + +Unit tests here focus on end-to-end testing, i.e. per-metaschema mappings from single model input to single JSON Schema output. + +The unit testing here is *less* granular than the specification testing. + +Neither of these actually test the JSON Schema, only the way in which one is produced. + + +This implies near-term and longer-term goals: + +# JSON Schema generation - planning + +## Near-term + +Even without running the JSON Schema (a 'field-test' to demonstrate its adequacy for the purpose, i.e. validation), we can test a great deal since we know what that JSON Schema should look like. + +I.e., we can test the mapping of Metaschema semantics into JSON by sketching the transformation from Metaschema source to the JSON Schema in its XML precursor format. + +- [ ] XSpec the XSLT + - [ ] `make-json-schema-metamap.xsl` for unit testing + - [ ] `../nist-metaschema-MAKE-JSON-SCHEMA-as-xml.xsl` with @external='true' for end to end +- [ ] Flesh out with micro-examples of special cases +- [ ] Deal with `choice` https://github.com/usnistgov/metaschema-xslt/issues/105 + +cf https://github.com/usnistgov/OSCAL/issues/1989 + +This will give us something to show that we can generate correct outputs, for given inputs, in the general case. + +Note that in this repo, the OSCAL models will *not* be used. + +(But it can be used in parallel work in the oscal-xslt repository.) + +## Longer-term + +"Field test" script able to distinguish between expected-valid and expected-invalid JSON, and report findings. + +Something that could be reused in oscal-xslt over OSCAL inputs, for example. + +## Punchlist + +- [ ] XSpec to test metamap XSLT +- [x] Makefile to run this XSpec using xspec-dev script cf ../InspectorXSLT/Makefile +- [ ] Show tests with proposed solution(s) via PR \ No newline at end of file diff --git a/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-mapping-xspec/choice-splitting.xspec b/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-mapping-xspec/choice-splitting.xspec new file mode 100644 index 00000000..38c94ca5 --- /dev/null +++ b/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-mapping-xspec/choice-splitting.xspec @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-mapping-xspec/metamap-test.xspec b/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-mapping-xspec/metamap-test.xspec new file mode 100644 index 00000000..4a617357 --- /dev/null +++ b/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-mapping-xspec/metamap-test.xspec @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-runtime-xspec/jsonschema-gen-test.xspec b/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-runtime-xspec/jsonschema-gen-test.xspec new file mode 100644 index 00000000..11eab3a4 --- /dev/null +++ b/src/schema-gen/JSON-schema/testing/tests/jsonschemagen-runtime-xspec/jsonschema-gen-test.xspec @@ -0,0 +1,49 @@ + + + + + + + + + + + + + On + + + + + + ... + + + + + + + + diff --git a/src/schema-gen/METASCHEMA-ALL-VALIDATORS.xpl b/src/schema-gen/METASCHEMA-ALL-VALIDATORS.xpl new file mode 100644 index 00000000..6b644191 --- /dev/null +++ b/src/schema-gen/METASCHEMA-ALL-VALIDATORS.xpl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/schema-gen/Makefile b/src/schema-gen/Makefile index 6a23d2e1..e88e0d86 100644 --- a/src/schema-gen/Makefile +++ b/src/schema-gen/Makefile @@ -4,13 +4,24 @@ include ../testing/make_common.mk test_metaschema:=../testing/models_metaschema.xml output_folder:=test_output + .PHONY: test -test: smoke-test ## Run all tests +test: smoke-test unit-test ## Run all tests + .PHONY: smoke-test -smoke-test: ## Run all smoke-tests +smoke-test: ## Generate schemas from ../testing/models_metaschema.xml ./mvn-schemas-xpl.sh "$(test_metaschema)" $(output_folder) models_metaschema + +.PHONY: unit-test +unit-test: xsd-proof-test ## Generate, validate and test run an XSD for ../testing/models_metaschema.xml + + +.PHONY: xsd-proof-test +xsd-proof-test: ## Proof test XSD schema for ../testing/models_metaschema.xml + ./mvn-xsd-proofcheck-xpl.sh "$(test_metaschema)" + .PHONY: clean clean: ## Remove test output rm -fr $(output_folder)/* diff --git a/src/schema-gen/XSD/make-metaschema-xsd.xsl b/src/schema-gen/XSD/make-metaschema-xsd.xsl index 59b03f55..3d5998db 100644 --- a/src/schema-gen/XSD/make-metaschema-xsd.xsl +++ b/src/schema-gen/XSD/make-metaschema-xsd.xsl @@ -68,6 +68,8 @@ IntegerDatatype IPV4AddressDatatype IPV6AddressDatatype + MarkupLineDatatype + MarkupMultilineDatatype NonNegativeIntegerDatatype PositiveIntegerDatatype StringDatatype diff --git a/src/testing/Makefile b/src/testing/Makefile new file mode 100644 index 00000000..d9fca3dd --- /dev/null +++ b/src/testing/Makefile @@ -0,0 +1,61 @@ +include ./make_common.mk + +# TODO: Build out targets and runtimes for XML <-> JSON conversions +# Including XSpec testing of conversion pipelines and steps +# Extend and integrate unit tests into this Makefile + +# See the Makefile at ../schema-gen/InspectorXSLT/Makefile for more logic to borrow + +# INCLUDES: +# smoke-test - smoke testing - for this directory, pre-checks models_metaschema.xml +# xspec - run XSpec tests in designated folder +# clean - clean up designated output folder + +module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +output_folder:=$(module_path)/test_output +xspec_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch-quiet.sh) +xspec_ci_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch.sh) +metaschema_validate_xsd_script=$(realpath $(module_path)/../validate/mvn-metaschema-xsd-validate-xpl.sh) +metaschema_validate_schematron_script=$(realpath $(module_path)/../validate/mvn-composition-validate-xpl.sh) + +folder=. +test_metaschema=models_metaschema.xml + + +.PHONY: test +test: smoke-test spec-test ## Run all tests + +# .PHONY: spec-test # +# spec-test: ## Run all specification tests +# LOGFILE="$(output_folder)/inspector-functional-tests.log" $(xspec_ci_script) \ +# "folder=$(module_path)/testing/tests/inspector-functional-xspec" \ +# "report-to=$(output_folder)/inspector-functional-tests_report.html" \ +# "junit-to=$(output_folder)/inspector-functional-tests_junit-report.xml" \ +# "stop-on-error=yes" \ +# "recurse=yes" + + +.PHONY: smoke-test +smoke-test: pre-checks ## For this directory, run pre-checks for other processes + + +.PHONY: pre-checks +pre-checks: ## Validate and check models_metaschema.xml + $(metaschema_validate_xsd_script) models_metaschema.xml + $(metaschema_validate_schematron_script) models_metaschema.xml + + +.PHONY: xspec +xspec: ## Run all *.xspec in a designated folder, quietly - use folder=[folder] + LOGFILE="$(output_folder)/$(folder)-xspec-tests.log" $(xspec_script) \ + "baseURI=file:$(module_path)/" \ + "folder=$(folder)" \ + "report-to=$(output_folder)/inspector-$(folder)-tests_report.html" \ + "stop-on-error=no" \ + "recurse=yes" + + +.PHONY: clean +clean: ## Remove test output + rm -fr $(output_folder)/* + diff --git a/src/testing/models_metaschema.xml b/src/testing/models_metaschema.xml index 0b72c8d6..4a441e7c 100644 --- a/src/testing/models_metaschema.xml +++ b/src/testing/models_metaschema.xml @@ -45,11 +45,11 @@ assembly everything. EVERYTHING + + Deprecated + a deprecated flag. + - - Deprecated - a deprecated flag. - overloaded1 diff --git a/src/testing/readme.md b/src/testing/readme.md new file mode 100644 index 00000000..245b60ce --- /dev/null +++ b/src/testing/readme.md @@ -0,0 +1,48 @@ +# Testing Resources + +See the [TESTING](../TESTING.md) docs for info on testing. + +This directory contains misc testing resources that do not have a home elsewhere, or have not yet been moved to their proper homes. + +## Warning: taking care editing resources + +The files and utilities in this subdirectory are used as inputs in testing across the repository. When editing them, be sure that dependent operations are still running. + +Don't edit and amend these resources without performing due diligence to align processes and tests that depend on them. + +## In this directory + + +Dynamic testing of Metaschema-based data conversions, XML to JSON and back. + +- models-testdata.xml +- models_metaschema.xml +- test-json-conversions.xpl +- test-xml-conversions.xpl +- test-xml-json-roundtrip.xpl + +Don't change any of these files without keeping the schema generation testing in place as it depends on them. + +## Tinydata model + +See the [tinydata](./tinydata) folder for a fully worked example, made to a different set of design requirements than models_metaschema.xml. + +It has its own tests and build scripts. + +The 'models' metaschema aims to present all assembly, field and flag model configurations and definitions in a 'lab-only' tag set. + +Tinydata, in contrast, is designed to be actually useful for some range of use cases, for example glossaries, data sheets or spreadsheet dumps. + +## Schema generation testing overhaul planning Summer 2024 + +- [ ] **Phase I** plan out, test and code solution to Issue 105 - JSON schema `choice` fail + - [x] use tinydata example to unit test this in schema-gen/JSON-schema + - [ ] demonstrate with some go/no-go testing in tinydata that this works + - [ ] make a new OSCAL catalog JSON Schema available for field testing in oscal-xproc3 + - [ ] clean up and push to address #105 +- [ ] **Phase II** build out XSpecs for schema generation - at least minimally (foothold) + - [ ] XSD and JSON Schema in detail + - [ ] both models_metaschema and tinydata +- [ ] **Phase III** Inspector XSLT generation + - [ ] free all schema generators from `metaschema` module runtime dependency + - [ ] make all schema generation available as runtimes in XSLT, XProc 1/3 diff --git a/src/testing/tinydata/TINYDATA-MAKE-JSON.xpl b/src/testing/tinydata/TINYDATA-MAKE-JSON.xpl new file mode 100644 index 00000000..1c34ed85 --- /dev/null +++ b/src/testing/tinydata/TINYDATA-MAKE-JSON.xpl @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/testing/tinydata/TINYDATA-XSD-VALIDATE.xpl b/src/testing/tinydata/TINYDATA-XSD-VALIDATE.xpl new file mode 100644 index 00000000..23e74366 --- /dev/null +++ b/src/testing/tinydata/TINYDATA-XSD-VALIDATE.xpl @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Checking { count(*/*) }{ if (count(*/*) eq 1) then ' document' else ' documents' } against a 'choices' XSD ... + + + + ALL GOOD - confirming expected results from XSD validation + + + + + + VALIDATION ANOMALY: a document expected to be valid is found to be INVALID + + + + VALIDATION ANOMALY: a marked document ('<?EXPECT ERROR?>') is found to be VALID + + + + CONFIRMED (invalid) + + + + CONFIRMED (valid) + + + + + + + + + + + + + + + + + { (1 to 12) ! ':::::' } + + + + + + + + + + : { . } + + + + + + + \ No newline at end of file diff --git a/src/testing/tinydata/current/tiny_COMPOSED.xml b/src/testing/tinydata/current/tiny_COMPOSED.xml new file mode 100644 index 00000000..2214fe8d --- /dev/null +++ b/src/testing/tinydata/current/tiny_COMPOSED.xml @@ -0,0 +1,446 @@ + + Seeing assembly#tiny:TINY, field#tiny:title, field#tiny:term, assembly#tiny:part, assembly#tiny:sheet, flag#tiny:key, flag#tiny:class, field#tiny:item, field#tiny:note + Tiny Data Model + 0.0.2 + tiny + http://csrc.nist.gov/ns/metaschema-xslt/tinydata + http://csrc.nist.gov/ns/metaschema-xslt/tinydata + +

Tiny Metaschema

+

A metaschema can be small and yet deep.

+
+ + Tiny Data + A minimally described data set. + TINY + + Tiny ID + An identifier. + + + + + + + + Stuff + Some amount of tiny stuff. + + + + + + + + + + + Title + markup-line example. + + + Term + Simple string value example. + + Term identifier + A token identifying this term uniquely within the document. + + +

For a more extensive model supporting definitions, acronyms etc. build this out into an assembly. As a field, this supports some control over the vocabulary and formatting without heavier embedded metadata.

+

Of course you could always make a structured glossary out of regular and controlled parts for your terminology, and use this inside it, potentially with title/insert.

+
+
+ + Note + Wrapped markup-multiline example. + + + Tiny part + A bit of tiny data. + + + + + + + Stuff + Some amount of tiny stuff. + + + + + + + + + + + + Tiny sheet + A list or grid of data points (items), or an entry (row or line item) in such a list or grid that contains such a list or grid. + + + + + + Stuff + Some amount of tiny stuff. + + + + entry + + + + item + + + + + + + + Line item + A value, potentially marked with @key or @class. + + + + N (position) + An indexed position (distinctive among values of parent::*/*/@n). + + + + Distinctive 'n' value + @n must be distinctive among sibling items. + +

A whole number is expected here although '0' is permitted. Values among siblings are not constrained to be ordered, only different. Ordering is up to the receiving application.

+
+
+
+ +

An application may constrain the value of the node to a datatype or other requirement, on the basis of @key, @class or other association(s).

+
+
+ + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + + + Class + Class or classes. + +
diff --git a/src/testing/tinydata/current/tiny_inspector.xsl b/src/testing/tinydata/current/tiny_inspector.xsl new file mode 100644 index 00000000..5acdeb58 --- /dev/null +++ b/src/testing/tinydata/current/tiny_inspector.xsl @@ -0,0 +1,1048 @@ + + + + + + + + inspected + + full + + none + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + av.152 + _UE unmatched-element + Unrecognized element { name() }. + + + + + + + + + + + + + + av.180 + _UT unexpected-text + Errant text content. + + + + + + + av.193 + _UA unmatched-attribute + Unrecognized attribute @{ name() } on element { name(..) }. + + + + + + + + + + exists(.) + + __U uncategorized + * + [info] + ERROR + + + + + + + + + + + + + + + + + + [info] + + + + + + + + + /{ name() } + + + + + /{ name() }[{ mx:element-position(.)[count($kin) gt 1] }] + + + + /@{ name() } + + + + + [{ count(preceding-sibling::text()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + [{ count(preceding-sibling::comment()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + [{ count(preceding-sibling::processing-instruction()|.) + }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + + + + + + + { $as } + { $as }s + + + + + + + + + + + + + + + + + + + + + + + + + + + + + File { replace(@src,'.*/','') } has { $error-count } { + mx:pluralize($error-count,'error')}. + File { replace(@src,'.*/','') } has { $report-count } { + mx:pluralize($report-count,'issue') } reported including { $error-count } { + mx:pluralize($error-count,'error')}. + + + + + + + + + + File { replace(@src,'.*/','') } is reported VALID, no issues ... + + + + + + + + + + + + + + + + + + + + + + + + + { (@level,'ERROR')[1] } [CLASS) { @class } ][PATH) { @xpath } ][REPORT) { + string(.) }] + + + + + + + + + + + + { $validating-filename } - { $checked } - { mx:metaschema/@shortname } validation + + + + + + +
+ + +

+ { $validating-filename } contains { @elements} { + mx:pluralize(@elements/number(),'element') } and { @attributes } { + mx:pluralize(@attributes/number(),'attribute') }.

+ + +
+ +
+
+
+ + + + + + + + + +
+

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'issue') } reported.

+

+ + 💥 + +

+
+
+ +
+

Good news - nothing to report - the instance is valid. 🚀 +

+
+
+ + + + +
+ + + +

{ @class }{ @level[not(.='ERROR')] ! (' ' || .) }

+
    + +
  • Rule ID: { . } +
  • +
    +
  • test: { @test } +
  • + +
  • matching: { @matching } +
  • +
    +
  • XPath: { @xpath } +
  • +
+
+
+ + + + + + + + + + + + + + + + + { codepoints-to-string(10) } + + + + + + + { $lf } + + + + { $lf2 }--- + + + + # + + + + + { $lf2 }# + + + + + { $lf2 }## + + + + + { $lf2 }### + + + + + { $lf2 } + + + + + + + + + { $lf }- + + + + ** + + ** + + + * + + * + + + ` + + ` + + + Tiny Data Model + + + + + + + + + + + + + + + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::notes) + + Element part is unexpected following notes/note. + + + + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::sheet | preceding-sibling::note) + + Element part is unexpected following sheet or note. + + + + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::note) + + Element sheet is unexpected following note. + + + + + + + + gix.362 + empty(preceding-sibling::entry) and exists(../(item)) + + VEXC violates-exclusive-choice + Element entry is unexpected along with item. + + + + + + + + + gix.347 + EATO element-appears-too-often + count(. | preceding-sibling::title) gt 1 + + Element title appears too many times: 1 maximum is permitted. + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element title is unexpected following term, stuff, part, or notes/note. + + + + + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element term is unexpected following stuff, part, or notes/note. + + + + + + + + + + + + + + + + gix.347 + EATO element-appears-too-often + count(. | preceding-sibling::title) gt 1 + + Element title appears too many times: 1 maximum is permitted. + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::sheet | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element title is unexpected following term, stuff, part, sheet, or note. + + + + + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::part | preceding-sibling::sheet | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element term is unexpected following stuff, part, sheet, or note. + + + + + + + + + gix.347 + EATO element-appears-too-often + count(. | preceding-sibling::note) gt 1 + + Element note appears too many times: 1 maximum is permitted. + + + + + + + + + gix.347 + EATO element-appears-too-often + count(. | preceding-sibling::title) gt 1 + + Element title appears too many times: 1 maximum is permitted. + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::entry | preceding-sibling::item | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element title is unexpected following stuff, entry, item, or note. + + + + + + + + + gix.362 + empty(preceding-sibling::item) and exists(../(entry)) + + VEXC violates-exclusive-choice + Element item is unexpected along with entry. + + + + + + + + + gix.347 + EATO element-appears-too-often + count(. | preceding-sibling::note) gt 1 + + Element note appears too many times: 1 maximum is permitted. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + gix.108 + EOOP element-out-of-place + Element { name() } is not permitted here. + + + + + gix.117 + AOOP attribute-out-of-place + Attribute @{ name() } is not permitted here. + + + + + + + + gix.748 + MRQA missing-required-attribute + empty(@id) + + Element { name() } requires attribute @id. + + + gix.445 + MRQC missing-required-contents + empty(title) + + Element { name() } requires element title. + + + + + + + + + + + + + + gix.748 + MRQA missing-required-attribute + empty(@id) + + Element { name() } requires attribute @id. + + + + + + + + + + + + gix.445 + MRQC missing-required-contents + empty(title) + + Element { name() } requires element title. + + + + + + + + + + + + + + + + + + + + + + + + + + + VDSX violates-datatype-syntax + + + gix.148 + + + { $class } + not(string(.) castable as xs:string and matches(.,'^\S(.*\S)?$')) + + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to string datatype. + + + + + VDSX violates-datatype-syntax + + + gix.148 + + + { $class } + not(string(.) castable as xs:string and matches(.,'^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$') and matches(.,'^\S(.*\S)?$')) + + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to token datatype. + + + + + VDSX violates-datatype-syntax + + + gix.148 + + + { $class } + not(string(.) castable as xs:nonNegativeInteger and matches(.,'^\S(.*\S)?$')) + + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to non-negative-integer datatype. + + + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::part | preceding-sibling::notes) + + Element stuff is unexpected following part or notes/note. + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::part | preceding-sibling::sheet | preceding-sibling::note) + + Element stuff is unexpected following part, sheet, or note. + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::entry | preceding-sibling::item | preceding-sibling::note) + + Element stuff is unexpected following entry, item, or note. + + + + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::notes | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element title is unexpected following term, stuff, part, or notes/note. + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::term | preceding-sibling::part | preceding-sibling::sheet | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element title is unexpected following term, stuff, part, sheet, or note. + + + + + gix.390 + EOOO element-out-of-order + exists(preceding-sibling::entry | preceding-sibling::item | preceding-sibling::note | preceding-sibling::h1 | preceding-sibling::h2 | preceding-sibling::h3 | preceding-sibling::h4 | preceding-sibling::h5 | preceding-sibling::h6 | preceding-sibling::table | preceding-sibling::img | preceding-sibling::pre | preceding-sibling::hr | preceding-sibling::blockquote | preceding-sibling::ul | preceding-sibling::ol | preceding-sibling::p) + + Element title is unexpected following stuff, entry, item, or note. + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/testing/tinydata/current/tiny_json-schema.xml b/src/testing/tinydata/current/tiny_json-schema.xml new file mode 100644 index 00000000..7fc22741 --- /dev/null +++ b/src/testing/tinydata/current/tiny_json-schema.xml @@ -0,0 +1,346 @@ + + http://json-schema.org/draft-07/schema# + http://csrc.nist.gov/ns/metaschema-xslt/tinydata/0.0.2/tiny-schema.json + Tiny Data Model: JSON Schema + object + + + Schema Directive + A JSON Schema directive to bind a specific schema to its document instance. + #/definitions/json-schema-directive + #/definitions/URIReferenceDatatype + + + Tiny Data + A minimally described data set. + #/definitions/tiny-tiny:TINY + object + + + Tiny ID + An identifier. + #/definitions/TokenDatatype + + + #/definitions/tiny-tiny:title + + + + + #/definitions/tiny-tiny:term + + + array + 1 + + #/definitions/tiny-tiny:term + + + + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + + + #/definitions/tiny-tiny:part + + + array + 1 + + #/definitions/tiny-tiny:part + + + + + + + + #/definitions/tiny-tiny:note + + + array + 1 + + #/definitions/tiny-tiny:note + + + + + + + id + title + + false + + + Title + markup-line example. + #/definitions/tiny-tiny:title + #/definitions/MarkupLineDatatype + + + Term + Simple string value example. + #/definitions/tiny-tiny:term + object + + + Term identifier + A token identifying this term uniquely within the document. + #/definitions/TokenDatatype + + + #/definitions/StringDatatype + + + + STRVALUE + id + + false + + + Note + Wrapped markup-multiline example. + #/definitions/tiny-tiny:note + #/definitions/MarkupMultilineDatatype + + + Tiny part + A bit of tiny data. + #/definitions/tiny-tiny:part + object + + + #/definitions/tiny-tiny:title + + + + + #/definitions/tiny-tiny:term + + + array + 1 + + #/definitions/tiny-tiny:term + + + + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + + + #/definitions/tiny-tiny:part + + + array + 1 + + #/definitions/tiny-tiny:part + + + + + + + + #/definitions/tiny-tiny:sheet + + + array + 1 + + #/definitions/tiny-tiny:sheet + + + + + + #/definitions/tiny-tiny:note + + + + title + + false + + + Tiny sheet + A list or grid of data points (items), or an entry (row or line item) in such a list or grid that contains such a list or grid. + #/definitions/tiny-tiny:sheet + object + + + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + #/definitions/TokenDatatype + + + Class + Class or classes. + #/definitions/StringDatatype + + + #/definitions/tiny-tiny:title + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + array + 1 + + #/definitions/tiny-tiny:sheet + + + + #/definitions/tiny-tiny:note + + + false + + + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + #/definitions/TokenDatatype + + + Class + Class or classes. + #/definitions/StringDatatype + + + #/definitions/tiny-tiny:title + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + + + #/definitions/tiny-tiny:item + + + array + 1 + + #/definitions/tiny-tiny:item + + + + + + #/definitions/tiny-tiny:note + + + false + + + + + Line item + A value, potentially marked with @key or @class. + #/definitions/tiny-tiny:item + object + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + #/definitions/TokenDatatype + + + Class + Class or classes. + #/definitions/StringDatatype + + + N (position) + An indexed position (distinctive among values of parent::*/*/@n). + #/definitions/NonNegativeIntegerDatatype + + + #/definitions/MarkupLineDatatype + + + + RICHTEXT + + false + + + A whole number value. + integer + + + A single line of Markdown content conformant to the Commonmark specification. + string + ^[^ +]+$ + + + A multiple lines of Markdown content conformant to the Commonmark specification. + string + + + An integer value that is equal to or greater than 0. + + + #/definitions/IntegerDatatype + + + number + 0 + + + + + A non-empty string with leading and trailing whitespace disallowed. Whitespace is: U+9, U+10, U+32 or [ + ]+ + string + ^\S(.*\S)?$ + + + A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName. + string + ^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$ + + + A URI Reference, either a URI or a relative-reference, formatted according to section 4.1 of RFC3986. + string + uri-reference + + + + + #/definitions/json-schema-directive + + + #/definitions/tiny-tiny:TINY + + + + TINY + + false + diff --git a/src/testing/tinydata/current/tiny_json-to-xml.xsl b/src/testing/tinydata/current/tiny_json-to-xml.xsl new file mode 100644 index 00000000..c5c5902e --- /dev/null +++ b/src/testing/tinydata/current/tiny_json-to-xml.xsl @@ -0,0 +1,780 @@ + + + + + + + + + + xml + + + No file found at { $file } + + + + + + + {{ $err:description }} + + + + + + + {{ $err:description }} + + + + + + + + + + + + Error in XSLT invocation - an initial template (-it) is expected ('from-json' or 'from-xdm-json-xml'), but none is given + + + + + + + + { $err:description } + + + + + + + + + + No XPath (XML) JSON found at { $file } - using syntax of http://www.w3.org/2005/xpath-functions + + + + + + + + + + + + + + + + + + + + + + + + + http://example.com/ns/tinydata + + + + + + TINY + + + + + + + + + + + + + + + + + + part + + + + + + + + + + + + + + + sheet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + title + + + + + + + + + + + + + + + term + + + + + + + + + + + + + + + + + items + + + + + + + + + + + + + + + + + + + note + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + +

+
+
+ + + + + + + + + + + + + + + + +
+ + + + + + + +
+         
+            language-{.}
+         
+         
+      
+
+ + +

+ + +

+
+
+ + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +

+ +

+
+ ^\s*(\*|\d+\.)\s + + + +
  • + + +
    +
    + +
    +
  • +
    +
    +
    + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + +
  • +
    + + +
  • + + + + + +
  • +
    +
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &amp; + &lt; + + &quot; + + &#x2A; + &#x60; + &#x7E; + &#x5E; + + + + + + + + + + + + + + + + + + + "" + !\[{{$noclosebracket}}\] + \{\{\s*insert: ,\s*\s*\}\} + \(\) + `` + + \*\*\*\*\*\* + + \*\*\*\* + \*\* + ~~ + \^\^ + + + + + + + + + + + + + + + + (.*?) + + + (\i\c*?) + + + ([^{ @not }]*?) + + + + < + + + xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel" + + + > + + </ + + > + + + $1 + + + + <insert xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel" + + + /> + + + type='$1' + + + id-ref='$2' + + + href='$2' + + + + alt='$1' + + + + src='$2' + + + { insertion } + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    diff --git a/src/testing/tinydata/current/tiny_schema.json b/src/testing/tinydata/current/tiny_schema.json new file mode 100644 index 00000000..3f72fb10 --- /dev/null +++ b/src/testing/tinydata/current/tiny_schema.json @@ -0,0 +1,247 @@ + + { "$schema" : "http://json-schema.org/draft-07/schema#", + "$id" : "http://csrc.nist.gov/ns/metaschema-xslt/tinydata/0.0.2/tiny-schema.json", + "$comment" : "Tiny Data Model: JSON Schema", + "type" : "object", + "definitions" : + { "json-schema-directive" : + { "title" : "Schema Directive", + "description" : "A JSON Schema directive to bind a specific schema to its document instance.", + "$id" : "#/definitions/json-schema-directive", + "$ref" : "#/definitions/URIReferenceDatatype" }, + "tiny-tiny:TINY" : + { "title" : "Tiny Data", + "description" : "A minimally described data set.", + "$id" : "#/definitions/tiny-tiny:TINY", + "type" : "object", + "properties" : + { "id" : + { "title" : "Tiny ID", + "description" : "An identifier.", + "$ref" : "#/definitions/TokenDatatype" }, + "title" : + { "$ref" : "#/definitions/tiny-tiny:title" }, + "terminology" : + { "anyOf" : + [ + { "$ref" : "#/definitions/tiny-tiny:term" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:term" } } ] }, + "stuff" : + { "title" : "Stuff", + "description" : "Some amount of tiny stuff.", + "$ref" : "#/definitions/MarkupMultilineDatatype" }, + "parts" : + { "anyOf" : + [ + { "$ref" : "#/definitions/tiny-tiny:part" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:part" } } ] }, + "notes" : + { "anyOf" : + [ + { "$ref" : "#/definitions/tiny-tiny:note" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:note" } } ] } }, + "required" : + [ "id", + "title" ], + "additionalProperties" : false }, + "tiny-tiny:title" : + { "title" : "Title", + "description" : "markup-line example.", + "$id" : "#/definitions/tiny-tiny:title", + "$ref" : "#/definitions/MarkupLineDatatype" }, + "tiny-tiny:term" : + { "title" : "Term", + "description" : "Simple string value example.", + "$id" : "#/definitions/tiny-tiny:term", + "type" : "object", + "properties" : + { "id" : + { "title" : "Term identifier", + "description" : "A token identifying this term uniquely within the document.", + "$ref" : "#/definitions/TokenDatatype" }, + "STRVALUE" : + { "$ref" : "#/definitions/StringDatatype" } }, + "required" : + [ "STRVALUE", + "id" ], + "additionalProperties" : false }, + "tiny-tiny:note" : + { "title" : "Note", + "description" : "Wrapped markup-multiline example.", + "$id" : "#/definitions/tiny-tiny:note", + "$ref" : "#/definitions/MarkupMultilineDatatype" }, + "tiny-tiny:part" : + { "title" : "Tiny part", + "description" : "A bit of tiny data.", + "$id" : "#/definitions/tiny-tiny:part", + "type" : "object", + "properties" : + { "title" : + { "$ref" : "#/definitions/tiny-tiny:title" }, + "terminology" : + { "anyOf" : + [ + { "$ref" : "#/definitions/tiny-tiny:term" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:term" } } ] }, + "stuff" : + { "title" : "Stuff", + "description" : "Some amount of tiny stuff.", + "$ref" : "#/definitions/MarkupMultilineDatatype" }, + "parts" : + { "anyOf" : + [ + { "$ref" : "#/definitions/tiny-tiny:part" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:part" } } ] }, + "sheets" : + { "anyOf" : + [ + { "$ref" : "#/definitions/tiny-tiny:sheet" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:sheet" } } ] }, + "note" : + { "$ref" : "#/definitions/tiny-tiny:note" } }, + "required" : + [ "title" ], + "additionalProperties" : false }, + "tiny-tiny:sheet" : + { "title" : "Tiny sheet", + "description" : "A list or grid of data points (items), or an entry (row or line item) in such a list or grid that contains such a list or grid.", + "$id" : "#/definitions/tiny-tiny:sheet", + "type" : "object", + "anyOf" : + [ + { "properties" : + { "key" : + { "title" : "Field key", + "description" : "Distinguishing a sheet or item (field) among siblings or neighbors.", + "$ref" : "#/definitions/TokenDatatype" }, + "class" : + { "title" : "Class", + "description" : "Class or classes.", + "$ref" : "#/definitions/StringDatatype" }, + "title" : + { "$ref" : "#/definitions/tiny-tiny:title" }, + "stuff" : + { "title" : "Stuff", + "description" : "Some amount of tiny stuff.", + "$ref" : "#/definitions/MarkupMultilineDatatype" }, + "sheets" : + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:sheet" } }, + "note" : + { "$ref" : "#/definitions/tiny-tiny:note" } }, + "additionalProperties" : false }, + + { "properties" : + { "key" : + { "title" : "Field key", + "description" : "Distinguishing a sheet or item (field) among siblings or neighbors.", + "$ref" : "#/definitions/TokenDatatype" }, + "class" : + { "title" : "Class", + "description" : "Class or classes.", + "$ref" : "#/definitions/StringDatatype" }, + "title" : + { "$ref" : "#/definitions/tiny-tiny:title" }, + "stuff" : + { "title" : "Stuff", + "description" : "Some amount of tiny stuff.", + "$ref" : "#/definitions/MarkupMultilineDatatype" }, + "items" : + { "anyOf" : + [ + { "$ref" : "#/definitions/tiny-tiny:item" }, + + { "type" : "array", + "minItems" : 1, + "items" : + { "$ref" : "#/definitions/tiny-tiny:item" } } ] }, + "note" : + { "$ref" : "#/definitions/tiny-tiny:note" } }, + "additionalProperties" : false } ] }, + "tiny-tiny:item" : + { "title" : "Line item", + "description" : "A value, potentially marked with @key or @class.", + "$id" : "#/definitions/tiny-tiny:item", + "type" : "object", + "properties" : + { "key" : + { "title" : "Field key", + "description" : "Distinguishing a sheet or item (field) among siblings or neighbors.", + "$ref" : "#/definitions/TokenDatatype" }, + "class" : + { "title" : "Class", + "description" : "Class or classes.", + "$ref" : "#/definitions/StringDatatype" }, + "n" : + { "title" : "N (position)", + "description" : "An indexed position (distinctive among values of parent::*/*/@n).", + "$ref" : "#/definitions/NonNegativeIntegerDatatype" }, + "RICHTEXT" : + { "$ref" : "#/definitions/MarkupLineDatatype" } }, + "required" : + [ "RICHTEXT" ], + "additionalProperties" : false }, + "IntegerDatatype" : + { "description" : "A whole number value.", + "type" : "integer" }, + "MarkupLineDatatype" : + { "description" : "A single line of Markdown content conformant to the Commonmark specification.", + "type" : "string", + "pattern" : "^[^\n]+$" }, + "MarkupMultilineDatatype" : + { "description" : "A multiple lines of Markdown content conformant to the Commonmark specification.", + "type" : "string" }, + "NonNegativeIntegerDatatype" : + { "description" : "An integer value that is equal to or greater than 0.", + "allOf" : + [ + { "$ref" : "#/definitions/IntegerDatatype" }, + + { "type" : "number", + "minimum" : 0 } ] }, + "StringDatatype" : + { "description" : "A non-empty string with leading and trailing whitespace disallowed. Whitespace is: U+9, U+10, U+32 or [ \n\t]+", + "type" : "string", + "pattern" : "^\\S(.*\\S)?$" }, + "TokenDatatype" : + { "description" : "A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName.", + "type" : "string", + "pattern" : "^(\\p{L}|_)(\\p{L}|\\p{N}|[.\\-_])*$" }, + "URIReferenceDatatype" : + { "description" : "A URI Reference, either a URI or a relative-reference, formatted according to section 4.1 of RFC3986.", + "type" : "string", + "format" : "uri-reference" } }, + "properties" : + { "$schema" : + { "$ref" : "#/definitions/json-schema-directive" }, + "TINY" : + { "$ref" : "#/definitions/tiny-tiny:TINY" } }, + "required" : + [ "TINY" ], + "additionalProperties" : false } \ No newline at end of file diff --git a/src/testing/tinydata/current/tiny_schema.xsd b/src/testing/tinydata/current/tiny_schema.xsd new file mode 100644 index 00000000..0fa3bbe5 --- /dev/null +++ b/src/testing/tinydata/current/tiny_schema.xsd @@ -0,0 +1,498 @@ + + + + Tiny Data Model + 0.0.2 + tiny + +

    Tiny Metaschema

    +

    A metaschema can be small and yet deep.

    +
    + TINY +
    +
    + + + + + Tiny Data + A minimally described data set. + + + Tiny Data: A minimally described data set. + + + + + + + + + + + + + Note + Wrapped markup-multiline example. + + + Note: Wrapped markup-multiline example. + + + + + + + + + + + + + Tiny ID + An identifier. + + + Tiny ID: An identifier. + + + + + + + Title + markup-line example. + + + Title: markup-line example. + + + + + + + + + Term + Simple string value example. + + + Term: Simple string value example. + + + + + + + Term identifier + A token identifying this term uniquely within the document. + + + Term identifier: A token identifying this term uniquely within the document. + + + + + + + + + Note + Wrapped markup-multiline example. + + + Note: Wrapped markup-multiline example. + + + + + + + + + Tiny part + A bit of tiny data. + + + Tiny part: A bit of tiny data. + + + + + + + + + + + Note + Wrapped markup-multiline example. + + + Note: Wrapped markup-multiline example. + + + + + + + + + + + Tiny sheet + A list or grid of data points (items), or an entry (row or line item) in such a list or grid that contains such a list or grid. + + + Tiny sheet: A list or grid of data points (items), or an entry (row or line item) in such a list or grid that contains such a list or grid. + + + + + + + + + + + + Note + Wrapped markup-multiline example. + + + Note: Wrapped markup-multiline example. + + + + + + + + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + + + Field key: Distinguishing a sheet or item (field) among siblings or neighbors. + + + + + + Class + Class or classes. + + + Class: Class or classes. + + + + + + + Line item + A value, potentially marked with @key or @class. + + + Line item: A value, potentially marked with @key or @class. + + + + + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + + + Field key: Distinguishing a sheet or item (field) among siblings or neighbors. + + + + + + Class + Class or classes. + + + Class: Class or classes. + + + + + + N (position) + An indexed position (distinctive among values of parent::*/*/@n). + + + N (position): An indexed position (distinctive among values of parent::*/*/@n). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The content model is the same as inlineMarkupType, but line endings need + to be preserved, since this is pre-formatted. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An insert can be used to identify a placeholder for dynamically inserting text related to a specific object, which is referenced by the object's identifier using an id-ref. This insert mechanism allows the selection of which text value from the object to dynamically include based on the application's display requirements. + + + + The type of object to include from (e.g., parameter, control, component, role, etc.) + + + + + The identity of the object to insert a value for. The identity will be selected from the index of objects of the specified type. The specific value to include is based on the application's display requirements, which will likely use a specific data element associated with the type (e.g., title, identifier, value, etc.) that is appropriate for the application. + + + + + + An integer value that is equal to or greater than 0. + + + + + This pattern ensures that leading and trailing whitespace is + disallowed. This helps to even the user experience between implementations + related to whitespace. + + + + + + + A non-empty string of Unicode characters with leading and trailing whitespace + disallowed. Whitespace is: U+9, U+10, U+32 or [ \n\t]+ + + + + The 'string' datatype restricts the XSD type by prohibiting leading + and trailing whitespace, and something (not only whitespace) is required. + + + + + This pattern ensures that leading and trailing whitespace is + disallowed. This helps to even the user experience between implementations + related to whitespace. + + + + + + + + A non-empty, non-colonized name as defined by XML Schema Part 2: Datatypes + Second Edition (https://www.w3.org/TR/xmlschema11-2/#NCName), with leading and trailing + whitespace disallowed. + + + + + + A single token may not contain whitespace. + + + + + +
    diff --git a/src/testing/tinydata/current/tiny_xml-to-json.xsl b/src/testing/tinydata/current/tiny_xml-to-json.xsl new file mode 100644 index 00000000..b63a218e --- /dev/null +++ b/src/testing/tinydata/current/tiny_xml-to-json.xsl @@ -0,0 +1,755 @@ + + + + + + + json + no + + + + + + + + + + + + + + + { $err:description } + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $err:description } + + + + + + + + + + + + + + + + + + http://example.com/ns/tinydata + + + + + TINY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + part + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sheet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + title + + + + + + + + + + + term + + + + + + + + + + + + items + + + + + + + + + + + + + + note + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # + ## + ### + #### + ##### + ###### + + + + + + + + + + + | + + --- | + + + + + + | + + + | + + + + ``` + + + + ``` + + + + + + + + + + + + + + + * + + + + + + + + + 1. + + + + + ` + + ` + + + * + + * + + + ** + + ** + + + " + + " + + + {{ insert: + + }} + + + [ + + ] + ( + + ) + + + ![ + + ] + ( + + + "{.}" + + ) + + diff --git a/src/testing/tinydata/readme.md b/src/testing/tinydata/readme.md new file mode 100644 index 00000000..8e86fa5c --- /dev/null +++ b/src/testing/tinydata/readme.md @@ -0,0 +1,62 @@ +# Tiny Data Example Metaschema + +Purpose: An illustrative metaschema for testing + +Meant to be complementary to other testing Metaschemas for example the 'Everything' or 'computer model' metaschemas. + +Aims: + +- Be lightweight, tractable and intelligible +- Be actually albeit hypothetically useful i.e. be plausible & 'realistic' - more than a toy +- Illustrate basic (but not advanced) Metaschema functionality +- Illustrate core concepts including + - Recursive assemblies + - Mixing prose with structure + - both `markup-line` and `markup-multiline` datatypes + - Key-based text expansion (**insert/@ref-id**) + - Data dumps + - Layered constraints? + +## Basic model + +TinyData provides a simple model suitable for glossaries, dictionaries and similar structured prose, supplemented with a general-purpose "grid" or data-dump model. + +It is suitable for high-level structured documentation. But also for what might be CSV, JSON, or HTML tables. Also suitable for documents with islands of structure, or structures with islands of documentation. + +Functional semantics provided for include indexing and reasonably decent formatting for reuse, as HTML and Markdown among other formats. + +But the entire markup language has no more than ten or fifteen tags (depending on how you count). + +Meanwhile we get XSD, JSON Schemas, converters and other utilities (InspectorXSLT) to play with. + +Since it is straightforward to map a [Metaschema-based](https://github.com/usnistgov/metaschema) format into another Metaschema-based format, producing OSCAL (for example) from TinyData ought to be an instructive if elementary exercise. + +## dev punchlist + +Addressing https://github.com/usnistgov/metaschema-xslt/issues/105 + +But also leaving this resource intact for later use + +- Copy scripting over from ../issue105/ +- Refresh validators: XSD, JSON Schema and InspectorXSLT + - leave XProc in place for later use +- Validate `choice` use case + - field test this against samples (good vs broken) + - demonstrate XSD, JSON Schema *and InspectorXSLT* + - XSpec JSON Schema correction in ../../src/schema-gen/JSON-schema/ +- Assess issue with datatype handling + - are markup-line and markup-multiline adequately handled + - https://github.com/usnistgov/OSCAL/issues/2007 + - also sketch this out in XSpec +- Build out solution + - using ../../src/schema-gen/JSON-schema/choice-split.xsl + +- Makefile - `run tests` should include + - XSpecs over in ../../src + - field testing JSON and XSD validations of TinyData? (maybe not) +- Utilities? + - XSLT for TinyData making HTML + - Markdown? + - CSS for editor or browser + +Further: build out TinyData examples \ No newline at end of file diff --git a/src/testing/tinydata/refresh-tiny-converters.sh b/src/testing/tinydata/refresh-tiny-converters.sh new file mode 100644 index 00000000..269fb621 --- /dev/null +++ b/src/testing/tinydata/refresh-tiny-converters.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=../common/subcommand_common.bash + +source "$SCRIPT_DIR/../../common/subcommand_common.bash" + +usage() { + cat <&2 + rm -f "$XJ_CONVERTER" +fi + +if [ -e "$JX_CONVERTER" ]; then + echo "Overwriting prior $JX_CONVERTER..." >&2 + rm -f "$JX_CONVERTER" +fi + +invoke_calabash "${CALABASH_ARGS}" + +if [ -e "$XJ_CONVERTER" ] && [ -e "$JX_CONVERTER" ]; then + echo "Wrote fresh XML/JSON conversion XSLTs into ${OUTPUT_DIR}" >&2 +fi + +fi diff --git a/src/testing/tinydata/refresh-tiny-schemas.sh b/src/testing/tinydata/refresh-tiny-schemas.sh new file mode 100644 index 00000000..8bf3ab2e --- /dev/null +++ b/src/testing/tinydata/refresh-tiny-schemas.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=../common/subcommand_common.bash + +source "$SCRIPT_DIR/../../common/subcommand_common.bash" + +usage() { + cat <&2 + rm -f "$COMPOSED_METASCHEMA" +fi + +if [ -e "$XSD_FILE" ]; then + echo "Overwriting prior $XSD_FILE..." >&2 + rm -f "$XSD_FILE" +fi + +if [ -e "$JSONSCHEMA_FILE" ]; then + echo "Overwriting prior $JSONSCHEMA_FILE..." >&2 + rm -f "$JSONSCHEMA_FILE" +fi + +if [ -e "$JSONSCHEMA_XMLFILE" ]; then + echo "Overwriting prior $JSONSCHEMA_XMLFILE..." >&2 + rm -f "$JSONSCHEMA_XMLFILE" +fi + +if [ -e "$INSPECTORXSLT_FILE" ]; then + echo "Overwriting prior $INSPECTORXSLT_FILE..." >&2 + rm -f "$INSPECTORXSLT_FILE" +fi + + +# echo "${CALABASH_ARGS}" + +invoke_calabash "${CALABASH_ARGS}" + +if [ -e "$XSD_FILE" ] && [ -e "$JSONSCHEMA_FILE" ] && [ -e "$INSPECTORXSLT_FILE" ]; then + echo "Wrote composed metaschema (de-referenced input) to $COMPOSED_METASCHEMA" >&2 + echo "Wrote XSD to $XSD_FILE" >&2 + echo "Wrote JSON schema to $JSONSCHEMA_FILE" >&2 + echo "Wrote JSON schema (XML notation) to $JSONSCHEMA_XMLFILE" >&2 + echo "Wrote Inspector XSLT to $INSPECTORXSLT_FILE" >&2 +fi + +fi diff --git a/src/testing/tinydata/tiny-data/bigbadtiny.xml b/src/testing/tinydata/tiny-data/bigbadtiny.xml new file mode 100644 index 00000000..71e83693 --- /dev/null +++ b/src/testing/tinydata/tiny-data/bigbadtiny.xml @@ -0,0 +1,30 @@ + + + Big Bad Tiny Data +

    A tiny data example sheet.

    +

    Find examples of both valid and invalid markup-line and markup-multiline in a pretend operational context.

    + + Some valid data +

    Here's some okay markup multiline, all clear.

    +

    A markup zoo permits all kinds of inline markup including bold, strong, italic, emphasis, code, subscript, superscript, hypertext anchors, and img alt-text for file.jpg (insertion points and images)

    + + Valid structures +

    Including:

    +
      +
    • lists
    • +
    • tables
    • +
    • preformatted blocks
    • +
    • block quotes
    • +
    +
    + + Here's a data sheet + + a + b + + +
    +
    diff --git a/src/testing/tinydata/tiny-data/tiny1.xml b/src/testing/tinydata/tiny-data/tiny1.xml new file mode 100644 index 00000000..5fb5c1f0 --- /dev/null +++ b/src/testing/tinydata/tiny-data/tiny1.xml @@ -0,0 +1,22 @@ + + + Hello World + + Part First + + Some part +

    Some parting words.

    +
    + +

    Take note here.

    +
    +
    + + +

    An endnote, with emphasis.

    +
    +
    +
    \ No newline at end of file diff --git a/src/testing/tinydata/tiny-json-validate-xp3.sh b/src/testing/tinydata/tiny-json-validate-xp3.sh new file mode 100644 index 00000000..17a5ae92 --- /dev/null +++ b/src/testing/tinydata/tiny-json-validate-xp3.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=../common/subcommand_common.bash + +source "$SCRIPT_DIR/../../common/subcommand_common.bash" + +usage() { + cat < + http://json-schema.org/draft-07/schema# + http://csrc.nist.gov/ns/metaschema-xslt/tinydata/0.0.2/tiny-schema.json + Tiny Data Model: JSON Schema + object + + + Schema Directive + A JSON Schema directive to bind a specific schema to its document instance. + #/definitions/json-schema-directive + #/definitions/URIReferenceDatatype + + + Tiny Data + A minimally described data set. + #/definitions/tiny-tiny:TINY + object + + + Tiny ID + An identifier. + #/definitions/TokenDatatype + + + #/definitions/tiny-tiny:title + + + + + #/definitions/tiny-tiny:term + + + array + 1 + + #/definitions/tiny-tiny:term + + + + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + + + #/definitions/tiny-tiny:part + + + array + 1 + + #/definitions/tiny-tiny:part + + + + + + + + #/definitions/tiny-tiny:note + + + array + 1 + + #/definitions/tiny-tiny:note + + + + + + + id + title + + false + + + Title + markup-line example. + #/definitions/tiny-tiny:title + #/definitions/MarkupLineDatatype + + + Term + Simple string value example. + #/definitions/tiny-tiny:term + object + + + Term identifier + A token identifying this term uniquely within the document. + #/definitions/TokenDatatype + + + #/definitions/StringDatatype + + + + STRVALUE + id + + false + + + Note + Wrapped markup-multiline example. + #/definitions/tiny-tiny:note + #/definitions/MarkupMultilineDatatype + + + Tiny part + A bit of tiny data. + #/definitions/tiny-tiny:part + object + + + #/definitions/tiny-tiny:title + + + + + #/definitions/tiny-tiny:term + + + array + 1 + + #/definitions/tiny-tiny:term + + + + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + + + #/definitions/tiny-tiny:part + + + array + 1 + + #/definitions/tiny-tiny:part + + + + + + + + #/definitions/tiny-tiny:sheet + + + array + 1 + + #/definitions/tiny-tiny:sheet + + + + + + #/definitions/tiny-tiny:note + + + + title + + false + + + Tiny sheet + A list or grid of data points (items), or an entry (row or line item) in such a list or grid that contains such a list or grid. + #/definitions/tiny-tiny:sheet + object + + + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + #/definitions/TokenDatatype + + + Class + Class or classes. + #/definitions/StringDatatype + + + #/definitions/tiny-tiny:title + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + array + 1 + + #/definitions/tiny-tiny:sheet + + + + #/definitions/tiny-tiny:note + + + false + + + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + #/definitions/TokenDatatype + + + Class + Class or classes. + #/definitions/StringDatatype + + + #/definitions/tiny-tiny:title + + + Stuff + Some amount of tiny stuff. + #/definitions/MarkupMultilineDatatype + + + + + #/definitions/tiny-tiny:item + + + array + 1 + + #/definitions/tiny-tiny:item + + + + + + #/definitions/tiny-tiny:note + + + false + + + + + Line item + A value, potentially marked with @key or @class. + #/definitions/tiny-tiny:item + object + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + #/definitions/TokenDatatype + + + Class + Class or classes. + #/definitions/StringDatatype + + + N (position) + An indexed position (distinctive among values of parent::*/*/@n). + #/definitions/NonNegativeIntegerDatatype + + + #/definitions/MarkupLineDatatype + + + + RICHTEXT + + false + + + A whole number value. + integer + + + A single line of Markdown content conformant to the Commonmark specification. + string + ^[^ +]+$ + + + A multiple lines of Markdown content conformant to the Commonmark specification. + string + + + An integer value that is equal to or greater than 0. + + + #/definitions/IntegerDatatype + + + number + 0 + + + + + A non-empty string with leading and trailing whitespace disallowed. Whitespace is: U+9, U+10, U+32 or [ + ]+ + string + ^\S(.*\S)?$ + + + A non-colonized name as defined by XML Schema Part 2: Datatypes Second Edition. https://www.w3.org/TR/xmlschema11-2/#NCName. + string + ^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$ + + + A URI Reference, either a URI or a relative-reference, formatted according to section 4.1 of RFC3986. + string + uri-reference + + + + + #/definitions/json-schema-directive + + + #/definitions/tiny-tiny:TINY + + + + TINY + + false + diff --git a/src/testing/tinydata/tiny_metaschema.xml b/src/testing/tinydata/tiny_metaschema.xml new file mode 100644 index 00000000..359dfd58 --- /dev/null +++ b/src/testing/tinydata/tiny_metaschema.xml @@ -0,0 +1,161 @@ + + + Tiny Data Model + 0.0.2 + tiny + http://csrc.nist.gov/ns/metaschema-xslt/tinydata + http://csrc.nist.gov/ns/metaschema-xslt/tinydata + + + + +

    Tiny Metaschema

    +

    A metaschema can be small and yet deep.

    +
    + + + Tiny Data + A minimally described data set. + TINY + + Tiny ID + An identifier. + + + + + + + + Stuff + Some amount of tiny stuff. + + + + + + + + + + + + Title + markup-line example. + + + + Term + Simple string value example. + + Term identifier + A token identifying this term uniquely within the document. + + +

    For a more extensive model supporting definitions, acronyms etc. build this out into an assembly. + As a field, this supports some control over the vocabulary and formatting without heavier embedded metadata.

    +

    Of course you could always make a structured glossary out of regular and controlled parts for your terminology, and use this inside it, potentially with title/insert.

    +
    +
    + + + Note + Wrapped markup-multiline example. + + + + Tiny part + A bit of tiny data. + + + + + + + Stuff + Some amount of tiny stuff. + + + + + + + + + + + + + Tiny sheet + A list or grid of data points (items), or an entry (row or line item) in such a list or grid that contains such a list or grid. + + + + + + + + Stuff + Some amount of tiny stuff. + + + + entry + + + + + item + + + + + + + + + Line item + A value, potentially marked with @key or @class. + + + + N (position) + An indexed position (distinctive among values of parent::*/*/@n). + + + + Distinctive 'n' value + @n must be distinctive among sibling items. + +

    A whole number is expected here although '0' is permitted. Values among siblings are not constrained to be ordered, only different. Ordering is up to the receiving application.

    +
    +
    +
    +

    An application may constrain the value of the node to a datatype or other requirement, on the basis of @key, @class or other association(s).

    +
    + + + Field key + Distinguishing a sheet or item (field) among siblings or neighbors. + + + + Class + Class or classes. + + +
    diff --git a/src/testing/tinydata/tinydata_xml-converter.xsl b/src/testing/tinydata/tinydata_xml-converter.xsl new file mode 100644 index 00000000..8ae7ca90 --- /dev/null +++ b/src/testing/tinydata/tinydata_xml-converter.xsl @@ -0,0 +1,17 @@ + + + + + + + yes + + + + + + + diff --git a/src/testing/tinydata/validate-tiny-json.xp3 b/src/testing/tinydata/validate-tiny-json.xp3 new file mode 100644 index 00000000..ebc0c7e4 --- /dev/null +++ b/src/testing/tinydata/validate-tiny-json.xp3 @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/validate/METASCHEMA-SCHXSLT-VALIDATE.xpl b/src/validate/METASCHEMA-SCHXSLT-VALIDATE.xpl index 53ce2154..474d2ea8 100644 --- a/src/validate/METASCHEMA-SCHXSLT-VALIDATE.xpl +++ b/src/validate/METASCHEMA-SCHXSLT-VALIDATE.xpl @@ -3,9 +3,7 @@ xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0" xmlns:metaschema="http://csrc.nist.gov/ns/metaschema/1.0" xmlns:schxslt="https://doi.org/10.5281/zenodo.1495494" - type="metaschema:METASCHEMA-ALL-SCHEMAS" name="METASCHEMA-ALL-SCHEMAS"> - - + type="metaschema:METASCHEMA-SCHXSLT-VALIDATE" name="METASCHEMA-SCHXSLT-VALIDATE"> @@ -28,6 +26,8 @@ + + diff --git a/src/validate/METASCHEMA-VALIDATE.xpl b/src/validate/METASCHEMA-VALIDATE.xpl deleted file mode 100644 index c0668bb2..00000000 --- a/src/validate/METASCHEMA-VALIDATE.xpl +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/validate/METASCHEMA-XSD-VALIDATE.xpl b/src/validate/METASCHEMA-XSD-VALIDATE.xpl new file mode 100644 index 00000000..cb3f6a47 --- /dev/null +++ b/src/validate/METASCHEMA-XSD-VALIDATE.xpl @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SUCCESS - XSD Validation has apparently run without error on document { $base } + + + + + + + + + \ No newline at end of file diff --git a/src/validate/Makefile b/src/validate/Makefile index 665c7ee4..683f1d8f 100644 --- a/src/validate/Makefile +++ b/src/validate/Makefile @@ -1,11 +1,22 @@ include ../testing/make_common.mk +# Note that Makefile definitions in other subdirectories use scripts defined in this one + + # XML Calabash prefers absolute paths test_metaschema:=../testing/models_metaschema.xml .PHONY: test -test: smoke-test ## Run all tests +test: pre-checks smoke-test ## Run all tests + +# As a pre-check we validate the test metaschema first; +# if this succeeds we check its composition + +.PHONY: pre-checks ## Validate test inputs (model metaschema) + ./mvn-metaschema-xsd-validate-xpl.sh "$(test_metaschema)" + ./mvn-composition-validate-xpl.sh "$(test_metaschema)" + .PHONY: smoke-test smoke-test: ## Run all smoke-tests - ./mvn-composition-validate-xpl.sh "$(test_metaschema)" + diff --git a/src/validate/mvn-metaschema-xsd-validate-xpl.sh b/src/validate/mvn-metaschema-xsd-validate-xpl.sh new file mode 100644 index 00000000..cf163d52 --- /dev/null +++ b/src/validate/mvn-metaschema-xsd-validate-xpl.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=../common/subcommand_common.bash +source "$SCRIPT_DIR/../common/subcommand_common.bash" + +usage() { + cat < - You are good - well-formed, no reported errors + You are good - well-formed, with no reported Schematron messages (reports or failed assertions)
    diff --git a/support/download-jars.sh b/support/download-jars.sh new file mode 100644 index 00000000..1e072ad2 --- /dev/null +++ b/support/download-jars.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# This script attempts to download MorganaXProcIII + + +mkdir -p lib + +download() { + proj=$1 + lcproj=`echo $proj | tr '[:upper:'] '[:lower:]'` + uri="https://github.com/nineml/$lcproj/releases/latest" + ver=`curl -sI $uri | grep -i location: | sed "s#^.*/tag/##" | tr -d '\n\r'` + if [ ! -f "lib/$proj-$ver.jar" ]; then + echo "Downloading $proj ..." + rm -f lib/$proj-*.jar + uri="https://github.com/nineml/$lcproj/releases/download/$ver/$lcproj-$ver.zip" + curl -s -L -o lib/$lcproj-$ver.zip $uri + cd lib + unzip -q -j $lcproj-$ver.zip "*.jar" + rm $lcproj-$ver.zip + cd .. + fi +} + +download CoffeeGrinder +download CoffeeFilter +download CoffeeSacks + +if [ ! -d lib/xmlcalabash1-coffeepress.jar ]; then + echo "Downloading CoffeePress ..." + curl -s -L -o coffeepress.zip \ + https://github.com/ndw/xmlcalabash1-coffeepress/releases/download/1.0.0/xmlcalabash1-coffeepress-1.0.0.zip + unzip -q -j coffeepress.zip "*.jar" + mv *.jar lib/ + rm -f coffeepress.zip +fi + +if [ ! -d xmlcalabash-1.5.7-120 ]; then + echo "Downloading XML Calabash ..." + curl -s -L -o xmlcalabash.zip \ + https://github.com/ndw/xmlcalabash1/releases/download/1.5.7-120/xmlcalabash-1.5.7-120.zip + unzip -q xmlcalabash.zip + rm -f xmlcalabash.zip +fi + +if [ ! -f saxon-he-12.3.jar ]; then + echo "Downloading Saxon 12.3 ..." + curl -s -L -o SaxonHE12-3J.zip https://www.saxonica.com/download/SaxonHE12-3J.zip + unzip -q -o SaxonHE12-3J.zip "*.jar" + rm -f SaxonHE12-3J.zip saxon-he-test*.jar saxon-he-xqj*.jar +fi + +if [ ! -f saxon-he-12.3.jar ]; then + echo "Downloading Saxon 12.3 ..." + curl -s -L -o SaxonHE12-3J.zip https://www.saxonica.com/download/SaxonHE12-3J.zip + unzip -q -o SaxonHE12-3J.zip "*.jar" + rm -f SaxonHE12-3J.zip saxon-he-test*.jar saxon-he-xqj*.jar +fi + + + https://sourceforge.net/projects/morganaxproc-iiise/files/MorganaXProc-IIIse-1.3.6/MorganaXProc-IIIse-1.3.6.zip/download + + + + diff --git a/support/pattern-test.xsl b/support/pattern-test.xsl new file mode 100644 index 00000000..d79ff1cd --- /dev/null +++ b/support/pattern-test.xsl @@ -0,0 +1,23 @@ + + + + + + + + + + C + g + I + + + + + + + + + + \ No newline at end of file diff --git a/support/refresh-lib.sh b/support/refresh-lib.sh new file mode 100644 index 00000000..4dc2b488 --- /dev/null +++ b/support/refresh-lib.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# This script attempts to download MorganaXProcIII + + +mkdir -p lib + +pushd lib + +morgana=MorganaXProc-IIIse-1.3.6 + +morgana_download="https://sourceforge.net/projects/morganaxproc-iiise/files/${morgana}/${morgana}.zip/download" + +if [ ! -f "${morgana}.zip" ]; then + echo "Downloading Morgana XProc III SE ..." + curl -L -o "${morgana}.zip" "${morgana_download}" + unzip -qo "${morgana}.zip" -x __MACOSX/** +fi + + +if [ ! -f MorganaXProc-IIIse-1.3.6/MorganaXProc-IIIse_lib/saxon-he-12.3.jar ]; then + echo "Downloading Saxon 12.3 ..." + curl -s -L -o SaxonHE12-3J.zip https://www.saxonica.com/download/SaxonHE12-3J.zip + unzip -q -o SaxonHE12-3J.zip "*.jar" + rm -f SaxonHE12-3J.zip saxon-he-test*.jar saxon-he-xqj*.jar lib/* + rmdir lib + mv -f saxon-he-12.3.jar MorganaXProc-IIIse-1.3.6/MorganaXProc-IIIse_lib + +fi + +# C:\Users\wap1\Documents\usnistgov\metaschema-xslt\support\lib\MorganaXProc-IIIse-1.3.6\MorganaXProc-IIIse_lib + +popd + diff --git a/support/schxslt b/support/schxslt index 87cf981d..3f961be6 160000 --- a/support/schxslt +++ b/support/schxslt @@ -1 +1 @@ -Subproject commit 87cf981dcefd80247d2203fbdf63f5f15f212e1d +Subproject commit 3f961be6b1e7b1bd6522b39002d1c082bc841071 diff --git a/support/xslt3-functions b/support/xslt3-functions new file mode 160000 index 00000000..c528c506 --- /dev/null +++ b/support/xslt3-functions @@ -0,0 +1 @@ +Subproject commit c528c506a4ee3f87cd508795b3965def9bd49815 diff --git a/support/xspec b/support/xspec deleted file mode 160000 index 9cef3713..00000000 --- a/support/xspec +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9cef3713f5a7aaedf38a4ec2190ba3262d51cd72 diff --git a/support/xspec-dev/XSPEC-BATCH.xsl b/support/xspec-dev/XSPEC-BATCH.xsl deleted file mode 100644 index 98ed7016..00000000 --- a/support/xspec-dev/XSPEC-BATCH.xsl +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - - - - - - ../xspec/src/reporter/junit-report.xsl - - - - - - - - - - - src - - *.xspec - - no - - - - - - - - - - no - - - no - - - - - - select={$pattern} - recurse={ if ($recurse=('no','false')) then 'no' else 'yes' } - on-error={ if ($stopping-on-error) then 'fail' else 'warning' } - - - - - - - - - - ERROR: Unable to resolve collection at URI {$collection-uri} - getting {$err:code} '{$err:description}' - - - - - - Param $baseURI is: { $baseURI } - Static base URI is: { static-base-uri() } - Collection location is: { $collection-location } - - - - - - Acquiring collection from { $collection-uri } - - - - - - - - ERROR: Unable to compile XSpec at { $my?name } - getting {$err:code} '{$err:description}' - - - - - - - - - - ERROR: - Unable to execute compiled XSpec from { /*/xsl:variable[@name='Q{{http://www.jenitennison.com/xslt/xspec}}xspec-uri'] } - getting {$err:code} - '{$err:description}' - - - - - - - - - - - - - - - - - - - - - - - WARNING: of { count($collection-in) } { if (count($collection-in)=1) then 'file' else 'files' }, { count($dropped) } { if (count($dropped) = 1) then 'file selected was' else 'were' } dropped - either unavailable, would not compile (XSpec to XSLT), or would not execute (XSLT): - { $dropped?name => string-join(', ') } - - - - - - - Failures detected - process terminating - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WARNING: No JUnit report is written to '{ $junit-to }' - try a file name with suffix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {$report-to}/{$xspec-basename}.html - - - - - - - - - - - - - - Writing report {$filename} ... - - - - - - - - - Writing report {$filename} ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/XSPEC-SINGLE.xsl b/support/xspec-dev/XSPEC-SINGLE.xsl deleted file mode 100644 index 5599a8ee..00000000 --- a/support/xspec-dev/XSPEC-SINGLE.xsl +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - ../xspec/src/compiler/compile-xslt-tests.xsl - - - - - - - - - - - - - - - ... and formatted a report. - - - - - - - - - - - - - - - - - - - - - - - - - - ... compiled XSpec ... - - - - - - - - - - - - - - - - - - - - ... executed XSpec ... - - - \ No newline at end of file diff --git a/support/xspec-dev/mvn-saxon-xspec-batch-quiet.sh b/support/xspec-dev/mvn-saxon-xspec-batch-quiet.sh deleted file mode 100644 index 9c64eb4e..00000000 --- a/support/xspec-dev/mvn-saxon-xspec-batch-quiet.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=../common/subcommand_common.bash - -source "$SCRIPT_DIR/../../src/common/subcommand_common.bash" - -XSLT_FILE="${SCRIPT_DIR}/XSPEC-BATCH.xsl" -LOGFILE=${LOGFILE:-"xspec_$(date +"%Y%m%d%H%M").log.txt"} - -usage() { - cat </dev/null to drop all runtime messages / progress reports instead of logging -# the process should error out only if stop-on-error=yes, otherwise it will do its best to complete -# invoke_saxon "${SAXON_ARGS}" 2>${LOGFILE} | echo_on_error "Failure running XSpec: see ${LOGFILE}" | tee ${LOGFILE} -invoke_saxon "${SAXON_ARGS}" 2>${LOGFILE} | tee ${LOGFILE} diff --git a/support/xspec-dev/mvn-saxon-xspec-batch.sh b/support/xspec-dev/mvn-saxon-xspec-batch.sh deleted file mode 100755 index 16c34ae0..00000000 --- a/support/xspec-dev/mvn-saxon-xspec-batch.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=../common/subcommand_common.bash - -source "$SCRIPT_DIR/../../src/common/subcommand_common.bash" - -XSLT_FILE="${SCRIPT_DIR}/XSPEC-BATCH.xsl" -LOGFILE=${LOGFILE:-"xspec_$(date +"%Y%m%d%H%M").log.txt"} - -usage() { - cat </dev/null to drop all runtime messages / progress reports instead of logging -# the process should error out only if stop-on-error=yes, otherwise it will do its best to complete -invoke_saxon "${SAXON_ARGS}" 2>&1 | tee ${LOGFILE} diff --git a/support/xspec-dev/mvn-saxon-xspec-html.sh b/support/xspec-dev/mvn-saxon-xspec-html.sh deleted file mode 100755 index 8aae060a..00000000 --- a/support/xspec-dev/mvn-saxon-xspec-html.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=../common/subcommand_common.bash - -source "$SCRIPT_DIR/../../src/common/subcommand_common.bash" - -XSLT_FILE="${SCRIPT_DIR}/XSPEC-SINGLE.xsl" - -usage() { - cat </dev/null` in the command invoking the script. - -``` -./mvn-saxon-xspec-batch.sh folder=src/project recurse=yes 2>/dev/null -``` - -All XSpec files in the folder `src/project` and any subfolders, reporting results to the console (STDOUT) but not creating HTML reports and not echoing warning or error messages to the console. - -It is best to silence STDERR only after you are confident that all XSpecs in your file set can be run successfully, especially if the "break early on error" option is set (since you will neither see STDERR nor get any results). - -## Enhanced HTML Production - -In order to work around limitations in the current XSpec HTML production (details with respect to its deployment under XProc 1.0), a [new HTML production XSLT](xspec-mx-html-report.xsl) is provided here, for use either for standalone XSpec reporting, or for reporting results from several XSpecs in aggregate ("batch"). - -[This XSLT ](xspec-mx-html-report.xsl) produces standalone HTML including embedded CSS and some lightweight Javascript supporting navigation features. - -### Theming HTML from XProc - -The XProc files support a runtime option, `theme`, which also exposes control of the theme setting (in the HTML and CSS). This takes the form of an HTML `class` value on the `body` element, along with CSS to be applied to the page on the basis of that setting. - -- `theme=clean` (the default) produces a medium-contrast color-neutral format -- `theme=uswds` uses colors for emphasis from the USWDS color scheme -- `theme=classic` uses colors drawn from the good-old XSpec HTML -- `theme=toybox` provides a more extravagant scheme. - -New themes can be added in the XSLT or in a new "shell" XSLT importing it, by copying and modifying an appropriate template to match the new theme and give it style. Such an importing XSLT can also modify any other feature of the HTML page result. - diff --git a/support/xspec-dev/testing.md b/support/xspec-dev/testing.md deleted file mode 100644 index 6bec6661..00000000 --- a/support/xspec-dev/testing.md +++ /dev/null @@ -1,28 +0,0 @@ -# Testing - -This work in support of XSpec is in need of more rigorous testing. - -Interactive testing has been performed with all scripts. - -But requirements and specifications are loose, having been driven up to this point by functional requirements faced by the metaschema-xslt project - for a flexible, performant runtime that works independently of licensed software, with developer-friendly controls from the command line and inside CI/CD. Specifically, this means a number of issues, including testing, that bear on full integration back into XSpec have been set aside for the present. - -Some experience in application will also be helpful in prioritizing the testing work to be done. - -Meanwhile, some interesting questions, both practical and theoretical, are posed by the need to test these capabilities, especially outside particular deployments. - -For which capabilities can we write XSpec or meaningfully test and confirm (expose and document) in other ways, including - - - `xsl:message` behavior including terminate="yes" - - side effects such as `xsl:result-document`? - - Runtime parameter semantics - - Exception handling - -(XSpec especially with `@run-as='external'` is able to provide support for much of this, but specific means are tbd.) - -Contributor at-galtm also notes that message handling code in the [xslt3-functions project repository](https://github.com/usnistgov/xslt3-functions) is configurable to emit processing instructions (instead of or with `xsl:message`) as message proxies, making this functionality testable. - -Additionally, plenty of 'obvious' tasks remain to be done, including - - - Addressing functional gaps e.g. Schematron, `x:label`, `x:pending` - - Scope/coverage analysis - - XSpec for "easy" stuff, including HTML rendering diff --git a/support/xspec-dev/testing/copy_me.xsl b/support/xspec-dev/testing/copy_me.xsl deleted file mode 100644 index 6e34968e..00000000 --- a/support/xspec-dev/testing/copy_me.xsl +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/support/xspec-dev/testing/iso8601.ixml b/support/xspec-dev/testing/iso8601.ixml deleted file mode 100644 index 9a4b6933..00000000 --- a/support/xspec-dev/testing/iso8601.ixml +++ /dev/null @@ -1,171 +0,0 @@ -{ An Invisible XML grammar for ISO 8601(:2004?) dates and times. } -{ Originally constructed by Norm Tovey-Walsh, 17 April 2022 } -{ See https://en.wikipedia.org/wiki/ISO_8601 among others } - --iso8601-datetime = date - ; time - ; datetime - ; duration - ; interval - ; recurrence . - -date = calendar-date ; ordinal-date ; week-date . - --time = local-time ; utc-time . - --datetime = local-datetime ; utc-datetime . - -local-datetime = -date, -'T', -local-time-no-t . -utc-datetime = -date, -'T', -utc-time-no-t . - -duration = -standard-duration; -alternate-duration . - -interval = start-end-interval - ; start-plus-duration-interval - ; duration-plus-end-interval . - -recurrence = repeat-count, -'/', interval . - -{ -- Calendar dates -- } - --calendar-date = complete-calendar-date - ; reduced-accuracy-calendar-date - ; expanded-calendar-date . - --complete-calendar-date = year, month, day; year, -'-', month, -'-', day . - --reduced-accuracy-calendar-date = year, -'-', month; year; century . - --expanded-calendar-date = expanded-year, month, day - ; expanded-year, -'-', month, -'-', day - ; expanded-year, -'-', month - ; expanded-year - ; expanded-century . - -{ -- Ordinal dates -- } - --ordinal-date = complete-ordinal-date ; expanded-ordinal-date . - --complete-ordinal-date = year, day-of-year - ; year, -'-', day-of-year . - --expanded-ordinal-date = expanded-year, day-of-year - ; expanded-year, -'-', day-of-year . - -{ -- Week dates -- } - --week-date = complete-week-date - ; reduced-accuracy-week-date - ; expanded-week-date . - --complete-week-date = year, -'W', week, day-of-week - ; year, -'-W', week, -'-', day-of-week . - --reduced-accuracy-week-date = year, -'W', week - ; year, -'-W', week . - --expanded-week-date = expanded-year, -'W', week, day-of-week - ; expanded-year, -'-W', week, '-', day-of-week - ; expanded-year, -'W', week - ; expanded-year, -'-W', week . - -{ -- Local time -- } - -local-time = local-time-t ; local-time-no-t . - --local-time-t = local-time-without-utc-t; local-time-with-utc-t . --local-time-no-t = local-time-without-utc; local-time-with-utc . - --local-time-without-utc-t = -'T', local-time-without-utc . - --local-time-without-utc = hour, minute, second - ; hour, -':', minute, -':', second - ; hour, minute - ; hour, -':', minute - ; hour - ; fractional-second-local-time - ; fractional-minute-local-time - ; fractional-hour-local-time . - --local-time-with-utc-t = -local-time-without-utc-t, utc-offset . --local-time-with-utc = -local-time-without-utc, utc-offset . - --fractional-second-local-time = (hour, minute, second; hour, -':', minute, -':', second), - fraction-sep, - fractional-second . - --fractional-minute-local-time = (hour, minute; hour, -':', minute), - fraction-sep, - fractional-minute . - --fractional-hour-local-time = hour, fraction-sep, fractional-hour . - -utc-offset = offset-hour, (-':'?, offset-minute)? . - -{ -- UTC time -- } - -utc-time = utc-time-t ; utc-time-no-t . --utc-time-t = -local-time-without-utc-t, -'Z' . --utc-time-no-t = -local-time-without-utc, -'Z' . - -{ -- Durations -- } - --standard-duration = -'P', (standard-ymdhs-duration ; standard-week-duration) . - -{ N.B. This tecnically allows a standard-ymdhs-duration with no fields. } --standard-ymdhs-duration = duration-years?, duration-months?, duration-days?, - (-'T', duration-hours?, duration-minutes?, duration-seconds?)? . --standard-week-duration = duration-weeks . - --alternate-duration = -'P', (alternate-ymd-duration ; alternate-yd-duration) . - --alternate-ymd-duration = year, month, day, -'T', hour, minute, second - ; year, -'-', month, -'-', day, -'T', hour, -':', minute, -':', second . --alternate-yd-duration = year, number-of-days, -'T', hour, minute, second - ; year, -'-', number-of-days, -'T', hour, -':', minute, -':', second . - --start-end-interval = (date; datetime), -'/', (date; datetime) . --start-plus-duration-interval = (date; datetime), -'/', duration . --duration-plus-end-interval = duration, -'/', (date; datetime) . - -duration-years = digit+, -'Y' . -duration-months = digit+, -'M' . -duration-days = digit+, -'D' . -duration-hours = digit+, -'H' . -duration-minutes = digit+, -'M' . -duration-seconds = digit+, -'S' . -duration-weeks = digit+, -'W' . - -{ -- Recurrence -- } - --repeat-count = -'R-1' ; -'R' ; -'R', repetitions . -repetitions = digit+ . - -{ -- Utility rules -- } - -expanded-year = sign, digit+, digit, digit, digit . -expanded-century = sign, digit+, digit, digit . --sign = -'+' ; '-' . - -offset-hour = @direction, digit, digit . -offset-minute = digit, digit . -direction = '+'; '-' . - -year = digit, digit, digit, digit . -century = digit, digit . -month = digit, digit . -week = digit, digit . -day = digit, digit . -hour = digit, digit . -minute = digit, digit . -second = digit, digit . -fractional-second = digit+ . -fractional-minute = digit+ . -fractional-hour = digit+ . - -day-of-year = digit, digit, digit . -number-of-days = -day-of-year . -day-of-week = digit . - --digit = ["0"-"9"] . --fraction-sep = -[','; '.'] . diff --git a/support/xspec-dev/testing/ixml-demo.xsl b/support/xspec-dev/testing/ixml-demo.xsl deleted file mode 100644 index da0232d5..00000000 --- a/support/xspec-dev/testing/ixml-demo.xsl +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - iso8601.ixml - - - - - 1962-06-28 - 1963-11-04 - 2024-02-30 - 2024-02-99 - 2024-01-17T17:26:38.416457100-05:00 - 2024-02-300 - 2025-12-25 - 2025-12-31T - - - - - - - - - - - - - - - - - - - - BUST on '{ $maybeDateTime }' - - - - - - diff --git a/support/xspec-dev/testing/ixml-parsing.xspec b/support/xspec-dev/testing/ixml-parsing.xspec deleted file mode 100644 index 6fdc1345..00000000 --- a/support/xspec-dev/testing/ixml-parsing.xspec +++ /dev/null @@ -1,92 +0,0 @@ - - - - - Parsing some dates - - - - 2024-01-20 - - - - - 2024 - 01 - 20 - - - - - - - 2024-01-0 - - - - BUST on '2024-01-0' - - - - - - 2024-01-18T14:44 - - - - - 2024 - 01 - 18 - 14 - 44 - - - - - - - 2024-01-18T14:44:10 - - - - - 2024 - 01 - 18 - 14 - 44 - 10 - - - - - - - 2024-01-18T14:44:10.777578600-05:00 - - - - - 2024 - 01 - 18 - 14 - 44 - 10 - 777578600 - - 05 - 00 - - - - - - - diff --git a/support/xspec-dev/testing/mvn-xproc-xspec-test-batch.sh b/support/xspec-dev/testing/mvn-xproc-xspec-test-batch.sh deleted file mode 100644 index 2fceeba5..00000000 --- a/support/xspec-dev/testing/mvn-xproc-xspec-test-batch.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=../common/subcommand_common.bash - -source "$SCRIPT_DIR/../../../src/common/subcommand_common.bash" - -XPROC_FILE="${SCRIPT_DIR}/xspec-test-batch.xpl" -REPORT_HTML="xspec-test-report.html" - -usage() { - cat < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/testing/xspec-basic.xspec b/support/xspec-dev/testing/xspec-basic.xspec deleted file mode 100644 index bdccf48c..00000000 --- a/support/xspec-dev/testing/xspec-basic.xspec +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/testing/xspec-shell.xspec b/support/xspec-dev/testing/xspec-shell.xspec deleted file mode 100644 index ba66430f..00000000 --- a/support/xspec-dev/testing/xspec-shell.xspec +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/testing/xspec-test-batch.xpl b/support/xspec-dev/testing/xspec-test-batch.xpl deleted file mode 100644 index 2b25a22f..00000000 --- a/support/xspec-dev/testing/xspec-test-batch.xpl +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/xspec-assurance.sch b/support/xspec-dev/xspec-assurance.sch deleted file mode 100644 index 42c624c2..00000000 --- a/support/xspec-dev/xspec-assurance.sch +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - No document found at - - - - \ No newline at end of file diff --git a/support/xspec-dev/xspec-batch-report.xpl b/support/xspec-dev/xspec-batch-report.xpl deleted file mode 100644 index abd9ea5d..00000000 --- a/support/xspec-dev/xspec-batch-report.xpl +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/xspec-mx-html-report.xsl b/support/xspec-dev/xspec-mx-html-report.xsl deleted file mode 100644 index a817368b..00000000 --- a/support/xspec-dev/xspec-mx-html-report.xsl +++ /dev/null @@ -1,538 +0,0 @@ - - - - - - - - - clean - - - - - - - - - - - - - - XSpec - { $result-count } { if ($result-count eq 1) then 'test' else 'tests'} in { $report-count } { if ($report-count eq 1) then 'report' else 'reports'} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • FAILING - - { ancestor-or-self::*/x:label => string-join(' - ') } -
  • -
    - - -
    -
    - -
    -

    XSpec Report - { @xspec/replace(.,'.*/','') }

    - -
    -
    - - - -
    - - XSpec Report - { @xspec/replace(.,'.*/','') } - -
    - -
    - -
    -
    - - - - - -
    - -
    -
    - -
    - - - - - - -
    - -
    -
    - - - - - - - - - - 🤞 - - - 👍 - - - 👎 - - - - -

    { local-name(..) }/{ local-name(.) }: { . }

    -
    - - - - -

    { local-name(..) }/{ local-name(.) }: { . }

    -
    - - -

    { local-name(..) }/{ local-name(.) }: { format-dateTime(xs:dateTime(.),'[MNn] [D1], [Y0001] [H01]:[m01]:[s01]') } ({.})

    -
    - - - - - -
    - - - open - - - - -
    - -
    -
    -
    - - - - - { $whose/ancestor::x:report ! ('report' || count(.|preceding-sibling::x:report || '-' )) }{ $whose/@id } - - - - - - - - - - { self::x:report/'Total tests '}{ child::x:label } -   - - - - - - - - - - - - { . } - : - - - - - - - - - { child::x:label } -   - - - { (child::x:test/@pending/('Pending ' || .),child::x:test[@successful='true']/'Passes','Fails')[1] } - - - - - Expecting { child::x:label } - - - -
    - - - -
    -
    - - -
    - - - - - -
    -
    - - -

    Expecting (testing against)

    -
    - - -

    Producing (actual result)

    -
    - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - - - - -

    From input

    -
    - - - -

    Expecting

    -
    - - - - - - -
    - - - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - -.uswds { - background-color: #f0f0f0; - - .label { background-color: #1a4480; color: white} - .pending .label { background-color: inherit; color: black } - .passing { background-color: #d9e8f6 } - .pending { background-color: white } - .failing { background-color: #f8dfe2 } - .failing .passing { background-color: #d9e8f6 } - .pending.zero, .failing.zero { background-color: inherit } -} - - - - - - - -.classic { - h1, .h1, .label { background-color: #606; color: #6f6 } - h1 { padding: 0.2em } - .pending .label { background-color: inherit; color: black } - .passing { background-color: #cfc } - .pending { background-color: #eee } - .failing { background-color: #fcc } - .failing .passing { background-color: #cfc } - .pending.zero, .failing.zero { background-color: inherit } -} - - - - - -.toybox { - .label { background-color: black; color: white } - .failing .label { background-color: darkred } - .passing .label { background-color: darkgreen } - .pending .label { background-color: inherit; color: black } - .passing { background-color: honeydew } - .pending { background-color: cornsilk } - .failing { background-color: mistyrose } - .failing .passing { background-color: honeydew } - .pending.zero, .failing.zero { background-color: inherit } -} - - - - - No template for theme '{ $theme }' - using 'simple' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/support/xspec-dev/xspec-single-report.xpl b/support/xspec-dev/xspec-single-report.xpl deleted file mode 100644 index a847de3b..00000000 --- a/support/xspec-dev/xspec-single-report.xpl +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/xspec-single-xspec-repo-report.xpl b/support/xspec-dev/xspec-single-xspec-repo-report.xpl deleted file mode 100644 index 402b1557..00000000 --- a/support/xspec-dev/xspec-single-xspec-repo-report.xpl +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/xspec-dev/xspec-summarize.xsl b/support/xspec-dev/xspec-summarize.xsl deleted file mode 100644 index 451f8d5e..00000000 --- a/support/xspec-dev/xspec-summarize.xsl +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - { @xspec } - { @stylesheet } - - - - - - { ancestor-or-self::*/child::label => string-join(' : ') } - - - - - \ No newline at end of file diff --git a/support/xspec-dev/xspec-summary-reduce.xsl b/support/xspec-dev/xspec-summary-reduce.xsl deleted file mode 100644 index fad32c0f..00000000 --- a/support/xspec-dev/xspec-summary-reduce.xsl +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - { (1 to 14) ! ' ...' } - XSpec summary report: { mx:enumerate('XSpec',count(report)) } - - { (1 to 14) ! ' ...' } - - - - - - - SUCCESS - { mx:give-report-counts(.) } - NO FAILURES REPORTED - - - - - - FAILURE - { mx:give-report-counts(.) } - { count(descendant::fail) } { mx:pluralize('failure',count(descendant::fail)) => upper-case() } REPORTED - - - - - { xspec-file ! tokenize(.,'/')[last()] } testing { xslt-file ! tokenize(.,'/')[last()] }: { mx:enumerate('test',@test-count) }, { @pending-count} pending, { mx:enumerate('failure',count(fail)) } - - - - - { mx:enumerate('report',count($r/report)) } with { mx:enumerate('test', sum($r/report/@test-count)) } ({ sum($r/report/@pending-count) } pending) - - - - - - - { $c } { mx:pluralize($nom,$c) } - - - - - - - - - - - - - { . }{ 's'[$plural] } - - - \ No newline at end of file

    { $checked } Validating { $validating-filename } - { mx:metaschema } - found { + 'IN'[not($reported-valid)] }VALID