Creating an XML file type XML-Letter - example
We will create an XML file type, XML-Letter, which the SDL file type software will apply to *.xml files that have a specified root element (<letter>). An example of a file of this file type is example-xml-file-letter.xml (in the zip archive example-xml-files.zip). For the purposes of the example, we create the file type in the default project template.
About this task
| XML Element | Translatable | Notes |
|---|---|---|
<letter> | No | This is the root element and represents the letter structure. |
<title maxlength="50"> | Yes | These elements have been inserted to show how you can handle sections of text that have length restrictions. |
<title maxlength="40"> | Yes | "Dear Daniel " should be translated. |
<salutation> | Yes | |
<text> | Yes | The body of the letter should be translated. |
<component translate="yes"> | Yes | These elements have been inserted to show how you can handle sections of text that have been tagged translatable or not translatable. |
<component translate="no"> | No | The emphasis tag changes the format of the text but the text should still be translated. |
<emphasis> | Yes | |
<signature> | No | We do not translate a person's name or address. |
<address> | No | We do not alter the web address. |
<weblink> | No | |
<logo alt> | Yes | The logo alt text should be in the local language. Alt is an attribute, so in the parser rule specify Rule type as Attribute. Whenever you specify a parser rule of type Attribute, the attribute's translate property is set to Always translate, which is what we want. |
<logo address> | No | We do not change the web address. Do not add a parser rule. (By default, the translate property for attributes is not translatable, which is what we want.) |
Procedure
Example - the Parser Rules Used in XML-Letter
About this task
The parser rules define how the XML-letter file type is handled by the file type support software.
Example - Setting Format Properties for XML-Letter
About this task
An example of creating a parser rule to format text inside a tag pair when the document is opened in the Editor. We use the example file type XML-Letter, and the file example-xml-file-letter.xml. The tag pair is <emphasis>...</emphasis>.
Example - Restricting Element Length in XML
About this task
You can set length restrictions on elements and translatable attributes. This topic shows how to set length restriction for the <title> element of file type XML-Letter, using the sample XML file example-xml-file-letter.xml. It builds on the example Example: Creating an XML File type, XML-Letter.