Example - Creating an XML File type XML-Letter

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.

We will specify the element contents as follows:

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  
<salutation> Yes "Dear Daniel "should be translated.
<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  
<emphasis> Yes The emphasis tag changes the format of the text but the text should still be translated.
<signature> No We do not translate a person's name or address.
<address> No  
<weblink> No We do not alter the web address.
<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.)
  1. Start the Create File Type Wizard.
  2. In the File Type Information page of the wizard, change the File type name to XML-Letter. Provide any unique name in the File type identifier. Do not change the data in the remaining boxes. In particular, keep the File dialog wildcard expression as *.xml.
  3. On the XML Settings Import page, define the parser rules settings based on a rule file, and specify the XML file example-xml-file-letter.xml. This file is included in the zip archive example-xml-files.zip; you can find the archive in the help table of contents. The wizard imports the parser rules from the letter file. With these rules, if an XML file has a <letter> root, the file will match this file type, and the contents of the file will be handled in accordance with the table above.
  4. Click Next save the file type in a known location.
  5. Click Finish to exit from the file creation wizard. You now have the new file type.
  6. To define preview settings for the new file type, so that you can see a usefully formatted version of the XML file, use the file example-xml-transform-file.xslt, as follows:
    1. Extract and save example-xml-transform-file.xslt from the zip archive example-xml-files.zip.
    2. On the Preview settings for the XML-Letter file type, click Select a StyleSheet transform and specify the saved copy of example-xml-transform-file.xslt.
Related tasks
Example - Defining a Parser Rule to Highlight Structure
Example - Restricting Element Length in XML
Downloading the Example XML Files