How to set an XML comment either as segment separator or inline element

Hi there,

let's assume that I've got this XML text:

<test>
<text>This is<!-- comment in segment--> test text.</text>
</test>

How can set in the XML2 parser, if the XML comment works as a segment separator (like a structure element) or as an inline tag? Can this be set via an XPATH definition?

Thank in advance!

Best regards,

Bodo

emoji
Parents
  • "Probability score": 0.8

    "Question improvement suggestion": Please provide the version of Trados Studio you are using and any error messages you may have encountered. Also, it would be helpful to know if you have tried any troubleshooting steps already.

    In the meantime, based on the information you have provided, here is a suggested answer to your question:

    Hello Bodo,

    To set an XML comment as a segment separator or inline element in Trados Studio, you can follow these steps:

    Step 1: Open Trados Studio and go to the "File Types" settings.

    Step 2: Select the XML file type you are working with.

    Step 3: Go to the "Parser Rules" section.

    Step 4: Here, you can define how Trados Studio should handle XML comments. If you want the XML comment to act as a segment separator, you can add it as a "Structure" element. If you want it to be an inline tag, you can add it as an "Inline" element.

    Step 5: To add a new rule, click on the "New" button and enter the XPath expression for the XML comment. The XPath for an XML comment is typically "//comment()".

    Please note that the exact steps may vary depending on the version of Trados Studio you are using.

    I hope this answer addressed your question. If not, please reject the answer, add the question improvement suggestion information, and click the RWS Community AI checkbox on the right to try again.

    RWS Community AI

    emoji
  • I've tried to use //comment(), comment() and /test/text/comment() as XPATH, this doesn't work.

    emoji
  •  

    Do you want to do this to be able to translate it or just manage it in some way?  I ask because comments in XML are not normally intended for translation as they are intended to be processing instructions.  They're usually meant for developers, translators, or systems as notes, explanations, or debugging hints.  The XML specification also clarifies this point stating the following:

    "An XML processor MAY, but need not, make it possible for an application to retrieve the text of comments."

    Trados Studio has taken the approach not to extract the comments for translation.  So if you want to extract for translation you'd have to do some pre-processing and content the comment markup into proper tags so you can expose the content for translation, then post process to remove them and add the comment markup back again.

    If you just want to be able to see them you can hover over the comments as they are "tagged" as a placeholder automatically by the XML filetype:

    Or... you could even use a stylesheet to show them in the preview:

    Screenshot of Trados Studio interface displaying a translation grid on the left and an XML preview on the right. The XML comment is visible as 'Comment: comment in segment' in the preview.

    Here's a couple of files to test in case it's helpful: xml_xsl.zip

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji


    Generated Image Alt-Text
    [edited by: RWS Community AI at 8:00 PM (GMT 1) on 2 May 2025]
Reply
  •  

    Do you want to do this to be able to translate it or just manage it in some way?  I ask because comments in XML are not normally intended for translation as they are intended to be processing instructions.  They're usually meant for developers, translators, or systems as notes, explanations, or debugging hints.  The XML specification also clarifies this point stating the following:

    "An XML processor MAY, but need not, make it possible for an application to retrieve the text of comments."

    Trados Studio has taken the approach not to extract the comments for translation.  So if you want to extract for translation you'd have to do some pre-processing and content the comment markup into proper tags so you can expose the content for translation, then post process to remove them and add the comment markup back again.

    If you just want to be able to see them you can hover over the comments as they are "tagged" as a placeholder automatically by the XML filetype:

    Or... you could even use a stylesheet to show them in the preview:

    Screenshot of Trados Studio interface displaying a translation grid on the left and an XML preview on the right. The XML comment is visible as 'Comment: comment in segment' in the preview.

    Here's a couple of files to test in case it's helpful: xml_xsl.zip

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji


    Generated Image Alt-Text
    [edited by: RWS Community AI at 8:00 PM (GMT 1) on 2 May 2025]
Children