deepl-python icon indicating copy to clipboard operation
deepl-python copied to clipboard

XML translation - Doctype statement turns < and > characters into entity characters

Open matsbert opened this issue 3 months ago • 1 comments

When translating XML documents, the doctype statement is not properly handled. The less than and greater than characters surrounding the DOCTYPE statement are being converted to entities:

Before translation:

<!ENTITY ICN-S1000DBIKE-AAA-D000000-0-U8025-00536-A-04-1 SYSTEM "ICN-S1000DBIKE-AAA-D000000-0-U8025-00536-A-04-1.CGM" NDATA cgm >

]>

After translation:

<!DOCTYPE dmodule[

<!ENTITY ICN-S1000DBIKE-AAA-D000000-0-U8025-00536-A-04-1 SYSTEM "ICN-S1000DBIKE-AAA-D000000-0-U8025-00536-A-04-1.CGM" NDATA cgm > ]&gt;

Code:

result = deepl_client.translate_text(
    text,
    tag_handling="xml",
    source_lang="SV",
    target_lang="EN-GB",
    model_type="prefer_quality_optimized",
    non_splitting_tags="div",
    split_sentences="nonewlines"
)

I have heard that DeepL is working on improving the tag handling, is there an expected timeframe for this?

Any settings that could help improve this situation?

matsbert avatar Sep 01 '25 11:09 matsbert

Image

Added image to better illustrate the translated text.

matsbert avatar Sep 01 '25 11:09 matsbert