Reputation: 193
Is there any way to use maven to generate java classes from an XSD (similar to jaxb2-maven-plugin) but just simply generates pojos without the javax.xml annotations?
Upvotes: 3
Views: 1273
Reputation: 1
You can use Perl regex replacements on the xjc generated java to remove all the javax annotations and references as below:
$s =~ s/\@\w+\([^\(\)]+\)//smg;
$s =~ s/\@\w+\r\n//g;
$s =~ s/javax\.xml\.datatype\.XMLGregorianCalendar/java\.util\.Date/g;
$s =~ s/import javax.*;\r\n//g;
$s =~ s/XMLGregorianCalendar/Date/g;
It is not perfect in its treatment of spaces/carriage returns between annotations, but worked for me on a commercial project to generate the POJOs I needed.
See the full script here: https://github.com/ajbarber/JAXStripper
Upvotes: 0
Reputation: 2456
You can use XML-Beans. It is fairly easy.
How to include automatically xmlbeans generated code into maven jar?
http://mojo.codehaus.org/xmlbeans-maven-plugin/
Please refer to this for further clarification - http://blog.bdoughan.com/2012/01/how-does-jaxb-compare-to-xmlbeans.html
Upvotes: 1