Schematron pattern not returning error; unsure why
Posted: Fri Jul 28, 2017 12:29 am
I'm working on developing custom rules for my team with Schematron. I'm trying to start off with a simple--but relevant--rule. I followed oXygen's help to create a custom framework and add my custom schema. I have confirmed that I did this successfully and my schema is applied to validation.
However, I am not getting my error reported. I've tried several versions of my rule.
For a test file with this image element: <image placement="inline" class="- topic/image " />
Version #1:
<pattern id="checkforaltelement">
<rule context="image">
<assert test="alt" >
An image requires a child alt element</assert>
</rule>
</pattern>
Version #2:
<pattern id="checkforaltelement">
<rule context="*[contains(@class, ' topic/image ')]">
<assert test="alt" >
An image requires a child alt element</assert>
</rule>
</pattern>
And my goal is to get to the point with an sqf:fix that is similar to the following:
<pattern id="checkforaltelement">
<rule context="image">
<assert test="alt" role="error" sqf:fix="addaltelement">
An image requires a child alt element</assert>
<sqf:fix id="addaltelement">
<sqf:description>
<sqf:title>Add required alt element</sqf:title>
</sqf:description>
<sqf:add node-type="element" target="image" position="first-child"/>
</sqf:fix>
</rule>
</pattern>
I'm at my wit's end because all training materials I've double checked have indicated that Version #1 should have worked. I checked oXygen's examples of your schematron rules, which is why I tried Version #2 instead (I noticed yours were always using the class attribute), but then that didn't work either.
Thank you for any help,
Miriam
However, I am not getting my error reported. I've tried several versions of my rule.
For a test file with this image element: <image placement="inline" class="- topic/image " />
Version #1:
<pattern id="checkforaltelement">
<rule context="image">
<assert test="alt" >
An image requires a child alt element</assert>
</rule>
</pattern>
Version #2:
<pattern id="checkforaltelement">
<rule context="*[contains(@class, ' topic/image ')]">
<assert test="alt" >
An image requires a child alt element</assert>
</rule>
</pattern>
And my goal is to get to the point with an sqf:fix that is similar to the following:
<pattern id="checkforaltelement">
<rule context="image">
<assert test="alt" role="error" sqf:fix="addaltelement">
An image requires a child alt element</assert>
<sqf:fix id="addaltelement">
<sqf:description>
<sqf:title>Add required alt element</sqf:title>
</sqf:description>
<sqf:add node-type="element" target="image" position="first-child"/>
</sqf:fix>
</rule>
</pattern>
I'm at my wit's end because all training materials I've double checked have indicated that Version #1 should have worked. I checked oXygen's examples of your schematron rules, which is why I tried Version #2 instead (I noticed yours were always using the class attribute), but then that didn't work either.
Thank you for any help,
Miriam