forked from usnistgov/metaschema-xslt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provisional implementation of ANY for XSD and JSON Schema usnistgov#117
- Loading branch information
1 parent
ff2385a
commit befc674
Showing
42 changed files
with
19,824 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Copy this file to config.sh in the same directory, and uncomment and customize the variables below to override default configuration options for all scripts. | ||
|
||
# The PROVIDER_DIR variable identifies the metaschema framework implementation to use. | ||
# A valid provider will have an "init.sh" file in the specified directory which implements the following set of bash functions: | ||
# | ||
# generate_xml_schema <metaschema_file> <generated_schema_file> | ||
# generate_json_schema <metaschema_file> <generated_schema_file> | ||
|
||
PROVIDER_DIR="${METASCHEMA_SCRIPT_DIR}/../toolchains/xslt-M4" | ||
|
||
# The location to write generated files to | ||
|
||
#WORKING_DIR="${PWD}" | ||
|
||
# The location to cache long-lived files used by scripts | ||
|
||
#CACHE_DIR="${WORKING_DIR}/.metaschema-cache" | ||
|
||
# Controls if scripts should produce verbose output | ||
|
||
#VERBOSE=false | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Preview files | ||
/preview |
55 changes: 55 additions & 0 deletions
55
test-suite/schema-generation/scratchdir/local-declarations/global-and-local.svrl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<svrl:schematron-output xmlns:svrl="http://purl.oclc.org/dsdl/svrl" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | ||
xmlns:saxon="http://saxon.sf.net/" | ||
xmlns:schold="http://www.ascc.net/xml/schematron" | ||
xmlns:iso="http://purl.oclc.org/dsdl/schematron" | ||
xmlns:xhtml="http://www.w3.org/1999/xhtml" | ||
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0" | ||
xmlns:nm="http://csrc.nist.gov/ns/metaschema" | ||
title="" | ||
schemaVersion=""><!-- | ||
--> | ||
<svrl:ns-prefix-in-attribute-values uri="http://csrc.nist.gov/ns/oscal/metaschema/1.0" prefix="m"/> | ||
<svrl:ns-prefix-in-attribute-values uri="http://csrc.nist.gov/ns/metaschema" prefix="nm"/> | ||
<svrl:active-pattern document="file:/C:/Users/wap1/Documents/usnistgov/metaschema/test-suite/schema-generation/local-declarations/global-and-local_metaschema.xml" | ||
id="top-level-and-schema-docs" | ||
name="top-level-and-schema-docs"/> | ||
<svrl:fired-rule context="/m:METASCHEMA"/> | ||
<svrl:fired-rule context="/m:METASCHEMA/m:define-assembly/m:root-name"/> | ||
<svrl:active-pattern document="file:/C:/Users/wap1/Documents/usnistgov/metaschema/test-suite/schema-generation/local-declarations/global-and-local_metaschema.xml" | ||
id="definitions-and-name-clashes" | ||
name="definitions-and-name-clashes"/> | ||
<svrl:fired-rule context="m:METASCHEMA/m:define-assembly | m:METASCHEMA/m:define-field | m:METASCHEMA/m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field"/> | ||
<svrl:fired-rule context="m:METASCHEMA/m:define-assembly | m:METASCHEMA/m:define-field | m:METASCHEMA/m:define-flag"/> | ||
<svrl:fired-rule context="m:METASCHEMA/m:define-assembly | m:METASCHEMA/m:define-field | m:METASCHEMA/m:define-flag"/> | ||
<svrl:fired-rule context="m:METASCHEMA/m:define-assembly | m:METASCHEMA/m:define-field | m:METASCHEMA/m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field"/> | ||
<svrl:active-pattern document="file:/C:/Users/wap1/Documents/usnistgov/metaschema/test-suite/schema-generation/local-declarations/global-and-local_metaschema.xml" | ||
id="flags_and_keys_and_datatypes" | ||
name="flags_and_keys_and_datatypes"/> | ||
<svrl:fired-rule context="m:flag | m:define-field/m:define-flag | m:define-assembly/m:define-flag"/> | ||
<svrl:fired-rule context="m:flag | m:define-field/m:define-flag | m:define-assembly/m:define-flag"/> | ||
<svrl:fired-rule context="m:field | m:assembly"/> | ||
<svrl:fired-rule context="m:field | m:assembly"/> | ||
<svrl:fired-rule context="m:field | m:assembly"/> | ||
<svrl:fired-rule context="m:field | m:assembly"/> | ||
<svrl:active-pattern document="file:/C:/Users/wap1/Documents/usnistgov/metaschema/test-suite/schema-generation/local-declarations/global-and-local_metaschema.xml" | ||
id="schema-docs" | ||
name="schema-docs"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
<svrl:fired-rule context="m:define-assembly | m:define-field | m:define-flag"/> | ||
</svrl:schematron-output> |
70 changes: 70 additions & 0 deletions
70
...hema-generation/scratchdir/local-declarations/global-and-local_generated-json-schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
{ "$schema" : "http://json-schema.org/draft-07/schema#", | ||
"$id" : "http://csrc.nist.gov/ns/metaschema/unit-test/group-as-singleton-or-array-optional-schema.json", | ||
"$comment" : "Metaschema Unit Test: group-as: JSON Schema", | ||
"type" : "object", | ||
"definitions" : | ||
{ "parent" : | ||
{ "title" : "parent", | ||
"description" : "parent assembly", | ||
"$id" : "#/definitions/parent", | ||
"type" : "object", | ||
"properties" : | ||
{ "local-flag" : | ||
{ "title" : "Flag defined locally", | ||
"description" : "Has a local definition", | ||
"type" : "string" }, | ||
"global-flag" : | ||
{ "title" : "Flag defined globally", | ||
"description" : "Has a global definition", | ||
"type" : "string" }, | ||
"local-field" : | ||
{ "title" : "Field defined locally", | ||
"description" : "Has a local definition", | ||
"$id" : "#/definitions/local-field", | ||
"type" : "string" }, | ||
"global-field" : | ||
{ "$ref" : "#/definitions/global-field" }, | ||
"local-assembly" : | ||
{ "title" : "Assembly defined locally", | ||
"description" : "Has a local definition", | ||
"$id" : "#/definitions/local-assembly", | ||
"type" : "object", | ||
"properties" : | ||
{ "local-field2" : | ||
{ "title" : "Field defined locally", | ||
"description" : "Has a local definition", | ||
"$id" : "#/definitions/local-field2", | ||
"type" : "string" }, | ||
"global-field" : | ||
{ "$ref" : "#/definitions/global-field" } }, | ||
"additionalProperties" : false }, | ||
"global-assembly" : | ||
{ "$ref" : "#/definitions/global-assembly" } }, | ||
"additionalProperties" : false }, | ||
"global-field" : | ||
{ "title" : "Field defined globally", | ||
"description" : "Has a global definition", | ||
"$id" : "#/definitions/global-field", | ||
"type" : "string" }, | ||
"global-assembly" : | ||
{ "title" : "Assembly defined globally", | ||
"description" : "Has a global definition", | ||
"$id" : "#/definitions/global-assembly", | ||
"type" : "object", | ||
"properties" : | ||
{ "local-field2" : | ||
{ "title" : "Field defined locally", | ||
"description" : "Has a local definition", | ||
"$id" : "#/definitions/local-field2", | ||
"type" : "string" }, | ||
"global-field" : | ||
{ "$ref" : "#/definitions/global-field" } }, | ||
"additionalProperties" : false } }, | ||
"properties" : | ||
{ "parent" : | ||
{ "$ref" : "#/definitions/parent" } }, | ||
"required" : | ||
[ "parent" ], | ||
"additionalProperties" : false, | ||
"maxProperties" : 1 } |
150 changes: 150 additions & 0 deletions
150
...schema-generation/scratchdir/local-declarations/global-and-local_generated-xml-schema.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0" | ||
xmlns:metaschema-group-as="http://csrc.nist.gov/ns/metaschema/unit-test/group-as-singleton-or-array-optional" | ||
xmlns:oscal-prose="http://csrc.nist.gov/ns/metaschema/unit-test/group-as-singleton-or-array-optional" | ||
elementFormDefault="qualified" | ||
targetNamespace="http://csrc.nist.gov/ns/metaschema/unit-test/group-as-singleton-or-array-optional" | ||
version="1.0-milestone1"> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:schema-name>Metaschema Unit Test: group-as</m:schema-name> | ||
<m:schema-version>1.0-milestone1</m:schema-version> | ||
<m:short-name>metaschema-group-as</m:short-name> | ||
<m:root>parent</m:root> | ||
</xs:appinfo> | ||
</xs:annotation> | ||
<xs:element name="parent" type="metaschema-group-as:parent-ASSEMBLY"/> | ||
<xs:complexType name="parent-ASSEMBLY"> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>parent</m:formal-name> | ||
<m:description>parent assembly</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>parent</b>: parent assembly</xs:documentation> | ||
</xs:annotation> | ||
<xs:sequence> | ||
<xs:element name="local-field" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Field defined locally</m:formal-name> | ||
<m:description>Has a local definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Field defined locally</b>: Has a local definition</xs:documentation> | ||
</xs:annotation> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"/> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:element name="global-field" | ||
type="metaschema-group-as:global-field-FIELD" | ||
minOccurs="0" | ||
maxOccurs="1"/> | ||
<xs:element name="local-assembly" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Assembly defined locally</m:formal-name> | ||
<m:description>Has a local definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Assembly defined locally</b>: Has a local definition</xs:documentation> | ||
</xs:annotation> | ||
<xs:sequence> | ||
<xs:element name="local-field2" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Field defined locally</m:formal-name> | ||
<m:description>Has a local definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Field defined locally</b>: Has a local definition</xs:documentation> | ||
</xs:annotation> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"/> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:element name="global-field" | ||
type="metaschema-group-as:global-field-FIELD" | ||
minOccurs="0" | ||
maxOccurs="1"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:element name="global-assembly" | ||
type="metaschema-group-as:global-assembly-ASSEMBLY" | ||
minOccurs="0" | ||
maxOccurs="1"/> | ||
</xs:sequence> | ||
<xs:attribute name="local-flag" type="xs:string"> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Flag defined locally</m:formal-name> | ||
<m:description>Has a local definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Flag defined locally</b>: Has a local definition</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="global-flag" type="xs:string"> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Flag defined globally</m:formal-name> | ||
<m:description>Has a global definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Flag defined globally</b>: Has a global definition</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
<xs:complexType name="global-field-FIELD"> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Field defined globally</m:formal-name> | ||
<m:description>Has a global definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Field defined globally</b>: Has a global definition</xs:documentation> | ||
</xs:annotation> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"/> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
<xs:complexType name="global-assembly-ASSEMBLY"> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Assembly defined globally</m:formal-name> | ||
<m:description>Has a global definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Assembly defined globally</b>: Has a global definition</xs:documentation> | ||
</xs:annotation> | ||
<xs:sequence> | ||
<xs:element name="local-field2" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<m:formal-name>Field defined locally</m:formal-name> | ||
<m:description>Has a local definition</m:description> | ||
</xs:appinfo> | ||
<xs:documentation> | ||
<b>Field defined locally</b>: Has a local definition</xs:documentation> | ||
</xs:annotation> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"/> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:element name="global-field" | ||
type="metaschema-group-as:global-field-FIELD" | ||
minOccurs="0" | ||
maxOccurs="1"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:schema> |
58 changes: 58 additions & 0 deletions
58
test-suite/schema-generation/scratchdir/metaschema-collect.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:math="http://www.w3.org/2005/xpath-functions/math" | ||
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xpath-default-namespace="http://csrc.nist.gov/ns/oscal/metaschema/1.0" | ||
exclude-result-prefixes="xs math m xsi" | ||
version="3.0"> | ||
|
||
<xsl:output indent="yes"/> | ||
|
||
<xsl:strip-space elements="METASCHEMA define-flag define-field define-assembly remarks model choice"/> | ||
|
||
<xsl:template match="/"> | ||
<xsl:apply-templates mode="acquire" select="/"> | ||
<xsl:with-param name="so-far" tunnel="true" select="document-uri(/)"/> | ||
</xsl:apply-templates> | ||
</xsl:template> | ||
|
||
|
||
<!-- ====== ====== ====== ====== ====== ====== ====== ====== ====== ====== ====== ====== --> | ||
<!-- Aggregate metaschema imports without further processing anything. | ||
Trace nominal sources. | ||
Defend against endless loops. --> | ||
|
||
<xsl:mode name="acquire" on-no-match="shallow-copy"/> | ||
|
||
<xsl:template match="comment() | processing-instruction()" mode="#all"/> | ||
|
||
<xsl:template match="METASCHEMA" mode="acquire"> | ||
<xsl:copy> | ||
<xsl:copy-of select="@* except @xsi:*"/> | ||
<xsl:attribute name="module" select="document-uri(/)"/> | ||
<xsl:apply-templates mode="#current"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="import" mode="acquire"> | ||
<xsl:param name="so-far" tunnel="yes" required="yes"/> | ||
<xsl:variable name="uri" select="resolve-uri(@href,document-uri(/))"/> | ||
<xsl:choose> | ||
<xsl:when test="$uri = $so-far"> | ||
<xsl:comment expand-text="true">Warning: circular import of { $uri } skipped</xsl:comment> | ||
</xsl:when> | ||
<xsl:when test="not(doc-available($uri))"> | ||
<xsl:message terminate="yes" expand-text="true">Error: No metaschema module is found at { $uri }</xsl:message> | ||
<xsl:comment expand-text="true">Warning: circular import of { $uri } skipped</xsl:comment> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:apply-templates select="document($uri)/METASCHEMA" mode="acquire"> | ||
<xsl:with-param name="so-far" select="$so-far,$uri"/> | ||
</xsl:apply-templates> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
Oops, something went wrong.