Skip to content

Commit ef8fa01

Browse files
committed
Add possible Schematron documentation checks
This is the product of the meeting and spike where we pair-programmed and came up with example Schematron rules for tentative editorial standards that can be used for reviews of models and embedded docs as part of #801. Co-authored-by: Chris Compton <[email protected]> Co-authored-by: Rene Rene Tshiteya <[email protected]> Co-authored-by: Wendell Piez <[email protected]> Add CI/CD checking of Schematron doc standards checking. Always zip and upload Schematron validation results for potential debug.
1 parent ef62215 commit ef8fa01

File tree

3 files changed

+69
-17
lines changed

3 files changed

+69
-17
lines changed

.github/workflows/workflow-generate-metaschema-resources.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,24 @@ jobs:
119119
run: |
120120
zip ${{ runner.temp }}/metaschema-artifacts.zip -r xml/schema/*.xsd json/schema/*.json xml/convert/*.xsl json/convert/*.xsl
121121
working-directory: ${{ env.CHECKOUT_PATH }}
122+
- name: Zip Schematron Validation Results for Debugging
123+
if: always()
124+
run: |
125+
zip ${{ runner.temp }}/schematron-validations.zip -r ${{ runner.temp }} build/metaschema/toolchains/xslt-M4/validate/metaschema-composition-check-compiled.xsl
126+
working-directory: ${{ env.CHECKOUT_PATH }}
122127
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
123128
with:
124129
name: schemas-and-converters
125130
path: |
126131
${{ runner.temp }}/metaschema-artifacts.zip
127132
retention-days: 5
133+
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
134+
if: always()
135+
with:
136+
name: schematron-validation-reports
137+
path: |
138+
${{ runner.temp }}/schematron-validations.zip
139+
retention-days: 5
128140
# Store Built Artifacts
129141
# ---------------
130142
- name: Publish Schemas and Converters

build/ci-cd/validate-metaschema.sh

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,23 @@ fi
9696

9797
# compile the schematron
9898
metaschema_toolchain="${OSCALDIR}/build/metaschema/toolchains/xslt-M4"
99-
schematron="${metaschema_toolchain}/validate/metaschema-composition-check.sch"
100-
compiled_schematron="${metaschema_toolchain}/validate/metaschema-composition-check-compiled.xsl"
99+
composition_check_schematron="${metaschema_toolchain}/validate/metaschema-composition-check.sch"
100+
documentation_check_schematron="${OSCALDIR}/src/utils/schematron/oscal-documentation.sch"
101+
compiled_composition_check_schematron="${metaschema_toolchain}/validate/metaschema-composition-check-compiled.xsl"
102+
compiled_documentation_check_schematron="${SCRATCH_DIR}/oscal-documentation.xsl"
101103
metaschema_xsd="${OSCALDIR}/build/metaschema/schema/xml/metaschema.xsd"
102104

103-
build_schematron "$schematron" "$compiled_schematron"
105+
build_schematron "$composition_check_schematron" "$compiled_composition_check_schematron"
104106
cmd_exitcode=$?
105107
if [ $cmd_exitcode -ne 0 ]; then
106-
echo -e "${P_ERROR}Compilation of Schematron '${P_END}${schematron}${P_ERROR}' failed.${P_END}"
108+
echo -e "${P_ERROR}Compilation of Schematron '${P_END}${composition_check_schematron}${P_ERROR}' failed.${P_END}"
109+
exit 1
110+
fi
111+
112+
build_schematron "$documentation_check_schematron" "$compiled_documentation_check_schematron"
113+
cmd_exitcode=$?
114+
if [ $cmd_exitcode -ne 0 ]; then
115+
echo -e "${P_ERROR}Compilation of Schematron '${P_END}${documentation_check_schematron}${P_ERROR}' failed.${P_END}"
107116
exit 1
108117
fi
109118

@@ -137,26 +146,39 @@ while IFS="|" read path gen_schema gen_converter gen_docs || [[ -n "$path" ]]; d
137146
echo -e "${P_ERROR}XML Schema validation failed for metaschema '${P_END}${metaschema_relative}${P_ERROR}'.${P_END}"
138147
echo -e "${P_ERROR}${result}${P_END}"
139148
exitcode=1
149+
fi
150+
151+
svrl_result="$SCRATCH_DIR/svrl/composition_check_${metaschema/$OSCALDIR\/src\//}.svrl"
152+
svrl_result_dir=${svrl_result%/*}
153+
mkdir -p "$svrl_result_dir"
154+
result=$(validate_with_schematron "$compiled_composition_check_schematron" "$metaschema" "$svrl_result")
155+
cmd_exitcode=$?
156+
if [ $cmd_exitcode -ne 0 ]; then
157+
echo -e "${P_ERROR}Schematron composition validation failed for metaschema '${P_END}${metaschema_relative}${P_ERROR}'.${P_END}"
158+
echo -e "${P_ERROR}${result}${P_END}"
159+
exitcode=1
140160
else
141-
svrl_result="$SCRATCH_DIR/svrl/${metaschema/$OSCALDIR\/src\//}.svrl"
142-
svrl_result_dir=${svrl_result%/*}
143-
mkdir -p "$svrl_result_dir"
144-
result=$(validate_with_schematron "$compiled_schematron" "$metaschema" "$svrl_result")
145-
cmd_exitcode=$?
146-
if [ $cmd_exitcode -ne 0 ]; then
147-
echo -e "${P_ERROR}Schematron validation failed for metaschema '${P_END}${metaschema_relative}${P_ERROR}'.${P_END}"
148-
echo -e "${P_ERROR}${result}${P_END}"
149-
exitcode=1
150-
else
151-
echo -e "${P_OK}XML Schema and Schematron validation passed for '${P_END}${metaschema_relative}${P_OK}'.${P_END}"
152-
fi
161+
echo -e "${P_OK}Schematron composition validation passed for '${P_END}${metaschema_relative}${P_OK}'.${P_END}"
162+
fi
163+
164+
svrl_result="$SCRATCH_DIR/svrl/documentation_check_${metaschema/$OSCALDIR\/src\//}.svrl"
165+
svrl_result_dir=${svrl_result%/*}
166+
mkdir -p "$svrl_result_dir"
167+
result=$(validate_with_schematron "$compiled_documentation_check_schematron" "$metaschema" "$svrl_result")
168+
cmd_exitcode=$?
169+
if [ $cmd_exitcode -ne 0 ]; then
170+
echo -e "${P_ERROR}Schematron documentation validation failed for metaschema '${P_END}${metaschema_relative}${P_ERROR}'.${P_END}"
171+
echo -e "${P_ERROR}${result}${P_END}"
172+
exitcode=1
173+
else
174+
echo -e "${P_OK}All XML Schema and Schematron validation passed for '${P_END}${metaschema_relative}${P_OK}'.${P_END}"
153175
fi
154176
done
155177
done < $OSCALDIR/build/ci-cd/config/metaschema
156178
shopt -u nullglob
157179
shopt -u globstar
158180

159181
# cleanup compiled schematron
160-
rm -f "$compiled_schematron"
182+
rm -f "$compiled_composition_check_schematron"
161183

162184
exit $exitcode
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
3+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4+
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
5+
xmlns:nm="http://csrc.nist.gov/ns/metaschema"
6+
xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
7+
xmlns:oscal="http://csrc.nist.gov/ns/oscal/1.0">
8+
9+
<sch:ns uri="http://csrc.nist.gov/ns/oscal/metaschema/1.0" prefix="m"/>
10+
<sch:ns uri="http://csrc.nist.gov/ns/metaschema" prefix="nm"/>
11+
12+
<sch:pattern>
13+
<sch:rule context="m:description">
14+
<sch:assert role="error" test="ends-with(.,'.')" id="description-ends-with-dot">Description should end with a period.</sch:assert>
15+
<sch:assert role="error" test="string-length(.) gt 6" id="description-long-enough">Description is too short.</sch:assert>
16+
</sch:rule>
17+
</sch:pattern>
18+
</sch:schema>

0 commit comments

Comments
 (0)