|
大家都知道Eclipse的自动输入或者自动完成的功能是用XML的DTD文件来控制的,但是安装了ANT的插件之后会发现Apache并没有为我们直接提供书写build.xml的DTD文件,可能是由于扩张方面的考虑。在Apache的 FAQ里有提到
An incomplete DTD can be created by the 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 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 and tasks, there are two XML elements named test (the task and the nested child element of ) with different attribute lists. This problem cannot be solved; DTDs don't give a syntax rich enough to support this.
原文在这里(http://ant.apache.org/faq.html#dtd)
但是Ant的预订标签里面提供了生成DTD的方法。这里需要在%ANT_HOME%的lib目录下面加一个JAR包,
下载地址http://apache.mirror.phpchina.com/commons/net/binaries/commons-net-1.4.1.zip
现在新建一个build.xml
内容如下
然后使用ANT命令执行这个build.xml文件,在相同路径下就会生成ant_DTD.dtd
现在用Eclipse引用这个DTD就可以实现编写build.xml的时候的自动提示了。
建议把这放在%ANT_HOME%的 etc目录下,以免误删。
Eclipse的设置在:Window--Preference--XML--XML Catalog 点击Add 输入刚才那个生成的DTD文件地址,KEY_TYPE选 public ID , 取一个名字(KEY),OK
现在按下alt+/ 就可以在有提示内容的地方弹出提示了
当然,如果想在输入的时候就直接弹出,要设置:Window--Preference--XML--XML File--Editor 在Content asist里,勾上 Automatically make suggestion, 然后在
Prompt when these characters are inserted 里面改成 |
|