Let us discuss how to generate or create java class from xml schema xsd using jaxb in eclipse with below example.
Steps:
1. Create a new JAXB project. File -> New -> Other -> JAXB -> JAXB Project.
2. Enter the project name and click on Finish button.
3. Download JAXB Jar and JAXB-XJC jar files and include in class path.
4. Create package which will contain xsd file.
5. Create package which will contain java classes.
6. Create xsd file.
7. Copy the below code into xsd file.
2. Enter the project name and click on Finish button.
3. Download JAXB Jar and JAXB-XJC jar files and include in class path.
4. Create package which will contain xsd file.
5. Create package which will contain java classes.
6. Create xsd file.
7. Copy the below code into xsd file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
8. Right click on your package -> New -> Other -> JAXB -> JAXB Classes from Schema.
9. Specify project for new Java classes and click on Next.
10. Select schema from which java classes have to generated and click on Next.
11. Specify package for new Java classes and click on Finish.
9. Specify project for new Java classes and click on Next.
10. Select schema from which java classes have to generated and click on Next.
11. Specify package for new Java classes and click on Finish.
On Console:
parsing a schema... |
No comments:
Post a Comment