Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : XML : Education - Tutorials
XML Schema Infoset Model, Part 2
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
3. Simple types
  


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);                                 
                                        

Main menuSection menuFeedbackPreviousNext
About IBM | Privacy | Legal | Contact