您的位置:首页 > 编程语言

根据xsd使用xmlbean生成代码的ant脚本

2014-04-29 18:07 274 查看
以下是相应的ant脚本:

<project name="Webapp Precompilation" default="build_xmlbean" basedir=".">

    <!-- set global properties for this build -->

      <property name="lib"  location="D:\lib"/>

      <property name="location"  location="."/>

      <property name="xmlbean_xsd" location="xsd路径"/>

      <property name="temp" location="res"/>

      <property name="xmlbean_bin" location="res/xmlbean_bin"/>

      <property name="xmlbean_src" location="res/xmlbean_src"/>

    <!--

        根据xsd文件生成xmlbean

        -->

      <target name="build_xmlbean" >

          

        <delete dir="${xmlbean_bin}"/>

        <delete dir="${xmlbean_src}"/>

          <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpath="${lib}/xbean.jar:${lib}/jsr173_1.0_api.jar"/>

          <xmlbean schema="${xmlbean_xsd}" verbose="true" classgendir="${xmlbean_bin}"

                  srconly="true" srcgendir="${xmlbean_src}"/>

              <javac srcdir="${xmlbean_src}" source="1.6" classpath="${lib}/xbean.jar:${lib}/jsr173_1.0_api.jar"

                  destdir="${xmlbean_bin}" target="1.6"/>

              <jar jarfile="${location}/xmlbeanbuild.jar" basedir="${xmlbean_bin}"/>

       </target>
</project>

生成jar包后,就可以方便进行相应的xml的解析和生成。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: