`
zy77612
  • 浏览: 278636 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

ant 的 dtd 在哪里?(转载)

阅读更多

看到很多人,包括一些老外,在网上问ant的dtd或者xsd在哪里。

其实在ant.apache.org的FAQ里有一条写的很清楚:

http://ant.apache.org/faq.html#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:

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 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.
虽然dtd会限制ant的可扩展性但是在语法提示的诱惑下还是生成了这个DTD;

方法大致如下:

1.建立一个build.xml

2.输入内容:

<?xml version="1.0" encoding="UTF-8"?>
       <project>
              <target name="makedtd">
                   <antstructure output="project.dtd" />
              </target>
       </project>

3.到build.xml所在目录下执行ant_home%/bin/ant makedtd

4.BUILD FAILED!发生一个NoClassDefFoundError错误,大致是说org/apache/commons/net/ftp/FTPClientConfig没找到

但是project.dtd还是生成了,我这里这个ANT1.7生成的115KB。

5.为了解决这个问题首先查得FTPClientConfig是apache的commons-net包的,于是下载http://apache.mirror.phpchina.com/commons/net/binaries/commons-net-1.4.1.zip,放到ant_home的lib目录下 ,再次构建 OK ,没有错误提示project.dtd生成202KB。

不过好像给XMLSpy挂上还是没有语法提示 -_-

6.仔细看了一下原来生成的DTD里边有几处问题。

   1)第六行<!ELEMENT project (target | %tasks; | %types;)*>

   此行末尾的‘*’号应该为‘+’号因为每个build.xml都应该起码有一个<project>元素

   2)根据XMLSpy提示,有个定义<!ELEMENT targe EMPTY>。

   3) 根据XMLSpy提示<!ELEMENT FTP.........>这块也有问题,由于平时基本不会用到因此删掉。

OK 现在已经是个良好格式(well-formet)的project.dtd文件了。

现在通过XMLSpy根据此project.dtd 建立的build.xml就具备了一般的语法提示功能了。

 

分享到:
评论

相关推荐

    ant_DTD.dtd

    ant_DTD.dtd 已生成好

    Ant DTD语法检查

    编写ant的时候提示语法所用的dtd,因为ant自带不带有必须要生成,比较麻烦。

    ant.dtd

    ant.dtd 编写build.xml文件时,让开发工具自动提示 ant.dtd 编写build.xml文件时,让开发工具自动提示 ant.dtd 编写build.xml文件时,让开发工具自动提示

    DTD 总结 DTD 总结 DTD 总结

    DTD 总结 QQ:292258449 DTD 总结DTD 总结

    DTD 教程 DTD 实例

    DTD 教程 ================== DTD 首页 DTD 简介 DTD 构建模块 DTD 元素 DTD 属性 DTD 实体 DTD 验证 DTD 实例 DTD 总结

    使用DTD验证XML文档

    使用DTD验证XML文档 一、 DTD的定义: a) DTD是Document Type Defintion的缩写,即文档类型定义。DTD用来描述XML文档的结构。 二、 DTD可能包含的内容: a) 元素的定义规则。 b) 元素之间的关系规则。 c) 属性的定义...

    dwr20.dtd

    dwr20.dtd

    struts+spring+mybatis+hibernate的dtd文件

    struts+spring+mybatis+hibernate的dtd文件

    xml与DTD,xml与DTD

    xml与DTD,xml与DTD,xml与DTD,xml与DTD

    使用DTD实现文档结构定义

    1.掌握DTD基本语法规范 2.掌握DTD对元素的声明 实验内容: 1.改正以下message.xml文档的语法错误,并将内部DTD改为外部DTD,并要求验证文档有效性。 &lt;?xml version="1.0" encoding= "gb2312"?&gt; &lt;!DOCTYPE myMessage...

    mybatis-3-config.dtd mybatis-3-mapper.dtd

    mybatis配置的重要文件包括mybatis-3-config.dtd mybatis-3-mapper.dtd

    mybatis-3-config/mapper.dtd 解决mybatis头文件报错

    然后打开eclipse -&gt;Window-&gt;prefenrence-&gt;XML-&gt;XML Catalog-&gt;User Specifiled Entreis-&gt;Add-&gt;Location(此处是你放dtd文件的位置例如:‪D:\mybatis\mybatis-3-config.dtd)-&gt;Key(如果更改config,此处应该是:-//...

    mybatis的两个Dtd文件,config.dtd mapper.dtd

    mybatis的两个Dtd文件,config.dtd mapper.dtd

    ( xhtml1-strict.dtd

    ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ( xhtml1-strict.dtd ...

    DTD的CHM帮助文档

    本压缩文件是DTD的CHM帮助文档。比较不错的一个文档。

    XML-DTD实例讲解

    XML入门精解之DTD 文件格式定义(XML DTD)  DTD实际上可以看作一个或多个XML文件的模板,这些XML文件中的元素、元素的属性、元素的排列方式/顺序、元素能够包含的内容等,都必须符合DTD中的定义。XML文件中的元素,...

    不同版本的 struts2.dtd

    不同 struts2.dtd

Global site tag (gtag.js) - Google Analytics