%preamble
    <!-- 
         This is a fairly strange schema.

         When you use type inheritence in the "normal" way, you get a
         schema that will require documents to specify elements
         attached to base types before elements attached to derived
         types.  Since our type hierachy matches an object hierarchy,
         and containment corresponds to either containment of child
         components or to assignment statements, we need to allow
         child elements in an arbitrary order.

         Convincing the schema system to allow this requires a fair
         amount of non-intuitive wrangling.

         The general idea is to provide an empty hierarchy of types
         (think of it as a bizarre interface inheritance scheme) that
         keeps track of the relationships between types.
         Unfortunately, a parallel hierarchy of empty elements is also
         required, due to the utterly odd way that substitutionGroup
         works.  Anyway, having this hierarchy is what allows you to
         specify a derived type anywhere a base type is required.

         We then define all the "meat" of each definition in a leaf
         type that derives from the interface.  To try to reduce
         repetition, we use a parallel group inheritance hierarchy
         whenever possible.  Because MXML/AS allows a derived class to
         remove the visibility of properties, we will occasionally
         fully "unroll" a type and list all local and base properties,
         minus the newly hidden property.  Also, any patches specified
         to the autogenerated schema will generally cause a type to be
         unrolled.
         
         In either case, the leaf type will contain either a full list
         of all available properties or else it will reaggregate a
         parent group definition with local types into a new group.
         
         All this work to get around the fact that the way that
         "extension" aggregates base type elements with derived type
         elements is via an implicit "sequence".
         
         Now, imagine that instead you did something like this:

              extension base="whatever" group="choice"

         Wouldn't that be nice?
                                         - rg@ieee.org
    -->
	<attributeGroup name="id.attr">
		<attribute name="id" type="ID"/>
		<!-- todo restrict type to valid AS identifiers -->
	</attributeGroup>

    <complexType name="ASPrimitive">
      <simpleContent>
        <extension base="string">
          <attributeGroup ref="mx:id.attr"/>
          <attribute name="source" type="string" />
        </extension>
      </simpleContent>
    </complexType>

	<simpleType name="Event">
		<annotation>
			<documentation> event handler </documentation>
		</annotation>
		<restriction base="mx:ActionScript"/>
	</simpleType>

    <element name="Model" type="mx:ModelType" substitutionGroup='mx:_X_Object' />
    <complexType name="ModelType" mixed="true">
      <complexContent>
        <extension base='mx:_I_Object'>
          <sequence minOccurs='0' maxOccurs='unbounded'>
              <any namespace="##any" processContents="lax" />
          </sequence>
          <attributeGroup ref="mx:id.attr"/>
          <attribute name="source" type="string"/>
        </extension>
      </complexContent>
    </complexType>

	<element name="Style">
		<complexType mixed="true">
			<attribute name="type" type="mx:ContentType"/>
			<attribute name="media" type="mx:MediaDesc"/>
            <attribute name="source" type="string"/>
			<!--			<attribute ref="xml:space" default="preserve"/> -->
		</complexType>
	</element>

	<element name="Effect">
		<complexType>
			<choice minOccurs="0" maxOccurs="unbounded">
				<any namespace="##any" processContents="lax" />
			</choice>
            <attribute name="name" type="string"/>
		</complexType>
	</element>

    <element name="Metadata">
      <simpleType>
        <restriction base="string"/>
      </simpleType>
    </element>

	<element name="Script">
        <complexType mixed="true">
            <simpleContent>
			    <extension base="mx:ActionScript">
                    <attribute name="source" type="string"/>
                </extension>
            </simpleContent>
        </complexType>
    </element>

	<simpleType name="ContentType">
		<annotation>
			<documentation> media type, as per [RFC2045] </documentation>
		</annotation>
		<list itemType="string"/>
	</simpleType>

	<simpleType name="MediaDesc">
		<annotation>
			<documentation> single or comma-separated list of media descriptors </documentation>
		</annotation>
		<restriction base="string"/>
	</simpleType>

	<simpleType name="ActionScript">
		<annotation>
			<documentation>typedef for a fragment of script</documentation>
		</annotation>
		<restriction base="string"/>
	</simpleType>
	<simpleType name="ActionScript.lvalue">
		<restriction base="mx:ActionScript"/>
	</simpleType>

%replaceType Boolean
<complexType mixed='true' name='_I_Boolean'>
  <complexContent>
    <extension base='mx:_I_Object'/>
  </complexContent>
</complexType>
<complexType mixed='true' name='Boolean'>
  <complexContent>
    <extension base='mx:_I_Boolean'>
      <attributeGroup ref="mx:id.attr"/>
    </extension>
  </complexContent>
</complexType>

%replaceType String
<complexType mixed='true' name='_I_String'>
  <complexContent>
    <extension base='mx:_I_Object'/>
  </complexContent>
</complexType>
<complexType mixed='true' name='String'>
  <complexContent>
    <extension base='mx:_I_String'>
      <attributeGroup ref="mx:id.attr"/>
    </extension>
  </complexContent>
