25

The question was asked but deleted by the asker before it received an answer. Because I believe the question is sound and legitimate and serves a purpose, I'm asking it again and provide the answer I already wrote for the original question.

Will XPath 2.0 and/or XSLT 2.0 be implemented in PHP some day or are there any plans?

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Abel
  • 56,041
  • 24
  • 146
  • 247
  • may help http://phpmyxml.sourceforge.net/ – Haim Evgi Jan 18 '10 at 11:33
  • phpmyxml does not support versions 2.0 of the XSLT / XPath standards. – Abel Jan 18 '10 at 11:38
  • possible duplicate of [Upgrade PHP XSLT processor to XSLT 2.0](http://stackoverflow.com/questions/3873996/upgrade-php-xslt-processor-to-xslt-2-0) – tripleee Sep 05 '12 at 21:18
  • @tripleee, this question was asked months before that, so I would assume it is the other way around. But the answers are largely different and the referred-to answer adds value, so effectively no true dupes ;). – Abel Sep 09 '15 at 14:16

2 Answers2

16

See this list of XSLT engines, from a thread on an XSL mailing list regarding XSLT 2.0 development.

A solution for PHP is to use the PHP/Java Bridge and Saxon, and follow a tutorial.

The current status of development for XSLT 2.0 (and XPath 2.0) means that there are no plans currently, so there can't be any for PHP either. To use XPath 2.0, you need to include Saxon 9.x and inter-operate with the Java libraries.

Even if someone wrote an open source native library for XPath 2.0 and XSLT 2.0 today, it would take time before it would be suitable for production.

Abel
  • 56,041
  • 24
  • 146
  • 247
  • 1
    @Abel: Is subscribing to the XSL list worthwhile? I fear my GMail account might get overrun by an onslaught of spam and that I will never be happy again once I have subscribed… – Tomalak Jan 18 '10 at 12:21
  • 1
    I've personally never received spam through XSL-list, they have a very strong filter and human monitoring. Of course, your e-mail will be publicly visible and that may result in (more) unsolicited mail. But with a good spam filter that's nowadays mandatory, I only receive one spam message a week. What I usually recommend: use a special address for all your list subscriptions or other public profiles. – Abel Jan 18 '10 at 12:42
  • 1
    PS: "is it worthwhile": definitely! Known XSLT experts as the XSLT 2.0 W3C Chief Editor Michael Kay, and others like Dimitre Novatchev, Andrew Welch, G. Ken Holman (also XSL-FO) and David Carlisle are very active and give solid advice. Make sure you read the FAQ before asking and you'll be very welcomed on the list. Will I be seeing you there? – Abel Jan 18 '10 at 12:45
  • I'm more interested in answering than asking, but I'm definitively thinking about it. Stack Overflow is a little weak on the XSLT side of things, only a few questions per day. – Tomalak Jan 18 '10 at 13:39
  • maybe this will help someone: https://stackoverflow.com/a/20371639/4941870 – Mykola Vasilaki Feb 21 '20 at 01:27
  • 1
    @nicholas, that's basically what Dimitri said in the answer below, both are about Saxon-C. Though good to also link that newer question. – Abel Feb 24 '20 at 02:24
3

Saxon C was built having this (PHP) use case in mind. This is a Saxon XSLT 2.0 processor and now it can be used from PHP.

More specifically, here is the information from the documentation on how to build the PHP extension:

PHP extension

To build the PHP extension follow the steps below.

(Alternatively, you may like to use the installation script install.sh supplied by Petr Zak - written for a 64-bit machine, but can be changed for a 32-bit machine.)

Run the commands:

• phpize

• ./configure --enable-saxon

• make

• sudo make

install

Update the php.ini file (if using Ubuntu it is usually in the location '/etc/php5/apache2/') to contain the PHP extension. Insert the following in the Dynamic Extensions section: extension=saxon.so, then run the command

• sudo service apache2 restart

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431