Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Jaxb: Generate classes from XML schema using xjc tool

By using xjc command line tool, you can Map Xml Schema to Java classes.

You can download xjc from following command.

https://jaxb.java.net/2.2.4/docs/xjc.html

Use following command to map Xml Schema to classes.

xjc.sh xsdFile


employees.xsd

xmlns:xs="http://www.w3.org/2001/XMLSchema">


name="id" type="xs:integer" />
name="firstname" type="xs:string" />
name="middlename" type="xs:string" />
name="lastname" type="xs:string" />
name="age" type="xs:integer" />
name="salary" type="xs:decimal" />
name="married" type="xs:string" />
name="department" type="xs:string" />
name="pjtname" type="xs:string" />
name="from" type="xs:date" />
name="to" type="xs:date" />


name="name">


ref="firstname" />
ref="middlename" />
ref="lastname" />
ref="age" />
ref="salary" />
ref="married" />





name="project">


ref="department" />
ref="pjtname" />
ref="from" />
ref="to" />





name="employee">


ref="id" />
ref="name" />
ref="project" maxOccurs="unbounded" />





name="employees">


ref="employee" maxOccurs="unbounded" />






$ ./xjc.sh ../../employees.xsd 
parsing a schema...
compiling a schema...
generated/Employee.java
generated/Employees.java
generated/Name.java
generated/ObjectFactory.java
generated/Project.java



Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Jaxb: Generate classes from XML schema using xjc tool

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×