XPath (TMS) - Phrase
XPath (TMS) - Phrase
Import Utilities
Enter keywords
Phrase TMS Phrase Strings Phrase Orchestrator Global Release notes Release Notes Archive
XPath (TMS)
Article content is machine translated from English to other languages by Phrase Translate.
XPath stands for XML Path Language. It can be used to navigate through elements and attributes in
an XML document. If new to XPATH, please see the XPath Tutorial first and study the official XPATH
documentation .
Axis in step
Supported
Not supported
Predicate
Supported
conditions on current node or ancestor nodes and its properties (attributes, namespaces)
Basic rules
Examples
XPath Example 1 and XPath example 2 (with namespace) are example files for the following:
//* | //@*
//* | //@attribute1
//Child//*
4. Import an element lis and its descendants only if the attribute translate='true'
//lis[@translate='true']/descendant-or-self::*
//*[@translate='true']/descendant-or-self::*
//data/@text
7. Import the <mT:translation> element and its descendants, except element <mT:ignore>
//mT:translation/descendant-or-self::*[not(ancestor-or-self::mT:ignore)]
8. Exclude all elements with the attribute translate='false'
//*[not(@translate='false')]
//*[not(self::lis[@translate='false'])]
10. Exclude elements 'lis' with the attribute translate='false' and their descentants
//*[not(ancestor-or-self::lis[@translate='false'])]
(<menu1link><tmenu41link>)
//*[not(contains(name(),'link'))]
12. Exclude all elements if they or their ancestor have an attribute 'lis' containing 'link'
//*[not(ancestor-or-self::node()[contains(@lis, 'link')])]
13. Import elements PT if their parent LANG has the attribute 'updated' with year 2015
(<LANG updated="20150213T121526"><PT>'
//LANG[contains(@updated,'2015')]/PT
14. Import elements 'Description' and 'Name' only if they are not descendants of elements
'Definitions' or 'Types'
://*[not(ancestor-or-self::*[(name()='Definitions') or (name()='Types')])]/*
[(name()='Description') or (name()='Name')]
//*[local-name()='Child']//*
translate='1'>translate this</Child>
17. XML with namespace. Import the element target from element tu , but not when the attribute id
contains 'img' or 'extra':
a. File example:
one</target></tu>
b. XPATH example:
name()='target']
18. Import all elements except <comment> and <lis> unless <lis translate="true"> and their
descendants:
name()='comment'])=0]
19. Import all elements except <comment> and except elements with attribute <... attribute2="Do
not translate"> and their descendants:
20. Import values of attributes varName and glossName but only if their ancestors have attribute
attribute1='translate' or attribute1='edit' :
//*[(self::node()[@attribute1='translate' or @attribute1='edit'])]//@*[local-name()='varName' or
local-name()='glossName']
21. Import all elements and attributes except elements with the attribute Name= Back , Menu , or
Time :
//*[not(ancestor-or-self::node()[@Name='Back' or @Name='Menu' or @Name='Time'])] | //@*
In this case it may be better to import all and lock the attributes not required for import. Once
segments are Locked, copy source to target in the editor in order to have the original transferred
to translation.
a. Lock all elements with the attribute Name with values: Back , Menu , or Time and their
descendants:
b. Lock all attributes of Name with values: Back , Menu , or Time and their descendants
Context note
<root>
</element>
</element>
</root>
xpath_example2.xml
(2 KB)
xpath_example1.xml
(2 KB)
Yes No
In this article
Basic rules
Examples
Context note
RESOURCES
Free Trial
Download Editor
Blog
Release Notes
Feature requests
Webinars