Skip to content

Commit

Permalink
Cleanup of models and data (usnistgov#476)
Browse files Browse the repository at this point in the history
* Schematron now reports duplicate definitions in a Metaschema as an error: see usnistgov#465, usnistgov#475

* Catalog metaschema and SP800-53 catalog adjustments renaming 'subcontrol' to 'control' per Issue usnistgov#473

* Refactored metaschemas to avoid definition clashes; more/better Schematron to detect such clashes

* Adding new module now required by catalog and profile metaschemas

* Revising profiles to be valid to newly revised schema (no more references to subcontrol elements only controls)

* Bug fix in Metaschema Schematron

* Delete FedRAMP_HIGH-baseline_profile.xml

* Delete FedRAMP_LOW-baseline_profile.xml

* Delete FedRAMP_MODERATE-baseline_profile.xml

* Create temp.txt

* Revised FedRAMP Profiles

These files include revisions to the FedRAMP baselines, plus a small FedRAMP catalog that provides three subcontrols added by FedRAMP.

* Delete temp.txt

* moved updated fedramp content to correct location

* New and improved FedRAMP profiles

* Repaired broken markdown conversion; added missing title content to FedRAMP catalog

* add note about b -> strong and i -> em (#9)

* Changed inline markup in FedRAMP profiles for lossless conversion

* One more adjustment in Markdown->XML conversion (images)

* One more time (cleaning up cleanup)
  • Loading branch information
wendellpiez authored and david-waltermire committed Aug 27, 2019
1 parent 102de09 commit 0153500
Show file tree
Hide file tree
Showing 15 changed files with 4,064 additions and 5,832 deletions.
59 changes: 44 additions & 15 deletions build/metaschema/json/md-oscal-converter.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<xsl:param name="target-ns" as="xs:string?">http://csrc.nist.gov/ns/oscal/1.0</xsl:param>

<xsl:template name="xsl:initial-template" match="/">
<!--<xsl:copy-of select="$tag-replacements"/>-->
<!--<xsl:copy-of select="$examples"/>-->
<xsl:call-template name="parse">
<xsl:with-param name="markdown-str" select="string($examples)"/>
Expand Down Expand Up @@ -85,10 +86,12 @@
<xsl:variable name="flat-structures">
<xsl:apply-templates select="$rough-blocks" mode="mark-structures"/>
</xsl:variable>
<!--<xsl:copy-of select="$flat-structures"/>-->
<!-- for debugging <xsl:copy-of select="$flat-structures"/>-->

<xsl:variable name="nested-structures">
<xsl:apply-templates select="$flat-structures" mode="build-structures"/>
</xsl:variable>
<!-- for debugging <xsl:copy-of select="$nested-structures"/>-->

<xsl:variable name="fully-marked">
<xsl:apply-templates select="$nested-structures" mode="infer-inlines"/>
Expand Down Expand Up @@ -239,10 +242,11 @@
<xsl:param name="group" select="m:li"/>

<xsl:variable name="this-type" select="$group[1]/@type"/>
<!-- first, splitting ul from ol groups -->
<xsl:for-each-group select="$group" group-starting-with="*[@level = $level and not(@type = preceding-sibling::*/@type)]">
<xsl:element name="m:{ $group[1]/@type }" namespace="http://csrc.nist.gov/ns/oscal/1.0/md-convertor">
<xsl:for-each-group select="current-group()" group-starting-with="li[@level = $level]">
<!--first, splitting ul from ol groups -->
<!--<xsl:for-each-group select="$group" group-starting-with="*[@level = $level and not(@type = preceding-sibling::*[1]/@type)]">-->
<!--<xsl:for-each-group select="$group" group-starting-with="*[@level = $level]">-->
<xsl:element name="m:{ $group[1]/@type }" namespace="http://csrc.nist.gov/ns/oscal/1.0/md-convertor">
<xsl:for-each-group select="$group" group-starting-with="m:li[(@level = $level) or not(@type = preceding-sibling::*[1]/@type)]">
<xsl:choose>
<xsl:when test="@level = $level (: checking first item in group :)">
<m:li>
Expand All @@ -269,7 +273,7 @@
</xsl:choose>
</xsl:for-each-group>
</xsl:element>
</xsl:for-each-group>
<!--</xsl:for-each-group>-->
</xsl:template>

<xsl:template match="m:pre//text()" mode="infer-inlines">
Expand Down Expand Up @@ -363,10 +367,10 @@

<q>"<text/>"</q>

<img alt="!\[{{$text}}\]" src="\({{$text}}\)"/>
<img alt="!\[{{$noclosebracket}}\]" src="\({{$nocloseparen}}\)"/>
<insert param-id="\{{\{{{{$nws}}\}}\}}"/>

<a href="\[{{$text}}\]">\(<text/>\)</a>
<a href="\[{{$nocloseparen}}\]">\(<text not="\)"/>\)</a>
<code>`<text/>`</code>
<strong>
<em>\*\*\*<text/>\*\*\*</em>
Expand Down Expand Up @@ -402,6 +406,14 @@
<xsl:value-of select="replace(., '\{\$text\}', '(.*)?')"/>
</xsl:template>

<xsl:template match="@*[matches(., '\{\$nocloseparen\}')]" mode="write-match">
<xsl:value-of select="replace(., '\{\$nocloseparen\}', '([^\\(]*)?')"/>
</xsl:template>

<xsl:template match="@*[matches(., '\{\$noclosebracket\}')]" mode="write-match">
<xsl:value-of select="replace(., '\{\$noclosebracket\}', '([^\\[]*)?')"/>
</xsl:template>

<xsl:template match="@*[matches(., '\{\$nws\}')]" mode="write-match">
<!--<xsl:value-of select="."/>-->
<!--<xsl:value-of select="replace(., '\{\$nws\}', '(\S*)?')"/>-->
Expand Down Expand Up @@ -435,6 +447,16 @@
<xsl:text>(.*?)</xsl:text>
</xsl:template>

<xsl:template match="m:text[@not]" mode="write-match">
<xsl:text expand-text="true">([^{ @not }]*?)</xsl:text>
</xsl:template>

<!--<xsl:template match="m:text" mode="write-match">
<xsl:variable name="match-char"
select="if (matches(@not,'\S')) then ('[' || @not || ']') else '.'"/>
<xsl:text expand-text="true">({ $match-char }*?)</xsl:text>
</xsl:template>-->

<xsl:variable name="line-example" xml:space="preserve"> { insertion } </xsl:variable>

<xsl:variable name="examples" xml:space="preserve">
Expand All @@ -448,10 +470,11 @@ Paragraph, \n\nand new paragraph
Bit of `code` here and there, such as one might have along with *italics*.

no insertion here: { ac-4.4_prm_2 }


An anchor looks like [this](this.file) or [that](that.file)

Extra long x
y and z
y and z **strong** and **bold**


Here's a text with a *parameter* insertion: {{ insert }}
Expand All @@ -465,7 +488,7 @@ And many paragraphs!
* One item in a list, with "quoted text"
* Another item in a list
* Sublist
* subsublist
* subsublist
* Item three

```xml
Expand All @@ -474,6 +497,8 @@ And many paragraphs!
... select ...>
```

Some paragraphs have ![images](http://www.links.com) in them, sometimes ![many](../many/links)

And Prose!

```
Expand All @@ -496,10 +521,14 @@ And stuff.

</p>
<p>Here's a markdown string.</p>
<p>This `string should *break` (overlap)*</p>
<p>`code` may occasionally turn up `in the middle`.</p>
<p>Here's a ***really interesting*** markdown string.</p>
<p>Some paragraphs might have [links elsewhere](https://link.org).</p>

<p>This `string should *break` (overlap)*</p>

<p>`code` may occasionally turn up `in the middle`.</p>

<p>Here's a ***really interesting*** markdown string.</p>

<p>Some paragraphs might have [links elsewhere](https://link.org).</p>
</xsl:variable>

</xsl:stylesheet>
7 changes: 3 additions & 4 deletions build/metaschema/lib/metaschema-check.sch
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<xsl:key name="invocation-by-ref" match="m:assembly[exists(@ref)] | m:field[exists(@ref)] | m:flag[exists(@ref)]" use="@ref"/>
<xsl:key name="flags-by-name" match="m:define-flag | m:flag[@name]" use="@name"/>


<sch:ns uri="http://csrc.nist.gov/ns/oscal/metaschema/1.0" prefix="m"/>

<xsl:variable name="example-ns" select="'http://csrc.nist.gov/ns/oscal/example'"/>
Expand All @@ -37,17 +36,17 @@
<!-- grouping name can't be the same as the name
group-as is present whenever not(@max-occurs = 1) -->
<sch:pattern>

<sch:rule context="m:define-assembly | m:define-field | m:define-flag">
<sch:assert role="warning" test="count(key('definition-by-name',@name)) = 1">Definition for '<sch:value-of select="@name"/>' is not unique in this metaschema module (only the last one found will be used)</sch:assert>
<!-- $compleat assembles all definitions from all modules (in metaschema-compose.xsl) -->
<sch:let name="contenders" value="key('definition-by-name',@name,$compleat)"/>
<sch:assert role="warning" test="count( $contenders ) = 1">Definition for '<sch:value-of select="@name"/>' is not unique in this metaschema; cf <xsl:value-of select="$contenders/../@module" separator=", "/>.</sch:assert>
<sch:assert test="exists(m:formal-name)">formal-name missing from <sch:name/></sch:assert>
<sch:assert test="exists(m:description)">description missing from <sch:name/></sch:assert>
<sch:assert test="empty(self::m:define-assembly) or exists(m:model)">model missing from <sch:name/></sch:assert>
<sch:assert test="not(@as-type='boolean') or empty(m:flag)">Property defined as boolean may not have flags.</sch:assert>
<sch:assert test="not(key('invocation-by-ref',@name)/m:group-as/@json-behavior='BY_KEY') or exists(m:json-key)"><sch:value-of select="substring-after(local-name(),
'define-')"/> is assigned a json key, but no 'json-key' is given</sch:assert>
<sch:report test="@name=('RICHTEXT','STRVALUE','PROSE')">Names "STRVALUE", "RICHTEXT" or "PROSE" (reserved names)</sch:report>

</sch:rule>

<sch:rule context="m:json-key">
Expand Down
2 changes: 2 additions & 0 deletions docs/content/documentation/schemas/datatypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ The following table describes the equavalent constructs in HTML and Markdown use
| Ordered List Item | &lt;ol&gt;&lt;li&gt;*text*&lt;/li&gt;&lt;/ol&gt; | 1. *text*
| Unordered List Item | &lt;ul&gt;&lt;li&gt;*text*&lt;/li&gt;&lt;/ul&gt; | - *text*

Note: Markdown does not have an equivalent of the HTML &lt;i&gt; and &lt;b&gt; tags, which indicate italics and bold respectively. These concepts are mapped in OSCAL markup text to &lt;em&gt; and &lt;strong&gt; [common mark](https://spec.commonmark.org/0.29/#emphasis-and-strong-emphasis), which render equivalently in browsers, but do not have exactly the same semantics. While this mapping is imperfect, it represents the common uses of these HTML tags.

#### Parameter Insertion

The OSCAL catalog, profile, and implementation layer models allow for control parameters to be defined and injected into prose text.
Expand Down
Loading

0 comments on commit 0153500

Please sign in to comment.