Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XSLTProcessor::importStylesheet()中的PHP警告,尽管XSL样式表几乎为空_Php_Xml_Xslt - Fatal编程技术网

XSLTProcessor::importStylesheet()中的PHP警告,尽管XSL样式表几乎为空

XSLTProcessor::importStylesheet()中的PHP警告,尽管XSL样式表几乎为空,php,xml,xslt,Php,Xml,Xslt,我正在尝试使用以下代码 # LOAD XML FILE $XML = new DOMDocument(); $XML->loadXML( $exporteddatatransformed ); # START XSLT $xslt = new XSLTProcessor(); $XSL = new DOMDocument(); $XSL->load( 'xsl/'.$xsltemplatefileid.'.xsl', LIBXML_NOCDATA); $xslt->impor

我正在尝试使用以下代码

# LOAD XML FILE
$XML = new DOMDocument();
$XML->loadXML( $exporteddatatransformed );

# START XSLT
$xslt = new XSLTProcessor();
$XSL = new DOMDocument();
$XSL->load( 'xsl/'.$xsltemplatefileid.'.xsl', LIBXML_NOCDATA);
$xslt->importStylesheet( $XSL );            <-- LINE 549
#PRINT
print $xslt->transformToXML( $XML );
#加载XML文件
$XML=newdomdocument();
$XML->loadXML($exporteddatatransformed);
#启动XSLT
$xslt=新的XSLTProcessor();
$XSL=newdomdocument();
$XSL->load('XSL/'.$xsltemplatefileid.'.XSL',LIBXML\u NOCDATA);
$xslt->importStylesheet($XSL);transformToXML($XML);
但它会产生以下错误

警告:XSLTProcessor::importStylesheet()[XSLTProcessor.importStylesheet]:编译错误:第549行/home/../xsl/1234567890.xsl第2行元素样式表

XSL表如下所示:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
</xsl:template>
</xsl:stylesheet> 


为了诊断问题发生的位置,我目前已经将其缩减为“无”,但它仍然保留在这个“基本”XSL版本中

如果您将xsl:stylesheet行替换为以下行,则似乎可以正常加载:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

这意味着拥有此xsl文件:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    </xsl:template>
</xsl:stylesheet>

而不是你的

当您尝试转换文件时,它是否起作用


注意:我不经常使用XSL,所以不知道为什么您提出的方案不起作用;但是“”在上和中都使用,并且在PHP手册中使用

所以,我猜这应该有助于解决你的问题,即使我真的不知道“为什么”^^