- General Information
- Connecting Third-party Systems
- crossConnect for content systems
- crossConnect for External Editing
- Purpose and usage
- Requirements
- Implementation
- Across XLIFF format
- Across-specific Extensions
- <xliff> Element Attributes
- <file> Element Extensions
- <trans-unit> Element Extension
- Paragraph States
- Paragraph State Flags
- <source> and <target> Element Content
- <bpt> Element Attributes
- <ph> Element Attributes
- <x> Element Attributes
- Across-specific Properties
- Analysis Results
- Sample Files
- Across XLIFF - import, export and segmentation
- Context information
- Exporting best matches in Across XLIFF
- Hyperlinks to XLIFF
- Secure file handling with C#
- Secure file handling with JAVA
- Workflow and vendor configuration
- Sample code - Integrated solution
- Across XLIFF format
- Generic File Connector
- Display Texts
- APIs
- APIs - Technology
- crossTank API v1
- crossTank API v2
- crossTerm API v1
- crossTerm API v2
- crossAPI SI
- Requirements
- Function Return Types
- crossAPI SI and Java
- List of Objects in crossAPI SI
- Sample - transferring checkout files via FileManager
- Sample - VBS
- Text Preprocessing API
crossTransform - examples
The file format
- For our example, we choose a simple format: It is an XML format with 4 different tags:
- The root tag named tst and its child tags:
- n
- i
- l
A file in this format could look like this:
<?xmlversion="1.0"encoding="UTF-8"standalone="no"?><tst><n>normal text</n><n>normal text with <i>inline text</i>.</n><l>locked text</l> </tst>
Across could surely read this file without crossTransform, but this format has been chosen, because it is easy to process in our little tool. So for this example, we assume, Across couldn't read this file format. To read it, Across needs "normal" instead of "n", "inline" instead of "i", and "locked" instead of "l".
The plugin xml
This file needs to be placed under %ProgramFiles%\across\across\plugin. According to the description of the format, the file looks like this:
<?xmlversion="1.0"encoding="UTF-8"?><plugintype="crossTransform plugin"name="tst crossTransform PlugIn"><docassoending=".tst"formatGUID="{61af5078-5509-4d3e-8739-a46961175402}"description="tst document"template="TST"extGUID="{075C51D9-EEEA-4583-8333-C76B44C27FFF}"/><preprocessingcommand="across SDK\Samples\crossTransform\Support for own format\TST2XML.bat"/><postprocessingcommand="across SDK\Samples\crossTransform\Support for own format\XML2TST.bat"/></plugin>
The tool
This tool is written in C# and is pretty straightforward. First, it determines whether it has been called during pre-processing or during post-processing. To do this, we just have to check the number of supplied parameters. If we have 2 parameters, we are in pre-processing, if we have 3, we are in post-processing.
When in pre-processing, the tool loads the file, replaces all "n" tags with "normal" tags, all "i" tags with "inline" tags and all "l" tags with "locked" tags. When in post-processing, the tools does this vice-versa.
Let's see the code:
staticvoid Main(string[] args){//We need at least 2 arguments!if(args.Length <2)return;// if first argument is /x we are in postprocessing:if(args[0]=="/x"){ XmlDocument doc =new XmlDocument(); doc.Load(args[1]); XmlNode root = doc.DocumentElement; postProcess(ref doc,ref root); doc.Save(args[1]);}else{ XmlDocument doc =new XmlDocument(); doc.Load(args[0]); XmlNode root = doc.DocumentElement; preProcess(ref doc,ref root); doc.Save(args[1]);}}privatestaticvoid preProcess(ref XmlDocument doc,ref XmlNode xmlElement){for(int i =0; i < xmlElement.ChildNodes.Count; i++){ XmlNode node = xmlElement.ChildNodes[i]; XmlNode newNode =null;if(node.Name =="n") newNode = doc.CreateElement("normal");elseif(node.Name =="i") newNode = doc.CreateElement("inline");elseif(node.Name =="l") newNode = doc.CreateElement("locked");elsecontinue; newNode.InnerXml = node.InnerXml; xmlElement.ReplaceChild(newNode, node);//we need to call it recursivly, to also//preprocess the child tags of the current tag preProcess(ref doc,ref newNode);}}privatestaticvoid postProcess(ref XmlDocument doc,ref XmlNode xmlElement){for(int i =0; i < xmlElement.ChildNodes.Count; i++){ XmlNode node = xmlElement.ChildNodes[i]; XmlNode newNode =null;if(node.Name =="normal") newNode = doc.CreateElement("n");elseif(node.Name =="inline") newNode = doc.CreateElement("i");elseif(node.Name =="locked") newNode = doc.CreateElement("l");elsecontinue; newNode.InnerXml = node.InnerXml; xmlElement.ReplaceChild(newNode, node);//we need to call it recursivly, to also,//postprocess the child tags of the current tag postProcess(ref doc,ref newNode);}}
Purge RC
The example Purge RC shows you how to carry out automatic post-processing via crossTransform without pre-processing. During the check-out, useless resources are deleted and country-related replacements are carried out.
Carry out the following steps to follow the example:
- Enabling crossTransform
- Copy the file PurgeRC.xml into the Across plugin folder at %ProgramFiles%\across\across\plugin.
- Restart Across.
- Checking the RC file
- Start the Across Client.
- Start the Project Wizard.
- Add the file MyResource.rc to the project as Resource Script File (with Purge RC).
- Set the target languages to German, Spanish, and Portuguese.
- As an option, you can carry out translations if you wish.
- Checking out
- Start the Check-Out Wizard.
- Check out source and/or target files.
- After the check-out has taken place, the batch file purgeRC.bat is automatically called. It starts the tool purgeRC.exe, which removes all ICON resources from the RC file. After that, the tool ssr.exe is used to replace an image file for each specific country.
- Now compare the original file with the resulting file.