Extension:XSL

From Linux Web Expert

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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 Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
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

  • <translate> [[<tvar name=2>Special:ExtensionDistributor/XSL</tvar>|Download]] and move the extracted <tvar name=name>XSL</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/XSL
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'XSL' );
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Usage

{{#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

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.