Java 错误:不允许匹配“[xX][mM][lL]”的处理指令目标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19889132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: The processing instruction target matching "[xX][mM][lL]" is not allowed
提问by Java Player
This error,
这个错误,
The processing instruction target matching "[xX][mM][lL]" is not allowed
不允许匹配“[xX][mM][lL]”的处理指令目标
occurs whenever I run an XSLT page that begins as follows:
每当我运行以如下方式开头的 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>
Note: I removed any leading spaces before the first line, but the error still occurs!
注意:我删除了第一行前的所有前导空格,但错误仍然发生!
回答by kjhughes
Xerces-based tools will emit the following error
基于 Xerces 的工具将发出以下错误
The processing instruction target matching "[xX][mM][lL]" is not allowed.
when an XML declarationis encountered anywhere other than at the top of an XML file.
当在 XML 文件顶部以外的任何地方遇到XML 声明时。
This is a valid diagnostic message; other XML parsers should issue a similar error message in this situation.
这是一个有效的诊断消息;在这种情况下,其他 XML 解析器应该发出类似的错误消息。
To correct the problem, check the following possibilities:
要纠正该问题,请检查以下可能性:
Some blank space or other visiblecontent exists before the
<?xml ?>
declaration.Resolution: remove blank space or any other visible content before the XML declaration.
Some invisiblecontent 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 ?>
。解决方法:删除 XML 声明前的空格或任何其他可见内容。
声明之前存在一些不可见的内容
<?xml ?>
。最常见的是字节顺序标记 (BOM)。解决方法:使用诸如W3C 页面在 HTML 中的 BOM 上建议的技术删除 BOM 。
一个流浪
<?xml ?>
声明XML内容中存在。当以编程方式或通过剪切和粘贴方式组合 XML 文件时,就会发生这种情况。<?xml ?>
一个 XML 文件中只能有一个声明,并且只能在顶部。解决方法:以
<?xml
不区分大小写的方式搜索,并从文件中删除除顶部 XML 声明之外的所有内容。
回答by Peter T.
Another reason of the above error is corrupted jar file. I got the same error but for Junit when running unit tests. Removing jar and downloading it again fix the issue.
上述错误的另一个原因是损坏的 jar 文件。我在运行单元测试时遇到了同样的错误,但对于 Junit。删除 jar 并再次下载它可以解决问题。
回答by Hitesh Sahu
回答by pikimota
in my case was a wrong path in a config file: file was not found (path was wrong) and it came out with this exception:
在我的情况下是配置文件中的错误路径:找不到文件(路径错误)并且出现此异常:
Error configuring from input stream. Initial cause was The processing instruction target matching "[xX][mM][lL]" is not allowed.
从输入流配置时出错。最初的原因是不允许匹配“[xX][mM][lL]”的处理指令目标。
回答by Anuj Jindal
Reason for me is 2 of following code in one xml
我的原因是在一个 xml 中包含以下 2 个代码
<?xml version="1.0" encoding="utf-8"?>
回答by user855443
I had a similar issue with 50,000 rdf/xml files in 5,000 directories (the Project Gutenberg catalog file). I solved it with riot (in the jena distribution)
我在 5,000 个目录(Project Gutenberg 目录文件)中有 50,000 个 rdf/xml 文件时遇到了类似的问题。我用 riot 解决了它(在 jena 发行版中)
the directory is cache/epub/NN/nn.rdf (where NN is a number)
目录是 cache/epub/NN/nn.rdf (其中 NN 是一个数字)
in the directory above the directory where all the files are, i.e. in cache
在所有文件所在目录上方的目录中,即在缓存中
riot epub/*/*.rdf --output=turtle > allTurtle.ttl
This produces possibly many warnings but the result is in a format which can be loaded into jena (using the fuseki web interface).
这可能会产生许多警告,但结果的格式可以加载到 jena(使用fuseki Web 界面)。
surprisingly simple (at least in this case).
出奇的简单(至少在这种情况下)。
回答by Beachhouse
For PHP, put this line of code before you start printing your XML:
对于 PHP,在开始打印 XML 之前输入以下代码行:
while(ob_get_level()) ob_end_clean();