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

发布于 2024-10-16 18:21:23 字数 694 浏览 4 评论 0原文

我有以下 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

家住魔仙堡 2024-10-23 18:21:23

感谢 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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文