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

<!--
  ~ Copyright The WildFly Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->

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

    <xs:element name="subsystem" type="subsystemType">
        <xs:annotation>
            <xs:documentation>
                The discovery subsystem root element.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:complexType name="subsystemType">
        <xs:annotation>
            <xs:documentation>
                The discovery subsystem root type.
            </xs:documentation>
        </xs:annotation>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="aggregate-provider" type="aggregateType">
                <xs:annotation>
                    <xs:documentation>
                        An aggregating discovery provider element.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="static-provider" type="staticType">
                <xs:annotation>
                    <xs:documentation>
                        A static discovery provider definition element.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:choice>
    </xs:complexType>

    <xs:complexType name="aggregateType">
        <xs:annotation>
            <xs:documentation>
                A provider which aggregates multiple other providers into one.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name of this provider.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="providers" type="providersType" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The list of providers which make up this provider.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="staticType">
        <xs:annotation>
            <xs:documentation>
                A provider which contains a list of static services.
            </xs:documentation>
        </xs:annotation>
        <xs:choice>
            <xs:element name="service" type="serviceType" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        A single service definition within the service list.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:choice>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name of this provider.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="serviceType">
        <xs:annotation>
            <xs:documentation>
                A definition of a single static service.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="attribute" type="attributeType" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        A single attribute in this attribute list.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="abstract-type" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The abstract type of the service being advertised.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="abstract-type-authority" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The name of the authority which defined the abstract service type.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="uri" type="xs:anyURI" use="required">
            <xs:annotation>
                <xs:documentation>
                    The concrete URI of the service being advertised.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="uri-scheme-authority" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The name of the authority which defined the concrete URI scheme.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="attributeType">
        <xs:annotation>
            <xs:documentation>
                A service's attribute definition.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    The attribute name.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="value" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The attribute value.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:simpleType name="providersType">
        <xs:annotation>
            <xs:documentation>
                A list of providers.
            </xs:documentation>
        </xs:annotation>
        <xs:list itemType="xs:string"/>
    </xs:simpleType>
</xs:schema>
