A plugin is simply a plain text file, using an UTF-8
character encoding, having a ".w2x_plugin
" file suffix, containing a number of w2x
command-line arguments and starting with comment lines containing information about the plugin (for example, its name). Example, w2x_install_dir/sample_plugins/rss/rss.w2x_plugin
:
### plugin.name: rss ### plugin.outputDescription: RSS 2.0 ### plugin.outputExtension: xml ### plugin.multiFileOutput: no -c -e w2x:xed/main.xed -t rss.xslt # Image files not useful here. -step:com.xmlmind.w2x.processor.DeleteFilesStep:cleanUp -p cleanUp.files "%{~pO}/%{~nO}_files"
Field Name | Default Value | Description |
| Basename of the " | The name of the plugin (a single word). |
| The name of the plugin. | A short description (just a few words) of the output format of this plugin. |
|
| Preferred extension for the files created by this plugin. |
|
| Whether this plugin creates multiple files or just a single one. A boolean: “ |
The above rss
plugin converts DOCX to RSS. This process is partly implemented by XSLT 1.0 stylesheet w2x_install_dir/sample_plugins/rss/rss.xslt
which is part of this plugin. Stylesheet rss.xslt
transforms its input, the semantic XHTML 1.0 Transitional file created by the Edit step (invoked using -e w2x:xed/main.xed
), to RSS.
Aside XSLT 1.0 stylesheets, a plugin may also include XED scripts as well as ".jar
" files containing support code and/or custom conversion steps implemented in Java™. Example, w2x_install_dir/sample_plugins/wh5_zip/wh5_zip.w2x_plugin
:
### plugin.outputDescription: Web Help ZIP containing "semantic" (X)HTML 5.0 ### plugin.outputExtension: zip -o webhelp5 -p webhelp.split-before-level 8 -p webhelp.use-id-as-filename yes -p webhelp.omit-toc-root yes -p webhelp.wh-layout simple # Generate all HTML files in a subdirectory of the output directory # having the same basename as the ".zip" output file. -p convert.xhtml-file "%{~pO}/%{~nO}/%{~nO}.xhtml" -p transform.out-file "%{~pO}/%{~nO}/%{~nO}_tmp.xhtml" -p webhelp.out-file "%{~pO}/%{~nO}/%{~nO}.html" -p cleanUp.files "%{~pO}/%{~nO}/%{~nO}_tmp.xhtml" -step:ZipStep:zip -p zip.out-file "%{O}"
The above wh5_zip
plugin specializes the stock conversion called webhelp5
(Web Help containing XHTML 5.0) by giving specific values to some of its parameters (e.g. -p webhelp.wh-layout simple
) and also by archiving all the output files in a single “.zip
” file.
This last step, -step:ZipStep:zip
, is implemented by a custom conversion step found in w2x_install_dir/sample_plugins/wh5_zip/src/ZipStep.java
. This Java™ code is compiled and archived in w2x_install_dir/sample_plugins/wh5_zip/zip_step.jar
by the means of ant build file w2x_install_dir/sample_plugins/wh5_zip/src/build.xml
.
Note that these ".jar
" files, just like the ".w2x_plugin
" files, are automatically discovered and loaded by w2x
and w2x-app
during their startup phase.