Skip to content

Commit

Permalink
Addressing #12, supporting collapsibility of fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez authored and david-waltermire committed Jan 10, 2020
1 parent 410e682 commit f7325ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- OSCAL CATALOG METASCHEMA -->
<!-- validate with XSD and Schematron (linked) -->
<?xml-model href="../../lib/metaschema-check.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-stylesheet type="text/css" href="../../lib/metaschema-author.css"?>
<?xml-model href="../../../toolchains/oscal-m2/lib/metaschema-check.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<METASCHEMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../../../schema/metaschema.xsd"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:o="http://csrc.nist.gov/ns/oscal/example" root="parent">
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../../../toolchains/oscal-m2/lib/metaschema.xsd"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0" root="parent">
<schema-name>Metaschema Unit Test: collapsible</schema-name>
<schema-version>1.0-milestone1</schema-version>
<short-name>metaschema-collapsible</short-name>
Expand Down
23 changes: 22 additions & 1 deletion toolchains/oscal-m2/json/json-schema-metamap.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,28 @@
</map>
</xsl:if>
</xsl:template>


<xsl:template match="define-field[@collapsible='yes']" mode="properties">
<xsl:apply-templates mode="declaration" select="flag"/>
<xsl:variable name="this-key" as="xs:string?">
<xsl:apply-templates select="." mode="value-key"/>
</xsl:variable>
<xsl:if test="matches($this-key, '\S')">
<map key="{$this-key}">
<array key="anyOf">
<map><string key="type">string</string></map>
<map>
<string key="type">array</string>
<map key="items">
<string key="type">string</string>
</map>
<number key="minItems">2</number>
</map>
</array>
</map>
</xsl:if>
</xsl:template>

<!--A flag declared as a key or value key gets no declaration since it
will not show up in the JSON as a separate property -->

Expand Down

0 comments on commit f7325ec

Please sign in to comment.