|
|
Parsing CDATA sections in an XML file |
SolutionConfiguring Alchemy Catalyst to Parse CDATA sections within XML files will require setup of 2 parsers; an XML parser and a Text parser which will handle the CDATA section itself. The sample file "elements_with_cdata.xml" contains 3 localisable elements with CDATA sections inside, like this: <element><key>Error_PseudoGlobalException</key><value><![CDATA[<br><b>Details- </b> {0}]]></value></element> It is necessary to setup the text parser first which will parse the contents of the CDATA section. This parser will handle the string contained between the [ ] brackets. We will configure the text parser to take all characters found in the CDATA section. Configuring the Text parser
The text parser is now created! Configuring the XML parser
Your parser is now ready to insert XML files with CDATA sections. Inserting files and translatingWhen you insert the XML file in Alchemy Catalyst, you will be prompted to select the XML parsing rule. Select the newly created rule, in this example "XML_with_CDATA". Once the file is inserted in Alchemy Catalyst, you will see that each CDATA section, treated as code segment, is listed under the XML file in the project navigator. In order to list out all the strings in the project, including the code segments, click on the Project title and click on the "Show all string" button:
Sample filesList of sample files for the Solution outlined above: elements_with_cdata.xml - Sample XML file including CDATA sections used in the above example. XML_with_cdata.ezp - ezParse rule built in the above Solution, exported from Alchemy Catalyst. You can import this rule in Tools > Options > ezParse. Click on the Import button.
Related topics
Products or Versions Affected
|