这个错误,

不允许处理指令目标匹配“[xX][mM][lL]”

每当我运行以如下开头的XSLT页面时,都会发生这种情况:

<?xml version="1.0" encoding="windows-1256"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:include href="../header.xsl"/>
  <xsl:template match="/">
    <xsl:call-template name="pstyle"/>
    <xsl:call-template name="Validation"/>
    <xsl:variable name="strLang">
      <xsl:value-of select="//lang"/>
    </xsl:variable>
    <!-- ////////////// Page Title ///////////// -->
    <title>
        <xsl:value-of select="//ListStudentFinishedExam.Title"/>
    </title>

注意:我删除了第一行之前的任何前导空格,但错误仍然发生!


当前回答

基于xerces的工具将发出以下错误

The processing instruction target matching "[xX][mM][lL]" is not allowed.

当在XML文件顶部以外的任何地方遇到XML声明时。

这是一条有效的诊断消息;在这种情况下,其他XML解析器应该发出类似的错误消息。

要纠正该问题,请检查以下可能性:

Some blank space or other visible content exists before the <?xml ?> declaration. Resolution: remove blank space or any other visible content before the XML declaration. Some invisible content exists before the <?xml ?> declaration. Most commonly this is a Byte Order Mark (BOM). Resolution: Remove the BOM using techniques such as those suggested by the W3C page on the BOM in HTML. A stray <?xml ?> declaration exists within the XML content. This can happen when XML files are combined programmatically or via cut-and-paste. There can only be one <?xml ?> declaration in an XML file, and it can only be at the top. Resolution: Search for <?xml in a case-insensitive manner, and remove all but the top XML declaration from the file.

其他回答

调试XML文件。要么有空间,要么添加了额外或更少的标签。

为了更好地理解,可以通过命令行构建项目。Windows: gradlew构建

在我的例子中,AndroidManifest.xml在第一行有一个空格

<Empty Row> // This Creates the issue 
<?xml version="1.0" encoding="utf-8"?>

上述错误的另一个原因是损坏的jar文件。我得到了同样的错误,但Junit运行单元测试时。删除jar并再次下载解决了这个问题。

对我来说,账单就是麻烦制造者。将标签替换为空白应该可以解决问题

基于xerces的工具将发出以下错误

The processing instruction target matching "[xX][mM][lL]" is not allowed.

当在XML文件顶部以外的任何地方遇到XML声明时。

这是一条有效的诊断消息;在这种情况下,其他XML解析器应该发出类似的错误消息。

要纠正该问题,请检查以下可能性:

Some blank space or other visible content exists before the <?xml ?> declaration. Resolution: remove blank space or any other visible content before the XML declaration. Some invisible content exists before the <?xml ?> declaration. Most commonly this is a Byte Order Mark (BOM). Resolution: Remove the BOM using techniques such as those suggested by the W3C page on the BOM in HTML. A stray <?xml ?> declaration exists within the XML content. This can happen when XML files are combined programmatically or via cut-and-paste. There can only be one <?xml ?> declaration in an XML file, and it can only be at the top. Resolution: Search for <?xml in a case-insensitive manner, and remove all but the top XML declaration from the file.

只需删除这一行:<?XML版本="1.0"编码="utf-8"?>,因为这种错误只出现在这一行,或者你也可以根据这个答案中提到的行检查你的行格式。