XML Parser rule example
Example: Select an element for translation based on an attribute value
'translate=yes', and ensures that these elements are presented for translation:
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 box.
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
XPath syntax Equivalent element syntax |
|
Example: Use XPath to specify an attribute value pair
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.
We can break down this expression as follows: | |
//* | 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 | Specifies the translate attribute. |
="yes" | Specifies elements for which the attribute has the value "yes". |