What are the chances to see XSLT 2.0 processors like saxon for php in the nearest future?
-
You can always shell out XSLT processing to an external XSLT 2.0 capable processor if need be… – Tomalak Dec 04 '09 at 10:58
-
In my opinion "Never with the [performance](http://www.davidpashley.com/articles/xslt-benchmarks.html) of [XSLT 1.0 processors](http://www.xmlsoft.org/XSLT.html)"... For middleware and data interchange, like in Gnome project, user needs performance, and need to perform single tasks (like old DTD validation and simple XSLT filters). For database applications (ex. consider the lack of xQuery at PostgreSQL) the PHP and [public software communities](http://en.wikipedia.org/wiki/Free_software_community) need to evolve and must justify open-source investments, agains existing options showed here. – Peter Krauss Jan 09 '13 at 11:05
-
**Good news** Checkout: http://stackoverflow.com/a/20275114/36305 – Reza S Dec 12 '13 at 23:56
6 Answers
This isn't entirely true.
If you are running PHP on the Windows platform, then there is a relatively easy to configure extension to the AltovaXML XSLT 2.0 processor... http://sourceforge.net/projects/xslt2processor/
If you are running PHP on Linux, then you will need to install a PHP/Java Bridge. This involves running a Java servlet contained like Apache/Tomcat, and is pretty involved. There is also some relatively complex hybrid java/php code necessary to make this work. If you are interested, I can post more details.

- 61
- 1
-
@JR: For the future - please use comments for this kind of answer (I know you can't comment *yet*). Answers like this one get out of context as soon as up/down votes are cast and the list of answers gets re-sorted. – Tomalak Dec 04 '09 at 10:56
Finally, there is a positive answer to this question.
Just today, Dr. Michael Kay announced Saxon/C.
See this for more information: https://stackoverflow.com/a/20275114/36305

- 1
- 1

- 240,661
- 26
- 293
- 431
-
Awesome thank you!! But I wish this was announced more than 2 weeks ago as I was scraping the web for something like this. either way time to refactor and upgrade to xstl 2.0 :) – Reza S Dec 12 '13 at 23:56
-
@RezaSanaie, Yes, XSLT 1.0 is 14 years old -- ancient in internet time. – Dimitre Novatchev Dec 13 '13 at 03:31
There is no XSLT2.o
support till now in PHP, the only option to use XSLT2.0 is to use SAXON which is java based and hence you will have to something like PHP XSLT2.0 processor, see this link: http://sourceforge.net/projects/xslt2processor/
XML_XSLT2Processor
is a PHP class that allows you to perform XSLT 2.0 transformations within PHP by using SAXON or AltovaXML.
-
saxon/c is not java based, its written in c++ ... http://www.saxonica.com/saxon-c/index.xml and here is php api for saxon/c http://www.saxonica.com/saxon-c/doc/html/index.html#php-api – Jiří Doubravský Jun 07 '16 at 12:38
There is an open source XSL 2.0 transpiler in PHP that can be found on github
Also Saxon/C version 1.0.0 supporting XSLT 2.0/3.0 on C/C++ and PHP has been released.

- 41
- 4
PHP use LibXML2 to implement all XML classes. It is very fast and stable, but today (2013) only supports XPath1 and XSLT1... Perhaps community need only this faster and simpler solution, and not need the powers of XSLT2 (see "option0").
option0: try to use better MVC separation!
... Many templates, used as View in a MVC context, not need the powers of XSLT2: see good explanation why. See how some good PHP projects are using XSLT1
option1: try a non-mainstream implementation
As showed by @collapsar at this similar question there are a open source developed to extend the classic LibXML2 with some powers of XSLT2 and XPath2. See http://www.explain.com.au/libx/
PHP community not yet motivated to complete this evolution... Why? Maybe just afraid of losing some performance and stability. Maybe just a lack of manpower to complete the task, mainly in a PHP driver.
option2: empower XSLT1 or XPath1 with PHP functions/conections
See example of usual workawound here, by registering PHP functions into XPath1 or XSLT1. I am using this solution at my projects.

- 1
- 1

- 13,174
- 24
- 167
- 304