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
- In the Project Explorer, in the XMLBeansWebService project,
locate the schemas folder that was added when you enabled
the XMLBeans Builder facet.
- Right-click the schemas folder, then click New > Other.
- In the New dialog, expand the XML node, click XML
Schema, then click Next.
- 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
- In the PurchaseItem.xsd Design view, right-click the Types box, then
click Add Complex Type.
- Rename the new type itemType.
- Double-click the itemType complex type to begin editing its definition.
- Right-click itemType and select Add
Sequence
- Right-click the sequence symbol, then click Add
Element. Rename the new element "name".
- Repeat steps 4 and 5 adding the following elements to the sequence: "price" and "quantity".
- Save PurchaseItem.xsd.
-
Right-click the price and select Show
properties.
- In the Properties tab, in the Type dropdown,
select double.
- Repeat step 8 and 9, changing the quantity element's type
to int.
- In the upper-left hand corner of the Design view click
on the icon to return to the schema Design view.
- Right-click the Elements box, then click Add
Element. Rename the new element "item".
- Right-click item and select Set
Type > Browse.
- In the Set Type dialog, scroll to itemType (the
complex schema type you created a moment ago), select that type, then OK.
- 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.