以下是相应的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的解析和生成。