XSLT Transformation Plugin

Plugin source location: <serge_root>/lib/Serge/Engine/Plugin/apply_xslt.pm

Before using the plugin for the first time, install additional Perl modules: XML::LibXSLT and XML::LibXML.

Plugin must be attached through the configuration file to exactly one of the following phases:

This plugin allows one to do apply XSLT transformations to an XML document. Examples of use: pre-processing source XML resource files before parsing; post-processing generated localized XML resource files before saving; pre- and post-processing of XML-based translation interchange files (e.g. XLIFF).

This plugin inherits all the configuration logic from the parent 'if' plugin and, if all conditions are met, executes its XSLT logic. Note that all if conditions are optional: if none are provided, the plugin's logic will be always executed.

Usage

example-project.serge

This example XSLT file that is referenced in the config above filters the resource XML file content by keeping only the resources/string nodes that have a comment="translate" attribute:

keep-translatable-nodes.xslt

Example source XML file that the above XSLT transformation can be applied to:

strings.xml (on disk)

XML content after in-memory XSLT transformation (this is what will be parsed by Serge, and what will be used as a template when generating localized versions of this resource file):

strings.xml (after in-memory transformation)