heiglandreas/holidayChecker

View on GitHub
share/holidays.xsd

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="https://heigl.org/holidays"
           xmlns="https://heigl.org/holidays"
           elementFormDefault="qualified">
    <xs:simpleType name="monthInt">
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="12"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="dayInt">
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="31"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="daynames">
        <xs:restriction base="xs:string">
            <xs:enumeration value="sunday"/>
            <xs:enumeration value="monday"/>
            <xs:enumeration value="tuesday"/>
            <xs:enumeration value="wednesday"/>
            <xs:enumeration value="thursday"/>
            <xs:enumeration value="friday"/>
            <xs:enumeration value="saturday"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="daynamelist">
        <xs:list itemType="daynames" />
    </xs:simpleType>
    <xs:simpleType name="calendars">
        <xs:restriction base="xs:string">
            <!--
            as described in the language files of ICU
            see https://github.com/unicode-org/icu/blob/d453c12bfacde783b7e985cdb4eb15c6db277f78/icu4c/source/data/lang/en.txt#L951-L970
            -->
            <xs:enumeration value="buddhist"/>
            <xs:enumeration value="chinese"/>
            <xs:enumeration value="coptic"/>
            <xs:enumeration value="dangi"/>
            <xs:enumeration value="ethiopic"/>
            <xs:enumeration value="ethiopic-amete-alem"/>
            <xs:enumeration value="gregorian"/>
            <xs:enumeration value="hebrew"/>
            <xs:enumeration value="indian"/>
            <xs:enumeration value="islamic"/>
            <xs:enumeration value="islamic-civil"/>
            <xs:enumeration value="islamic-umalqura"/>
            <xs:enumeration value="islamic-tbla"/>
            <xs:enumeration value="iso8601"/>
            <xs:enumeration value="japanese"/>
            <xs:enumeration value="persian"/>
            <xs:enumeration value="roc"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:attributeGroup name="restriction">
        <xs:attribute name="restriction" type="xs:string" />
    </xs:attributeGroup>
    <xs:attribute name="firstobservance" type="xs:gYear"/>
    <xs:attribute name="lastobservance" type="xs:gYear"/>
    <xs:attributeGroup name="observanceRestrictions">
        <xs:annotation xml:lang="en">
            <xs:documentation>
                The attributes firstobservance and lastobservance are including.
                The attribute interval describes that the holiday is only observed every $interval years with the first observance in year $firstobservance.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="firstobservance" type="xs:gYear"/>
        <xs:attribute name="lastobservance" type="xs:gYear"/>
        <xs:attribute name="interval" type="xs:integer"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="observanceInterval">
        <xs:attribute ref="firstobservance" use="required"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="easterAttributes">
        <xs:attribute name="offset" type="xs:integer" use="required"/>
        <xs:attribute name="free" type="xs:boolean" use="required"/>
        <xs:attribute name="comment" type="xs:string"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="dateAttributes">
        <xs:attribute name="day" type="dayInt" use="required"/>
        <xs:attribute name="month" type="monthInt" use="required"/>
        <xs:attribute name="year" type="xs:integer" />
        <xs:attribute name="free" type="xs:boolean" use="required"/>
        <xs:attribute name="comment" type="xs:string"/>
        <xs:attribute name="calendar" type="calendars"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="dateFollowUpAttributes">
        <xs:attribute name="day" type="dayInt" use="required"/>
        <xs:attribute name="month" type="monthInt" use="required"/>
        <xs:attribute name="followup" type="daynames" use="required" />
        <xs:attribute name="replaced" type="daynamelist" use="optional" />
        <xs:attribute name="free" type="xs:boolean" use="required"/>
        <xs:attribute name="comment" type="xs:string"/>
        <xs:attribute name="calendar" type="calendars"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="relativeAttributes">
        <xs:attribute name="day" type="dayInt" use="required"/>
        <xs:attribute name="month" type="monthInt" use="required"/>
        <xs:attribute name="relation" type="xs:string" use="required"/>
        <xs:attribute name="free" type="xs:boolean" use="required"/>
        <xs:attribute name="comment" type="xs:string"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="resourceAttributes">
        <xs:attribute name="href" type="xs:anyURI" use="required"/>
        <xs:attribute name="lastChecked" type="xs:date" use="required" />
    </xs:attributeGroup>
    <xs:attributeGroup name="forward">
        <xs:attribute name="forwardto" type="daynames" use="optional"/>
        <xs:attribute name="forwardwhen" type="daynamelist" use="optional" />
        <xs:attribute name="alternateforwardto" type="daynames"/>
        <xs:attribute name="alternateforwardwhen" type="daynamelist"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="rewind">
        <xs:attribute name="rewindto" type="daynames" use="optional"/>
        <xs:attribute name="rewindwhen" type="daynamelist" use="optional" />
        <xs:attribute name="alternaterewindto" type="daynames"/>
        <xs:attribute name="alternaterewindwhen" type="daynamelist"/>
    </xs:attributeGroup>
    <xs:element name="resources">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="resource" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="xs:string">
                                <xs:attributeGroup ref="resourceAttributes"/>
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="easter">
        <!--
        Days that are relative to the Easter date as calculated for the
        Western christian churches. The actual day is referenced by an
        offset from easter-sunday. Days before easter sunday have a
        negative offset, days after have a positive offset
        -->
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attributeGroup ref="easterAttributes"/>
                    <xs:attributeGroup ref="restriction"/>
                    <xs:attributeGroup ref="observanceRestrictions"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:element name="easterorthodox">
        <!--
        Days that are relative to the Easter date as calculated for the
        Eastern Christian churches. The actual day is referenced by an
        offset from easter-sunday. Days before easter sunday have a
        negative offset, days after have a positive offset
        -->
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attributeGroup ref="easterAttributes"/>
                    <xs:attributeGroup ref="restriction"/>
                    <xs:attributeGroup ref="observanceRestrictions"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:element name="date">
        <!--
        Days that are defined by their actual date like the 4th of July
        or 25th of December.

        The actual day is referenced by at least a day and a month attribute.
        For special occasions where a day is only a holiday in a certain year
        it can also have a year attribute. Note that you will need multiple
        entries for multiple years.
        -->
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attributeGroup ref="dateAttributes"/>
                    <xs:attributeGroup ref="rewind"/>
                    <xs:attributeGroup ref="forward"/>
                    <xs:attributeGroup ref="restriction"/>
                    <xs:attributeGroup ref="observanceRestrictions"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:element name="dateFollowUp">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attributeGroup ref="dateFollowUpAttributes"/>
                    <xs:attributeGroup ref="restriction"/>
                    <xs:attributeGroup ref="observanceRestrictions"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:element name="relative">
        <!--
        This is similar to the dateFollowUp but the relation can be
        more complext.

        Again the date the relation is referenced from is given via
        day and month attributes but the relation itself is given in
        the relation attribute and can be anything that
        http://php.net/manual/de/datetimeimmutable.modify.php
        can handle. Like "last sunday -3 weeks" from 25th of december
        would be the 1st sunday in advent
        -->
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attributeGroup ref="relativeAttributes"/>
                    <xs:attributeGroup ref="restriction"/>
                    <xs:attributeGroup ref="rewind"/>
                    <xs:attributeGroup ref="forward"/>
                    <xs:attributeGroup ref="observanceRestrictions"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>



    <xs:element name="holidays">
        <!--
        All elements have to be within the root element "holidays".

        Within this root element we expect a list of entries of type
        "easter", "easterorthodox", "date", "dateFollowUp" or "relative"

        Explanations follow on the respective elements
        -->
        <xs:complexType>
            <xs:choice maxOccurs="unbounded">
                <xs:element ref="resources" minOccurs="0" maxOccurs="1"/>
                <xs:element ref="easter" minOccurs="0" maxOccurs="unbounded" />
                <xs:element ref="easterorthodox" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="date" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="dateFollowUp" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="relative" minOccurs="0" maxOccurs="unbounded" />
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>