zoukankan      html  css  js  c++  java
  • Apache Ant编写build.xml的自动提示 ANT DTD

    大家都知道Eclipse的自动输入或者自动完成的功能是用XML的DTD文件来控制的,但是安装了ANT的插件之后会发现Apache并没有为我们直接提供书写build.xml的DTD文件,可能是由于扩张方面的考虑。在Apache的 FAQ里有提到

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

    原文在这里(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

    内容如下

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

    然后使用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 里面改成 <=:abcdefghijklmnopqrstuvwxyz ${

    OK!当然这样做会是Eclipse的速度变慢,喜忧参半。

     

    仅供参考学习交流。




    Then, we've got it
    There, show me open air
  • 相关阅读:
    日期格式
    典型的三行两列居中高度自适应div+css布局
    转javascript倒计时例子
    javascript encode64 decode64
    【转】Linux下 zip 和 unzip的用法
    【转】matlab reshape使用
    【转】MySQL修改root密码的各种方法整理
    【转】汇编语言里 eax, ebx, ecx, edx, esi, edi, ebp, esp
    [转]ExtJS xtype class对照表
    vc 字符串转时间,并取时间差
  • 原文地址:https://www.cnblogs.com/lzsu1989/p/2117718.html
Copyright © 2011-2022 走看看