To import a multilingual XML file, you need import rules.

An entry in a multilingual XML file has the same text in several languages. An import rule tells memoQ where to find the text for one of these languages.

The import rule also tells memoQ if there is a context, a comment, and maybe a length limit for the text in that language. Practically, you need one import rule for each language.

An import rule uses XPath expressions to point to the place of the text or other information in an XML file. In a way, XPath describes the "coordinates" of an element in an XML file.

In the XML import rules window, you can set up import rules without actually knowing or writing XPath expressions.

How to get here

1.Start importing a multilingual XML file.

2.In the Document import options window, select the XML files, and click Change filter and configuration.

3.The Document import settings window appears. From the Filter drop-down list, choose Multilingual XML filter.

4.Click the Import rules tab. The list of XML import rules appears. At the bottom, click Edit import rules. The XML import rules window appears.

muli_xml_importrules1

What can you do?

Set up one rule for each language in the project - or for each language in the document.

On the left, memoQ shows the contents of one of the XML files that you are importing. Normally, this is the first one in the selection.

The XML file appears in an XML tree. At first, you see the topmost element only. You can expand and collapse elements by clicking the little arrowheads on the left.

To use a different file for preview: Choose another file from the drop-down box at the bottom left. Then click Update preview. You can choose from files that you originally selected for importing.

First, set up the rule for the source language. In the XML tree on the left, click the tag that contains the source text. Make sure you click the tag. Don't click the text itself, or one of its attributes.

In the XPath for selected row box, memoQ displays the XPath expression that points to that one tag. If there are other similar places in the document, this XPath expression still ignores them.

At the Content XPath box, click Fill from selected row. The XPath expression appears in the Content XPath box, too.

You're not done yet: You need to edit this XPath expression to pick up all similar elements from the document. Then, in the memoQ language drop-down box, choose the language for this element.

Example:

The source language is German. In the example below, click the 'string' tag where the 'lang' attribute is "de".

memoQ inserts this XPath expression:

/doc[1]/entry[1]/string[1]

This doesn't mean 'all the German strings'. It means the first string element from the first entry from the first document. If you leave the rule like that, it will import exactly one segment, even if there are thousands of similar ones in the documents you're importing.

So, instead of this, you need an XPath element that says: all the strings where the 'lang' attribute is "de", from every specific 'entry', from any document in the import. You don't care about which document, but you want to make sure that the text parts imported in one segment actually come from the same 'entry'.

In the Content XPath box, edit the XPath expression as follows:

//entry/string[@lang="de"]

From the memoQ language drop-down box, choose German.

In addition to the content, you can pick up the context, and an optional length restriction and an optional comment from the XML document.

It is recommended that you pick up at least the context.

Example:

In the sample file, the context for an entry is the entry ID. Click the 'id' attribute of the first 'entry' tag. At the Context (ID) Xpath for content box, click Fill from selected row.

memoQ inserts this XPath expression:

/doc[1]/entry[1]/@id

This means the 'id' attribute of first entry from the first document. Instead, you need an XPath element that says: the 'id' attribute from every 'entry', from any document in the import. You don't care about which document, but you want to make sure that all the date imported in one segment actually come from the same 'entry'.

In the Context (ID) XPath for content box, edit the XPath expression as follows:

//entry/@id

If necessary - and if those data are there - set up similar rules for the length restriction and comment for the text. After you insert the XPath expression for the comment, use the memoQ comment type drop-down box to choose the type of the comment.

Remember that an automatically created XPath expression points to just one element or attribute in the XML. You must edit the expression to make it more general - to pick up all relevant elements or attributes. In the example, this is exactly what we've done.

After you set up an XPath expression for every element that you want in the segment, click Save to rule set.

At this point, you need to add rules for the other languages, too. Repeat the above steps.

In the example, the XPath expression to pick up the English strings is //entry/string[@lang="en"]

After you set up everything for the German text, and click Save to rule set, the XPath expressions and other settings remain in the XML import rules window.

In the example, to add the rule for the English text, simply edit the Content XPath box to contain //entry/string[@lang="en"]. Then click Save to rule set again.

To change an existing rule, and not add a new one: Click the rule at the bottom (in the Import rule set list). The details of the rule appear in the text boxes at the top. To make changes to that rule, click Edit rule at the bottom. Then, edit the XPath expressions and change the settings as needed. When you click Save to rule set, the existing rule is updated.

If you simply change the XPath expressions and the settings, but you don't click Edit rule, the Save to rule set button adds a new rule.

memoQ highlights all elements that the current rule picks up: When you click an import rule, memoQ highlights all the elements in the XML tree that are picked up by the rule. These are color-coded: see the legend at the bottom of the XML import rules window. When you click a rule, check if all the relevant elements are highlighted. Expand several entries in the document if necessary.

When you finish

To save the rules, and return to the Document import settings window: Click OK.

To discard the rules, and return to the Document import settings window without any new rules: Click Cancel.