Skip to content

Commit

Permalink
More adjustments to profile semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez committed Jan 30, 2018
1 parent 5e9147f commit d973486
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 106 deletions.
186 changes: 93 additions & 93 deletions OSCAL-dev.xpr

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion examples/mini-testing/10_some-params-profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

<!-- From here on, we exclude ra.9 just to show that exclusions work -->
<exclude>
<call control-id="ra.9"/>
<match pattern="ra\.9"/>
<!--<call control-id="ra.9"/>-->
</exclude></import>


<modify>

<set-param param-id="ac-5_a">
Expand Down
2 changes: 1 addition & 1 deletion examples/mini-testing/dinosaur-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<group><title>Predators</title>
<control id="allosaur"/>
<control id="tyrannosaur">
<subcontrol id="rex"/>
<subcontrol id="tyrannosaurus-rex"/>
</control>
<control id="velociraptor"/>
</group>
Expand Down
5 changes: 3 additions & 2 deletions examples/mini-testing/dinosaur-profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<title>Dinosaur Profile</title>
<import href="dinosaur-catalog.xml">
<include>
<call with-subcontrols="yes" control-id="allosaur"/>
<call control-id="triceratops"/>
<match pattern="(allosaur|triceratops)"/>
<!--<call with-subcontrols="yes" control-id="allosaur"/>
<call control-id="triceratops"/>-->
</include>
</import>

Expand Down
11 changes: 8 additions & 3 deletions examples/mini-testing/dinosaur-testing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
<import href="dinosaur-profile.xml"/>
<import href="dinosaur-catalog.xml">
<include>
<call control-id="triceratops"/>
<match pattern="tyrannosaur" with-control="yes" with-subcontrols="yes"/>

<match pattern="triceratops"/>
<!--<call control-id="triceratops"/>
<call with-subcontrols="yes" control-id="tyrannosaur"/>
<call control-id="archeopteryx"/>
<call control-id="archeopteryx"/>-->
</include>
</import>
<merge/>
<merge>
<build/>
</merge>
</profile>
5 changes: 3 additions & 2 deletions schema/xml/RNC/oscal-profile.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ profile = element profile { idAttr, title, import+, merge?, modify? }
import = element import { hrefAttr, (\include?, exclude?) }

# presence of element merge means to merge (not merely aggregate)
merge = element merge { empty }
merge = element merge { element build { empty }? }

modify = element modify { (param_setting | alteration )* }

Expand All @@ -21,6 +21,7 @@ modify = element modify { (param_setting | alteration )* }
all = element all { withSubContrlsAttr }

withSubContrlsAttr = attribute with-subcontrols { ('yes'|'no') }?
withContrlAttr = attribute with-control { ('yes'|'no') }?

# 'call' can call *either* a control or a subcontrol by its @id
# Schematron requirement: there exists in the catalog a control or subcontrol
Expand All @@ -29,7 +30,7 @@ call = element call {
(withSubContrlsAttr, attribute control-id { xsd:NCName } ) |
attribute subcontrol-id { xsd:NCName } }

match = element match { withSubContrlsAttr, attribute pattern { text } }
match = element match { withSubContrlsAttr, withContrlAttr, attribute pattern { text } }

exclude = element exclude { ( match |
element call {
Expand Down
10 changes: 6 additions & 4 deletions working/lib/XSLT/profile-resolver.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,11 @@
<xsl:variable name="matched" select="some $re in ($invocation/include/match/@pattern ! ('^' || . || '$') ) satisfies (matches($comp/@id,$re))"/>
<xsl:variable name="parent-control" select="$comp/(parent::control | parent::comp[oscal:classes(.)='control'] )"/>
<xsl:variable name="subcontrol-matched" select="some $re in ($invocation/include/match[@with-subcontrols='yes']/@pattern ! ('^' || . || '$') ) satisfies (matches($parent-control/@id,$re))"/>
<xsl:variable name="control-implied" select="some $re in ($invocation/include/match[@with-control='yes']/@pattern ! ('^' || . || '$') ) satisfies (matches($comp/subcontrol/@id,$re))"/>

<xsl:variable name="unmatched" select="some $re in ($invocation/exclude/match/@pattern ! ('^' || . || '$') ) satisfies (matches($comp/@id,$re))"/>

<xsl:sequence select="($matched or $subcontrol-matched or $included) and not($unmatched)"/>
<xsl:sequence select="($included or $matched or $subcontrol-matched or $control-implied) and not($unmatched)"/>
</xsl:function>

<xsl:template match="control | component[oscal:classes(.)='control']" priority="3" mode="import">
Expand Down Expand Up @@ -238,6 +239,7 @@
<xsl:variable name="called" select="exists($invocation/include/call[@subcontrol-id = current()/@id])"/>
<!-- The subcontrol can still be excluded -->
<xsl:variable name="excluded" select="exists($invocation/exclude/call[@subcontrol-id = current()/@id])"/>

<xsl:if test="$included or oscal:matched(.,$invocation) (: $included or $called) and not($excluded :)">
<xsl:copy>
<xsl:copy-of select="@*"/>
Expand Down Expand Up @@ -281,15 +283,15 @@
</xsl:for-each-group>
</merged>
</xsl:variable>
<xsl:sequence select="$merged"/>
<!--<xsl:sequence select="$merged"/>-->

<!--<xsl:for-each select="$so-far/*">
<xsl:for-each select="$so-far/*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="node()"/>
<xsl:sequence select="$merged"/>
</xsl:copy>
</xsl:for-each>-->
</xsl:for-each>
<xsl:apply-templates select="." mode="echo"/>


Expand Down

0 comments on commit d973486

Please sign in to comment.