forked from usnistgov/OSCAL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple control call link checker Schematron cf Issue usnistgov#534
- Loading branch information
1 parent
47b2550
commit aa223f3
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:sqf="http://www.schematron-quickfix.com/validator/process" | ||
xmlns:oscal="http://csrc.nist.gov/ns/oscal/1.0"> | ||
|
||
<!-- Quick little Schematron for checking link integrity from | ||
profile //call/@control-id *only* | ||
and *only* when catalogs, not profiles, are sourced. | ||
A more complete error check will resolve profile sources as well as query catalogs. | ||
--> | ||
<sch:ns uri="http://csrc.nist.gov/ns/oscal/1.0" prefix="oscal"/> | ||
|
||
<xsl:key name="resource-fetch" match="oscal:resource" use="'#' || @id"/> | ||
|
||
<xsl:function name="oscal:get-import" as="document-node()?"> | ||
<xsl:param name="import" as="element(oscal:import)"/> | ||
<xsl:variable name="source" select="($import/key('resource-fetch',@href)/oscal:rlink/@href,$import/@href[. castable as xs:anyURI])[1]"/> | ||
<xsl:sequence select="document($source, $import)"/> | ||
</xsl:function> | ||
|
||
<sch:pattern> | ||
<sch:rule context="oscal:import"> | ||
<sch:let name="importing" value="oscal:get-import(.)"/> | ||
|
||
<sch:assert test="exists($importing)">Nothing found at <sch:value-of select="@href"/>...</sch:assert> | ||
<sch:assert role="warning" test="exists($importing/oscal:catalog)">Not importing a catalog.</sch:assert> | ||
</sch:rule> | ||
<sch:rule context="oscal:import/*/oscal:call"> | ||
<sch:let name="importing" value="oscal:get-import(../parent::oscal:import)"/> | ||
<sch:let name="not-a-catalog" value="empty($importing/oscal:catalog)"/> | ||
|
||
<sch:assert test="$not-a-catalog or (@control-id = $importing//oscal:control/@id)">No control found with @id='<sch:value-of select="@control-id"/>'</sch:assert> | ||
</sch:rule> | ||
</sch:pattern> | ||
|
||
|
||
</sch:schema> |
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