Home » Php » XSLT 2.0 PHP support. When?

XSLT 2.0 PHP support. When?

Posted by: admin July 12, 2020 Leave a comment

Questions:

What are the chances to see XSLT 2.0 processors like saxon for php in the nearest future?

How to&Answers:

In the nearest future? None.

PHP5 relies exclusively on LibXSLT for XSLT processing (Sablotron is out), and there is no plan to support XSLT 2.0 in this library.

Answer:

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.

Answer:

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

Answer:

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.

Answer:

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.

Answer:

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.