Summary: Include processed XML into PmWiki 2.2 pages
Version: 20070621
Status: Beta
Prerequisites: pmwiki-2.2, PHP 4.x (php_domxml, php_xslt) or PHP 5.x (php_xsl) and the Linked Resource Extras recipe
Maintainer: Dfaure
Categories: Includes
Discussion: IncludeXML-Talk?


This recipe takes advantage of XML and XSL functions provided by PHP and its associated modules to let you apply a XSL transformation on XML data and display the results into a wiki page.

A basic sample usage may be to syndicate your PmWiki site to other feeders (and display their datas).


Before all, XML and XSL support must enabled for your PHP installation. You may check this by temporary setting $EnableDiag = 1 in your config-file and using ?action=phpinfo as described in AvailableActions.

According to the PHP version, the recipe needs the following extensions enabled:

  • PHP 4.x: php_domxml, php_xslt
  • PHP 5.x: php_xsl

You may refer to your ISP and the PHP documentation for more details on extensions availability and how to enable it.

As usual, download and copy includexml.phpΔ to your cookbook/ directory and enable it in your LocalCustomizations file.


Once installed, the following markups are available:

Renders an external xml DATA_SOURCE using the external xsl STYLESHEET_SOURCE.
(:xsl xml=DATA_SOURCE OPTIONS:)...STYLESHEET_DATA...(:xslend:)
Renders an external xml DATA_SOURCE using the enclosed xsl definition.
(:xslend:) is not required when using (:xsl ...:) [=...=].
(:xml xsl=STYLESHEET_SOURCE OPTIONS:)...XML_DATA...(:xmlend:)
Renders enclosed xml data using an external xsl STYLESHEET_SOURCE.
(:xmlend:) is not required when using (:xml ...:) [=...=].

Parameters and options

Respectively, the XML data source to process and the XSL stylesheet data source to use for the transformation.
This could be either:
  • an Uploaded attachement: Attach:some_data.xml,
  • an Intermap? link: InterMap:something/somewhere/else.xsl,
  • or a fully qualified external link: http://host/my/external/resource.rss.
The link target specification is handled by the Linked Resource Extras recipe. See there for syntaxic details and usage options.
The parameter src=DATA_SOURCE is equivalent to xml=DATA_SOURCE for the (:includexml ...:) markup.
Disables PmWiki Markup formatting of processed datas (useful when generating xhtml).
Disables most of output formatting (for development phases).

The expected XSL transformation should generate a plain text stream decorated with PmWiki markup. Nevertheless, with the -markup option, you may use appropriate stylesheet to generate (x)html directly.

The markup parameters are filtered and all +... and -... unhandled options are silently discarded. All other parameters are forwarded to the XSL stylesheet, including xml=... and xsl=... as global parameters (according to the triggering markup, the xml=... and xsl=... values may only be available as '-' for the relevant stylesheet).

The includexml-samples.zipΔ provides samples stylesheets to apply on rss feeds. As an usage example, the following directive (on a single line) would retrieve the 7 last PmWiki-users mailing-list messages:


Technical hints

The following configuration variables may be helpful to suit the recipe to your needs:

Maintains the different parameters such as include_path options and stream context data useful when fetching external datas (auth, proxy,...). You may refer to the PHP documentation for more details.
Gives the name of the character decoding function processing the transformation result before returning it to PmWiki.

Release Notes

Fixed trimming bug of (:xsl:)...(:xslend:) and (:xml:)...(:xmlend:).
Major rewrite.
Cleaned code, merging unreleased enhancements. Updated licensing terms.
Enabled wiki link convention.
Tidy up code and parameters forwarding.
First public release.

See Also



See discussion at IncludeXML-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.