Hi,
It has something to do with the rules matching on an attribute. I've
modified a bit the Schematron file to match on the element that contains
that attribute and the tests pass. I've attached these changed resources
(actually just /media-type.sch/ is changed).
I'm not sure why it behaves like that. I've reproduced the issue with
the command line XSpec 2.1.4 latest release. I recommend asking a
question in an issue on the XSpec GitHub project [1] or on the email
address xspec-us...@googlegroups.com . I'm sure the project maintainers
will know the cause and give you a recommendation.
[1] https://github.com/xspec/xspec/issues
Best regards,
Alex
--
Alex Jitianu
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
On 7/2/2021 11:28 PM, Gary Gapinski wrote:
Hello, all:
I have found creation of XSPec unit tests for Schematron assertions a
bit puzzling. I frequently manage to create Schematron which works
correctly for instance document validation but related XSpec scenarios
produce incorrect results. I may be repeatedly doing something
erroneous but have yet to determine what.
I am using <oXygen/> XML Editor 23.1, build 2021061407 which includes
an XSpec 1.6.0 framework.
An exemplar of my problem can be seen at
https://github.com/18F/fedramp-automation/commit/d023c719754ee5ed14dfc8a8991fbfafb82ff18b.
The Schematron (media-type.sch) works correctly with an instance
document (media-type.xml) but both XSpec scenarios (in
media-type.xspec) fail when the inbuilt "Run XSpec Test" translation
scenario is used.
Any and all suggestions are welcome.
Best regards,
Gary
--
Gary Gapinski's contact information
Gary Gapinski
℡ +1 216 820 1849 <tel:+1-216-820-1849>
℡ g...@garygapinski.com <sip:g...@garygapinski.com>
✉ g...@garygapinski.com <mailto:g...@garygapinski.com>
_______________________________________________
oXygen-user mailing list
oXygen-user@oxygenxml.com
https://www.oxygenxml.com/mailman/listinfo/oxygen-user
<?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>
<?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>
<?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>
<?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="@media-type = $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(.)" /> has a media-type=" <sch:value-of
select="@media-type" />" 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>
_______________________________________________
oXygen-user mailing list
oXygen-user@oxygenxml.com
https://www.oxygenxml.com/mailman/listinfo/oxygen-user