Problem in xml import: how to exclude a tag and word combination from translation?

Hi,

I have several xml files from a customer where there are some lines with these entries that need to be excluded from translation: <baugrup>Einbauorte</baugrup>

I know how to exclude these segments from import with a custom xml filter, but the problem is that I can't do that because there might be different content within those tags that needs to be translated. So how can I exclude that exact tag+text combination from the import or block it after import? If I import everything in the editor the tags don't display, so I can't filter by them.

  • Probably many ways to tackle this... so here's just one.  Take this example:

    XML code snippet with root element containing four 'baugrup' tags, two of which are marked for translation as segment #1 and #2.

    I only want to extract two segments as noted so I use a rule like this:

    //baugrup[not(contains(text(), 'Einbauorte'))]

    Trados Studio rule configuration window showing a search rule to exclude text containing 'Einbauorte' from translation.

    Gets me this:

    Trados Studio preview window displaying two segments marked 'Translate this as segment #1' and 'Translate this as segment #2' for translation.

    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: Trados AI at 1:52 AM (GMT 0) on 29 Feb 2024]
  • In fact this would be better:

    //baugrup[not(text()='Einbauorte')]

    Just in case you have 'Einbauorte' in a longer sentence!

    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

  • Hi Paul,

    Thank you for your tips. I must be missing something, because I cannot get it to work... I've edited the file type just like you mentioned, but the segment is still getting imported and translated. What am I doing wrong?

    Trados Studio screenshot showing the File Types settings with a highlighted error in the Parser rule for 'baugrupnot(text())=Einbaute' indicating a potential issue with the file type configuration.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 2:54 PM (GMT 0) on 1 Mar 2024]
  • Try creating your filetype exactly as I did and don't just import all these rules without any attempt to define them correctly.  Then define the rules properly so you only focus on what you need.  If you simply import the file to create your rules you will rarely achieve what you need unless the file is really simple.  For example, on the basis of your screenshot you probably only need these:

    titel

    gessamttitel

    modell... maybe?

    baugrup

    So possibly just these four rules and one to block everything else.

    I also wonder why you are surprised that this was extracted?

    Screenshot of Trados Studio showing an error with the XML tag 'baugrup' containing the text 'teste' highlighted in red.

    You asked for this:

    there are some lines with these entries that need to be excluded from translation: <baugrup>Einbauorte</baugrup>
    So how can I exclude that exact tag+text combination from the import or block it after import?

    "teste" does not equal "Einbauorte".

    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: Trados AI at 1:52 AM (GMT 0) on 29 Feb 2024]
  • Thank you, Paul.

    What I want is for that segment to not be imported at all, because it should never be translated. That was just a test to see if it would get translated and indeed it was.

    I'll try recreating the filetype from scratch, although I will have to learn Xpath first. Any good online resources for that?

  • What I want is for that segment to not be imported at all, because it should never be translated. That was just a test to see if it would get translated and indeed it was.

    But you used this rule:

    //baugrup[not(text()='Einbauorte')]

    For your test it looks like you should have used this:

    //baugrup[not(text()='teste')]

    You asked for a rule to exclude that exact tag+text combination and then you tested with a different text :-|

    To learn Xpath... this might be a good place to start:

    https://www.w3schools.com/xml/xpath_intro.asp

    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

  • Oh sorry, I should have explained better: the screenshot I posted before is from the target file, after importing the original file with the //baugrup[not(text()='Einbauorte')] rule and doing some mockup translation. 

    I'll look into that xpath link, thank you!

  • In this case the problem is not the Xpath.  It's your preparation of the filetype.  If you send me your actual test file I'll create it for you so you can see the difference.

    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

  • Thank you very much for the offer, but unfortunately I can't send the original file because it's confidential. I'm going to try to create the filetype from scratch without importing any rules, I just have one last question regarding what you said earlier:

    "So possibly just these four rules and one to block everything else."

    What would be the rule to block everything else?

  • Trados Studio screenshot showing the Options menu with an arrow pointing to the 'Parser' section, which has an error message 'Not translatable' next to a rule.

    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: Trados AI at 1:52 AM (GMT 0) on 29 Feb 2024]