Page 1 of 1

Schematron test does not work as expected

Posted: Mon Feb 04, 2019 6:06 pm
by susannecm
I am trying to set up some Schematron tests for our DITA documentation, and I am new to Schematron.
I want the validation to report an error for draft-comment elements whose translation attribute has not been explicitly set to no.
This is my pattern:

Code: Select all

    <pattern id="not_excluded_from_translation">
<rule context="draft-comment">
<assert test="@translate='no'">attribute translate must be set to no for draft-comment element</assert>
</rule>
</pattern>
The pattern works as expected if my DITA topic contains the translate attribute with a value of yes or no.
However, if the translate attribute is not set at all, nothing is reported. I would expect an error or warning in this case.
Is this error or warning not issued because no is the default value according to the DITA specification?
Our translation tool is not aware of these default values.

Thank you for any help
Susanne

Re: Schematron test does not work as expected

Posted: Tue Feb 05, 2019 9:28 am
by Radu
Hi Susanne,

I placed the caret inside a "draft-comment" element in the Author visual editing mode, looked at the "Attributes" view and indeed it seems that the DTD explicitly sets the default value for @translate to "no" in case of draft comments.
When Schematron rules are applied by Oxygen over the XML document, the associated DTD information is taken into account and in the Schematron file it's impossible to know later on if the attribute @translate="no" was actually set on the element or if it's a default value coming from the DTDs.
There is no setting to avoid expanding default attribute values specified in the DTDs when the Schematron checks are applied in Oxygen, in a way these default attribute values are usually useful with DITA because you can have your validation rules match elements by @class name.

A possible workaround, go to the Oxygen main menu Tools->XML Refactoring and there is an "Add/change attribute" pre-defined operation. Refactoring operation are not aware of default attribute values so you can use this operation to add the translate='no' attribute on all draft comments in your project before sending it for translation. It's not the same thing as flagging this as a validation error while editing though.
Or when you prepare the DITA content for translation, use the same refactoring actions to remove all draft comments (or even all elements with translate='no') from the DITA content.

Regards,
Radu

Re: Schematron test does not work as expected

Posted: Tue Feb 05, 2019 6:04 pm
by susannecm
Thank you for the quick help
Susanne