-
Notifications
You must be signed in to change notification settings - Fork 31
Testing Schematron with Attributes
This page pertains to XSpec v2.3.2 and earlier. When using v3.0.3 and later, you will not see the failures in the example below and do not need a workaround.
Suppose you have this Schematron schema containing <sch:rule context="@media-type">
:
test.sch
<sch:schema queryBinding="xslt2" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
<sch:pattern>
<sch:rule context="@media-type">
<sch:assert test=". = 'text/plain'">A media-type attribute must be an allowed value.</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
And suppose you test it with this XSpec:
test.xspec
<x:description schematron="test.sch" xmlns:x="http://www.jenitennison.com/xslt/xspec">
<x:scenario label="when a media-type attribute is not an allowed value">
<x:context>
<rlink media-type="image/png" />
</x:context>
<x:expect-assert label="that should raise an assertion failure" />
</x:scenario>
</x:description>
The test fails:
C:\test>xspec.bat -s test.xspec
...
when a media-type attribute is not an allowed value
that should raise an assertion failure assert
FAILED
...
passed: 0 / pending: 0 / failed: 1 / total: 1
It fails, because the skeleton Schematron implementation bundled into XSpec fails to visit attributes in this case:
- Attribute optimization bug
- Bug related to attributes
- attribute nodes in context of schematron rule
- When using XSLT 2, Schematron ignores rules that have attributes in their context
To make sch:rule
work with attributes, you have to either rewrite your @context
or fix the skeleton Schematron implementation privately. See a StackOverflow answer. Unfortunately, the development of the skeleton Schematron implementation has been ceased and there is virtually no hope of its official fixes.
Alternatively, use another implementation of Schematron, following instructions in Using SchXslt with XSpec v2.3.2 and earlier.
If you have any questions about XSpec or want to discuss, contribute, and share information with the XSpec community, please go to our issue tracker.
For historical searches, the Google group might also be useful.
- Writing Scenarios
- Nesting Scenarios
- Focusing Your Efforts
- Global Context Item
- Selecting Nodes
- Whitespace-only Text Nodes
- Attribute Value Templates
- Text Value Templates
- Special Names
- Code Coverage
- XML Catalog Support
- Environment Variables
- Testing Dynamic Errors
- Integrating Your Own Test Helpers
- External Transformation
- Getting Started with XSpec and Schematron
- Writing Scenarios for Schematron
- Testing Schematron with Text Nodes
- Testing Schematron with Attributes
- Using Another Implementation of Schematron