Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Model XSD

XML schemas are modeled using UML Class diagrams. The XML Schema pages of the Toolbox provide in-built support for the UML profile for XSD. This enables an abstract UML Class model to be automatically generated as a W3C XML Schema (XSD) file.

The following Class diagram models simple schema for an example Employee Details system, intended to store a company's employee contact information. The Classes shown form the EmployeeDetails package. The UML attributes of the Classes map directly to XML elements or attributes. Note that the Classes have no methods, since there is no meaningful correspondence between Class methods and XSD constructs.


The following code shows the schema generated for the Employee Details package by default. Notice how each UML Class corresponds to a complexType definition in the schema. The Class attributes are generated as schema elements contained in a Sequence model group within the definition. The Enumeration Class is the exception here - it maps directly to an XSD enumeration, contained within a simpleType definition.


<?xml version="1.0"?>

<xs:schema xmlns:xs="">

       <xs:element name="ContactInfo" type="ContactInfo"/>

       <xs:complexType name="ContactInfo">


                       <xs:element name="ContactInfo.homePhone" type="xs:string" maxOccurs="1"/>

                       <xs:element name="" type="xs:string"/>

                       <xs:element name="ContactInfo.streetAddress" type="xs:string"/>


                               <xs:element name="ContactInfo.mobilePhone" type="xs:string"/>

                               <xs:element name="ContactInfo.officePhone" type="xs:string"/>




       <xs:simpleType name="Gender">

               <xs:restriction base="xs:string">

                       <xs:pattern value="male|female"/>



       <xs:element name="Employee" type="Employee"/>

       <xs:complexType name="Employee">


                       <xs:extension base="Person">


                                       <xs:element name="status" type="Status"/>

                                       <xs:element name="jobTitle" type="xs:string"/>

                                       <xs:element name="startDate" type="xs:date"/>

                                       <xs:element name="department" type="xs:string"/>





       <xs:element name="Person" type="Person"/>

       <xs:complexType name="Person">


                       <xs:element name="surName" type="xs:string" maxOccurs="1"/>

                       <xs:element name="firstName" type="xs:string" maxOccurs="1"/>

                       <xs:element name="birthDate" type="xs:string" maxOccurs="1"/>

                       <xs:element name="contactDetails" type="ContactInfo"/>


               <xs:attribute name="gender" use="optional" type="Gender"/>


       <xs:element name="EmployeeRecords" type="EmployeeRecords"/>

       <xs:complexType name="EmployeeRecords">


                       <xs:element name="Employee" type="Employee"/>



       <xs:simpleType name="Status">

               <xs:restriction base="xs:string">

                       <xs:enumeration value="Full-Time"/>

                       <xs:enumeration value="Part-Time"/>

                       <xs:enumeration value="Casual"/>

`                        <xs:enumeration value="Contract"/>





The following topics provide further explanation: