Here is my sample schemagen ant file:
<?xml version="1.0" encoding="UTF-8"?>
<project name="projectname" default="generate-schema" basedir=".">
<path id="classpath">
<pathelement location="path/to/classes"/>
<fileset dir="/path/to/jaxb/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask">
<classpath refid="classpath"/>
</taskdef>
<target name="generate-schema">
<schemagen srcdir="path/to/src" destdir="path/to/generatedfiles">
<classpath refid="classpath"/>
<schema namespace="http://namespace" file="nameOfMySchema.xsd" />
</schemagen>
</target>
</project>
However, if java classes contains jpa specific annotations, the apt tool could not handle this and throw annotation specific exceptions when the lib coming with jaxb ri is used in the classpath.
Annotations for Persistence part on http://www.devx.com/Java/Article/34069/0/page/1 solves this. download sample code on http://assets.devx.com/sourcecode/18778.zip and use the lib coming with the sample on path 18778/JAXB/lib. Actually, the above ant file is a simplified version of 18778/JAXB/3-JAXB and JPA/build.xml coming with the example..
So, it is ok for now :)