<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
 * $Id: 741c5c45105c9bef54ffe79eb4dbfc8f5cadc2aa $
 * 
 * Copyright (c) OSGi Alliance (2011, 2012). All Rights Reserved.
 * 
 * Licensed 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.
 */
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
	xmlns:repo="http://www.osgi.org/xmlns/repository/v1.0.0"
	targetNamespace="http://www.osgi.org/xmlns/repository/v1.0.0"
	elementFormDefault="unqualified" 
	attributeFormDefault="unqualified"
	version="1.0.0">
	
	<element name="repository" type="repo:Trepository" />
	<complexType name="Trepository">
		<sequence>
			<choice minOccurs="0" maxOccurs="unbounded">
				<element name="resource" type="repo:Tresource" />
				<element name="referral" type="repo:Treferral" />
			</choice>
			<!-- It is non-deterministic, per W3C XML Schema 1.0: 
			http://www.w3.org/TR/xmlschema-1/#cos-nonambig
			to use name space="##any" below. -->
			<any namespace="##other" processContents="lax" minOccurs="0"
				maxOccurs="unbounded" />
		</sequence>
		<attribute name="name" type="string">
			<annotation>
				<documentation xml:lang="en">
					The name of the repository. The name may contain
					spaces and punctuation.
				</documentation>
			</annotation>
		</attribute>
		<attribute name="increment" type="long">
			<annotation>
				<documentation xml:lang="en">
					An indication of when the repository was last changed. Client's can
					check if a
					repository has been updated by checking this increment value.
				</documentation>
			</annotation>
		</attribute>
		<anyAttribute />
	</complexType>

	<complexType name="Tresource">
		<annotation>
			<documentation xml:lang="en">
				Describes a general resource with
				requirements and capabilities.
			</documentation>
		</annotation>
		<sequence>
			<element name="requirement" type="repo:Trequirement" minOccurs="0" maxOccurs="unbounded"/>
			<element name="capability" type="repo:Tcapability" minOccurs="1" maxOccurs="unbounded"/>
			<!-- It is non-deterministic, per W3C XML Schema 1.0: 
			http://www.w3.org/TR/xmlschema-1/#cos-nonambig
			to use name space="##any" below. -->
			<any namespace="##other" processContents="lax" minOccurs="0"
				maxOccurs="unbounded" />
		</sequence>
		<anyAttribute />
	</complexType>

	<complexType name="Treferral">
		<annotation>
			<documentation xml:lang="en">
				A referral points to another repository XML file. The
				purpose of this element is to create a federation of
				repositories that can be accessed as a single
				repository.
			</documentation>
		</annotation>
		<attribute name="depth" type="int" use="optional">
			<annotation>
				<documentation xml:lang="en">
					The depth of referrals this repository acknowledges.
				</documentation>
			</annotation>
		</attribute>
		<attribute name="url" type="anyURI" use="required">
			<annotation>
				<documentation xml:lang="en">
					The URL to the referred repository. The URL can be
					absolute or relative from the given repository’s
					URL.
				</documentation>
			</annotation>
		</attribute>
		<anyAttribute />
	</complexType>

	<complexType name="Tcapability">
		<annotation>
			<documentation xml:lang="en">
				A named set of type attributes and directives. A capability can be
				used to resolve a requirement if the resource is included.
			</documentation>
		</annotation>
		<sequence>
			<choice minOccurs="0" maxOccurs="unbounded">
				<element name="directive" type="repo:Tdirective" />
				<element name="attribute" type="repo:Tattribute" />
			</choice>
			<!-- It is non-deterministic, per W3C XML Schema 1.0: 
			http://www.w3.org/TR/xmlschema-1/#cos-nonambig
			to use name space="##any" below. -->
			<any namespace="##other" processContents="lax" minOccurs="0"
				maxOccurs="unbounded" />
		</sequence>
		<attribute name="namespace" type="string">
			<annotation>
				<documentation xml:lang="en">
					Name space of the capability. Only requirements with the
					same name space must be able to match this capability.
				</documentation>
			</annotation>
		</attribute>
		<anyAttribute />
	</complexType>

	<complexType name="Trequirement">
		<annotation>
			<documentation xml:lang="en">
				A filter on a named set of capability attributes.
			</documentation>
		</annotation>
		<sequence>
			<choice minOccurs="0" maxOccurs="unbounded">
				<element name="directive" type="repo:Tdirective" />
				<element name="attribute" type="repo:Tattribute" />
			</choice>
			<!-- It is non-deterministic, per W3C XML Schema 1.0: 
			http://www.w3.org/TR/xmlschema-1/#cos-nonambig
			to use name space="##any" below. -->
			<any namespace="##other" processContents="lax" minOccurs="0"
				maxOccurs="unbounded" />
		</sequence>
		<attribute name="namespace" type="string">
			<annotation>
				<documentation xml:lang="en">
					Name space of the requirement. Only capabilities within the
					same name space must be able to match this requirement.
				</documentation>
			</annotation>
		</attribute>
		<anyAttribute />
	</complexType>

	<complexType name="Tattribute">
		<annotation>
			<documentation xml:lang="en">
				A named value with an optional type that decorates
				a requirement or capability.
			</documentation>
		</annotation>
		<sequence>
			<any namespace="##any" processContents="lax" minOccurs="0"
				maxOccurs="unbounded" />
		</sequence>
		<attribute name="name" type="string">
			<annotation>
				<documentation xml:lang="en">
					The name of the attribute.
				</documentation>
			</annotation>
		</attribute>
		<attribute name="value" type="string">
			<annotation>
				<documentation xml:lang="en">
					The value of the attribute.
				</documentation>
			</annotation>
		</attribute>
		<attribute name="type" type="repo:TpropertyType" default="String">
			<annotation>
				<documentation xml:lang="en">
					The type of the attribute.
				</documentation>
			</annotation>
		</attribute>
		<anyAttribute />
	</complexType>

	<complexType name="Tdirective">
		<annotation>
			<documentation xml:lang="en">
				A named value of type string that instructs a resolver
				how to process a requirement or capability.
			</documentation>
		</annotation>
		<sequence>
			<any namespace="##any" processContents="lax" minOccurs="0"
				maxOccurs="unbounded" />
		</sequence>
		<attribute name="name" type="string">
			<annotation>
				<documentation xml:lang="en">
					The name of the directive.
				</documentation>
			</annotation>
		</attribute>
		<attribute name="value" type="string">
			<annotation>
				<documentation xml:lang="en">
					The value of the directive.
				</documentation>
			</annotation>
		</attribute>
		<anyAttribute />
	</complexType>

	<simpleType name="TpropertyType">
		<restriction base="string">
			<enumeration value="String" />
			<enumeration value="Version" />
			<enumeration value="Long" />
			<enumeration value="Double" />
			<enumeration value="List&lt;String&gt;" />
			<enumeration value="List&lt;Version&gt;" />
			<enumeration value="List&lt;Long&gt;" />
			<enumeration value="List&lt;Double&gt;" />
		</restriction>
	</simpleType>
	<attribute name="must-understand" type="boolean" default="false">
		<annotation>
			<documentation xml:lang="en">
				This attribute should be used by extensions to documents to require that
				the document consumer understand the extension. This attribute must be
				qualified when used.
			</documentation>
		</annotation>
	</attribute>
</schema>
