schematron replace-curly-doublequotes

Questions about XML that are not covered by the other forums should go here.
Posts: 37
Joined: Fri Feb 28, 2020 4:02 pm

schematron replace-curly-doublequotes

Post by vishwavaranasi » Tue Sep 01, 2020 3:27 pm

Hello team , we have implemented a schematron rule for replacing curly double quotes.

<sch:pattern id="isTopicContainsCurlyDoubleQuotes">
<sch:rule context="/*[contains(@class, ' topic/topic ')]">
<sch:let name="text" value="normalize-space(.)"/>
<sch:report test=".//text()[contains(., '&#x201C;')]" role="error" sqf:fix="replace-curly-doublequotes">Replace curly double
quotes ” with &lt;q&gt; your text goes here &lt;/q&gt; . </sch:report>
<sqf:fix id="replace-curly-doublequotes">
<sqf:title>Replace curly double quotes</sqf:title>
<!-- <sqf:stringReplace match="//text()[contains(., '&#x201D;')]" regex="&#x201D;" select="</q>"/>
<sqf:stringReplace match="//text()[contains(., '&#x201C;')]" regex="&#x201C;" select="<q>"/> -->
<sqf:stringReplace match="//text()[contains(., '&#x201D;')]" regex="&#x201D;" select=" '&lt;/q&gt;' "/>
<sqf:stringReplace match="//text()[contains(., '&#x201C;')]" regex="&#x201C;" select=" '&lt;q&gt;' "/>

the <sqf:fix> for example it replaces
“test1 test2 - Success” to <q>test1 test2 - Success</q>

in author mode it's treating like a normal text only <q>test1 test2 - Success</q>
image.png (3.31 KiB) Viewed 549 times
would you pleas help me here?

Posts: 284
Joined: Thu Jul 01, 2004 12:29 pm

Re: schematron replace-curly-doublequotes

Post by tavy » Wed Sep 02, 2020 4:44 pm


In Author mode we automatically render "&lt;" with "<", and "&gt;" with ">". But if you switch to Text page you will notice that is correct, based on your replace.
How do you want the result to bein text, like this " &lt;q&gt;test1 test2 - Success&lt;/q&gt;" or like this " <q>test1 test2 - Success</q>"?

Best Regards,
Octavian Nadolu
<oXygen/> XML Editor

Post Reply