<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://purl.org/dc/terms/" xmlns:ext="http://rs.gbif.org/extension/"
    targetNamespace="http://rs.gbif.org/extension/" elementFormDefault="qualified"
    attributeFormDefault="unqualified">
    <xs:import namespace="http://purl.org/dc/terms/" schemaLocation="dc.xsd"/>
    <xs:element name="extension">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="property" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:attribute name="name" type="xs:NCName" use="required">
                            <xs:annotation>
                                <xs:documentation>lowerCamelCase, whitespace less simple name for the property that can for example be used to generate XML tags or json attribute names</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="namespace" type="xs:anyURI" use="required">
                            <xs:annotation>
                                <xs:documentation>The namespace this extension belongs to</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="qualName" type="xs:anyURI" use="required">
                            <xs:annotation>
                                <xs:documentation>The fully qualified name combining the simple name with the namespace.</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="group" type="xs:string" use="optional">
                            <xs:annotation>
                                <xs:documentation>Optional group name to organise properties in extensions in case there are many</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="columnLength" type="xs:positiveInteger" default="128"/>
                        <xs:attribute name="type" type="ext:dataType" default="string" use="optional">
                            <xs:annotation>
                                <xs:documentation>The data type for the property. Defaults to a string.</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="comments" type="xs:string" use="optional">
                            <xs:annotation>
                                <xs:documentation>Recommendations for the content for the property.</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="examples" type="xs:string" use="optional">
                            <xs:annotation>
                                <xs:documentation>Examples of content for the property. If multiple are given, separate them with ' | '.</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute ref="dc:relation"/>
                        <xs:attribute ref="dc:subject" use="optional"/>
                        <xs:attribute ref="dc:description" use="optional"> </xs:attribute>
                        <xs:attribute name="thesaurus" type="xs:anyURI">
                            <xs:annotation>
                                <xs:documentation>A uri identifying a vocabulary to be used for property values</xs:documentation>
                            </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="required" type="xs:boolean" default="false"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute ref="dc:title" use="required">
                <xs:annotation>
                    <xs:documentation>The human readable english title for the entire extension</xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="name" type="xs:NCName" use="required">
                <xs:annotation>
                    <xs:documentation>Capital, whitespace less simple name for the extension that can for example be used to generate XML tags</xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="namespace" type="xs:anyURI" use="required">
                <xs:annotation>
                    <xs:documentation>The namespace this extension belongs to</xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="rowType" type="xs:anyURI" use="required">
                <xs:annotation>
                    <xs:documentation>The rowType is the qualified name when combined with the namespace. Double or missing slashes are removed/added when name + namespace is combined.</xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute ref="dc:creator" use="optional">
                <xs:annotation>
                    <xs:documentation>The agent responsible for creating the extension.</xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute ref="dc:issued" use="required">
                <xs:annotation>
                    <xs:documentation>The date that the extension (version) was officially released.</xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute ref="dc:description" use="optional"/>
            <xs:attribute ref="dc:relation" use="optional"/>
            <xs:attribute ref="dc:subject" use="optional"/>

        </xs:complexType>
    </xs:element>

    <!-- Enumeration of supported data types -->
    <xs:simpleType name="dataType">
        <xs:restriction base="xs:token">
            <xs:enumeration value="string"/>
            <xs:enumeration value="boolean"/>
            <xs:enumeration value="integer"/>
            <xs:enumeration value="decimal"/>
            <xs:enumeration value="date"/>
            <xs:enumeration value="uri"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
