Skip to content

Commit

Permalink
More touchups; providing missing file for CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez committed Jan 15, 2025
1 parent 3ab7d80 commit 6baa5dd
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 28 deletions.
31 changes: 31 additions & 0 deletions projects/usds-playbook-import/GRAB-RESOURCES.xpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step" version="3.0"
xmlns:ox="http://csrc.nist.gov/ns/oscal-xproc3"
type="ox:GRAB-RESOURCES"
name="GRAB-RESOURCES">


<!-- Purpose: update local copies of some OSCAL resources from its release repository -->

<p:variable name="download-path" select="'https://github.com/usnistgov/OSCAL/releases/download/v1.1.2'"/>

<!-- A $prefix is used to tag messages, expected to match the process type -->
<p:variable name="prefix" select="'[' || 'GRAB-RESOURCES' || ']'"/>

<p:for-each message="{$prefix} Saving resources in ./lib ...">
<!-- iterating over each 'resource' as a discrete document node -->
<p:with-input>
<p:document href="{$download-path}/oscal_catalog_schema.xsd"/>
</p:with-input>
<p:variable name="filename" select="p:document-property(.,'base-uri') ! replace(.,'.*/','')"/>

<!-- No exception handling since a failed load often produces a result
making it difficult to anticipate what a failure looks like - -->
<!-- NB - A Schematron error comes back as soon as this is out of line with /*/@type i.e. the file name
- starting the @message with { $prefix } silences the error, but please reset $prefix -->

<p:store message="{$prefix} ... saving { $filename }" href="lib/{ $filename }"/>
</p:for-each>

</p:declare-step>
57 changes: 31 additions & 26 deletions projects/usds-playbook-import/OSCAL-PLAYBOOK.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
xmlns:ox="http://csrc.nist.gov/ns/oscal-xproc3" type="ox:OSCAL-PLAYBOOK" name="OSCAL-PLAYBOOK">


<!-- This pipeline delivers errors if either of the files designated as
<!-- This pipeline delivers errors if either
$source-html-file or $schema-file is not found -
Run pipelines GRAB-RESOURCES.xpl and GRAB-PLAYBOOK.xpl to restore them. -->

<!-- subpipeline starts here -->

<!-- Cached copy -->
<!-- Cached copies -->
<p:variable name="schema-file" select="resolve-uri('lib/oscal_catalog_schema.xsd')"/>
<p:variable name="source-html-file" select="resolve-uri('archive/playbook-source.html')"/>

<!--starting - - - -->

<p:choose name="acquire-catalog-schema">
<!-- We can't use doc-available since the HTML is not XML (grr) -->
<p:when test="doc-available($schema-file)">
<p:load href="{ $schema-file }" message="[OSCAL-PLAYBOOK] Loading schema { $schema-file }"/>
</p:when>
Expand Down Expand Up @@ -53,7 +52,8 @@

<p:cast-content-type content-type="application/xml"/>

<p:store href="archive/playbook_01_extract.xhtml" message="[OSCAL-PLAYBOOK] p:store: archive/playbook_01_extract.xhtml ..."/>
<p:store href="archive/playbook_01_extract.xhtml"
message="[OSCAL-PLAYBOOK] p:store: archive/playbook_01_extract.xhtml ..."/>

<p:namespace-delete prefixes="html" xmlns:html="http://www.w3.org/1999/xhtml"/>

Expand All @@ -62,13 +62,15 @@
</p:xslt>

<!-- Validate to presumed model -->
<p:validate-with-relax-ng assert-valid="true" message="[OSCAL-PLAYBOOK] Validating extract against contract -">
<p:validate-with-relax-ng assert-valid="true"
message="[OSCAL-PLAYBOOK] Validating extract against contract -">
<p:with-input port="schema" href="src/playbook.rnc"/>
</p:validate-with-relax-ng>

<p:identity message="[OSCAL-PLAYBOOK] ... things looking good ..."/>

<p:store href="archive/playbook_02_rendered.xml" serialization="map{ 'indent': true() }" message="[OSCAL-PLAYBOOK] p:store: archive/playbook_02_rendered.xml ..."/>
<p:store href="archive/playbook_02_rendered.xml" serialization="map{ 'indent': true() }"
message="[OSCAL-PLAYBOOK] p:store: archive/playbook_02_rendered.xml ..."/>
</p:group>

<p:group name="map-to-oscal">
Expand All @@ -77,35 +79,38 @@

<p:insert match="/*" position="first-child">
<p:with-input port="insertion">
<p:inline>
<metadata>
<title>US Digital Service Playbook (OSCAL rendition)</title>
<last-modified>{ current-dateTime() }</last-modified>
<version>0.1</version>
<oscal-version>1.1.2</oscal-version>
<link rel="source" href="https://playbook.usds.gov/"/>
</metadata>
</p:inline>
<metadata>
<title>US Digital Service Playbook (OSCAL rendition)</title>
<last-modified>{ current-dateTime() }</last-modified>
<version>0.1</version>
<oscal-version>1.1.2</oscal-version>
<link rel="source" href="https://playbook.usds.gov/"/>
</metadata>
</p:with-input>
</p:insert>

<p:add-attribute match="/catalog" attribute-name="uuid"
attribute-value="00000000-0000-0000-0000-000000000000"/>
<p:add-attribute match="/catalog" attribute-name="uuid" attribute-value="00000000-0000-0000-0000-000000000000"/>
<p:uuid match="/catalog/@uuid"/>

<p:namespace-delete prefixes="c ox"/>

<!-- apply-to="elements" is essential to avoid hiding attributes in XSD validation -->
<p:namespace-rename apply-to="elements" to="http://csrc.nist.gov/ns/oscal/1.0"
message="[OSCAL-PLAYBOOK] Casting to OSCAL"/>
message="[OSCAL-PLAYBOOK] Casting to OSCAL"/>

<!-- Validate OSCAL - REQUIRES SAXON EE for XML Calabash -->
<p:validate-with-xml-schema name="oscal-catalog-validation"
message="[OSCAL-PLAYBOOK] Validating OSCAL catalog -"
assert-valid="true" version="1.0">
<p:with-input port="schema" pipe="@acquire-catalog-schema"/>
</p:validate-with-xml-schema>

<p:choose>
<p:when test="p:step-available('p:validate-with-xml-schema')">
<p:validate-with-xml-schema name="oscal-catalog-validation" assert-valid="true" version="1.0"
message="[OSCAL-PLAYBOOK] Validating OSCAL catalog -">
<p:with-input port="schema" pipe="@acquire-catalog-schema"/>
</p:validate-with-xml-schema>
</p:when>
<p:otherwise>
<p:identity message="[OSCAL-PLAYBOOK] Skipped schema validation (not supported in the installed { p:system-property('p:product-name') })"/>
</p:otherwise>
</p:choose>

<p:store href="archive/playbook_99_oscal.xml" serialization="map{ 'indent': true() }"
message="[OSCAL-PLAYBOOK] p:store: archive/playbook_99_oscal.xml ..."/>
</p:group>
Expand Down
4 changes: 2 additions & 2 deletions projects/usds-playbook-import/archive/playbook_99_oscal.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<catalog uuid="a9f2845a-029f-46a7-aa95-7811747678a8"
<catalog uuid="d6988121-e246-4f18-9717-c9585e187b94"
xmlns="http://csrc.nist.gov/ns/oscal/1.0">
<metadata>
<title>US Digital Service Playbook (OSCAL rendition)</title>
<last-modified>2025-01-14T16:45:09.93-05:00</last-modified>
<last-modified>2025-01-14T17:49:16.96-05:00</last-modified>
<version>0.1</version>
<oscal-version>1.1.2</oscal-version>
<link rel="source"
Expand Down
26 changes: 26 additions & 0 deletions projects/usds-playbook-import/src/playbook.rnc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
default namespace = ""

# Schema represents an ad hoc semantic reduction describing ../archive/playbook_02_rendered.xml
# RNC generated using Trang, no mods

start =
element catalog {
element control {
attribute id { xsd:NCName },
title,
element part {
attribute name { xsd:NCName }?,
title?,
(element ol { li+ }
| element ul { li+ }
| element p { (text | a)+ }+)
}+
}+
}
title = element title { text }
a =
element a {
attribute href { xsd:anyURI },
text
}
li = element li { (text | a)+ }

0 comments on commit 6baa5dd

Please sign in to comment.