How to Set Element Length Restrictions for XML

This topic describes an example for setting up the length restriction properties for the sample XML file. When the document is opened in the Editor window in the Editor view, the length restrictions are displayed in red in the document structure column. Length restrictions can be set for elements and translatable attributes.

If you want to follow the steps below in SDL Trados Studio, click the link to download the sample file. Sample XML file

 

In this Topic: Hide

XML Length Restriction Example

Setting Element Length Restrictions

Translating with Length Restrictions

XML Length Restriction Example

The following highlighted attributes are examples of different element length restrictions that an XML document might contain:

<?xml version="1.0" encoding="UTF-8"?>

<letter>

  <title maxlength="10"> Quote Letter </title>

  <salutation limit="60"> Dear Daniel,</salutation>

  <text>Thank you for sending us the information on <emphasis>SDL Trados Studio 2009</emphasis>. </text>

    <title maxlength="40"> Quote Details </title>

       <text> Please send us a quote for 50 licenses. Keep up the good work! </text>

</letter>

Setting Element Length Restrictions

NOTE

This example explains how to set length restrictions for the <title> element only. Setting length restrictions for the <salutation> element must be performed separately.

 

To set element length restrictions:

  1. Create a new XML file type called XML_Letters in the Options dialog box and upload the sample.xml file.   

  2. In the Options dialog box, select Parser rules from the navigation tree under XML_Letters. The Parser rules are displayed on the right.

  3. Select the <title> element and click Edit. The Edit Rule dialog box is displayed.

Edit Rule Dialog Box

structure.gif

  1. Under Properties, select structure from the Tag type drop-down list.

  2. Click Advanced. The Advanced Tag Settings box is displayed.

Advanced Tag Settings Dialog Box

max.gif

  1. Under Length restrictions, enter @maxlength in the Maximum length box. Entering this value means that when the file is opened for translation, for any <title> element that has a maxlength attribute, the length restrictions are displayed in red in the document structure column in the Editor window.

 

NOTE

If the XML file does not contain a maximum length value, you can enter a constant number, for example, 40.

  1. Click OK until you have returned to the Parser rules page.

  2. Select Verification > QA Checker 3.0 > Length Verification from the navigation tree. The Length Verification settings are displayed on right.

QA Checker 3.0 > Length Verification settings

QAlength.gif

  1. Select the Check length limitation check box and then select the Check if target segments are within file specific limits option underneath the check box.

  2. Click OK to save your changes and close the Options dialog box.

Translating with Length Restrictions

When you set the element length restrictions as described above and do not adhere to them, the following results occur:

  1. Open the sample.xml file for translation in the Editor window in the Editor view. Any <title> elements with length restrictions have LN.gif highlighted in red in the document structure column.

  2. In segment 1, hover over LN.gif with your cursor. The tooltip with the restriction details is displayed.

tooltip.gif

  1. Enter Angebot für Lizenzen as the translation for segment 1 and press Ctrl+Enter to confirm the translation.

Verification is performed and an error is reported in the Messages window because the character limit for that element was exceeded.

 

Verification Error in the Messages Window

 

length_example.gif

 

Related Topics

Sample XML File for XML Example