Generating SDO from XML Schema sample details

This sample represents how to generate Service Data Objects from an XML Schema, and how to use the generated SDOs. The sample includes PurchaseOrder.xsd file and PurchaseOrderSample.java class.

Parent topic: Generating SDO from XML Schema

po.test.PurchaseOrderSample.java

Currently, the SDO generator does not generate a sample application that can show the users how the generated Java™ classes can be used. PurchaseOrderSample.java is provided in the example to demonstrate the following actions:

  • Add initialization code before using the generated classes.
  • Create an instance of PurchaseOrder and the other classes.
  • Serialize the PurchaseOrder instance into an XML file.
  • Load PurchaseOrder from the XML file.

Generating Service Data Objects from PurchaseOrder.xsd

To generate SDOs from PurchaseOrder.xsd, follow the steps below:
  1. Click Window > Open Perspective > Java
  2. Right-click on PurchaseOrder.xsd from the Package Explorer, then select Generate > Java to bring up the Java generation wizard.
  3. From the Generator list, select SDO Generator.
  4. For the Container field, click Browse to locate the SDOFromXSDExample project in your workspace.
  5. Click Finish to generate the Java classes.
  6. The following is a screen snapshot of the generated Java classes.
    Generate Java

Invoking PurchaseOrderSample.java

To run PurchaseOrderSample.java:
Right-click on PurchaseOrderSample.java from the Package Explorer, and select Run As > Java Application. The serialized file "sample.xml" is created, and reloaded. The reconstructed Java instances are displayed in the Console view.
Note: In order to see the sample.xml file, you will need to refresh your project. To do so, right-click the project and select Refresh.
Image of the sample.xml file

The following is a screen snapshot of the serialized XML output.

Image of the serialized XML output


Feedback