Will XPath 2.0 and/or XSLT 2.0 be implemented in PHP?

安稳与你 提交于 2019-11-26 09:46:21

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/2085632/will-xpath-2-0-and-or-xslt-2-0-be-implemented-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!