Generating Java beans from an XML schema

To help you quickly build an XML application, you can use the Generate Java wizard to generate 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.

Before you begin

Your workspace must contain at least one project that is configured to work with Java™ source code, such as a Java, Web, EJB, or Application Client project.

About this task

The following instructions were written for the Resource perspective, but they will also work in other perspectives.

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

Procedure

  1. In the Navigator view, right-click the XML schema file and click Generate > Java. The Generate Java wizard opens.
    Note: The XML schema that you select as input to the generator must contain at least one global (or top-level) element declaration.
  2. From the Generator list, select SDO Generator and then click Next.
  3. In the Container field, specify your project or folder to contain the Java beans. Click Browse to select from a list of all valid projects and folders that exist in the workbench.
  4. By default, the SDO Generator will output Java classes that comply to the same JDK level that is used by the project that you chose for your container. To change the JDK compliance level:
    1. Click Advanced.
    2. Click Other and then select a JDK version from the list.
  5. Click Finish.

Results

The beans and classes are created in the location that you specified, as well as a utility class containing methods that can be used to load and save XML instance documents Double-click them to edit them in the Java or Class editor

Feedback