Extension:XSL

MediaWiki extensions manual
XSL
Release status: beta
Implementation Parser function
Description Applies XSL transformations to XML documents
Author(s) Greg Rundlett (GregRundletttalk)
Latest version 2.0.0 (2019-10-31)
MediaWiki 1.32+
Database changes No
License GNU General Public License 3.0 or later
Download
Quarterly downloads 2 (Ranked 134th)
Translate the XSL extension if it is available at translatewiki.net

The XSL extension performs an XSL transformation on XML documents. The purpose of the extension is to be able to re-use XML output from external systems. The parser function lets you take an XML document, apply an XSL transform and pull the resulting document into the wiki page. There are two optional parameters that allow you to enable wikitext parsing of the document; and to enable/disable caching of the result.

Installation

edit
  • Download and move the extracted XSL folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/XSL
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'XSL' );
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

edit
{{#xsl: xsl |xml |parse=true |nocache=false }}
  • xsl- The URL of the stylesheet
  • xml - The URL of the XML document
  • parse - (optional) if enabled the output of the transformation will be parsed as wikitext
  • nocache - (optional) if enabled caching will be disabled for this page. Enable this to allow dynamic content

Using wiki pages

edit

The URL of an XML or XSLT stylesheet may refer to a file on your server or even a page on your wiki. If you want to use the latter, you should refer to the "raw" source of the page, for instance

{{#xsl: {{fullurl:Test file.xslt|action=raw}}
|{{fullurl:Test file.xml|action=raw}}
|...
}}

Although it is probably not required, you may want to change the content type of your page to "plain text" (XML is not supported by default) or use a custom namespace and set its default content model to "plain text". See Manual:ContentHandler for further details.