<!--
	Licensed to the Apache Software Foundation (ASF) under one
	or more contributor license agreements.  See the NOTICE file
	distributed with this work for additional information
	regarding copyright ownership.  The ASF licenses this file
	to you under the Apache License, Version 2.0 (the
	"License"); you may not use this file except in compliance
	with the License.  You may obtain a copy of the License at
	
	http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing,
	software distributed under the License is distributed on an
	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
	KIND, either express or implied.  See the License for the
	specific language governing permissions and limitations
	under the License.
-->
<xs:schema elementFormDefault="qualified"
	targetNamespace="org.apache.felix.ipojo.composite"
	xmlns="org.apache.felix.ipojo.composite"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ipojo="org.apache.felix.ipojo">

	<xs:import namespace="org.apache.felix.ipojo" schemaLocation="http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"></xs:import>
	<xs:complexType name="CompositeType">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element ref="subservice" minOccurs="0"
				maxOccurs="unbounded">
			</xs:element>
			<xs:element ref="provides" minOccurs="0"
				maxOccurs="unbounded">
			</xs:element>
			<xs:element ref="instance" minOccurs="0"
				maxOccurs="unbounded">
			</xs:element>
			<xs:any namespace="##other" processContents="lax"
				minOccurs="0" maxOccurs="unbounded">
			</xs:any>
		</xs:choice>
		<xs:attribute name="name" type="xs:string" use="optional"></xs:attribute>
		<xs:attribute name="public" type="xs:boolean" use="optional"></xs:attribute>
		<xs:attribute name="architecture" type="xs:boolean"
			use="optional">
		</xs:attribute>
	</xs:complexType>

	<xs:element name="subservice" type="SubserviceType" />
	<xs:element name="provides" type="CompositeProvidesType" />
	
	<xs:complexType name="CompositeProvidesType">
		<xs:complexContent>
			<xs:extension base="ipojo:ServiceDependencyType">
				<xs:sequence>
					<xs:element name="delegation" type="DelegationType"></xs:element>
				</xs:sequence>
				<xs:attribute name="specification" type="xs:string"
					use="required">
				</xs:attribute>

				<xs:attribute name="action">
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:enumeration value="implement"></xs:enumeration>
							<xs:enumeration value="export"></xs:enumeration>
						</xs:restriction>
					</xs:simpleType>
				</xs:attribute>



			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<xs:complexType name="SubserviceType">
		<xs:complexContent>
			<xs:extension base="ipojo:ServiceDependencyType">

				<xs:sequence minOccurs="0" maxOccurs="unbounded">
					<xs:element name="property" type="CompositePropertyType"></xs:element>
				</xs:sequence>
				<xs:attribute name="action" use="required">
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:enumeration value="import"></xs:enumeration>
							<xs:enumeration value="instantiate"></xs:enumeration>
						</xs:restriction>
					</xs:simpleType>
				</xs:attribute>

				<xs:attribute name="specification" type="xs:string"
					use="required">
				</xs:attribute>
				<xs:attribute name="context-source" type="xs:string"
					use="optional">
				</xs:attribute>
				<xs:attribute name="scope">
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:enumeration value="global"></xs:enumeration>
							<xs:enumeration value="composite"></xs:enumeration>
							<xs:enumeration value="composite+global"></xs:enumeration>
						</xs:restriction>
					</xs:simpleType>
				</xs:attribute>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<xs:simpleType name="actionType">
		<xs:restriction base="xs:string"></xs:restriction>
	</xs:simpleType>

	<xs:complexType name="CompositePropertyType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:element name="property" type="CompositePropertyType" minOccurs="0" maxOccurs="unbounded"></xs:element>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required"></xs:attribute>
		<xs:attribute name="value" type="xs:string" use="optional"></xs:attribute>
	</xs:complexType>

	<xs:complexType name="CompositeInstanceType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:element name="property" type="CompositePropertyType"></xs:element>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="optional"></xs:attribute>
		<xs:attribute name="component" type="xs:string"
			use="required">
		</xs:attribute>
	</xs:complexType>

    <xs:element name="instance" type="CompositeInstanceType"></xs:element>

    <xs:element name="composite" type="CompositeType"></xs:element>

    <xs:complexType name="DelegationType">
    	<xs:attribute name="method" type="xs:string" use="required"></xs:attribute>
    	<xs:attribute name="policy" use="required">
    		<xs:simpleType>
    			<xs:restriction base="xs:string">
    				<xs:enumeration value="all"></xs:enumeration>
    				<xs:enumeration value="one"></xs:enumeration>
    			</xs:restriction>
    		</xs:simpleType>
    	</xs:attribute>
    </xs:complexType>
</xs:schema>