Exercise 3 solution | page 9 of 10 |
//Exercise 3 builds from Exercise 2
Lab2 lab2 = new Lab2();
XSDSchema schema = lab2.createSchema(xsdFile); //Schema from lab2
//USState
XSDSimpleTypeDefinition usStateType = schema.resolveSimpleTypeDefinition("USState");
//Create the list type
XSDSimpleTypeDefinition listType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
//Set the name="USStateList"
listType.setName("USStateList");
//Set the itemType="po:USState"
listType.setItemTypeDefinition(usStateType);
//Add the listType to the root schema
schema.getContents().add(listType);
// Save the contents of the resource to the file system.
schema.eResource().save(Collections.EMPTY_MAP);
|