Hi!
How can i generate java domain objects that represents XSD elements?
I have tested jaxb and it generates too many things (annotations, statci
classes inside, enums etcetera).
I just need to generate classes with fields, getters and setter.
Is there some tool that can do this?
Pozdro, Wojtas
Steve W. Jackson - 19 Sep 2007 15:41 GMT
> Hi!
>
[quoted text clipped - 6 lines]
>
> Pozdro, Wojtas
Sounds like <http://xmlbeans.apache.org/> might have a solution you can
use. You provide the schema (XSD) file, and it creates Java classes
around it.

Signature
Steve W. Jackson
Montgomery, Alabama
Roedy Green - 19 Sep 2007 17:11 GMT
On Wed, 19 Sep 2007 10:33:35 +0200, "Wojtas"
<wkrugiolka@poczta.onet.pl> wrote, quoted or indirectly quoted someone
who said :
>I just need to generate classes with fields, getters and setter.
>Is there some tool that can do this?
See http://mindprod.com/jgloss/parser.html
Look for a Java parser. Then prune it to ignore anything you don't
want.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Stefan Ram - 19 Sep 2007 17:20 GMT
>I just need to generate classes with fields, getters and setter.
public class Main
{ public static void main( final java.lang.String[] args )
throws java.lang.Throwable
{
final java.lang.String nl = "\n";
final String path = "Example.java";
final String encoding = "UTF-8";
new java.io.OutputStreamWriter
( new java.io.FileOutputStream( path ), encoding ).append
( "class Example" + nl +
"{ private int field;" + nl +
" public int getField(){ return field; }" + nl +
" public void setField( final int field )" + nl +
" { this.field = field; }}" + nl ).close(); }}
Manish Pandit - 19 Sep 2007 18:11 GMT
> Hi!
>
[quoted text clipped - 6 lines]
>
> Pozdro, Wojtas
XMLBeans, as pointed out by Steve is the best option. You will see
enums if the XSD contains <xsd:enumeration>. What gets generated is a
reflection of the model defined in the XSD. Of course there is no way
to enforce rules like minOccurs, maxOccurs and similar constraints.
-cheers,
Manish