簡體   English   中英

PHP XSLTProcessor 編譯錯誤

[英]PHP XSLTProcessor Compilation error

無法使用樣式表進行轉換,該樣式表在 xsl:text 節點中具有實體。 如果我輸入 &some; 我沒有錯誤和空輸出在 xsl:text 節點之外。

測試文件

$xml = new DOMDocument;
$xml->load('test.xml');

$xsl = new DOMDocument;
$xsl->load('test.xsl');

$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);

echo $proc->transformToXML($xml);

測試文件

<?xml version="1.0" ?>
<test>123</test>

測試.xsl

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE xsl:stylesheet [ <!ENTITY some "22323"> ]>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


    <xsl:output method="text" />

    <xsl:template match="/">
        <xsl:text>&some;</xsl:text>
    </xsl:template>

</xsl:stylesheet>

有錯誤:

Warning: XSLTProcessor::importStylesheet(): xsltParseTemplateContent: xslt:text content problem in /Users/stexe/Repos/umi.cms.2/test.php on line 13

Call Stack:
    0.0003     226288   1. {main}() /Users/stexe/Repos/umi.cms.2/test.php:0
    0.0009     228424   2. XSLTProcessor->importStylesheet() /Users/stexe/Repos/umi.cms.2/test.php:13

操作系統 X,PHP 5.4.45(自制軟件)

PHP信息

libxml2 Version => 2.9.5
ibxslt Version => 1.1.29
libxslt compiled against libxml Version => 2.9.4

嘗試設置

$xsl = new DOMDocument;
$xsl->substituteEntities = TRUE;

load調用之前。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM