为什么没有用于构建脚本的 Apache Ant xml 模式定义或 DTD? [英] How come there is no Apache Ant xml schema definition or DTD for build scripts?

查看:22
本文介绍了为什么没有用于构建脚本的 Apache Ant xml 模式定义或 DTD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我解释一下这是为什么?我一直在使用 Maven,并且缺少 Ant 构建脚本的 xml 定义,这让我不得不通过互联网和文档进行搜索,而不是只查看 xsd 或 DTD.

Could please anybody explain to me why is that? I've been always using Maven and absence of xml definition for Ant build script is something that makes me searching through internet and documentation instead of one look at the xsd or DTD.

例如,几乎不可能确定目标定义是否可以声明自己的属性.

For instance it is almost impossible to find out whether target definition can have own property declared or not.

推荐答案

有一个 FAQ这个:

<antstructure> 任务可以创建不完整的 DTD - 但这个任务有几个问题:

Is there a DTD that I can use to validate my build files?

An incomplete DTD can be created by the <antstructure> task - but this one has a few problems:

  • 它不知道必需的属性.只有手动调整此文件才能在此处提供帮助.
  • 它还没有完成 - 如果您通过 <taskdef> 添加新任务,它不会知道它.请参阅 Michel Casabianca 的 本页这个问题.请注意,您可以在此页面下载的 DTD 基于 Apache Ant 0.3.1.
  • 它甚至可能是无效的 DTD.由于 Ant 允许任务编写者定义任意元素,名称冲突会经常发生 - 如果您的 Ant 版本包含可选的 任务,有两个名为 test 的 XML 元素(任务和 的嵌套子元素)具有不同的属性列表.这个问题无法解决;DTD 没有提供足够丰富的语法来支持这一点.
  • It doesn't know about required attributes. Only manual tweaking of this file can help here.
  • It is not complete - if you add new tasks via <taskdef> it won't know about it. See this page by Michel Casabianca for a solution to this problem. Note that the DTD you can download at this page is based on Apache Ant 0.3.1.
  • It may even be an invalid DTD. As Ant allows tasks writers to define arbitrary elements, name collisions will happen quite frequently - if your version of Ant contains the optional <test> and <junit> tasks, there are two XML elements named test (the task and the nested child element of <junit>) with different attribute lists. This problem cannot be solved; DTDs don't give a syntax rich enough to support this.

这篇关于为什么没有用于构建脚本的 Apache Ant xml 模式定义或 DTD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