Home

 

Generating JavaBeans from an XML schema

To allow developers to quickly build an XML application, the XML schema editor supports the generation of beans from an XML schema. Using these beans, you can quickly create an instance document or load an instance document that conforms to the XML schema.

To generate beans from an XML schema, do the following steps:

Create a Java project to contain the beans:

Select File Æ New Æ Project Æ Java Æ Java Project and click Next.
Type RAD75XMLBankJava in the Project name field and click Finish.
If you are prompted to switch to the Java perspective, click Yes.

Generate the JavaBeans:

In the Enterprise Explorer, expand project RAD75XMLBank, right-click Accounts.xsd and select Generate Æ Java.
When the Generate Java dialog is displayed (Figure | 0-22), select the SDO Generator and click Next.

Figure 10-22 XSD to Java Dialog

For the Container field, click Browse, select /RAD75XMLBankJava/src, and click Finish.

Expand the RAD75XMLBankJava project and study the generated packages:

com.xml.rad75.itso-interfaces
com.xml.rad75.itso.impl-implementation classes
com.xml.rad75.itso.util-utility classes
ibm.com/redbooks