Schematron pattern not returning error; unsure why

Miriam
Posts: 14

Schematron pattern not returning error; unsure why

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
Radu
Posts: 5757

Re: Schematron pattern not returning error; unsure why

Fri Jul 28, 2017 8:20 am

Hi Miriam,

I checked adding in a DITA topic this image element:

Code: Select all

<image id="image_qsw_mx5_r1b" href="a.png"/>


and then I opened the Schematron schema used by default for DITA validation by Oxygen:

OXYGEN_INSTALL_DIR\frameworks\dita\resources\dita-1.2-for-xslt2-mandatory.sch

added the pattern to it:

Code: Select all

    <pattern id="checkforaltelement">
        <rule context="image">
            <assert test="alt" >
                An image requires a child alt element</assert>
        </rule>
    </pattern>


went back and manually validated the DITA topic and the image was highlighted with an error marker.
So it works for me. It's probably something on your side causing the Schematron not to be applied on the topic.
On the Oxygen XML blog there is a recommendation about sharing Schematron rules:

http://blog.oxygenxml.com/2017/02/sharing-schematron-validation-rules.html

What exactly did you do on your side to associate the Schematron with the topic?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Miriam
Posts: 14

Re: Schematron pattern not returning error; unsure why

Fri Jul 28, 2017 10:04 pm

Hi Radu,

The culprit turned out to be a duplicate copy of my schema that I didn't know was in my framework file. With your confirmation that my code was correct, I went through the steps for extending the framework again and found the errant file. When I deleted it and reconfigured my settings, my schema worked. I added the quick fix component and that also worked.

Miriam

Return to “DITA (Editing and Publishing DITA Content)”

Who is online

Users browsing this forum: No registered users and 1 guest