prolog 中不允许使用 Eclipse 内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5445143/
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
Eclipse Content is not allowed in prolog
提问by Ranger
I'm having trouble opening my main in my eclipse project. It keeps coming up with:
我在 eclipse 项目中打开主文件时遇到问题。它不断出现:
"content is not allowed in prolog"
“序言中不能有内容”
I haven't altered my code or anything. I have no idea what has gone wrong, anybody seen this before?
我没有改变我的代码或任何东西。我不知道出了什么问题,有人见过这个吗?
回答by Aquanauta
I had the same error and figured it out.
我有同样的错误并想通了。
When I tried to create a new string resource, I tried to paste the new resource value on the "Android Resources" screen. To my surprise, the paste operation (using CTRL + V) does not work on that screen, and I tried it several times.
当我尝试创建新的字符串资源时,我尝试将新的资源值粘贴到“Android 资源”屏幕上。令我惊讶的是,粘贴操作(使用 CTRL + V)在该屏幕上不起作用,我尝试了几次。
After that I started getting the error. When I switched from the "Android Resources" screen to the raw XML screen of the Strings.xml file, I noticed that all the text that I tried to paste was at the beginning of the file, like this:
之后我开始收到错误。当我从“Android 资源”屏幕切换到 Strings.xml 文件的原始 XML 屏幕时,我注意到我尝试粘贴的所有文本都在文件的开头,如下所示:
Image content description. Image content description.<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My App</string>
</resources>
And that was causing the error for me.
这导致了我的错误。
回答by Konstantin Komissarchik
This error is generated during parsing of an XML document. Here is one writeup:
此错误是在解析 XML 文档期间生成的。这是一篇文章:
http://www.mkyong.com/java/sax-error-content-is-not-allowed-in-prolog/
http://www.mkyong.com/java/sax-error-content-is-not-allowed-in-prolog/
You didn't provide sufficient information in your question to know which file might be corrupted, but search for xml files in your project and see if they look ok.
您没有在问题中提供足够的信息来了解哪个文件可能已损坏,但在您的项目中搜索 xml 文件并查看它们是否正常。
回答by Raghu Nandan
Restarting Eclipse and Cleaning the problem dint help.
I opened the .xml file in a XML editor and did a Validate
on that error alone. this solved my problem. Hope this helps for people who still got the problem
重新启动 Eclipse 并清理问题可以提供帮助。我在 XML 编辑器中打开了 .xml 文件,并Validate
单独处理了该错误。这解决了我的问题。希望这对仍然遇到问题的人有所帮助
回答by Jwalant Bhatt
Its most likely an encoding problem: (edit in notepad++ and select) encoding utf-8 -BOM
它很可能是编码问题:(在记事本++中编辑并选择)编码 utf-8 -BOM
回答by James Oravec
I had a similar issue and wanted to make a note, in case other had the same root cause that I did.
我有一个类似的问题,想记下,以防其他人有和我一样的根本原因。
My issue was related to the xsi:schemaLocation
. The url stated was no longer being served. Via googling, I got a copy of the actual xsd file, which I included locally then updated the reference. This solved my issue.
我的问题与xsi:schemaLocation
. 不再提供所述网址。通过谷歌搜索,我得到了一份实际 xsd 文件的副本,我将其包含在本地,然后更新了参考。这解决了我的问题。
e.g. http://dozer.sourceforge.net/schema/beanmapping.xsd
became beanmapping.xsd
in the snippet below, after adding the .xsd
file to the same folder.
例如,在将文件添加到同一文件夹后,http://dozer.sourceforge.net/schema/beanmapping.xsd
变成beanmapping.xsd
了下面的代码片段.xsd
。
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dozer.sourceforge.net beanmapping.xsd">
回答by reza rahmad
i delete the c:/users/your_computer/appdata/.gradle/cache and it went go to normal
我删除了 c:/users/your_computer/appdata/.gradle/cache 并且它变得正常
回答by anjaneya
I also had the same error.Check your Xml files.There may be syntax error in xml files.
我也有同样的错误。检查您的 Xml 文件。xml 文件中可能存在语法错误。
回答by Greg Domjan
Having incorrect encoding information might cause this.
编码信息不正确可能会导致这种情况。
?<?xml version="1.0" encoding="utf-16"?>
at the top of an ascii or utf-8 encoded file for example.
例如,在 ascii 或 utf-8 编码文件的顶部。
回答by Highstaker
Yeah, I had the same, and the first line in strings.xml:
是的,我有同样的,以及 strings.xml 中的第一行:
<?xml version="1.0" encoding="utf-8"?>
was marked with this error. Though I also didn't alter any code, yesterday, when I closed Eclipse, everything was fine, no errors (though some warnings were present, but that doesn't matter, I think)
被标记有此错误。虽然我也没有改变任何代码,昨天,当我关闭 Eclipse 时,一切都很好,没有错误(虽然存在一些警告,但这并不重要,我认为)
All I did now is Selecting this line, Ctrl+X (Cut) it, Ctrl+S to save, Ctrl+V (Paste) it back and Ctrl+S again, and the error is gone. Not sure if it will work for everybody, but it did for me 8)
我现在所做的就是选择这一行,Ctrl+X(剪切)它,Ctrl+S 保存,Ctrl+V(粘贴)返回并再次 Ctrl+S,错误消失了。不确定它是否适用于每个人,但它对我有用 8)
回答by Egor Volk
Check: that you have no any additional wrong text before in the beginning of file.
检查:在文件开头之前没有任何额外的错误文本。