Schematron pattern not returning error; unsure why
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 14
- Joined: Fri Nov 01, 2013 8:16 pm
Schematron pattern not returning error; unsure why
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
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Schematron pattern not returning error; unsure why
Hi Miriam,
I checked adding in a DITA topic this image element:
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:
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/shari ... rules.html
What exactly did you do on your side to associate the Schematron with the topic?
Regards,
Radu
I checked adding in a DITA topic this image element:
Code: Select all
<image id="image_qsw_mx5_r1b" href="a.png"/>
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>
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/shari ... 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
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 14
- Joined: Fri Nov 01, 2013 8:16 pm
Re: Schematron pattern not returning error; unsure why
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
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)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service