<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * This schema must be used to validate resources.xml files
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="config">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="resource" type="resourceDeclaration" minOccurs="1" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
        <xs:unique name="uniqueResourceName">
            <xs:annotation>
                <xs:documentation>Resource name must be unique.</xs:documentation>
            </xs:annotation>
            <xs:selector xpath="resource" />
            <xs:field xpath="@name" />
        </xs:unique>
    </xs:element>

    <xs:complexType name="resourceDeclaration">
        <xs:annotation>
            <xs:documentation>
                Resource declaration.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" type="nameIdentifier" use="required" />
        <xs:attribute name="extends" type="nameIdentifier" use="optional" />
        <xs:attribute name="connection" type="nameIdentifier" use="optional" />
    </xs:complexType>

    <xs:simpleType name="nameIdentifier">
        <xs:annotation>
            <xs:documentation>
                Name identifier can contain only [A-Za-z_0-9].
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-Za-z_0-9]+" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