</complexType>

%replaceType Number
<complexType mixed='true' name='_I_Number'>
  <complexContent>
    <extension base='mx:_I_Object'/>
  </complexContent>
</complexType>
<complexType mixed='true' name='Number'>
  <complexContent>
    <extension base='mx:_I_Number'>
      <attributeGroup ref="mx:id.attr"/>
    </extension>
  </complexContent>
</complexType>


%replaceType Object
<complexType mixed='true' name='_I_Object'></complexType>
<complexType mixed='true' name='Object'><complexContent><extension base='mx:_I_Object'>
  <sequence minOccurs='0' maxOccurs='unbounded'><choice>
    <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
  </choice></sequence>
    <anyAttribute namespace="##any" processContents="lax"/>
</extension></complexContent></complexType>

%replaceType Array
<complexType mixed='true' name='_I_Array'><complexContent><extension base='mx:_I_Object'></extension></complexContent></complexType>
<complexType mixed='true' name='Array'><complexContent><extension base='mx:_I_Array'>
  <sequence minOccurs='0' maxOccurs='unbounded'><choice>
    <element ref="mx:_X_Object" />
    <any namespace="##other" processContents="lax"/>
  </choice></sequence>
  <attributeGroup ref="mx:id.attr"/>
</extension></complexContent></complexType>

%showProperty mx.controls.ComboBox.labels

%showProperty mx.validators.Validator.field
%showProperty mx.validators.Validator.listener
%showProperty mx.validators.Validator.validate
%showProperty mx.validators.NumberValidator.minValue
%showProperty mx.validators.NumberValidator.maxValue

%addTypeAttribute mx.core.UIObject
  <attributeGroup ref="mx:id.attr" />

%addTypeAttribute mx.controls.RadioButtonGroup
  <attributeGroup ref="mx:id.attr" />

%addTypeAttribute mx.formatters.Formatter
  <attributeGroup ref="mx:id.attr"/>

%addTypeAttribute mx.validators.Validator
  <attributeGroup ref="mx:id.attr"/>

%addTypeAttribute mx.effects.Effect
  <attribute name="name" type="ID" />

%addTypeChild mx.effects.Effect
  <any namespace="##other" processContents="lax"/>
  <element ref="mx:_X_mx.effects.Effect" />

%addTypeChild mx.core.View
  <any namespace="##other" processContents="lax"/>
  <element ref="mx:_X_MovieClip"/>
  <element ref="mx:Style"/>
  <element ref="mx:Model"/>
  <element ref="mx:Effect"/>
  <element ref="mx:Script"/>
  <element ref="mx:_X_WebService"/>
  <element ref="mx:_X_HTTPService"/>
  <element ref="mx:_X_XMLNode"/>

%addTypeChild MovieClip
  <element ref="mx:_X_String" />
  <element ref="mx:_X_Boolean" />
  <element ref="mx:_X_Array" />
  <element ref="mx:_X_Number" />
  <element ref="mx:_X_Formatter" />
  <element ref="mx:_X_Validator" />
  <element ref="mx:Metadata"/>

%addTypeChild mx.core.UIObject
  <element ref="mx:_X_Repeater" />
  <element ref="mx:_X_Binding" />
  <element ref="mx:_X_RadioButtonGroup" />

%addTypeAttribute mx.binding.Binding
  <attribute name="source" type="string" />
  <attribute name="destination" type="string" />

%addTypeChild mx.binding.Binding
  <element name="source" />
  <element name="destination" />

%addTypeAttribute mx.servicetags.HTTPService
  <attributeGroup ref="mx:id.attr"/>

%addTypeAttribute mx.binding.Binding
  <attributeGroup ref="mx:id.attr"/>

%replaceType mx.core.Repeater
<complexType mixed='true' name='_I_mx.core.Repeater'>
  <complexContent><extension base='mx:_I_Object'/></complexContent>
</complexType>
<complexType mixed='true' name='mx.core.Repeater'>
  <complexContent><extension base='mx:_I_mx.core.Repeater'>
    <sequence minOccurs='0' maxOccurs='unbounded'>
      <any namespace="##any" processContents="lax" />
    </sequence>
    <attribute name='count' type='string' />
    <attribute name='dataProvider' type='string' />
    <attribute name='recycleChildren' type='string' />
    <attribute name='repeat' type='string' />
    <attribute name='startingIndex' type='string' />
  </extension></complexContent>
</complexType>

%replaceType XMLNode
  <complexType mixed='true' name='_I_XMLNode'>
    <complexContent>
      <extension base='mx:_I_Object'>
		<sequence>
			<any namespace="##any" processContents="lax" 
                 minOccurs="0" maxOccurs="unbounded"/>
		</sequence>
		<attributeGroup ref="mx:id.attr"/>
		<attribute name="source" type="string"/>
      </extension>
    </complexContent>
  </complexType>
  <complexType mixed='true' name='XMLNode'>
    <complexContent><extension base='mx:_I_XMLNode'/></complexContent>
  </complexType>


