The Hippo XSL Transformer plugin applies XSL transformations to a selected set of documents in the repository
|
Never use this tool on a production repository. It is too easy to accidentally corrupt data. |
Getting the code
The code is available in SVN
Compile and run as described in Hippo Webdav Batch Processor plugins.
A more detailed description of the process:
Check out http://svn.hippocms.org/repos/hippo/hippo-tools/hippo-wdbp-plugin-xsltransformer/trunk
To build the jar, type:
maven clean uberjar
Edit plugin.properties to use your repository. Never use a production repository!
Always use a copy of the respository data. (There are several tools you can use to
copy data from the production repository to a local repsitory and (after throrough
testing if the conversion was successful) vice versa.
The hippo-wdbp-plugin-xsltransformer uses a standard XSL transformer to transform
the XML. example.xsl is an example of an XSL that adds, removes or renames some
elements without changing the rest of the document. Look at it, and change it
(or a copy of it) to do the conversion you need. Edit plugin.properties to use
that XSL file.
To run wdbp with the plugin, type:
java \-jar target\wdbp-xsl-transformer-1.01.02-uber.jar plugin.properties
After running the XSL transformer, check very thoroughly if the conversion
happened the way you wanted. If not, copy the original content over the
incorrectly converted content and try again.
Sample configuration
In this sample configuration file transform all files in /files/default.preview/content/bulk.
# location of the repository # Never use this on a production repository! location.host=localhost location.port=60000 location.rootpath=/default # path of the content you want to change. make this is specific as # possible; converting data that doesn't need to be converted is # time consuming and dangerous location.path=/files/default.preview/content/bulk # authentication for the repository authentication.username=root authentication.password=admin # the WDBP plugin that you want to use. (don't change this) plugin.1.classname=nl.hippo.webdav.batchprocessor.xsltransformer.XSLTransformer # the xsl file that will be used for the conversion plugin.1.configuration.transformer.stylesheet=example.xsl # if the documenttype is not empty it will only transform the documents of this type # otherwise alll documents in the selected folder and its subfolders will be converted #plugin.1.configuration.transformer.doctype=text # optional parameters can be set for the XSL. They can be accessed in the XSL with <xsl:param name="test"/> # by default the documenttype is passed to the XSL and can be accessed with <xsl:param name="type"/> plugin.1.configuration.transformer.parameter.1.name=test plugin.1.configuration.transformer.parameter.1.value=testvalue
An example XSL file:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- the document type is always passed as parameter to the XSL. other parameters can be configured in plugin.properties --> <xsl:param name="type"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <!-- template for when a new element called 'type' needs to be added to 'content' --> <xsl:template match="content"> <xsl:copy> <type> <xsl:value-of select="type"/> </type> <xsl:apply-templates/> </xsl:copy> </xsl:template> <!-- template for when element 'foo' is deprecated and needs to be removed --> <xsl:template match="foo"/> <!-- template for when you want to change the name of element 'bar' to 'newname' --> <xsl:template match="bar"> <newname> <xsl:apply-templates/> </newname> </xsl:template> <!-- simply copy everything that doesn't need to be changed (do not remove this!) --> <xsl:template match="*" priority="-1"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet>