XML 注释中的回车:“元素的内容必须由格式正确的字符数据或标记组成”
我有以下 Ant 构建文件:
<?xml version="1.0" encoding="UTF-8"?>
<project default="build" name="MyAntScript">
<!--
A comment explaining
the ant file going over
multiple lines
like this
quite poetic, huh?
-->
<import file="myant.xml" />
...
</project>
在 Eclipse 中查看此文件并运行 Ant 脚本时,它会给出以下错误消息
c:\myant.xml:6: The content of elements must consist of well-formed
character data or markup.
如果我将 XML 注释转换为单行,错误就会消失(编辑:当我把换行符放回时就会回来...)。什么给?
编辑 问题出在导入的 ant 文件中。Eclipse 存在一个问题,它在主 Ant 构建文件而不是导入的构建文件中标记了第 6 行。
I have the following Ant build file:
<?xml version="1.0" encoding="UTF-8"?>
<project default="build" name="MyAntScript">
<!--
A comment explaining
the ant file going over
multiple lines
like this
quite poetic, huh?
-->
<import file="myant.xml" />
...
</project>
When viewing this file in Eclipse and when running my Ant script, it gives me the following error message
c:\myant.xml:6: The content of elements must consist of well-formed
character data or markup.
The error goes away if I turn the XML comment into a single line (edit: and comes back when I put the newline back in...). What gives??
Edit The problem was in the imported ant file..Eclipse had an issue where it marked line 6 in the main Ant build file rather than the imported build file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢 Jon Skeet 的指点,我尝试缩短 Ant 文件,直到发现问题实际上出在导入的 Ant 构建文件的第六行,而不是主文件本身。这让我很困惑,因为 Eclipse 正在标记主 Ant 构建文件的第六行。
导入的 Ant 构建文件存在 SVN 冲突,这显然会导致 XML 格式良好的问题。
对此感到抱歉。我会将其保留,以防其他人遇到类似的愚蠢错误......
Thanks to Jon Skeet's pointers, I tried shortening the Ant file until I figured out the problem was actually in line six of an imported Ant build file, not the main file itself. This had thrown me off since Eclipse was marking line six of the main Ant build file.
The imported Ant build file had a SVN conflict which obviously led to issues with XML well-formedness.
Sorry about that. I'll leave this open in case someone else encounters a similar silly mistake...