MediaWiki extension: Page transform
- This page gives general documentation valid for all MediaWiki installations which use the PageTransform extension.
PageTransform.php is a MediaWiki extension that adds a parser hook to MediaWiki, <PageTransform>, that supports regular expression search and replace and/or XSL transformation of XML content, with optional wikitext rendering in the output of the transformation.
PageTransform was initially developed by Eric Hartwell in the spring of 2006 for the Apollo 17 Flight Journal.
Contents |
[edit] Synopsis
-
<'''PageTransform'''[ xslpage=["''id''"|''id''] | xslimage=["''id''"|''id''] | regexpage=["''id''"|''id''] | render ]>XML data or wikitext<'''/PageTransform'''>— the quotes are only needed if id contains whitespace, where whitespace is one of - There can be one or more attributes, each one defining a transformation. All attributes are processed sequentially in left-to-right order, so you can apply multiple transformations to the same text with a single reference. Recursion of
<PageTransform>tags within the transformed text is fully supported by therenderattribute.-
'''xslpage'''="title of page containing XSL"wiki page for XSL -
'''xslimage'''="title of uploaded image file"wiki "image" uploaded file for XSL -
'''regexpage'''="title of page containing regular expression"wiki page for regular expression pattern and substitution -
'''render'''render wikitext in output of transformation (default is no rendering)
-
[edit] Description
<PageTransform> supports regular expression search and replace and/or XSL transformation of XML content, with optional wikitext rendering in the output of the transformation.
For instance, try typing the following in an edit box and clicking "Show preview":
This is a generic block of wikitext.
And here is a block to translate ... <nowiki><PageTransform regexpage="RegEx" render="yes">Here's the raw input block of text. The transform will translate test="target 1" into <code>test="output 1"</PageTransform>.</nowiki></code> but leave test="target 1" alone.The wikitext continues past that.
will result in the following text on the article page:
This is a generic block of wikitext. And here is a block to translate ... Here's the raw input block of text. The transform will translatetest="output 1"intotest="output 1"but leave test="target 1" alone. The wikitext continues past that.
[edit] Customization
[edit] Internals
For a detailed discussion of how the extension works and how it was developed, see : Create a MediaWiki Extension for XML/XSL Data.
[edit] Issues
[edit] Current issues
- Can't use a template that uses
<PageTransform render>in a page that uses<PageTransform render> <PageTransform>uses$wgOut->parseto render wikitext in the output if therenderattribute is used. If a template uses$wgOut->parse, and you call this template from another page that uses$wgOut->parse, the<PageTransform>on the calling page fails.[1] The the message is of the form "NaodW..." or "UNIQ...", depending on the MediaWiki version. EHartwell 09:25, 4 April 2006 (EDT)
Workaround: if you can, use a special transform or series of transforms that don't require using therenderattribute. EHartwell 10:00, 4 April 2006 (EDT)- Verify that
<PageTransform>won't allow malicious code injection. - It's possible to use an XSL stylesheet to inject JavaScript (possibly malicious) into the rendered page, which is not a good thing. The extension should check for this in cases where the last step is not
render.
[edit] Past issues
- There are no past issues.
- This is the first version of the extension.