Turn Off Tracked Changes for All Topics Via XSLT Custom Refactoring

Post here questions and problems related to oXygen frameworks/document types.
dreifsnider
Posts: 124
Joined: Thu Aug 30, 2018 10:06 pm

Turn Off Tracked Changes for All Topics Via XSLT Custom Refactoring

Post by dreifsnider »

Hi,

I'm trying to create a new custom refactoring operation that will add one additional step to the out-of-the-box refactoring operation "Accept all tracked changes, remove all comments and highlights".

The one additional step is to also turn off the tracked changes state in the file. I've tried to accomplish this via using the same Xpath syntax to select processing-instructions that exists in the out-of-the-box refactoring operation, for example:

Code: Select all

<xsl:template match="processing-instruction()[starts-with(name(), 'oxy_options')][contains(., 'track_changes=&quot;on&quot;')]"/>   
However, this doesn't actually select the "oxy_options" processing-instruction. Indeed, even a blanket match="processing-instruction()" doesn't even select this processing-instruction. Is this processing-instruction removed from the DOM and is unselectable?

To test, I used Oxygen's XPath/XQuery Builder, and it selects this processing-instruction as expected:
image.png
image.png (45.89 KiB) Viewed 512 times
For context, the reason why I'd also like to remove the track_changes processing-instruction on top of all the other review processing-instructions is because our translation teams report that Trados either has issues with this processing-instruction or that the presence of this processing-instruction adds additional noise to the topic.

Therefore, we'd like a single refactoring operation to remove all tracked changes, comments, and highlights, as well as turn off tracked changes in all topics across a DITA Map.

Thank you!

Daniel
Radu
Posts: 9164
Joined: Fri Jul 09, 2004 5:18 pm

Re: Turn Off Tracked Changes for All Topics Via XSLT Custom Refactoring

Post by Radu »

Hi Daniel,
The XML refactoring XSLT can use some special functions to manipulate the content before and after the root element as this content is not sent directly to the XSLT processor:
https://www.oxygenxml.com/doc/versions/ ... w_custom_r
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dreifsnider
Posts: 124
Joined: Thu Aug 30, 2018 10:06 pm

Re: Turn Off Tracked Changes for All Topics Via XSLT Custom Refactoring

Post by dreifsnider »

Thanks Radu, I was able to use these functions to select the track_changes processing instruction and delete it.

Here's the XSLT that worked for me:

Code: Select all

    <xsl:template match="/">        
        <xsl:variable name="content-after-root" as="xs:string" select="xrf:get-content-after-root()"/>
        <xsl:variable name="content-except-track_change_toggle" as="xs:string">
            <xsl:value-of select="replace($content-after-root, '&lt;\?oxy_options track_changes=&quot;on&quot;\?&gt;', '' )"/>
        </xsl:variable>
        <xsl:value-of select="xrf:set-content-after-root($content-except-track_change_toggle)"/>
        <xsl:apply-templates/>
    </xsl:template>
Daniel
Radu
Posts: 9164
Joined: Fri Jul 09, 2004 5:18 pm

Re: Turn Off Tracked Changes for All Topics Via XSLT Custom Refactoring

Post by Radu »

Hi Daniel,
Great, thanks for posting the solution!
I know it's a bit rough but for most devs making changes before and after the root element is not something usual.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply