<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--

    Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
    and other contributors as indicated by the @author tags.

    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.

-->
<xs:schema xmlns="urn:jboss:galleon:package:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:jboss:galleon:package:1.0"
  version="2.0">

  <xs:element name="package-spec" type="packageType" />

  <xs:complexType name="packageType">
    <xs:annotation>
      <xs:documentation>
        Describes a feature-pack package which is an atomic unit of content.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence minOccurs="0" maxOccurs="1">
      <xs:element name="dependencies" type="dependenciesType" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The name of the package which must be unique inside the feature-pack.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="dependenciesType">
    <xs:annotation>
      <xs:documentation>
        Describes a list of package dependencies.
      </xs:documentation>
    </xs:annotation>
    <xs:choice maxOccurs="unbounded" minOccurs="1">
      <xs:element name="package" type="packageDependencyType" />
      <xs:element name="origin" type="originType"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="packageDependencyType">
    <xs:annotation>
      <xs:documentation>
        Describes a package dependency on another package.
        When a package is selected to be installed, all the packages it depends
        on will also be installed unless they have been explicitly excluded by
        the user.
        If a user installs a package which has a required dependency on an
        excluded package, the provisioning process will terminate with an error.
        If a user installs a package which has an optional dependency on an
        excluded package, the provisioning process will proceed installing
        the package the user chose to install.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          Name of a package, the package declaring dependency depends on. 
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="optional" type="xs:boolean" use="optional" default="false">
      <xs:annotation>
        <xs:documentation>
          Indicates whether the dependency is optional or required.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="originType">
    <xs:annotation>
      <xs:documentation>
        Describes an external package dependency.
        I.e a dependency on packages that belong to another feature-pack.
        External dependencies are assumed to be required dependencies.
      </xs:documentation>
    </xs:annotation>
    <xs:choice maxOccurs="unbounded" minOccurs="1">
      <xs:element name="package" type="packageDependencyType" />
    </xs:choice>
    <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          Name assigned to a dependency on the feature-pack (in
          the feature-pack.xml of the feature-pack this package belongs to)
          which will be used as a source for external package dependencies
          specified as children of the element of this type. 
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

</xs:schema>