Skip to content

Commit 24e5007

Browse files
authored
JSON Schema generation improvements (#108)
Refactoring submodules; XProc-based testing; XSpec testing of JSON Schema generation; improvements to JSON Schema generation - addressing #105 also #2007.
1 parent a0816ac commit 24e5007

File tree

88 files changed

+6673
-2718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+6673
-2718
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v3
2020
with:
21-
submodules: true
21+
submodules: "recursive"
2222
fetch-depth: 0
2323
- uses: actions/setup-java@v3
2424
with:

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88

99
# test outputs
1010
src/**/test_output/
11+
12+
# downloaded miscellaneous
13+
14+
support/lib/*

.gitmodules

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
[submodule "support/xspec"]
2-
path = support/xspec
3-
url = https://github.com/xspec/xspec.git
41
[submodule "support/metaschema"]
52
path = support/metaschema
63
url = https://github.com/usnistgov/metaschema.git
74
branch = develop
85
fetchRecurseSubmodules = false
6+
[submodule "support/xslt3-functions"]
7+
path = support/xslt3-functions
8+
url = https://github.com/usnistgov/xslt3-functions.git
99
[submodule "support/schxslt"]
1010
path = support/schxslt
1111
url = https://github.com/schxslt/schxslt.git
12-
[submodule "metaschema"]
13-
url = https://github.com/usnistgov/metaschema.git

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ Additionally, we care about, but do not prioritize:
4242

4343
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.
4444

45-
### Project sunset
45+
### Maturity and project sunset
46+
47+
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.
4648

4749
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.
4850

TESTING.md

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Currently we are emulating and re-engineering some specific XSpec capabilities i
4040

4141
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).
4242

43-
4443
## Test-driven development
4544

4645
Almost all testing in this repository falls into the category of either XSLT transformations, or runtimes that embed transformations.

src/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ dirs:=$(shell find '.' ! -wholename ./Makefile -name 'Makefile' -printf "%h\n")
1010
test: ## Run all tests
1111
$(call FOREACH_MAKE,$@,$(dirs))
1212

13+
.PHONY: pre-checks
14+
pre-checks: ## Run all "pre checks", enforcing validation contracts across input artifacts
15+
$(call FOREACH_MAKE_OPTIONAL,$@,$(dirs))
16+
1317
.PHONY: smoke-test
1418
smoke-test: ## Run all "smoke tests", establishing a baseline of sanity across the project
1519
$(call FOREACH_MAKE_OPTIONAL,$@,$(dirs))

src/common/metaschema-ws-strip.xsl

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
4+
xmlns:mx="http://csrc.nist.gov/ns/csd/metaschema-xslt"
5+
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
6+
xmlns:fn="http://www.w3.org/2005/xpath-functions"
7+
exclude-result-prefixes="xs math mx"
8+
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
9+
xpath-default-namespace="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
10+
version="3.0">
11+
12+
13+
<!-- This XSLT relies on a global strip-space to strip whitespace-only nodes from
14+
everything except the Markdown elements -->
15+
<xsl:strip-space elements="*"/>
16+
17+
<xsl:preserve-space elements="p h1 h2 h3 h4 h5 h6 pre li td
18+
a insert code em i b strong sub sup fn:string"/>
19+
20+
<xsl:mode name="mx:stripping" on-no-match="shallow-copy"/>
21+
22+
<xsl:function name="mx:scrub-up" as="element()">
23+
<xsl:param name="in" as="node()"/>
24+
<xsl:apply-templates mode="mx:stripping" select="$in"/>
25+
</xsl:function>
26+
27+
</xsl:stylesheet>

src/testing/issue_235_regression.xspec src/converter-gen/issue_235_regression.xspec

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<x:description
33
xmlns:x="http://www.jenitennison.com/xslt/xspec"
44
xmlns:mv="http://g"
5-
stylesheet="../converter-gen/xml-to-json/supermodel-to-json.xsl">
5+
stylesheet="xml-to-json/supermodel-to-json.xsl">
6+
7+
<!-- Tests serialization into JSON format of 'supermodel' XML sources -->
68
<x:scenario label="Regression Test for usnistgov/metaschema#235">
79
<x:scenario label="If a document instance has a field with no value or flag defined">
810
<x:context mode="write-json">

src/schema-gen/InspectorXSLT/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ include ../../testing/make_common.mk
1010

1111
module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
1212
output_folder:=$(module_path)/test_output
13-
xspec_script=$(realpath $(module_path)/../../../support/xspec-dev/mvn-saxon-xspec-batch-quiet.sh)
14-
xspec_ci_script=$(realpath $(module_path)/../../../support/xspec-dev/mvn-saxon-xspec-batch.sh)
13+
xspec_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch-quiet.sh)
14+
xspec_ci_script=$(realpath $(module_path)/../../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch.sh)
1515
smoketest_script=$(realpath $(module_path)/testing/smoketest-computer-inspector.sh)
1616
testing-refresh_script=$(realpath $(module_path)/testing/refresh-test-inspectors.sh)
1717
folder=.

src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-inspector.xsl

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<?xml version="1.0" encoding="us-ascii"?>
21
<xsl:transform xmlns="http://www.w3.org/1999/xhtml"
32
xmlns:mx="http://csrc.nist.gov/ns/csd/metaschema-xslt"
43
xmlns:xs="http://www.w3.org/2001/XMLSchema"
54
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
65
version="3.0"
76
xpath-default-namespace="http://example.com/ns/computer"
8-
exclude-result-prefixes="#all"><!-- Generated 2024-02-12T18:06:18.57633-05:00 -->
7+
exclude-result-prefixes="#all"><!-- Generated 2024-03-11T14:53:43.203885-04:00 -->
98
<xsl:mode on-no-match="fail"/>
109
<xsl:mode name="test" on-no-match="shallow-skip"/>
1110
<!-- . . . . . . . . . . . . . . . . . -->

0 commit comments

Comments
 (0)