<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.mulesource.org/schema/mule/bpm/2.0"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:mule="http://www.mulesource.org/schema/mule/core/2.0"
            targetNamespace="http://www.mulesource.org/schema/mule/bpm/2.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified">
            
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
    <xsd:import namespace="http://www.mulesource.org/schema/mule/core/2.0" 
                schemaLocation="http://www.mulesource.org/schema/mule/core/2.0/mule.xsd" />

    <xsd:element name="connector" type="bpmConnectorType" substitutionGroup="mule:abstract-connector"/>

    <xsd:complexType name="bpmConnectorType">
        <xsd:complexContent>
            <xsd:extension base="mule:connectorType">
                <xsd:attribute name="bpms-ref" type="xsd:IDREF" use="required">
                    <xsd:annotation>
                        <xsd:documentation>
                            A reference to the underlying BPMS.
                            This must implement the org.mule.providers.bpm.BPMS interface.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="allowGlobalReceiver" type="mule:substitutableBoolean" default="false">
                    <xsd:annotation>
                        <xsd:documentation>
                            The global receiver allows an endpoint of type "bpm://*" to receive any incoming message
                            to the BPMS, regardless of the process.
                            If this is false, the process name must be specified for each endpoint,
                            e.g. "bpm://MyProcess" will only receive messages for the process "MyProcess".
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="allowGlobalDispatcher" type="mule:substitutableBoolean" default="false">
                    <xsd:annotation>
                        <xsd:documentation>
                            If false, any message generated by the process is routed from the component on which
                            it is received.
                            If true, a process can send messages to any endpoint on any component.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="processIdField" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            This field will be used to correlate messages with processes.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
            </xsd:extension>
        </xsd:complexContent>
   </xsd:complexType>
 
    <xsd:complexType name="customElement">
        <xsd:choice>
            <xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
        </xsd:choice>
        <xsd:anyAttribute namespace="##any" processContents="lax"/>
    </xsd:complexType>

    <xsd:element name="inbound-endpoint" type="inboundEndpointType" substitutionGroup="mule:abstract-inbound-endpoint"/>
    <xsd:complexType name="inboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:inboundEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="outbound-endpoint" type="outboundEndpointType" substitutionGroup="mule:abstract-outbound-endpoint"/>
    <xsd:complexType name="outboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:outboundEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="endpoint" type="globalEndpointType" substitutionGroup="mule:abstract-global-endpoint"/>
    <xsd:complexType name="globalEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:globalEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:attributeGroup name="addressAttributes">
        <xsd:attribute name="process" type="xsd:string"/>
    </xsd:attributeGroup>

	<!-- 
	This is merely a shortcut for:
	     <endpoint-selector-router selectorExpression="header:MULE_BPM_ENDPOINT"> 
	-->
    <xsd:element name="outbound-router" type="bpmOutboundRouterType"
                 substitutionGroup="mule:abstract-outbound-router"/>
    <xsd:complexType name="bpmOutboundRouterType">
        <xsd:complexContent>
            <xsd:extension base="mule:filteringOutboundRouterType"/>
        </xsd:complexContent>
    </xsd:complexType>

	<!-- TODO MULE-3205
    <xsd:element name="component" type="bpmComponentType" substitutionGroup="mule:abstract-component">
        <xsd:annotation>
            <xsd:documentation>
                Used to embed a BPM process inside a Mule config.
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>
    <xsd:complexType name="bpmComponentType">
        <xsd:complexContent>
            <xsd:extension base="mule:defaultComponentType"/>
        </xsd:complexContent>
    </xsd:complexType>
	-->
</xsd:schema>
