php - 如何在 PHP 5 中启用 XSLT 函数?

标签 php xml xslt mediatemple

我想使用 xslt 将 xml 文件作为 HTML 嵌套列表打印出来,据我所知代码是正确的,但是我遇到了这个错误

Fatal error: Call to undefined function xslt_create()

我认为这意味着尚未启用 xslt 功能。如何在 PHP 中启用这些功能?是否有我需要包含的 php 文件(如 Javascript 库的工作方式)或者它是否更复杂?我由 MediaTemple 托管。

这是我正在使用的 php 代码:

        <?php 

    // Allocate a new XSLT processor 
    $xh = xslt_create(); 

    // Process the document, returning the result into the $result variable 
    $result = xslt_process($xh, 'armstrong.xml', 'familyToNestedList.xsl'); 
    if ($result) { 
        print "SUCCESS, sample.xml was transformed by sample.xsl into the \$result"; 
        print " variable, the \$result variable has the following contents\n<br>\n"; 
        print "<pre>\n"; 
        print $result; 
        print "</pre>\n"; 
    } 
    else { 
        print "Sorry, sample.xml could not be transformed by sample.xsl into"; 
        print "  the \$result variable the reason is that " . xslt_error($xh) .  
        print " and the error code is " . xslt_errno($xh); 
    } 

    xslt_free($xh); 

    ?>

提前致谢!

最佳答案

根据您的 Linux 发行版,您可以只安装 php5-xsl 模块,将行“extension=php_xsl.so”添加到您的 php.ini 文件,然后重新启动您的 apache2 服务器。

这对我在 Ubuntu 11.10 上有效。您可以在命令行中输入“sudo apt-get install php5-xsl”来安装php5-xml。

关于php - 如何在 PHP 5 中启用 XSLT 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4451042/

相关文章:

php - 如何使用 php 和 mysql 制作组合框?

xml - Xpath查找重复的节点值

geoserver - 使用 XML (GeoServer) 的 PHP Post WMS GetMap 请求

xml - 如何使用数据工厂管道转换 xml 数据

xml - 为什么我的 XSLT 简化样式表不起作用?

php - Amazon S3 与 PHP 的接口(interface)?

php - 在 codeigniter 中插入批处理选项

javascript - 迭代脚本的内存消耗

xslt - 理解一些 xpath 表达式

xml - 如何添加具有新 ID 的第二个元素?