How to retrieve original XLIFF fragment for segment while editing?

Hello everyone!

The issue is limited to such projects where the initial document that is to be translated is in XLIFF 1.2 format. All other documents and projects I cannot and do not wish to support.
Trivia: when the original XLIFF document is imported into the project, it is converted to SDLXLIFF.

The issue: the plugin I am working on will have the ability to provide live preview of the translated segment. For that however, I need to be able to submit the translated XLIFF fragment to our service. Since the editor works with the SDLXLIFF, our service cannot "understand" what the user did.

Let me demonstrate the difference through an example. One of the original XLIFF's trans-unit's source:

&quot;Yes, I quite<ph ctype="x-x-html-br" equiv-text="[]" id="_1">&lt;x ctype=&quot;x-html-br&quot; equiv-text=&quot;&quot; id=&quot;_1&quot;/&gt;</ph>
agree.&quot;<ph ctype="x-x-html-br" equiv-text="[]" id="_2">&lt;x ctype=&quot;x-html-br&quot; equiv-text=&quot;&quot; id=&quot;_2&quot;/&gt;</ph>
<ph ctype="x-x-html-br" equiv-text="[]" id="_3">&lt;x ctype=&quot;x-html-br&quot; equiv-text=&quot;&quot; id=&quot;_3&quot;/&gt;</ph>

When I try to access the segment from C#, I get a completely different structure:

"Yes, I quite<ph ctype="x-x-html-br" equiv-text="[]" id="_1">
agree."

 This is how I tried it:

editorController.ActiveDocument.GetActiveSegmentPair().Source.toString();

The problems:

  • 2 `x` tags are missing from the end 
  • I cannot reconstruct the original XLIFF format only from the information extracted from that

What way could I reconstruct the original XLIFF format for the segment "live" - while the translator is editing the segment?

Thanks in advance!