Writing XPath Files for Fortis Revolution
From Fortis
Fortis Revolution files of [XPath] statements to identify the translatable text in an [XML] file, each xpath statement on it's own line. You can have as many XPath statements in your .xpath file as are necessary to select every translatable section in your document.
It may be possible to reuse XPath files between similar projects, but you should never assume that an XPath file that works for one XML file will work for another.
The following is a super generic non-discriminatory XPath statement. If placed as the only line in an xpath files this will select all text between the tags (but none of the attributes).
//*/text() |
You can test your Xpath files at this website.
Identifying more specific xpath statements
Identifying more specifi xpath statements than the example above can be complicated. Fortunately there is a tool that will simply the process greatly.
- Download www.bizbert.com/xmlviewer/ the Dan Sharp XML Viewer
- Open the XML viewer and open your xml file in it.
- Identify where in the XML tree one part of the translatable text is and click on it. (If you see an '@' symbol that means it is an attribute (the sort of thing the simple example above does not catch.)
- When you click then below the tree view an xpath statement will be generated. Copy the xpath statemt then go to the XPath Queries tab.
- Paste the xpath statement in the XPath Query window and press the Execute Button.
- Modify the xpath statement until you get all the text you're looking for. The most reliable way is to find a number in brackets (like [1]) and deleting the number and brackets. There are probably several of these and it's a matter of experimentation to find out which ones should stay and which ones should go.
- Try appending "/text()" to the end of the statement to see if that cleans up your results. If you get no results then take the "/text()" back out.
- Copy that xpath statement and paste it into a text file. Add any other xpath statement you need and save the text file with an .xpath extension.
Note: The "/text()" option is needed if you want to target the text of a block but will break the xpath if you are trying to get attribute data. This is why the next to last step is a "try it and see" as opposed to a lengthy discussion trying to teach the difference.