Wrapping text() with a Quick Fix not working as expected. Why?

raybiss
Posts: 3

Wrapping text() with a Quick Fix not working as expected. Why?

Tue Jul 25, 2017 2:00 am

Hi,

The following Quick Fix does wrap the text() in a paragraph but puts it as a next sibling to the section.

How could I fix this? I've tried many variations all afternoon but nothing worked! Using Oxygen 18.

Code: Select all

        <rule context="*[contains(@class, ' topic/section ')]/text()[string-length(normalize-space(.)) > 0]">
            <report test="true()" role="warn" subject="child::node()[1]" sqf:fix="wrapInParagraph">
                The text in a section element should be in a paragraph.</report>
           
            <!-- Wrap the current element in a paragraph. -->
            <sqf:fix id="wrapInParagraph">
                <sqf:description>
                    <sqf:title>Wrap text in a paragraph</sqf:title>
                </sqf:description>
                <sqf:replace node-type="element" target="p">
                    <xsl:apply-templates mode="copyExceptClass" select="."/>
                </sqf:replace>
                <sqf:delete/>
            </sqf:fix>
        </rule>


TIA,
Raymond
tavy
Posts: 123

Re: Wrapping text() with a Quick Fix not working as expected. Why?

Tue Jul 25, 2017 11:06 am

Hello,

Thank you for the feedback.
It seems that we do not compute the context node correctly in this case. The context code for the insert element operation should be the text node and the quick fix must insert the element after the text node, not after the section. I added an issue on out issue tracker to analyze this situation.
As an workaround you can replace the text node with a fragment that contains the text. The Schematron can be something like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
    xmlns:sqf="http://www.schematron-quickfix.com/validator/process" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <sch:pattern>
     <sch:rule context="*[contains(@class, ' topic/section ')]/text()[string-length(normalize-space(.)) > 0]">
         <sch:report test="true()" role="warn" subject="child::node()[1]" sqf:fix="wrapInParagraph">
             The text '<sch:value-of select="."/>' from section element should be in a paragraph.</sch:report>
         
         <!-- Wrap the current element in a paragraph. -->
         <sqf:fix id="wrapInParagraph">
             <sqf:description>
                 <sqf:title>Wrap text '<sch:value-of select="."/>' in a paragraph</sqf:title>
             </sqf:description>
             <sqf:replace>
                 <p>
                     <xsl:value-of select="."/>
                 </p>
             </sqf:replace>
         </sqf:fix>
     </sch:rule>
 </sch:pattern>   
</sch:schema>



Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

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

Who is online

Users browsing this forum: Bing [Bot] and 2 guests