Page 1 of 1

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

Posted: Tue Jul 25, 2017 2:00 am
by raybiss
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

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

Posted: Tue Jul 25, 2017 11:06 am
by tavy
Hello,

Thank you for the feedback.
It seems that we do not compute the context node correctly in this case. The context node 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

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

Posted: Mon Mar 19, 2018 12:51 pm
by tavy
Hello Raymond,

We just released <oXygen/> XML Editor version 20. Please note that the issue that you reported regarding the sqf:replace operation was solved.

You can download the build from here:
https://www.oxygenxml.com/xml_editor/do ... ditor.html

Thanks again for your feedback.

Best Regards,
Octavian