eclipse XML 注释中的回车:“元素的内容必须由格式良好的字符数据或标记组成”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4954951/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:45:19  来源:igfitidea点击:

Carriage returns in XML comment: "The content of elements must consist of well-formed character data or markup"

xmleclipseantxml-validationwell-formed

提问by Epaga

I have the following Ant build file:

我有以下 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>

When viewing this file in Eclipse and when running my Ant script, it gives me the following error message

在 Eclipse 中查看此文件并运行我的 Ant 脚本时,它给了我以下错误消息

      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??

如果我将 XML 注释变成一行,错误就会消失(edit: 并在我将换行符放回时返回......)。是什么赋予了??



EditThe 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.

编辑问题出在导入的 ant 文件中。Eclipse 有一个问题,它在主 Ant 构建文件而不是导入的构建文件中标记了第 6 行。

回答by Epaga

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.

感谢 Jon Skeet 的指点,我尝试缩短 Ant 文件,直到我发现问题实际上出在导入的 Ant 构建文件的第 6 行,而不是主文件本身。由于 Eclipse 标记了主要 Ant 构建文件的第 6 行,这让我很不高兴。

The imported Ant build file had a SVN conflict which obviously led to issues with XML well-formedness.

导入的 Ant 构建文件存在 SVN 冲突,这显然会导致 XML 格式良好的问题。

Sorry about that. I'll leave this open in case someone else encounters a similar silly mistake...

对于那个很抱歉。如果其他人遇到类似的愚蠢错误,我会保持开放状态......