<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="categoryEnum">
        <xs:annotation>
            <xs:documentation>List of category names</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="Activities"/>
            <xs:enumeration value="Facilities"/>
            <xs:enumeration value="Articles"/>
            <xs:enumeration value="Organizations"/>
            <xs:enumeration value="Videos &amp; Photos"/>
            <xs:enumeration value="People"/>
            <xs:enumeration value="Products"/>
            <xs:enumeration value="eteamz Sites"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:attribute name="row">
        <xs:simpleType>
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
    
    <xs:attribute name="destinationID">
        <xs:simpleType>
            <xs:restriction base="semiShortString">
                <xs:minLength value="1"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
    
    <xs:simpleType name="minLengthOne">
        <xs:annotation>
            <xs:documentation>String with min length of 1</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:element name="zip" type="minLengthOne"/>
    <xs:element name="city" type="minLengthOne"/>
    
    <xs:group name="zipOrCity">
        <xs:choice>
            <xs:element ref="zip"/>
            <xs:element ref="city"/>
        </xs:choice>
    </xs:group>
    
    <xs:group name="baseAssetProp">
        <xs:sequence>
            <xs:element name="isSearchable" type="xs:boolean"/>
            <xs:element name="assetId" type="guid" minOccurs="0"/>
            <xs:element name="assetTypeId" type="guid"/>
            <xs:element name="substitutionUrl" type="minLengthOne"/>
            <xs:element name="assetName" type="minLengthOne"/>
        </xs:sequence>
    </xs:group>
    
    <xs:group name="commonMetaProp">
        <xs:sequence>
            <xs:element name="category" type="categoryEnum"/>
            <xs:element name="channel" type="xs:string" maxOccurs="unbounded"/>
            <xs:element name="mediaType" type="xs:string" maxOccurs="unbounded"/>
            <xs:element name="searchWeight" type="searchWeightScale" default="1" minOccurs="0"/>
        </xs:sequence>
    </xs:group>
    
    <xs:simpleType name="guid">
        <xs:annotation>
            <xs:documentation>
                String formatted as a UUID/GUID - F1D4DA24-1045-4328-9635-4079B43692AE.
                Does NOT detect characters out of HEX range (gt than ''F'').
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="(\w{8}-\w{4}-\w{4}-\w{4}-\w{12})"/>
            <!-- <xs:pattern value=""/> -->
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="searchWeightScale">
        <xs:annotation>
            <xs:documentation>How to weight asset in search results.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:nonNegativeInteger">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="10"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="zipCode">
        <xs:annotation>
            <xs:documentation>String formatted as 00000 or 00000-0000</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="(\d{5}-\d{4})|(\d{5})"/>
            <xs:pattern value=""/>
            <!-- this allows an empty element to pass validation -->
        </xs:restriction>
    </xs:simpleType>
  
        <xs:simpleType name="sqlServerDate">
        <xs:annotation>
        <xs:documentation>Date from 1753-01-01 to 9999-12-31</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:date">
        <xs:minInclusive value="1753-01-01"/>
        <xs:maxInclusive value="9999-12-31"/>
        </xs:restriction>
        </xs:simpleType>
    
    <xs:simpleType name="veryShortString">
        <xs:annotation>
            <xs:documentation>String with max length 20</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="20"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="shortString50">
        <xs:annotation>
            <xs:documentation>String with max length 20</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="50"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="semiShortString">
        <xs:annotation>
            <xs:documentation>String with max length 100</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="100"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="emailAddress">
        <xs:annotation>
            <xs:documentation>String of letters, digits and certain punctuation characters</xs:documentation>
        </xs:annotation>
        <xs:restriction base="semiShortString">
            <xs:pattern value="[\p{L}\d_]+(\.[\p{L}\d_]+)*@[\p{L}\d_]+(\.[\p{L}\d_]+)+"/>
            <xs:pattern value=""/>
            <!-- this allows an empty element to pass validation -->
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="httpAddress">
        <xs:annotation>
            <xs:documentation>URI reference beginning with http:// with max length 250</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:anyURI">
            <xs:maxLength value="250"/>
            <xs:pattern value="http://.+"/>
            <xs:pattern value="https://.+"/>
            <xs:pattern value=""/>
            <!-- this allows an empty element to pass validation -->
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="phoneNumber">
        <xs:annotation>
            <xs:documentation>String of digits and hyphens with max length 20</xs:documentation>
        </xs:annotation>
        <xs:restriction base="veryShortString">
            <xs:pattern value="\d+(-\d+)*"/>
            <xs:pattern value=""/>
            <!-- this allows an empty element to pass validation -->
        </xs:restriction>
    </xs:simpleType>
    
    <xs:element name="assetCollection">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="asset" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:choice minOccurs="0" maxOccurs="unbounded">
                            <xs:element name="isSearchable" type="xs:boolean"/>
                            <xs:element name="assetId" type="guid" minOccurs="0"/>
                            <xs:element name="assetTypeId" type="guid"/>
                            <xs:element name="substitutionUrl" type="minLengthOne"/>
                            <xs:element name="assetName" type="minLengthOne"/>
                            <xs:element name="category" type="categoryEnum"/>
                            <xs:element name="channel" type="minLengthOne" maxOccurs="unbounded"/>                        
                            <xs:element name="mediaType" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
                            <xs:element name="searchWeight" type="searchWeightScale" default="1" minOccurs="0"/>
                            <xs:element name="title" type="xs:string" minOccurs="0"/>
                            <xs:element name="summary" type="xs:string" minOccurs="0"/>
                            <xs:element name="allText" type="xs:string" minOccurs="0"/>
                            <xs:element ref="zip" minOccurs="0"/>
                            <xs:element ref="city" minOccurs="0"/>
                            <xs:element name="state" type="minLengthOne"/>
                            <xs:element name="country" type="minLengthOne"/>
                            <xs:element name="startDate" type="xs:string" minOccurs="0"/>
                            <xs:element name="startTime" type="xs:string" minOccurs="0"/>
                            <xs:element name="endDate" type="xs:string" minOccurs="0"/>
                            <xs:element name="endTime" type="xs:string" minOccurs="0"/>
                            <xs:element name="participationCriteria" type="xs:string" minOccurs="0"/>
                            <xs:element name="onlineRegistrationAvailable" type="xs:boolean"
                                minOccurs="0"/>
                            <xs:element name="onlineRegistrationCost" type="xs:string" minOccurs="0"/>
                            <xs:element name="onlineDonationAvailable" type="xs:boolean"
                                minOccurs="0"/>
                            <xs:element name="onlineMembershipAvailable" type="xs:boolean"
                                minOccurs="0"/>
                            <xs:element name="onlineFacilityReservationAvailable" type="xs:string"
                                minOccurs="0"/>
                            <xs:element name="onlineMembershipCost" type="xs:string" minOccurs="0"/>
                            <xs:element name="numberRegistered" type="xs:nonNegativeInteger"
                                minOccurs="0"/>
                            <xs:element name="registrationSlotsRemaining"
                                type="xs:nonNegativeInteger" minOccurs="0"/>
                            <xs:element name="tags" type="xs:string" minOccurs="0"/>
                            <xs:element name="avgUserRating" type="xs:string" minOccurs="0"/>
                            <xs:element name="userCommentText" type="xs:string" minOccurs="0"/>
                            <xs:element name="image1" type="httpAddress" minOccurs="0"/>
                            <xs:element name="image2" type="httpAddress" minOccurs="0"/>
                            <xs:element name="contactEmail" type="xs:string" minOccurs="0"/>
                            <xs:element name="contactPhone" type="xs:string" minOccurs="0"/>
                            <xs:element name="address" type="xs:string" minOccurs="0"/>
                            <xs:element name="author" type="xs:string" minOccurs="0"/>
                            <xs:element name="duration" type="xs:string" minOccurs="0"/>
                            <xs:element name="eventResults" type="httpAddress" minOccurs="0"/>
                            <xs:element name="image2Trackbacklink" type="httpAddress" minOccurs="0"/>
                            <xs:element name="location" type="xs:string" minOccurs="0"/>
                        </xs:choice>
                        <xs:attribute name="destinationID" use="required"/>
                        <xs:attribute ref="row" use="required"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>