-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
605d505
commit 04bc6e5
Showing
2 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
toolchains/xslt-M4/testing/issue_235_regression-metaschema.xml
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"> | ||
<schema-name>issue-235-test-schema</schema-name> | ||
<schema-version>0.1</schema-version> | ||
<short-name>oscal-value-testing-mini</short-name> | ||
<namespace>http://csrc.nist.gov/ns/metaschema/unit-tests</namespace> | ||
<json-base-uri>http://csrc.nist.gov/ns/oscal</json-base-uri> | ||
<define-assembly name="root-assembly"> | ||
<formal-name>Issue 235 Regression Test</formal-name> | ||
<description>A sample Metaschema definition for <a href="https://github.com/usnistgov/metaschema/issues/235">regression testing</a>.</description> | ||
<root-name>root</root-name> | ||
<model> | ||
<define-field name="field1" as-type="uri"> | ||
<formal-name>Field 1</formal-name> | ||
<description>An example field with a flag constrained with optional values.</description> | ||
<!--<json-value-key>id</json-value-key>--> | ||
<define-flag name="optional-flag" as-type="string"> | ||
<constraint> | ||
<allowed-values allow-other="yes"> | ||
<enum value="value1"/> | ||
<enum value="value2"/> | ||
</allowed-values> | ||
</constraint> | ||
</define-flag> | ||
</define-field> | ||
</model> | ||
</define-assembly> | ||
</METASCHEMA> |
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,144 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec" | ||
xmlns:mv="http://g" | ||
stylesheet="../converter-gen/supermodel-to-json.xsl"> | ||
<x:scenario label="Regression Test for usnistgov/metaschema#235"> | ||
<x:scenario label="If a document instance has a field has no value or flag defined"> | ||
<x:context mode="write-json"> | ||
<!-- | ||
<root xmlns="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field1 optional-flag="value2">https://example.com</field1> | ||
</root> | ||
--> | ||
<assembly xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel" | ||
name="root-assembly" | ||
key="root" | ||
gi="root" | ||
namespace="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field collapsible="no" | ||
as-type="uri" | ||
name="field1" | ||
key="field1" | ||
gi="field1"> | ||
<value as-type="uri" key="STRVALUE" in-json="string"/> | ||
</field> | ||
</assembly> | ||
</x:context> | ||
<x:expect label="the JSON serialization XML format should be correct."> | ||
<map xmlns="http://www.w3.org/2005/xpath-functions"> | ||
<map key="root"> | ||
<map key="field1"> | ||
<string key="STRVALUE"/> | ||
</map> | ||
</map> | ||
</map> | ||
</x:expect> | ||
</x:scenario> | ||
<x:scenario label="If a document instance has a field with a value defined and no optional flag defined"> | ||
<x:context mode="write-json"> | ||
<!-- | ||
<root xmlns="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field1>https://example.com</field1> | ||
</root> | ||
--> | ||
<assembly xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel" | ||
name="root-assembly" | ||
key="root" | ||
gi="root" | ||
namespace="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field collapsible="no" | ||
as-type="uri" | ||
name="field1" | ||
key="field1" | ||
gi="field1"> | ||
<value as-type="uri" key="STRVALUE" in-json="string">https://example.com</value> | ||
</field> | ||
</assembly> | ||
</x:context> | ||
<x:expect label="the JSON serialization XML format should be correct."> | ||
<map xmlns="http://www.w3.org/2005/xpath-functions"> | ||
<map key="root"> | ||
<map key="field1"> | ||
<string key="STRVALUE">https://example.com</string> | ||
</map> | ||
</map> | ||
</map> | ||
</x:expect> | ||
</x:scenario> | ||
<x:scenario label="If a document instance has its optional flag and a value defined"> | ||
<x:context mode="write-json"> | ||
<!-- | ||
<root xmlns="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field1 optional-flag="value2">https://example.com</field1> | ||
</root> | ||
--> | ||
<assembly xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel" | ||
name="root-assembly" | ||
key="root" | ||
gi="root" | ||
namespace="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field collapsible="no" | ||
as-type="uri" | ||
name="field1" | ||
key="field1" | ||
gi="field1"> | ||
<flag in-json="string" | ||
as-type="string" | ||
name="optional-flag" | ||
key="optional-flag" | ||
gi="optional-flag">value2</flag> | ||
<value as-type="uri" key="STRVALUE" in-json="string">https://example.com</value> | ||
</field> | ||
</assembly> | ||
</x:context> | ||
<x:expect label="the JSON serialization XML format should be correct."> | ||
<map xmlns="http://www.w3.org/2005/xpath-functions"> | ||
<map key="root"> | ||
<map key="field1"> | ||
<string key="optional-flag">value2</string> | ||
<string key="STRVALUE">https://example.com</string> | ||
</map> | ||
</map> | ||
</map> | ||
</x:expect> | ||
</x:scenario> | ||
<x:scenario label="If a document instance has its optional flag defined and no value defined"> | ||
<x:context mode="write-json"> | ||
<!-- | ||
<root xmlns="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field1 optional-flag="value2"/> | ||
</root> | ||
--> | ||
<assembly xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel" | ||
name="root-assembly" | ||
key="root" | ||
gi="root" | ||
namespace="http://csrc.nist.gov/ns/metaschema/unit-tests"> | ||
<field collapsible="no" | ||
as-type="uri" | ||
name="field1" | ||
key="field1" | ||
gi="field1"> | ||
<flag in-json="string" | ||
as-type="string" | ||
name="optional-flag" | ||
key="optional-flag" | ||
gi="optional-flag">value2</flag> | ||
<value as-type="uri" key="STRVALUE" in-json="string"/> | ||
</field> | ||
</assembly> | ||
</x:context> | ||
<x:expect label="the JSON serialization XML format should be correct."> | ||
<map xmlns="http://www.w3.org/2005/xpath-functions"> | ||
<map key="root"> | ||
<map key="field1"> | ||
<string key="optional-flag">value2</string> | ||
<string key="STRVALUE"/> | ||
</map> | ||
</map> | ||
</map> | ||
</x:expect> | ||
</x:scenario> | ||
</x:scenario> | ||
</x:description> |