<?xml version="1.0"?>
<!-- 
XML schema for zooml.com's interpretation of OMG's UML 2.0 specifications
(http://www.omg.org/spec/UML/2.1.2/). Includes basic support for classes 
and several different kinds of relationships.

Changes noted in comments with differences identified by category:
    clarification: full support (mostly) with restating of intention
    restriction: partial support
    modification: differs significantly (but general idea is similar)
    not supported

The material herein was derived from the L1.merged.cmof document 
(http://www.omg.org/cgi-bin/doc?ptc/2006-10-06), with the addition of 
the (Auxiliary Constructs) Model.

Linking within the document is performed via the "idref" XMI attribute.
For example, a typed element's "type" child element will have a single
attribute, "idref" which has the id of the type object (e.g. particular class).
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
            xmlns:uml="http://www.zooml.com/schemas/2008/11/UML"
            targetNamespace="http://www.zooml.com/schemas/2008/11/UML">
    <xsd:import namespace="http://schema.omg.org/spec/XMI/2.1" schemaLocation="http://www.omg.org/spec/XMI/20071213/XMI.xsd"/>

    <xsd:simpleType name="AggregationKind">
        <xsd:annotation>
            <xsd:documentation>AggregationKind is an enumeration type that specifies the literals for defining the kind of aggregation of a property.</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:NCName">
            <xsd:enumeration value="none"/>
            <xsd:enumeration value="shared"/>
            <xsd:enumeration value="composite"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="VisibilityKind">
        <xsd:annotation>
            <xsd:documentation>VisibilityKind is an enumeration type that defines literals to determine the visibility of elements in a model.</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:NCName">
            <xsd:enumeration value="public"/>
            <xsd:enumeration value="private"/>
            <xsd:enumeration value="protected"/>
            <xsd:enumeration value="package"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="Comment">
        <xsd:annotation>
            <xsd:documentation>A comment is a textual annotation that can be attached to a set of elements.</xsd:documentation>
        </xsd:annotation>
        <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
            <xsd:element name="body" minOccurs="0" type="xsd:string"/>
            <!-- (restriction) Must be ownedComment (annotatedElement is always parent)
                 <xsd:element name="annotatedElement" minOccurs="0" maxOccurs="unbounded">
                     <xsd:complexType>
                         <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                     </xsd:complexType>
                 </xsd:element> -->
        </xsd:choice>
        <xsd:attribute ref="xmi:id"/>
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>
    <xsd:element name="Comment" type="uml:Comment"/>

    <xsd:complexType name="LiteralInteger">
        <xsd:annotation>
            <xsd:documentation>A literal integer is a specification of an integer value.</xsd:documentation>
        </xsd:annotation>
        <xsd:attribute name="value" type="xsd:integer"/>
    </xsd:complexType>

    <xsd:complexType name="LiteralUnlimitedNatural">
        <xsd:annotation>
            <xsd:documentation>A literal unlimited natural is a specification of an unlimited natural number.
            Note that this is either the string 'unbounded' or a non-negative integer.</xsd:documentation>
        </xsd:annotation>
        <xsd:attribute name="value">
            <xsd:simpleType>
                <xsd:union>
                    <xsd:simpleType>
                        <xsd:restriction base='xsd:nonNegativeInteger'/>
                    </xsd:simpleType>
                    <xsd:simpleType>
                        <xsd:restriction base='xsd:string'>
                            <xsd:enumeration value='unbounded'/>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:union>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="PackageableElement">
        <xsd:attribute ref="xmi:id"/>
        <!-- (modification) use xsi:type in place of xmi:type -->
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>

    <xsd:complexType name="Package">
        <xsd:annotation>
            <xsd:documentation>
                A package is used to group elements, and provides a namespace for 
                the grouped elements.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
            <xsd:element name="ownedComment" minOccurs="0" maxOccurs="unbounded" type="uml:Comment"/>
            <xsd:element name="packagedElement" minOccurs="0" maxOccurs="unbounded" type="uml:PackageableElement"/>
        </xsd:choice>
        <xsd:attribute name="name" type="xsd:string"/>
        <!-- (not supported)
             <xsd:attribute name="visibility" type="uml:VisibilityKind" use="optional"/>-->
        <xsd:attribute ref="xmi:id"/>
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>
    <!-- (restriction) There MUST be a single Package packagedElement child of Model
         <xsd:element name="Package" type="uml:Package"/>-->

    <xsd:complexType name="Model">
        <xsd:annotation>
            <xsd:documentation>
                The Model construct is defined as a Package. It contains a (hierarchical) 
                set of elements that together describe the physical system being modeled. 
                A Model may also contain a set of elements that represents the environment 
                of the system, typically Actors, together with their interrelationships, 
                such as Associations and Dependencies.
                
                zOOml Modeler requires a single Package inside the (XMI child) Model
                element to represent (and bound) the system or subsystem.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
            <xsd:element name="ownedComment" minOccurs="0" type="uml:Comment"/>
            <xsd:element name="packagedElement" type="uml:Package"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string"/>
        <!-- (not supported)
        <xsd:attribute name="viewpoint" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The name of the viewpoint that is expressed by a model 
                    (this name may refer to a profile definition).
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>-->
        <xsd:attribute ref="xmi:id"/>
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>
    <xsd:element name="Model" type="uml:Model"/>

    <xsd:complexType name="Property">
        <xsd:annotation>
            <xsd:documentation>
                A property is a structural feature of a classifier that characterizes
                instances of the classifier. A property related by ownedAttribute to a
                classifier (other than an association) represents an attribute and might
                also represent an association end. It relates an instance of the class
                to a value or set of values of the type of the attribute. A property
                related by memberEnd or its specializations to an association represents
                an end of the association. The type of the property is the type of the end
                of the association.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
            <xsd:element name="ownedComment" minOccurs="0" maxOccurs="unbounded" type="uml:Comment"/>
            <!-- (clarification) For association ends this points to the type of the end,
                 otherwise the xmi:type attribute should be set to the name of a 
                 primitive type (any name accepted). -->
            <xsd:element name="type" minOccurs="0">
                <xsd:complexType>
                    <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                </xsd:complexType>
            </xsd:element>
            <!-- (clarification) Type ValueSpecification changed to a literal subclass. -->
            <xsd:element name="upperValue" minOccurs="0" type="uml:LiteralUnlimitedNatural"/>
            <xsd:element name="lowerValue" minOccurs="0" type="uml:LiteralInteger"/>
            <!-- (restriction) Class-owned properties are fully specified as children of Class 
                 elements using the ownedAttribute tag (this is not needed).
                 <xsd:element name="class" minOccurs="0">
                     <xsd:complexType>
                         <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                     </xsd:complexType>
                 </xsd:element>-->
            <!-- (restriction) Association-owned properties are fully specified as children of
                 Association elements using the ownedEnd tag (this is not needed).
                 <xsd:element name="owningAssociation" minOccurs="0">
                     <xsd:complexType>
                         <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                     </xsd:complexType>
                 </xsd:element>-->
            <!-- (clarification) When the property represents an association end
                 not owned by the association this is a link to the Association element 
                 (otherwise this element does not occur). A property/end owned 
                 by the association must not contain this link. -->
            <xsd:element name="association" minOccurs="0">
                <xsd:complexType>
                    <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:choice>
        <xsd:attribute name="name" type="xsd:string" use="optional"/>
        <!-- (not supported)
        <xsd:attribute name="visibility" type="uml:VisibilityKind" use="optional"/>
        <xsd:attribute name="isLeaf" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="isStatic" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="isReadOnly" type="xsd:boolean" use="optional"/>-->
        <xsd:attribute name="aggregation" type="uml:AggregationKind" use="optional"/>
        <xsd:attribute name="isOrdered" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="isUnique" type="xsd:boolean" use="optional"/>
        <xsd:attribute ref="xmi:id"/>
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>
    <!-- (restriction) Global properties are not supported (properties are either 
         a Class ownedAttribute or an Association ownedEnd).
         <xsd:element name="Property" type="uml:Property"/>-->

    <xsd:complexType name="Operation">
        <xsd:annotation>
            <xsd:documentation>
                An operation is a behavioral feature of a classifier that specifies
                the name, type, parameters, and constraints for invoking an
                associated behavior.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
            <xsd:element name="ownedComment" minOccurs="0" maxOccurs="unbounded" type="uml:Comment"/>
            <!-- not supported
            <xsd:element name="ownedParameter" minOccurs="0" maxOccurs="unbounded" type="uml:Parameter"/>-->
        </xsd:choice>
        <xsd:attribute name="name" type="xsd:string"/>
        <!-- (not supported)
        <xsd:attribute name="visibility" type="uml:VisibilityKind" use="optional"/>
        <xsd:attribute name="isLeaf" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="isStatic" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="isAbstract" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="concurrency" type="uml:CallConcurrencyKind" use="optional"/>
        <xsd:attribute name="isQuery" type="xsd:boolean" use="optional"/>-->
        <xsd:attribute ref="xmi:id"/>
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>
    <!-- (restriction) Global operations are not supported (restricted to 
         Class ownedOperation).
         <xsd:element name="Operation" type="uml:Operation"/>-->

    <xsd:complexType name="Class">
        <xsd:annotation>
            <xsd:documentation>
                A class describes a set of objects that share the same specifications
                of features, constraints, and semantics.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="uml:PackageableElement">
                <xsd:choice maxOccurs="unbounded" minOccurs="0">
                    <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
                    <xsd:element name="ownedComment" minOccurs="0" maxOccurs="unbounded" type="uml:Comment"/>
                    <xsd:element name="generalization" minOccurs="0" maxOccurs="unbounded" type="uml:Generalization"/>
                    <!-- (restriction) fully specified Propery (not link) -->
                    <xsd:element name="ownedAttribute" minOccurs="0" maxOccurs="unbounded" type="uml:Property"/>
                    <!-- (restriction) fully specified Operation (not link) -->
                    <xsd:element name="ownedOperation" minOccurs="0" maxOccurs="unbounded" type="uml:Operation"/>
                </xsd:choice>
                <xsd:attribute name="name" type="xsd:string"/>
                <!-- (not supported)
                <xsd:attribute name="isLeaf" type="xsd:boolean" use="optional"/>
                <xsd:attribute name="visibility" type="uml:VisibilityKind" use="optional"/>
                <xsd:attribute name="isAbstract" type="xsd:boolean" use="optional"/>
                -->
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <!-- (restriction) Classes are restricted to packagedElement elements of Package
         <xsd:element name="Class" type="uml:Class"/> -->

    <xsd:complexType name="Association">
        <xsd:annotation>
            <xsd:documentation>
                An association describes a set of tuples whose values refer
                to typed instances. An instance of an association is called a link.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="uml:PackageableElement">
                <xsd:choice maxOccurs="unbounded" minOccurs="0">
                    <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
                    <xsd:element name="ownedComment" minOccurs="0" maxOccurs="unbounded" type="uml:Comment"/>
                    <!-- (clarification) Fully specified Propery (not link) when association owns the end. 
                         Note that ownedEnd does not have an "association" subelement that refers back
                         to the Association. Must provide an id. -->
                    <xsd:element name="ownedEnd" minOccurs="0" maxOccurs="unbounded" type="uml:Property"/>
                    <!-- (restriction) Limited to binary association (maxOccurs="2").
                         (clarification) Links to the Properties that represent the association ends.
                         These elements must be present even if the properties are owned by the association,
                         i.e. are ownedEnd elements of this association. Must not provide an id. -->
                    <xsd:element name="memberEnd" minOccurs="2" maxOccurs="2">
                        <xsd:complexType>
                            <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:choice>
                <xsd:attribute name="name" type="xsd:string" use="optional"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <!-- (restriction) Associations are restricted to packagedElement elements of Package
         <xsd:element name="Association" type="uml:Association"/> -->

    <xsd:complexType name="Generalization">
        <xsd:annotation>
            <xsd:documentation>
                A generalization is a taxonomic relationship between a more general
                classifier and a more specific classifier. Each instance of the
                specific classifier is also an indirect instance of the general classifier.
                Thus, the specific classifier inherits the features of the more general
                classifier.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
            <!-- (restriction) Not supported, nothing much to say about generalizations.
                 <xsd:element name="ownedComment" minOccurs="0" maxOccurs="unbounded" type="uml:Comment"/>
                -->
            <!-- (restriction) The specific classifier is the owning element and so
                 is not included.
                 <xsd:element name="specific">
                     <xsd:complexType>
                         <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                     </xsd:complexType>
                 </xsd:element> -->
            <xsd:element name="general">
                <xsd:complexType>
                    <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:choice>
        <xsd:attribute ref="xmi:id"/>
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>
    <!-- (restriction) Generalizations must appear inside a Class as a generalization.
    <xsd:element name="Generalization" type="uml:Generalization"/> -->

    <xsd:complexType name="Dependency">
        <xsd:annotation>
            <xsd:documentation>
                A dependency is a relationship that signifies that a single or a set
                of model elements requires other model elements for their specification
                or implementation. This means that the complete semantics of the
                depending elements is either semantically or structurally dependent
                on the definition of the supplier element(s).
            </xsd:documentation>
        </xsd:annotation>
        <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element maxOccurs="unbounded" minOccurs="0" ref="xmi:Extension"/>
            <xsd:element name="ownedComment" minOccurs="0" maxOccurs="unbounded" type="uml:Comment"/>
            <xsd:element name="supplier" maxOccurs="unbounded">
                <xsd:complexType>
                    <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="client" maxOccurs="unbounded">
                <xsd:complexType>
                    <xsd:attributeGroup ref="xmi:LinkAttribs"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:choice>
        <xsd:attribute name="name" type="xsd:string" use="optional"/>
        <xsd:attribute ref="xmi:id"/>
        <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
    </xsd:complexType>
    <!-- (restriction) Dependencies are restricted to packagedElement elements of Package
         <xsd:element name="Dependency" type="uml:Dependency"/> -->
</xsd:schema>

