]> Wikimedia Canada | Git repositories - eccc_to_commons.git/blobdiff - commons_rules.xsd
Rewrite almanach merge logic
[eccc_to_commons.git] / commons_rules.xsd
index 1bfd00dbc0e07f457c9905ce6316975868d5cdd0..49a50d31976575893aa56c5578143430ac779c09 100644 (file)
@@ -3,7 +3,12 @@
      historical data prior of its import into Wikidata.
 
      All tests done in ECCC's bulkschema.xsd aren't replicated here as we're
      historical data prior of its import into Wikidata.
 
      All tests done in ECCC's bulkschema.xsd aren't replicated here as we're
-     focusing into pure Wikimedia Commons data quality -->
+     focusing into pure Wikimedia Commons data quality.
+
+     Schema is restrictive on purpose: up to date extreme values are hard coded
+     just like current year. It WILL break starting 2021 so we can make sure
+     someone has checked potential upstream structure change before running
+     Commons data update. -->
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <!-- Define elements -->
        <xsd:element name="climatedata">
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <!-- Define elements -->
        <xsd:element name="climatedata">
                                <xsd:element ref="lang" minOccurs="1" maxOccurs="1" />
                                <xsd:element ref="stationinformation" minOccurs="1" maxOccurs="1" />
                                <xsd:element ref="legend" minOccurs="1" maxOccurs="1" />
                                <xsd:element ref="lang" minOccurs="1" maxOccurs="1" />
                                <xsd:element ref="stationinformation" minOccurs="1" maxOccurs="1" />
                                <xsd:element ref="legend" minOccurs="1" maxOccurs="1" />
-                               <xsd:element ref="stationdata" minOccurs="1" maxOccurs="unbounded" />
+                               <xsd:choice>
+                                       <xsd:element ref="stationdata" minOccurs="1" maxOccurs="unbounded" />
+                                       <xsd:element ref="month" minOccurs="1" maxOccurs="unbounded" />
+                               </xsd:choice>
                        </xsd:sequence>
                </xsd:complexType>
        </xsd:element>
                        </xsd:sequence>
                </xsd:complexType>
        </xsd:element>
                </xsd:complexType>
        </xsd:element>
 
                </xsd:complexType>
        </xsd:element>
 
+       <xsd:element name="month">
+               <xsd:complexType>
+                       <xsd:sequence>
+                               <xsd:element ref="day" minOccurs="0" maxOccurs="31" />
+                       </xsd:sequence>
+                       <xsd:attributeGroup ref="attrgroup-month" />
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="day">
+               <xsd:complexType>
+                       <xsd:sequence>
+                               <xsd:element ref="temperature" minOccurs="5" maxOccurs="5" />
+                               <xsd:element ref="precipitation" minOccurs="4" maxOccurs="4" />
+                               <xsd:element ref="pop" minOccurs="1" maxOccurs="1" />
+                       </xsd:sequence>
+                       <xsd:attributeGroup ref="attrgroup-day" />
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="temperature">
+               <xsd:complexType>
+                       <xsd:simpleContent>
+                               <xsd:extension base="temperature-values">
+                                       <xsd:attributeGroup ref="attrgroup-temperature" />
+                               </xsd:extension>
+                       </xsd:simpleContent>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="precipitation">
+               <xsd:complexType>
+                       <xsd:simpleContent>
+                               <xsd:extension base="precipitation-values">
+                                       <xsd:attributeGroup ref="attrgroup-precipitation" />
+                               </xsd:extension>
+                       </xsd:simpleContent>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="pop">
+               <xsd:complexType>
+                       <xsd:simpleContent>
+                               <xsd:extension base="pop-values">
+                                       <xsd:attributeGroup ref="attrgroup-pop" />
+                               </xsd:extension>
+                       </xsd:simpleContent>
+               </xsd:complexType>
+       </xsd:element>
+
        <!-- Define attributes -->
        <xsd:attribute name="flag">
                <xsd:annotation>
        <!-- Define attributes -->
        <xsd:attribute name="flag">
                <xsd:annotation>
                        <xsd:simpleType>
                                <xsd:restriction base="xsd:integer">
                                        <xsd:minInclusive value="1840" />
                        <xsd:simpleType>
                                <xsd:restriction base="xsd:integer">
                                        <xsd:minInclusive value="1840" />
-                                       <xsd:maxInclusive value="2019" />
+                                       <xsd:maxInclusive value="2020" />
                                </xsd:restriction>
                        </xsd:simpleType>
                </xsd:attribute>
                                </xsd:restriction>
                        </xsd:simpleType>
                </xsd:attribute>
                </xsd:attribute>
        </xsd:attributeGroup>
 
                </xsd:attribute>
        </xsd:attributeGroup>
 
