XML Parser rule example
Example: Select an element for translation based on an attribute value
The following parser rule specifies all elements that have the attribute value pair
'translate=yes', and ensures that these elements are presented for translation:
| Option | Description |
|---|---|
Rule identifier Translate settings | The XPath identifier is:
This specifies that the rule applies to all elements that have the attribute translate with the value yes |
Example: XPath and equivalent element specification
The SDL file type software uses XPath to specify elements, and you too can use XPath. However, you can also specify the element more simply in the Add/Edit Parser Rule dialog.
| Option | Description |
|---|---|
XPath syntax Equivalent element syntax |
In the Rule group box, Element box, enter the element name as: text |
Example: XPath and equivalent for an element attribute pair
| Option | Description |
|---|---|
XPath syntax Equivalent element syntax |
|
Example: Use XPath to specify an attribute value pair
The XML example file,
example-xml-file-letter.xml, includes elements that have an attribute translate, which can take the values yes and no. The intention is clear: all content within the scope of an attribute value translate="yes" should be translated.
| Option | Description |
|---|---|
We can break down this expression as follows: | |
//* | This option specifies all elements, at any depth. |
[...] | Square brackets delimit selection criteria. To specify elements by the values of an attribute (for example with =, > or <), surround the expression with square brackets. |
@translate | This option specifies the translate attribute. |
="yes" | This option specifies elements for which the attribute has the value "yes". |