%replaceGroup mx.servicetags.Service
  <element name="operation" minOccurs="0" maxOccurs="unbounded">
					<complexType>
						<sequence>
							<element name="request" minOccurs="0">
								<complexType>
									<sequence>
                                        <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
									</sequence>
                                    <attribute name="literal" type="boolean"/>
								</complexType>
							</element>
						</sequence>
                        <attributeGroup ref="mx:id.attr"/>                        
						<attribute name="name" type="string"/>
						<attribute name="resultFormat">
                            <simpleType>
                                <restriction base="string">
                                    <enumeration value="object" />
                                    <enumeration value="xml" />
                                </restriction>
                            </simpleType>
						</attribute>
						<attribute name="result" type="mx:Event"/>
						<attribute name="fault" type="mx:Event"/>
						<attribute name="concurrency">
							<simpleType>
								<restriction base="string">
									<enumeration value="single"/>
									<enumeration value="last"/>
									<enumeration value="multiple"/>
								</restriction>
							</simpleType>
						</attribute>
					</complexType>
  </element>

%addTypeAttribute mx.servicetags.Service
			<attributeGroup ref="mx:id.attr"/>
			<attribute name="load" type="mx:ActionScript"/>
			<attribute name="wsdl" type="string"/>
			<attribute name="fault" type="mx:Event"/>
			<attribute name="result" type="mx:Event"/>
			<attribute name="service" type="string"/>
			<attribute name="port" type="string"/>
			<attribute name="serviceName" type="string"/>
            <attribute name="concurrency">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="single"/>
                        <enumeration value="last"/>
                        <enumeration value="multiple"/>
                    </restriction>
                </simpleType>
            </attribute>
            <attribute name="showBusyCursor" type="boolean" />

%replaceGroup mx.servicetags.RemoteObject
                <element name="method" minOccurs="0" maxOccurs="unbounded">
                    <complexType>
                        <sequence>
                            <element name="arguments" minOccurs="0">
                                <complexType>
                                    <sequence>
                                        <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                                    </sequence>
                                </complexType>
                            </element>
                        </sequence>
                        <attributeGroup ref="mx:id.attr"/>
                        <attribute name="name" type="string"/>
                        <attribute name="result" type="mx:Event"/>
                        <attribute name="fault" type="mx:Event"/>
                        <attribute name="concurrency">
                            <simpleType>
                                <restriction base="string">
                                    <enumeration value="single"/>
                                    <enumeration value="last"/>
                                    <enumeration value="multiple"/>
                                </restriction>
                            </simpleType>
                        </attribute>
                        <attribute name="resultType" type="string"/>
                   </complexType>
                </element>

%replaceAttributeGroup mx.servicetags.RemoteObject
            <attributeGroup ref="mx:id.attr"/>
            <attribute name="named" type="string"/>
            <attribute name="source" type="string"/>
            <attribute name="type">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="stateful-class"/>
                        <enumeration value="stateless-class"/>
                        <enumeration value="jndi"/>
                        <enumeration value="ejb"/>
                    </restriction>
                </simpleType>
            </attribute>
            <attribute name="fault" type="mx:Event"/>
            <attribute name="result" type="mx:Event"/>
            <attribute name="concurrency">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="single"/>
                        <enumeration value="last"/>
                        <enumeration value="multiple"/>
                    </restriction>
                </simpleType>
            </attribute>
            <attribute name="showBusyCursor" type="boolean" />
            <attribute name="encoding">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="soap" />
                        <enumeration value="amf" />
                    </restriction>
                </simpleType>
            </attribute>

%replaceGroup mx.servicetags.HTTPService
                <element name="request" minOccurs="0" maxOccurs="1">
                    <complexType>
                        <sequence>
                            <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                        </sequence>
                    </complexType>
                </element>

%replaceAttributeGroup mx.servicetags.HTTPService
            <attributeGroup ref="mx:id.attr"/>
            <attribute name="url" type="string" />
            <attribute name="serviceName" type="string"/>
            <attribute name="method">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="GET" />
                        <enumeration value="POST" />
                    </restriction>
                </simpleType>
            </attribute>
            <attribute name="fault" type="mx:Event"/>
            <attribute name="result" type="mx:Event"/>
            <attribute name="concurrency">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="single"/>
                        <enumeration value="last"/>
                        <enumeration value="multiple"/>
                    </restriction>
                </simpleType>
            </attribute>
            <attribute name="resultFormat">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="xml"/>
                        <enumeration value="object"/>
                        <enumeration value="flashvars"/>
                        <enumeration value="text"/>
                    </restriction>
                </simpleType>
            </attribute>
            <attribute name="showBusyCursor" type="string" />
            <attribute name="xmlDecode" type="string" />
            <attribute name="xmlEncode" type="string" />
