How to generate xml schema xsd from java class using jaxb in eclipse

Let us discuss how to generate or create xml schema xsd from java class using jaxb in eclipse with below example.

Steps:

1. Create a new JAXB project. File -> New -> Other -> JAXB -> JAXB Project.
jaxb1
 
2. Enter the project name and click on Finish button.
jaxb2
 
3. Download JAXB Jar and JAXB-XJC jar files and include in class path.
jaxb11
 
4. Create package which will contain xsd file.
jaxb3
 
5. Create package which will contain java classes.
jaxb4
 
6. Create a java class. Here we are using the java classes generated from previous example.
jaxb12
 
7. Right click on your package -> New -> Other -> JAXB -> Schema from JAXB Classes and click on Next.
jaxb13
 
8. Specify file name and location for new xsd file and click on Next.
jaxb14
 
9. Select java classes from which schema have to generated and click on Finish.
jaxb15
 

On Console:

loading...
com.w3spoint.javaclass.Address
com.w3spoint.javaclass.ObjectFactory
com.w3spoint.javaclass.Student
generating schema...
Schema 
D:\TestWorkspace\JAXBXSDTest2\src\com\w3spoint\xsd\test1.xsd 
generated

Download this example.
 
Previous Topic: How to generate java class from xml schema xsd using jaxb in eclipse.

 

Content Protection by DMCA.com
Please Share