Reserved characters and namespacesCaractères réservés et espaces de noms
Two points of syntax turn up in every interchange file. Recognizing them saves you a headache later, over strange characters in the text or a file that no longer opens the way it should.
Reserved characters
Angle brackets delimit tags: a < in text would be read as the start of a tag.
XML therefore gives it a replacement spelling, and gives the ampersand one too,
since every replacement begins with an ampersand:
| In the text | Written in the file |
|---|---|
< | < |
& | & |
>, " and ' have replacement spellings too (>, ", '),
required only in certain contexts; tools often write them anyway.
In practice: a company called Smith & Sons appears in the file as
Smith & Sons, and the translation is written the same way. Do not replace
& with & by hand, you would break the file.
Namespaces
The first tag tagbalise markupbalisage A marker that delimits and identifies an element in a markup document, usually working as a pair: an opening tag and a closing tag around the content they label.Marqueur qui délimite et identifie un élément dans un document balisé, fonctionnant généralement par paire : une balise ouvrante et une balise fermante autour du contenu qu'elles désignent. of an XLIFF XML Localization Interchange File Format (XLIFF)XML Localization Interchange File Format (XLIFF) exchange formatsformats d'échange The XML-based bilingual format for passing content through a localization workflow: source and target segments travel together with workflow metadata such as translation status, rather than exchanging linguistic resources.Format bilingue fondé sur XML pour faire circuler du contenu dans un flux de localisation : segments source et cible voyagent ensemble, avec des métadonnées de flux de travail comme le statut de traduction, contrairement aux formats d'échange de ressources linguistiques. file looks like this:
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.1"
srcLang="en-CA" trgLang="fr-CA">xmlns announces that <unit>, <segment> and the other tags that follow are
XLIFF’s, and not those of some other format using the same names. A document
can declare several namespaces, each marked by a prefix of the form
prefix:tag. This is how a tool adds tags of its own to a standard format
without colliding with it, and it is also a source of trouble in exchange: a
tool that does not know that vocabulary will get nothing out of those tags.
One namespace is declared in advance by the XML standard itself, the one for
the xml prefix. That is why xml:lang appears everywhere with no matching
declaration in the file.
Deux détails de syntaxe reviennent dans tous les fichiers d’échange. Les reconnaître vous évitera bien des ennuis devant des caractères étranges ou un fichier qui ne s’ouvre plus comme il devrait.
Caractères réservés
Les chevrons délimitent les balises : un < dans du texte serait lu comme le
début d’une balise. XML lui prévoit donc une écriture de remplacement, et à
l’esperluette aussi, puisque chaque remplacement commence par une esperluette :
| Dans le texte | S’écrit dans le fichier |
|---|---|
< | < |
& | & |
>, " et ' ont eux aussi une écriture de remplacement (>, ",
'), obligatoire seulement dans certains contextes ; les outils les
écrivent souvent par prudence.
En pratique : une entreprise nommée Smith & Sons apparaît dans le fichier sous
la forme Smith & Sons, et la traduction s’écrit de la même façon. Ne
remplacez pas & par & à la main, vous casseriez le fichier.
Espaces de noms
La première balise tagbalise markupbalisage A marker that delimits and identifies an element in a markup document, usually working as a pair: an opening tag and a closing tag around the content they label.Marqueur qui délimite et identifie un élément dans un document balisé, fonctionnant généralement par paire : une balise ouvrante et une balise fermante autour du contenu qu'elles désignent. d’un fichier XLIFF XML Localization Interchange File Format (XLIFF)XML Localization Interchange File Format (XLIFF) exchange formatsformats d'échange The XML-based bilingual format for passing content through a localization workflow: source and target segments travel together with workflow metadata such as translation status, rather than exchanging linguistic resources.Format bilingue fondé sur XML pour faire circuler du contenu dans un flux de localisation : segments source et cible voyagent ensemble, avec des métadonnées de flux de travail comme le statut de traduction, contrairement aux formats d'échange de ressources linguistiques. ressemble à ceci :
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.1"
srcLang="en-CA" trgLang="fr-CA">xmlns annonce que <unit>, <segment> et les autres balises qui suivent
sont celles de XLIFF, et non celles d’un autre format qui emploierait les mêmes
noms. Un document peut déclarer plusieurs espaces de noms, chacun repéré par un
préfixe de la forme prefixe:balise. C’est ainsi qu’un outil ajoute ses
propres balises à un format normalisé sans entrer en conflit avec lui, et c’est
aussi une source de difficultés à l’échange : un outil qui ne connaît pas ce
vocabulaire ne tirera rien de ces balises.
Un espace de noms est déclaré d’avance par la norme XML elle-même, celui du
préfixe xml. C’est pourquoi xml:lang apparaît partout sans déclaration
correspondante dans le fichier.
Sources
- W3C (2008). Extensible Markup Language (XML) 1.0 (Fifth Edition). W3C Recommendation. https://www.w3.org/TR/xml/
- W3C (2009). Namespaces in XML 1.0 (Third Edition). W3C Recommendation. https://www.w3.org/TR/xml-names/
- OASIS (2025). XLIFF Version 2.2. Organization for the Advancement of Structured Information Standards, Committee Specification 01. https://www.oasis-open.org/standard/xliff-v2-2-cs01/
Sources
- W3C (2008). Extensible Markup Language (XML) 1.0 (Fifth Edition). W3C Recommendation. https://www.w3.org/TR/xml/
- W3C (2009). Namespaces in XML 1.0 (Third Edition). W3C Recommendation. https://www.w3.org/TR/xml-names/
- OASIS (2025). XLIFF Version 2.2. Organization for the Advancement of Structured Information Standards, Committee Specification 01. https://www.oasis-open.org/standard/xliff-v2-2-cs01/