Php 未能通过HTML5验证的XML处理指令

Php 未能通过HTML5验证的XML处理指令,php,xml,xslt,Php,Xml,Xslt,我使用PHP读取服务器上的.xml和.xsl文件,然后转换xml($xml)。当我通过W3C标记验证服务运行生成的HTML5代码时,我得到以下验证错误: Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.) <?xml version="1.0"?> Saw

我使用PHP读取服务器上的.xml和.xsl文件,然后转换xml($xml)。当我通过W3C标记验证服务运行生成的HTML5代码时,我得到以下验证错误:

Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML. 
(XML processing instructions are not supported in HTML.) <?xml version="1.0"?>
Saw
问题似乎是,除了通过XSL转换生成的HTML之外,下面的一行正在写入HTML中(当我在浏览器中查看页面源代码时可见):


PHP代码:

<!DOCTYPE html>
<html>
<head>
    ....
</head>
<body>
    ... some hard-coded HTML here ...

    <?php
        // Load XML file
        $xml = new DOMDocument;
        $xml->load('cdcatalog.xml');

        // Load XSL file
        $xsl = new DOMDocument;
        $xsl->load('cdcatalog.xsl');

        // Configure the transformer
        $proc = new XSLTProcessor;

        // Attach the xsl rules
        $proc->importStyleSheet($xsl);

        echo $proc->transformToXML($xml);
    ?>

    ... more hard-coded HTML here ...
</body>
</html>

....
... 这里有一些硬编码的HTML。。。
... 这里有更多硬编码HTML。。。
XML代码:

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
    <cd>
        <title>Empire Burlesque</title>
        <artist>Bob Dylan</artist>
        <country>USA</country>
        <company>Columbia</company>
        <price>10.90</price>
        <year>1985</year>
    </cd>
    ...
</catalog> 

皇帝讽刺剧
鲍勃·迪伦
美国
哥伦比亚
10.90
1985
...
XSL代码:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
    <table border="1">
        <tr bgcolor="#9acd32">
            <th style="text-align:left">Title</th>
            <th style="text-align:left"="left">Artist</th>
        </tr>
        <xsl:for-each select="catalog/cd">
        <tr>
            <td><xsl:value-of select="title" /></td>
            <td><xsl:value-of select="artist" /></td>
        </tr>
        </xsl:for-each>
    </table>
    </xsl:for-each>
</xsl:template>
</xsl:stylesheet> 

标题
艺术家
有人知道如何解决这个问题吗?或者,真正的问题是我将转换后的HTML嵌入到PHP文件中现有的硬编码HTML中间

谢谢你的指导

添加以下内容之一:

<xsl:output method="html"/>

或者这个:

<xsl:output omit-xml-declaration="yes"/>


在XSLT样式表的顶层:

这不是有效的XSLT代码。
<xsl:output omit-xml-declaration="yes"/>