Step 2: Create an XMLBeans Schema

In this step, you'll create a simple schema from which the XMLBeans builder will generate Java types. A "schemas" folder was created when you enabled the builder facet. XML schemas put into this directory will be automatically compiled into Java types by the XMLBeans builder

The tasks in this step are:

Create an XMLBeans Schema

  1. In the Project Explorer, in the XMLBeansWebService project, locate the schemas folder that was added when you enabled the XMLBeans Builder facet.
  2. Right-click the schemas folder, then click New > Other.
  3. In the New dialog, expand the XML node, click XML Schema, then click Next.
  4. In the Create XML Schema dialog, ensure that the schemas directory is selected.
    In the File name box, enter PurchaseItem.xsd.
    Click Finish.

Edit the XMLBeans Schema

  1. In the PurchaseItem.xsd Design view, right-click the Types box, then click Add Complex Type.
  2. Rename the new type itemType.
  3. Double-click the itemType complex type to begin editing its definition.
  4. Right-click itemType and select Add Sequence
  5. Right-click the sequence symbol, then click Add Element. Rename the new element "name".
  6. Repeat steps 4 and 5 adding the following elements to the sequence: "price" and "quantity".
  7. Save PurchaseItem.xsd.
  8. Right-click the price and select Show properties.
  9. In the Properties tab, in the Type dropdown, select double.
  10. Repeat step 8 and 9, changing the quantity element's type to int.
  11. In the upper-left hand corner of the Design view click on the icon to return to the schema Design view.
  12. Right-click the Elements box, then click Add Element. Rename the new element "item".
  13. Right-click item and select Set Type > Browse.
  14. In the Set Type dialog, scroll to itemType (the complex schema type you created a moment ago), select that type, then OK.
  15. Be sure to save the file so that the IDE will generate Java types from your schema.

Click one of the following arrows to navigate through the tutorial:


Still need help? Post a question on the Workshop newsgroup.