Space in front of slash of self-closing tag

I'm translating an XML file with self-closing tags using a custom XML2 filet type.

For example:

<decvar/>

<displayfeedback linkrefid="0"/>

When I generate my output, Trados Studio adds a space in front of the slash of self-closing tags.

For example:

<decvar />

<displayfeedback linkrefid="0" />

This space is breaking the import in the native application.

The workaround is to manually fix it by find and replace, but it's tedious. Is there a setting in Trados Studio I can tweak to avoid the space?

  • There is an item in the XML2 File Type settings called 'Whitespaces'. Probably you should select 'Always preserve' (but I'm not sure if it helps though).

  • ,

    The question of slash versus no slash is dealt with here: https://stackoverflow.com/questions/462741/space-before-closing-slash

    I'd mighty odd that an application should stumble over the space, but you could use CleanUp Task to modify the target file:

    Search: \s\/>

    Replace: />

    (with Regex)

    Then you could make a custom "Finalize" batch task to get it all done in one click.

    Or you just do it in EditPad Pro or Notepad++ with search and replace - you can generate a macro in both of them easily.

    Daniel

  • Hi and @daniel,

    Thanks for the contributions!

    Firstly, I fully agree that the client's application should be more robust and mature enough to handle the space. I politely told them that, but they don't improve their application. I'm not in a position to insist (you know, don't bite the hand that feeds you...)

    The whitespace settings of the file types don't seem to do anything... Looking at the docs, I think it's about replacing whitespaces in XML elements by one single space.

    I found the same stackoverflow article, and I also used a manual find&replace as a workaround. However, the files come in daily batches, with a complicated folder structure. I want to avoid any manual effort, because it's silly work and error prone. I liked the idea of a CleanUp batch task (added to a batch task sequence), but again, all 4 colleagues need to remember to pick the right one for this specific customer.

    Luckily, there's a weird solution: The XML2 file types add the space, but the old XML 1.3 (Embedded content) do not... So, I had to recreate the XML file type in the old flavour, which seems to work fine!