Skip to content

Commit

Permalink
Updating Schematron rules in view of ongoing changes. (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez authored Dec 14, 2023
1 parent 8499951 commit b66ca2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</sch:rule>

<sch:rule context="oscal:control">
<sch:let name="expected-id" value="o:reduce-label(oscal:prop[@name='label'][not(@class='sp800-53a')]/@value)"/>
<sch:let name="expected-id" value="oscal:prop[@name='alt-identifier'][@class='sp800-53']/@value ! o:reduce-label(.)"/>
<sch:assert test="@id = $expected-id">Expected id to be '<sch:value-of select="$expected-id"/>'</sch:assert>
</sch:rule>

Expand Down Expand Up @@ -115,7 +115,7 @@

<xsl:function name="o:reduce-label">
<xsl:param name="what" as="node()"/>
<xsl:value-of select="lower-case($what) ! replace(., '\(', '.') ! replace(., '\)', '') ! replace(.,'\.$','')"/>
<xsl:value-of select="lower-case($what) ! replace(., '\(', '.') ! replace(., '\)', '') ! replace(.,'\.$','') ! replace(.,'0(\d)','$1')"/>
</xsl:function>

<xsl:template mode="number-format" priority="1" match="oscal:part[@name='item']">a.</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@
<sch:pattern id="required-items">
<sch:rule context="o:control">
<sch:let name="withdrawn" value="o:prop[@name='status']/@value = 'withdrawn'"/>
<sch:assert test="o:prop/@name='label'">control must have a child 'prop' with @name='label'</sch:assert>
<sch:assert test="o:prop/@name='sort-id'">control must have a child 'prop' with @name='sort-id'</sch:assert>
<sch:assert test="count(o:prop[@class='sp800-53']/@name='alt-identifier') eq 1">control must have a child 'prop' with @name='alt-identifier' and @class='sp800-53' (<sch:value-of select="@id"/>)</sch:assert>
<sch:assert test="count(o:prop[@class='sp800-53a']/@name='alt-identifier') eq 1">control must have a child 'prop' with @name='alt-identifier' and @class="sp800-53a' (<sch:value-of select="@id"/>)</sch:assert>
<sch:assert test="empty(o:prop[@name='label'])">'label' props are not now being used (<sch:value-of select="@id"/>)</sch:assert>
<sch:assert test="o:prop/@name='sort-id'">control must have a child 'prop' with @name='sort-id'</sch:assert>
<sch:assert test="o:part/@name='statement' or $withdrawn">control must have a child 'part' with @name='statement'</sch:assert>
<!--<sch:assert test="o:part/@name='objective' or $withdrawn">control with name='SP800-53' must have a child 'part' with @name='objective'</sch:assert>-->
</sch:rule>
Expand All @@ -141,15 +143,15 @@
<!-- pre-empting rules for 53A labels -->
<sch:rule context="o:control/o:prop[@name = 'label'][@class='sp800-53a']"/>

<sch:rule context="o:control/o:control/o:prop[@name = 'label']">
<sch:rule context="o:control/o:control/o:prop[@name = 'alt-identifier'][@class='sp800-53']">
<sch:let name="label-regex" value="'^(AC|AT|AU|CA|CM|CP|IA|IR|MA|MP|PE|PL|PM|PS|PT|RA|SA|SC|SI|SR)\-\d\d?\(\d\d?\)$'"/>
<!--<sch:assert test="o:singleton(.)">prop with name='label'
must be a singleton: no other properties named 'label' may appear in the same
context</sch:assert>-->
<sch:assert test="matches(@value, $label-regex)">prop with name='label' must match regular expression <sch:value-of select="$label-regex"/></sch:assert>
<sch:let name="parent-label" value="../../o:prop[@name = 'label'][not(@class='sp800-53a')]"/>
<sch:let name="parent-label" value="../../o:prop[@name = 'alt-identifier'][@class='sp800-53']"/>
<xsl:variable name="formatted-no">
<xsl:number count="o:control" format="(1)"/>
<xsl:number count="o:control" format="(01)"/>
</xsl:variable>
<sch:assert test="@value = (($parent-label/@value) || $formatted-no)">Control enhancement
label is inconsistent: we expect <sch:value-of select="$parent-label/@value || $formatted-no"/> here</sch:assert>
Expand Down

0 comments on commit b66ca2c

Please sign in to comment.