This package is abandoned and no longer maintained. No replacement package was suggested.

An XSL wrapper / extension to the PHP 5.x XSLTProcessor with Exception and extended Callback support





Installs: 2 153 659

Dependents: 1

Suggesters: 0

Security: 0

Stars: 17

Watchers: 1

Forks: 6

Open Issues: 1

1.1.1 2014-11-27 20:08 UTC

This package is auto-updated.

Last update: 2020-01-23 01:11:19 UTC


The classes contained within this repository extend the standard XSLTProcessor to use exceptions at all occasions of errors instead of PHP warnings, notices or semi completed transformations. They also add various custom methods and shortcuts for convinience and to allow a nicer API to implement callbacks to the PHP stack.


PHP: 5.3.3 (5.3.0-5.3.2 had serious issues with spl stacked autoloaders)
Extensions: dom, xsl, libxml


fXSL can be installed using the PEAR Installer, the backbone of the PHP Extension and Application Repository that provides a distribution system for PHP packages.

Depending on your OS distribution and/or your PHP environment, you may need to install PEAR or update your existing PEAR installation before you can proceed with the instructions in this chapter. sudo pear upgrade PEAR usually suffices to upgrade an existing PEAR installation. The PEAR Manual explains how to perform a fresh installation of PEAR.

The following two commands are all that is required to install fDOMDocument using the PEAR Installer:

sudo pear channel-discover
sudo pear install TheSeer/fXSL

After the installation you can find the source files inside your local PEAR directory; the path is usually either /usr/share/pear/TheSeer/fXSL (Fedora/Redhat) or /usr/lib/php/TheSeer/fXSL (Debian/Ubuntu).


Simply require/include the autoload.php supplied and you can start using fXSL as a drop in replacement for the standard XSLTProcessor.

Usage Samples

PHP Code:


use TheSeer\fXSL\fXSLCallback;
use TheSeer\fXSL\fXSLTProcessor;

require 'TheSeer/fXSL/autoload.php';

function demo() {
   return 'Demo reply';

class foo {
   public function bar($a, $b) {
      $x = new \DOMDocument();
      $x->loadXML('<?xml version="1.0" ?><root />');
      $p = $x->createTextNode($a . ' -> ' . $b);
      return $x->documentElement;

$tpl = new DOMDocument();

$dom = new DOMDocument();

$xsl = new fXSLTProcessor($tpl);

$test = new fXSLCallback('test:only','test');
$test->setObject(new foo());


$result = $xsl->transformToXml($dom);

$tpl->formatOutput = true;
echo "Template:\n" . $tpl->saveXML();

echo "\n\nOutput:\n".$result;


The 'test.xsl' XSL Stylesheet used:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="php foo"
	extension-element-prefixes="php func" xmlns:xsl=""

	<xsl:output method="xml" indent="yes" encoding="utf-8" />

	<xsl:template match="/">
			<!-- classic php function callback -->
			<demo><xsl:value-of select="php:function('demo')" /></demo>

			<!-- fXSL registered callback method -->
			<test><xsl:copy-of select="test:bar('hello','world')" /></test>



#####Release 1.1.0

  • Added loadStylesheetFromFile and loadStylesheetFromXML methods
  • Clear xml errors on construct
  • Changed protected properties and methods to private

#####Release 1.0.4

  • PHP 5.4 compatibilty: set a default security preference so writing files is allowed

#####Release 1.0.3

  • Changed error detecting code to catch more problems

#####Release 1.0.2

  • Extended Exception code to better show actual errors

#####Release 1.0.1

  • Added support for black- and whitelisting of methods
  • Generate nicer xsl code
  • Various Bugfixes

#####Release 1.0.0

  • Initial release