To generate the JavaBeans from the schema follow the next steps:

1.Select passengerList.xsd.

2.Right-clickGenerate—>JavaBeans.

3.Enter the container created before.

4.Enter a name for the package.

5.Select Flight as the root element.

6.Select Generate sample test program. Click Finish.

Figure 7-6 is showing the generated Java codes.

Figure 7-6 JavaBeans from schema

Take a few minutes to review the generated code, you will notice that some classes extend ComplexType corresponding to main elements, and the other classes extend SimpleType corresponding to sub elements. Try to run the sample application to follow how it builds the XML file.

7.5 Generate XML/XSL from JavaBeans

You can generate Web pages that can access JavaBeans using XSL. For this section we are going to use the JavaBean showed in Example 7-4. We create this Java file in our Travel Web Project and the package is airline.

Example 7-4 passenger.java

package airline;

/**

*@author osamurs2

Chapter 7. Generators 153

Page 169
Image 169
IBM Version 5 manual Generate XML/XSL from JavaBeans, Select passengerList.xsd Right-clickGenerate-JavaBeans