SQF for keydef + topicref attributes

This should cover W3C XML Schema, Relax NG and DTD related problems.
urbanrobots
Posts: 79
Location: San Francisco

SQF for keydef + topicref attributes

Fri Apr 22, 2016 9:01 pm

Hello,

We have two similar rules, one works and one doesn't. Can you help?

This rule works. It highlights the <topicref> element when the @type attribute is specified but doesn't throw a warning otherwise.

Code: Select all

<sch:rule id="attribute_002" context="topicref">
            <sch:report xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
                test="attribute::type = 'concept' or attribute::type = 'task' or attribute::type = 'reference'"
                sqf:fix="removeType" role="warning"
                >attribute_002: This is unnecessary. The DITA Open Toolkit can automatically identify the information type.</sch:report>

            <sqf:fix xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
                id="removeType">
                <sqf:description>
                    <sqf:title>Remove the @type attribute?</sqf:title>
                </sqf:description>
                <sqf:delete match="@type"/>
            </sqf:fix>
            </sch:rule>



This rule does not work. It will always throw a warning on any <keydef> element, even when the element does not have the @processing-role attribute specified.

Code: Select all

 <sch:rule id="attribute_001" context="keydef">
            <sch:report xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
                test="attribute::processing-role ='resource-only'" sqf:fix="removeprocessing-role"
                role="warning"
                see="https://www.oasis-open.org/committees/download.php/40946/understanding-dita-keys-and-key-spaces.pdf"
                >attribute_001: @processing-role = "resource-only" is the default processing for key
                definitions. </sch:report>

            <sqf:fix xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
                id="removeprocessing-role">
                <sqf:description>
                    <sqf:title>Remove the @processing-role attribute?</sqf:title>
                </sqf:description>
                <sqf:delete match="@processing-role"/>
            </sqf:fix>
        </sch:rule>



Suggestions?

Also, we notice that sometimes the schematron rules only work when we add the processing instruction to associate the schema on the specific file, like this:

Code: Select all

<?xml-model href="../../../../documentation/documents/schematron_rules.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>


But we would prefer to associate the schema to all files in the Preferences > Document Type Association configuration.

Thanks for your help.

Take care,
- Nick
tavy
Posts: 122

Re: SQF for keydef + topicref attributes

Tue Apr 26, 2016 9:56 am

Hello Nick,

The assert for the "keydef/@processing-role" attribute does not work because the default value for the "processing-role" attribute is "resource-only". When the XML is validated against Schematron you cannot determine if the attribute is set in document or is just the default value from the schema. This is why after the attribute is removed from document the assert still fails because it gets the default attribute value from the schema.

There is a discussion on our forum related with this, but we do not have a solution yet:
topic11639.html

We have an issue on our issue tracker. I added your comment there and we will notify you when this issue will be solved.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
urbanrobots
Posts: 79
Location: San Francisco

Re: SQF for keydef + topicref attributes

Thu Apr 28, 2016 12:33 am

Okay. Thanks, Octavian.

Take care,
- Nick
Radu
Posts: 5094

Re: SQF for keydef + topicref attributes

Mon Oct 02, 2017 4:04 pm

Hi,

Starting with Oxygen 19.1, by default Schematron applied on XML Schema based XML documents will also take into account default attributes so this should be useful when adding rules for DITA-based validation.

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

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests