dongliao1860 2017-10-04 13:35
浏览 70
已采纳

在macOS和PHP 7.1上使用disable-output-escaping的问题

I have weird issue; I installed Apache 2.4 with PHP 7.1.8. But when trying to compile a HTML site using XML and XSL it keeps ignoring the "disable-output-escaping=yes" option.

Anyone has an idea what can cause it?

Here is my PHP code:

                $doc = $processor->transformToDoc( $this->_xml );
                $doc->formatOutput = true;
                return $this->cleanOut( $doc->saveXML() );

Regards, Radek

PS: It works on many other servers

  • 写回答

1条回答 默认 最新

  • douhuan1901 2017-10-04 17:14
    关注

    Lots of things can cause this. The most likely are:

    (a) Your XSLT processor might not support disable-output-escaping (it's an optional and deprecated feature)

    (b) You might be sending the XSLT output to a destination other than a serializer (for example, to a DOM tree)

    Really, you shouldn't be using disable-output-escaping. 90% of the time it's only used by people who really haven't mastered the right way to do things in XSLT.

    LATER

    As is clear from the latest update your post, you are using transformToDoc, which writes the XSLT result tree to a DOM; you are then serializing the DOM using doc->formatOutput which uses the DOM serializer rather than the XSLT serializer; this has no knowledge of the disable output escaping attributes in the XSLT.

    (The documentation at http://php.net/manual/en/xsltprocessor.transformtodoc.php has a user-contributed comment pointing out that it's usually better to use transformToXML because that way, the XSLT processor gets to control the output format.)

    I don't know anything much about the native PHP XSLT processor but the same problem occurs with other language environments.

    Incidentally, you might like to know that XSLT 3.0 is now available for the PHP environment via the Saxon/C product (see www.saxonica.com). One of the reasons people resort to disable-output-escaping in XSLT 1.0 is because XSLT 1.0 doesn't provide easy ways to do grouping. This is fixed in later XSLT versions but unfortunately the PHP XSLTProcessor was never updated.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM