PHPackages                             jdomenechb/xslt2processor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jdomenechb/xslt2processor

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

jdomenechb/xslt2processor
=========================

XSLT v2 processor for PHP

13.0kPHP

Since Dec 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jdomenechb/xslt2processor)[ Packagist](https://packagist.org/packages/jdomenechb/xslt2processor)[ RSS](/packages/jdomenechb-xslt2processor/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

XSLT2Processor
==============

[](#xslt2processor)

***WARNING:** This project is in **alpha** state, and as such, does not have any stable release and has partial support. Use at your own risk, but feel free to contribute via pull requests, bug issues or feature requests.*

XSLT2Processor is a pure PHP library for processing XSLT stylesheets up to version 2.0 and XPath expressions. It offers support for:

- XPath syntax parsing, evaluation and query
- Standard XPath function library and EXSLT function library
- XSLT v2.0 stylesheets execution

Requirements
------------

[](#requirements)

This library requires:

- PHP 5.6 or greater
- PHP Extension mbstring
- PHP Extension xml
- PHP Extension xsl

Installation
------------

[](#installation)

### Composer

[](#composer)

To install the library using composer, execute the following line in your favourite terminal, at the root of your project:

```
$ php composer.phar require jdomenechb/xslt2processor

```

Usage
-----

[](#usage)

### XSLT

[](#xslt)

To use XSLT2Processor in your code:

```
$processor = new Jdomenechb\XSLT2Processor\XSLT\Processor($xslt, $xml);
$result = $processor->transformXML();

```

`$xslt` and `$xml` are `DOMDocument` objects, each one containing the XSLT stylesheet and the XML to be transformed, respectivelly.

#### Caching

[](#caching)

To speed up the transformation, a caching class following the [PSR-6 recommendation](http://www.php-fig.org/psr/psr-6/) `CacheItemPoolInterface` can be provided to the processor to avoid parsing again expressions that have already been parsed. Note that it should be provided before processing.

```
$processor->setCache($cacheItemPool);

```

If no cache is provided anyway, the XPath factory has an internal memory-based cache to reuse XPaths already parsed in the current template. Note that although this can be faster, this option can use more memory.

### XPath

[](#xpath)

The full list of available XPath classes can be found under [the XPath src folder](src/XPath). But generally, a developer might be more interested in parsing a string that represents an XPath. For this goal, the `Factory` class may be more useful:

```
$factory = new Jdomenechb\XSLT2Processor\XPath\Factory;
$xPath = $factory->create('/*/some/x-path[representation = 1]');

```

Once you have parsed or build your xPath, you can evaluate or query the expression by executing:

```
// Evaluates the expression
$evaluationResult = $xPath->evaluate($context);

// Queries the nodes represented by the expression
$queryResult = $xPath->query($context);

```

`$content` can be any element extending the PHP class `DOMNode` ().

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1197b4ce0411048910993d1b98874c69f8811614aefc414b012d0eb7e4c7a314?d=identicon)[jdomenechb](/maintainers/jdomenechb)

---

Top Contributors

[![jdomenechb](https://avatars.githubusercontent.com/u/11862227?v=4)](https://github.com/jdomenechb "jdomenechb (160 commits)")

### Embed Badge

![Health badge](/badges/jdomenechb-xslt2processor/health.svg)

```
[![Health](https://phpackages.com/badges/jdomenechb-xslt2processor/health.svg)](https://phpackages.com/packages/jdomenechb-xslt2processor)
```

###  Alternatives

[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[typo3/cms-reports

TYPO3 CMS Reports - Show status reports and installed services in the (System&gt;Reports) backend module.

137.1M58](/packages/typo3-cms-reports)[lcharette/uf_formgenerator

Form generator for UserFrosting V5

178.7k3](/packages/lcharette-uf-formgenerator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
