3

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Welcome to Stack Overflow! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. See here for instructions how to write better "link-based" answers.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.