Adding or Editing an XML Parser Rule

Studio uses a default set of Parser rules for extracting content from the most important types of XML documents. When a document does not match the detection rules of any of the default XML file types, Studio processes it with the XML: Any XML file type.

If you do not want Studio to apply the default parser rules for extracting XML content, you can create a new XML file type with custom parser rules. You can also customize the existing parser rules for the XML file types whose Parser rules can be edited.

 

To add or edit an XML Parser rule:

  1. Click Add or Edit on the Parser page of your XML file type to open the Edit Rule or the Add Rule page.
  2. Edit the Rule and Properties sections to create custom XML Parser rules.

 

Customizing an XML Parser rule

Use the parser rule settings available on the Add Rule and Edit Rule pages to define the properties of the XML parser rules. These settings help Studio better sort translatable from non-translatable text and correctly display the content extracted from the XML documents.

XML Parser rule settings

Rule Type and Rule

 

The specification of the nodes to which the rule applies. Studio uses XPath to specify the applicable nodes. This specification helps Studio to identify the rule, and so does not allow you to have two rules with the same XPath location.


Specify the XPath for the Parser rule by providing one of the following:
  • Attribute. Provide the element attribute pair, even if you do not know XPath syntax.

  • Element. Provide an element name, even if you do not know XPath syntax.
  • XPath. Provide the XPath directly.

Translate

 

Assign one of the following translate setting to an XML element:

  • Always translatable - The content of the XML element can be edited in the Editor view.

  • Not translatable - The content is displayed as locked content and cannot be edited. When a translatable element creates e separate segment, Studio only displays it with the All content filter in the Review tab. This is because you would not normally need to see a segment that only contains locked and not translatable content.
  • Translatable (but not in protected content) - Translatable unless the parent element is not translatable. Effectively the same as Not Specified.
  • Not specified - The element inherits the parent's translatable setting, if there is such a setting. Otherwise, the setting is Translatable.

 

Content is translatable if any of the following is true:

  • The content is not subject to a parser rule.
  • The content is set in the parser rule to translatable.
  • The content inherits the setting translatable from its ancestor.
Tag type

A parser rule can force an element to be presented to the translator as a tag. A tag can also have translatable text. A tag can be specified as any of the following:

  • Inline with the text - The content is displayed to the translator.
  • Structure tag - The element creates a new paragraph unit in the target file.
  • Not specified - The element inherits the parent's tag setting, if there is such a setting. Otherwise, the setting is Structure.

Note: You cannot set both the Translate setting and the tag type to Not specified.

Whitespace

Choose whether Studio preserves or normalizes any whitespace in your document. Preservation means that whitespace is not modified. Normalization replaces whitespace with a single space. Normalization is done when the file is converted to sdlxliff. This setting overrides the setting in the Whitespace page of your XML file type.

 

Choose an option from the drop-down list.

  • Inherit Parent. Whitespace handling is inherited from the parent element.
  • Always preserve. Whitespace is not normalized.
  • Normalize unless xml:space='preserve'. Whitespace is normalized unless the element has xml:space='preserve'
  • Always  normalize. Whitespace is always replaced wirh a single space.

Formatting

Formatting applies to inline tags and specifies how the contents of an inline tag is displayed in the Editor. For example, you might want text within an inline tag pair <b> ... </b> to be displayed as bold text.

 Click Edit... and select one of the following options for each of the six available styles:

  • Inherit - Applies the style that is specified for the parent, if there is such a setting.
  • Activate - Applies that style to the text.
  • Deactivate - Does not apply that style to the text.

The Sample box shows a preview of how the text extracted by the rule will look in the Editor.  

Structure info

Structure information allows you to add additional details about the context of a structure element in the XML documents. You can also use structure information to control how Studio displays the content of structure tags in the Editor view.

You can only add document structure information for structure tags. Click Edit next to the Structure info field to change the structural properties for an XML element. You can then view this information in the Editor view, in the Document Structure column and in the Document Structure tree.

Related topics

Creating a File Type

About XML Parser Rules with Examples

XML Whitespace

Review tab in the Editor view