SablotronPlugin
Apply a stylesheet to XML using the Sablotron tool
Introduction
The SablotronPlugin uses
CPAN:XML::Sablotron
to transform an XSL stylesheet and XML data file into HTML. Both the XSL stylesheet and XML document are Wiki Topics.
Syntax Rules
Place the directive %XSLTRANSFORM{xsl="SablotronXsl",xml=...}% at the top of the XML document where
SablotronXsl is the name of the stylesheet and ... is the xml codes.
Examples
Plugin Settings
Plugin settings are stored as preferences variables. To reference a plugin setting write
%<plugin>_<setting>%, i.e.
%NEWPLUGIN_SHORTDESCRIPTION%
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Apply a stylesheet to XML using the Sablotron tool
- Debug plugin: (See output in
data/debug.txt)
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
- Install the dependencies (see below)
- Download the ZIP file from the Plugin Home (see below)
- Unzip
SablotronPlugin.zip in your twiki installation directory. Content: | File: | Description: |
data/TWiki/SablotronPlugin.txt | Plugin topic |
data/TWiki/SablotronXsl.txt | Sample stylesheet |
data/TWiki/SablotronXml.txt | Sample XML document |
lib/TWiki/Plugins/SablotronPlugin.pm | Plugin Perl module |
- Run the configure script to enable the plugin in the {Plugins} section.
- Check SablotronXml if SablotronPlugin shows up in the list of activated plugins: SpreadSheetPlugin, AutoSectionsPlugin, BackupRestorePlugin, BlackListPlugin, CalendarPlugin, ChartPlugin, ColorPickerPlugin, CommentPlugin, DatePickerPlugin, EditTablePlugin, GaugePlugin, GeoLookupPlugin, HeadlinesPlugin, IfThenActionPlugin, InterwikiPlugin, JQueryPlugin, LocalCityTimePlugin, PercentCompletePlugin, PerlDocPlugin, PreferencesPlugin, QRCodePlugin, RecentVisitorPlugin, RenderListPlugin, SetGetPlugin, ShareMePlugin, SlideShowPlugin, SmiliesPlugin, SyntaxHighlightingPlugin, TWikiDrawPlugin, TWikiOrgPlugin, TWikiSheetPlugin, TablePlugin, TagMePlugin, TinyMCEPlugin, TwistyPlugin, VarCachePlugin, WatchlistPlugin, WysiwygPlugin
Design History
- Thanks to TWiki:Main.MartinCleaver
for the TWiki:Plugins.XmlXslPlugin
. My browser apparently does not have the feature needed to do client-side transformations so I make use of XML::Sablotron to perform the transformation on the server.
- I wanted to be able to see the transformation take place during the Preview Changes of an XML document. This way any extraneous characters or parsing problems will show up as an error.
Issues Outstanding
- Double quotes are used in the xml code so cannot follow proper form for TWiki::Func::extractNameValuePair
- In most cases of error in the XML the result is an "Internal Server Error" - viewing the web server error log tells you the line number to fix. I really should handle this in the plugin.
Plugin Info
Related Topics: SablotronXml,
SablotronXsl,
TWikiPlugins,
DeveloperDocumentationCategory,
AdminDocumentationCategory,
TWikiPreferences