This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
forked from GSA/fedramp-automation
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add XSpec problem definition example documents
- Loading branch information
1 parent
b55dade
commit d023c71
Showing
4 changed files
with
143 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,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema | ||
queryBinding="xslt2" | ||
xmlns:sch="http://purl.oclc.org/dsdl/schematron" | ||
xmlns:sqf="http://www.schematron-quickfix.com/validator/process"> | ||
<!-- evaluate a media-type attribute for allowed values --> | ||
<sch:pattern> | ||
<sch:rule | ||
context="@media-type" | ||
role="error"> | ||
<sch:let | ||
name="media-types-url" | ||
value="'media-types.xml'" /> | ||
<sch:assert | ||
test="doc-available($media-types-url)">media-types document is available.</sch:assert> | ||
<sch:let | ||
name="media-types" | ||
value="doc($media-types-url)" /> | ||
<sch:let | ||
name="media-types" | ||
value="$media-types//value-set[@name = 'media-type']//enum/@value" /> | ||
<sch:assert | ||
test="count($media-types) > 1">media-types have been correctly obtained.</sch:assert> | ||
<sch:assert | ||
diagnostics="has-allowed-media-type-diagnostic" | ||
id="has-allowed-media-type" | ||
role="error" | ||
test="current() = $media-types">A media-type attribute must have an allowed value.</sch:assert> | ||
</sch:rule> | ||
</sch:pattern> | ||
<sch:diagnostics> | ||
<sch:diagnostic | ||
id="has-allowed-media-type-diagnostic">This <sch:value-of | ||
select="name(parent::node())" /> has a media-type=" <sch:value-of | ||
select="current()" />" which is not in the list of allowed media types. Allowed media types are <sch:value-of | ||
select="string-join($media-types, ' ∨ ')" />.</sch:diagnostic> | ||
</sch:diagnostics> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-model href="file:media-type.sch" schematypens="http://purl.oclc.org/dsdl/schematron" ?> | ||
<!-- This is an instance document for testing media-types.sch --> | ||
<stuff> | ||
<rlink | ||
media-type="text/plain" /> | ||
<rlink | ||
media-type="text/text" /> | ||
</stuff> |
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,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- This XSpec document is unit tests for media-type.sch --> | ||
<x:description | ||
schematron="media-type.sch" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec"> | ||
<x:scenario | ||
label="when a media-type attribute"> | ||
<x:scenario | ||
label="has an allowed value"> | ||
<x:context> | ||
<rlink | ||
media-type="text/plain" /> | ||
</x:context> | ||
<x:expect-not-assert | ||
id="has-allowed-media-type" | ||
label="that is correct" /> | ||
</x:scenario> | ||
<x:scenario | ||
label="lacks an allowed value"> | ||
<x:context> | ||
<rlink | ||
media-type="text/text" /> | ||
</x:context> | ||
<x:expect-assert | ||
id="has-allowed-media-type" | ||
label="that is an error" /> | ||
</x:scenario> | ||
</x:scenario> | ||
</x:description> |
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,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- This is a companion document to media-types.sch --> | ||
<value-sets> | ||
<value-set | ||
name="media-type"> | ||
<formal-name>Resource Media Types</formal-name> | ||
<description>A subset of IANA media types expected to be encountered.</description> | ||
<binding | ||
pattern="rlink/@media-type" /> | ||
<binding | ||
pattern="base64/@media-type" /> | ||
<allowed-values> | ||
<enum | ||
value="application/gzip">application/gzip</enum> | ||
<enum | ||
value="application/msword">application/msword</enum> | ||
<enum | ||
value="application/octet-stream">application/octet-stream<!-- (NOTE: Used for a variety of binary formats, often ZIP archives.) --></enum> | ||
<enum | ||
value="application/pdf">application/pdf</enum> | ||
<enum | ||
value="application/vnd.ms-excel">application/vnd.ms-excel</enum> | ||
<enum | ||
value="application/vnd.ms-works">application/vnd.ms-works</enum> | ||
<enum | ||
value="application/vnd.oasis.opendocument.graphics">application/vnd.oasis.opendocument.graphics</enum> | ||
<enum | ||
value="application/vnd.oasis.opendocument.presentation">application/vnd.oasis.opendocument.presentation</enum> | ||
<enum | ||
value="application/vnd.oasis.opendocument.spreadsheet">application/vnd.oasis.opendocument.spreadsheet</enum> | ||
<enum | ||
value="application/vnd.oasis.opendocument.text">application/vnd.oasis.opendocument.text</enum> | ||
<enum | ||
value="application/vnd.openxmlformats-officedocument.presentationml.presentation">application/vnd.openxmlformats-officedocument.presentationml.presentation</enum> | ||
<enum | ||
value="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</enum> | ||
<enum | ||
value="application/vnd.openxmlformats-officedocument.wordprocessingml.document">application/vnd.openxmlformats-officedocument.wordprocessingml.document</enum> | ||
<enum | ||
value="application/x-bzip">application/x-bzip</enum> | ||
<enum | ||
value="application/x-bzip2">application/x-bzip2</enum> | ||
<enum | ||
value="application/x-tar">application/x-tar</enum> | ||
<enum | ||
value="application/zip">application/zip</enum> | ||
<enum | ||
value="image/bmp">image/bmp</enum> | ||
<enum | ||
value="image/jpeg">image/jpeg<!-- (NOTE: Not standard, but very frequently used)--></enum> | ||
<enum | ||
value="image/png">image/png</enum> | ||
<enum | ||
value="image/tiff">image/tiff</enum> | ||
<enum | ||
value="image/webp">image/webp</enum> | ||
<enum | ||
value="image/svg+xml">image/svg+xml</enum> | ||
<enum | ||
value="text/csv">text/csv</enum> | ||
<enum | ||
value="text/html">text/html</enum> | ||
<enum | ||
value="text/plain">text/plain</enum> | ||
</allowed-values> | ||
</value-set> | ||
</value-sets> |
d023c71
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an XSpec bug but a bug of the skeleton Schematron implementation:
Unfortunately the development of the skeleton Schematron implementation has been ceased and there is virtually no hope of its fix.
Note that the skeleton Schematron implementation has other quirks and bugs that have never been fixed.
A longer-term solution would be to switch to SchXslt as mentioned in Schematron/schematron#89. XSpec v2.1.2 and onwards are fully tested with SchXslt. SchXslt may have its own quirks but it is maintained actively. See Using another implementation of Schematron for how to use SchXslt with XSpec.