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 2: Create an atomic simple type with enumeration facets page 5 of 10


Using the XML Schema Model APIs and adding on to the schema document created in Exercise 1: Create a root schema document, create a user-defined simple type called "USState" that has a primitive base type "string" and three enumeration facets called "AK","AL", and "AR".


<?xml version="1.0"?>
<schema
  targetNamespace="http://www.eclipse.org/xsd/examples/po"
  xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:po="http://www.eclipse.org/xsd/examples/po">
 
  <simpleType name="USState">
    <restriction base="string">
      <enumeration value="AK"/>
      <enumeration value="AL"/>
      <enumeration value="AR"/>
    </restriction>
  </simpleType>
  
</schema>
                                

New constructs created in this exercise:

  • <simpleType> - Global simple type with name="USState"
  • <enumeration> - Enumeration facets ("AK","AL", and "AR")
Solution: Exercise 2 solution


Main menuSection menuFeedbackPreviousNext
About IBM | Privacy | Legal | Contact