XSL-Transformation Macro


The XsltMacro allows you to embed the result of an XSL-transformation in a page. It takes two parameters, a stylesheet and a document to transform. These can be an attachment on any wiki-page or ticket, any page from the htdocs area, any file in the repository, or any url. These options are similar to those for Trac's native ImageMacro. For more details see the documentation in the macro.

With this macro call:

[[Xslt(format.xsl, info.xml)]]

The following table is produced:

Name Address Email
John Smith 42 Easy St
Mary Francis 1 Heavenly Way

Here's how you would tell it to use an iframe:

[[Xslt(format.xsl, info.xml, use_iframe, if_height=500)]]

For the full docs see the WikiMacros page after installing this macro.

The macro can either be installed as a simple macro or as a plugin; the use_iframe and use_object options (see below) only work when installed as a plugin.

This macro requires that libxml2, libxslt, and their python bindings are installed.


Because a macro's output is embedded in the html of the wiki page, the xsl-stylesheet must not produce a full html page. As an alternative, you can pass the use_iframe or use_object option to the macro; this will cause the macro put an <iframe> or <object> tag (respectively) into the page instead of the results from the stylesheet. The stylesheet can (and must) then generate a complete html page.

The downside of iframes/objects is that you need to know the height of the result in order to set the height of the iframe/object; otherwise you will either get extra space at the bottom or you'll have to scroll through the frame. The macro generates some javascript to automatically set this height, but that only works if the user has javascript enabled of course.

Bugs/Feature Requests

Existing bugs and feature requests for XsltMacro are here.

If you have any issues, create a new ticket.


4 / 4


1 / 1


2 / 2


Download the zipped source from here.


You can check out XsltMacro from here using Subversion, or browse the source with Trac.


General instructions on installing Trac plugins can be found on the TracPlugins page.

Recent Changes

15871 by rjollos on 2016-09-06 17:28:57
Rename 0.9 directory to 0.10
7914 by roadrunner on 2010-05-02 14:32:16
Pass (http) request parameters which start with xp_ to the stylesheet as
additional parameters. This can be useful for example to implement paging.

This closes #5275.

7913 by roadrunner on 2010-05-02 14:32:04
Simplified parameter extraction a bit.


Author: roadrunner
Maintainer: roadrunner
Contributors: wuxxin at

Last modified 7 years ago Last modified on Sep 11, 2017, 3:32:20 AM

Attachments (2)

Download all attachments as: .zip