The XML file filter by default imports files with the following extensions:
Tag Content Visualized
The tag content of the source XML file can be visualized via Edit - Expand Tags and edited via F2 in Memsource Editor and Web Editor.
Default XML Settings
The XML file format has not been primarily designed for translation. That is why it is at times necessary to provide additional settings for XML files, so that appropriate content for translation is extracted.
XML file settings can be modified when adding a new job for translation into a project. Memsource XML import options, as described below, provide ample options for configuring the Memsource XML import filter.
The default settings, with an asterisk in the Element field will import all XML elements for translation. If different than the default behaviour is requested, it can be customized via the two options below:
- Plain import rules
Plain Import Rules
This method allows a simple way of specifying from which elements and attributes content for translation should be extracted, using the following options:
- Elements: only the selected elements name,title,para will be imported. Use * to import all elements.
- Attributes: note will be imported for translation. Use * to import all attributes.
- Translatable inline elements: if the Identify inline elements automatically option is selected, Memsource will import all elements inside translatable text as the Translatable inline elements.
- Non-translatable inline elements: the selected inline element productname will be converted into Memsource tags and its content will not be translatable
- Identify inline elements automatically - with this option enabled, elements that are neighbors of text nodes will be automatically converted to inline tags.
- Elements (processed as HTML): the selected element code will be processed as HTML. Please note that HTML Import Settings (such as "Preserve Whitespace" or break segment on
tag) can be used for these elements.
- Locked elements : the selected elements will be imported as locked
- Locked attributes: the selected attributes will be imported as locked
- Import XML entities: When selected, XML entities in DTP Declaration will be included for translation
- A line break creates a new segment: This option should be used rarely. Normally, a new line in an XML file should not create a new segment
- Segment XML: Unselect this option if segmentation is not desired
- Convert to Memsource tags (use regexp) - use regular expression to convert specific text to tags
- Convert to character entities - enter comma separated list of character references required in the output file. For example when you want quotes " represented as " and character Σ represented as Σ use ",Σ. Please note that & and < are always exported as & and <.
Plain Import Rules
XML Settings Using XPath
Translatable content can also be defined using XPath query language. This method allows for creating complex import rules and some additional to Plain import (described above):
- Context key - value that constitutes TM context (101% match) if applicable
- Context note - import element or attribute of context for each element
- Max. target length - import element or attribute of max. target length for each element
- Preserve whitespaces - keep empty to preserve whitespaces in elements having xml:whitespace='preserve'. //* will preserve all whitespaces in all elements or you can use an arbitrary XPath expression.
- Convert character entities - enter comma separated list of character references (such as " or Σ) required in the output file. Please note that & and < are always exported as & and <.
However the user must be familiar with XPath.
A subset of XPath 1.0 is accepted with the following limitations:
- Axis in step
- Supported: ancestor, ancestor-or-self, attribute, child, descendant, descendant-or-self
- Not supported: following, preceding, following-sibling, preceding-sibling, namespace
- Supported conditions on current node or ancestor nodes and its properties (attributes, namespaces)
- Not supported for example: position number, axis child::, descendant::, descendant-or-self::, following::, preceding::, following-sibling::, preceding-sibling::, function last()
Please note that the XPath expression should define the elements and/or attributes whose text/value should be translated and not the actual text node. See more information on XPath.
XPath Import Rules
HTML Preview with XSLT stylesheet
XSLT language (Extensible Stylesheet Language Transformations) can be used to transform XML documents into HTML format for in context preview purposes. Memsource currently supports XSLT 2.0.
To import the XML file with a stylesheet (XSL or XSLT), simply navigate to the bottom of the XML import settings and choose a XSLT file. When you import an XML with a stylesheet, the Preview Translation (Document -> Preview Translation) in Memsource Desktop Editor will generate an HTML preview instead of an XML one (video). Once used for file import, XSLT can also be downloaded from the file import settings page.