+       <xsd:attributeGroup name="attrgroup-month">
+               <xsd:attribute name="index" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:integer">
+                                       <xsd:minInclusive value="1" />
+                                       <xsd:maxInclusive value="12" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+       </xsd:attributeGroup>
+
+       <xsd:attributeGroup name="attrgroup-day">
+               <xsd:attribute name="index" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:integer">
+                                       <xsd:minInclusive value="1" />
+                                       <xsd:maxInclusive value="31" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+       </xsd:attributeGroup>
+
+       <xsd:attributeGroup name="attrgroup-temperature">
+               <xsd:attribute name="class" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:enumeration value="extremeMax" />
+                                       <xsd:enumeration value="extremeMin" />
+                                       <xsd:enumeration value="normalMax" />
+                                       <xsd:enumeration value="normalMin" />
+                                       <xsd:enumeration value="normalMean" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="units" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:annotation>
+                                               <xsd:documentation xml:lang="en">temperature must be provided in °C.
+                                               </xsd:documentation>
+                                       </xsd:annotation>
+                                       <xsd:enumeration value="°C" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="unitType" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:annotation>
+                                               <xsd:documentation xml:lang="en">unitType must be provided metric.
+                                               </xsd:documentation>
+                                       </xsd:annotation>
+                                       <xsd:enumeration value="metric" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="period" use="optional" />
+               <xsd:attribute name="year" use="optional">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:integer">
+                                       <xsd:minInclusive value="1840" />
+                                       <xsd:maxInclusive value="2020" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="quality" use="optional">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:enumeration value="†" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+       </xsd:attributeGroup>
+
+       <xsd:attributeGroup name="attrgroup-precipitation">
+               <xsd:attribute name="class" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:enumeration value="extremeRainfall" />
+                                       <xsd:enumeration value="extremeSnowfall" />
+                                       <xsd:enumeration value="extremePrecipitation" />
+                                       <xsd:enumeration value="extremeSnowOnGround" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="units" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:annotation>
+                                               <xsd:documentation xml:lang="en">precipitation must be provided in mm or cm.
+                                               </xsd:documentation>
+                                       </xsd:annotation>
+                                       <xsd:enumeration value="mm" />
+                                       <xsd:enumeration value="cm" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="unitType" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:annotation>
+                                               <xsd:documentation xml:lang="en">unitType must be provided metric.
+                                               </xsd:documentation>
+                                       </xsd:annotation>
+                                       <xsd:enumeration value="metric" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="period" use="required" />
+               <xsd:attribute name="year" use="optional">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:integer">
+                                       <xsd:minInclusive value="1840" />
+                                       <xsd:maxInclusive value="2020" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+               <xsd:attribute name="quality" use="optional">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:enumeration value="†" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+       </xsd:attributeGroup>
+
+       <xsd:attributeGroup name="attrgroup-pop">
+               <xsd:attribute name="units" use="required">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:string">
+                                       <xsd:enumeration value="%" />
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:attribute>
+       </xsd:attributeGroup>
+
        <!-- Define types -->
        <xsd:simpleType name="meanmaxtemp-values">
                <xsd:union memberTypes="empty">
        <!-- Define types -->
        <xsd:simpleType name="meanmaxtemp-values">
                <xsd:union memberTypes="empty">
                </xsd:union>
        </xsd:simpleType>
 
                </xsd:union>
        </xsd:simpleType>
 
+       <xsd:simpleType name="temperature-values">
+               <xsd:union memberTypes="empty">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:float">
+                                       <xsd:minInclusive value="-63.0" />
+                                       <xsd:maxInclusive value="50.0">
+                                               <xsd:annotation>
+                                                       <xsd:documentation xml:lang="en">Value is currently between -63.0 and 50.0.
+                                                       </xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:maxInclusive>
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:union>
+       </xsd:simpleType>
+
+       <xsd:simpleType name="precipitation-values">
+               <xsd:union memberTypes="sharps empty">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:float">
+                                       <xsd:minInclusive value="0.0" />
+                                       <xsd:maxInclusive value="999">
+                                               <xsd:annotation>
+                                                       <xsd:documentation xml:lang="en">Max value is currently 999.
+                                                       </xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:maxInclusive>
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:union>
+       </xsd:simpleType>
+
+       <xsd:simpleType name="pop-values">
+               <xsd:union memberTypes="empty">
+                       <xsd:simpleType>
+                               <xsd:restriction base="xsd:float">
+                                       <xsd:minInclusive value="0.0" />
+                                       <xsd:maxInclusive value="100.0">
+                                               <xsd:annotation>
+                                                       <xsd:documentation xml:lang="en">Percentage.</xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:maxInclusive>
+                               </xsd:restriction>
+                       </xsd:simpleType>
+               </xsd:union>
+       </xsd:simpleType>
+
        <xsd:simpleType name="empty">
                <xsd:restriction base="xsd:string">
                        <xsd:length value="0" />
        <xsd:simpleType name="empty">
                <xsd:restriction base="xsd:string">
                        <xsd:length value="0" />