<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2009 sp1 (http://www.altova.com) by ICT (Stichting Deltares) -->
<!--Delft FEWS (Copyright 2009 Deltares (Delft Hydraulics)) -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:fews="http://www.wldelft.nl/fews" targetNamespace="http://www.wldelft.nl/fews" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
	<include schemaLocation="sharedTypes.xsd"/>
	<complexType name="SecondaryValidationBaseComplexType">
		<complexContent>
			<extension base="fews:ClassNameComplexType">
				<sequence>
					<element name="loggingTimeSeries" type="fews:SecondaryValidationVariableComplexType"
							 minOccurs="0" maxOccurs="unbounded">
						<annotation>
							<documentation>Since 2024.01. Definition of a time series to be used for storing logged messages.</documentation>
						</annotation>
					</element>
				</sequence>
			</extension>
		</complexContent>
	</complexType>
	<simpleType name="secondaryValidationOutputModeEnumStringType">
		<restriction base="string">
			<enumeration value="logs_only"/>
			<enumeration value="flags_and_logs"/>
		</restriction>
	</simpleType>
	<group name="LogEventGroup">
		<sequence>
			<element name="logLevel" type="fews:logLevelEnumStringType">
				<annotation>
					<documentation>Log level for the log message that is logged by the check. If level is error or fatal, then the module will stop running after logging the first log message.</documentation>
				</annotation>
			</element>
			<element name="logEventCode" type="fews:logEventCodeStringType">
				<annotation>
					<documentation>Event code for the log message that is generated by this check. This event code has to contain a dot, e.g. "TimeSeries.Check", because the log message is only visible to the master controller if the event code contains a dot.</documentation>
				</annotation>
			</element>
			<element name="logMessage" type="fews:nonEmptyStringType">
				<annotation>
					<documentation>Log message that is logged by the check. It is possible to use the following tags: %HEADER% and %LOCATION_NAME%. The %HEADER% tag will be replaced with the header of the time series. The %LOCATION_NAME% tag will be replaced with the name of the location of the time series. For minNumberOfValuesCheck, minNonMissingValuesCheck, minReliableOrDoubtfulValuesCheck and minReliableValuesCheck it is also possible to use additional tags between "@" signs, e.g. "@ID@", that refer to location attributes that are defined in the locationSets config file. The values of the location attributes can be different for different locations. The location attributes are evaluated first, then the other tags (between % signs) are evaluated. Checks that update the flags can use %AMOUNT_CHANGED_FLAGS% to display the number of flags that have been altered. The tag %CHECK_ID% puts in the id of the check that caused the flags to be altered. The SeriesComparisonCheck can use %EXPRESSION%, which is the expression that caused the flags to be altered.  The tag %LOCATION_ID% displays the locationId where the alterations took place. The tag %OUTPUT_FLAG% contains the flag that has been set. The tag %PARAMETER_ID%  contains  the parameterId where the alterations took place. The tag %PARAMETER_NAME% contains the name of the parameter where the alterations took place. The tag %PERIOD% contains the period in which flags were changed. The tag %NONE% hides the autogenerated location and parameter in the log message. The SeriesComparisonCheck also may contain the tag %VALUE%, which will be replaced with the latest value for the validating timeseries.</documentation>
				</annotation>
			</element>
			<element name="onErrorResumeNext" type="boolean" default="false" minOccurs="0">
				<annotation>
					<documentation>If true, the validation check will continue logging after the first error. NB. Be aware that lots of event-codes might be generated using this option and that these may trigger a lot of emails being sent automatically by the master-controller.</documentation>
				</annotation>
			</element>
		</sequence>
	</group>
	<element name="secondaryValidation" type="fews:SecondaryValidationComplexType">
		<annotation>
			<documentation>Contains a list of checks on timeSeries. These checks are different from transformations in that they do not have impact on the data, merely on the reliability flags or the generation of log events. Also different from primary validation as the tests using LogEventGroup can be added to a workflow for monitoring missing data values over time, generating log-messages, whereas primary validation is only run when the data is imported.</documentation>
		</annotation>
	</element>
	<complexType name="SecondaryValidationComplexType">
		<sequence>
			<element name="variableDefinition" type="fews:SecondaryValidationVariableDefinitionComplexType" minOccurs="0" maxOccurs="unbounded">
				<annotation>
					<documentation>Definitions of variable that can be used as input for checks. Alternatively, variable definitions can be embedded in the checks.</documentation>
				</annotation>
			</element>
			<choice maxOccurs="unbounded">
				<element name="minNumberOfValuesCheck" type="fews:MinimumNumberOfValuesCheckComplexType">
					<annotation>
						<documentation>Checks whether there are enough values within a configured period. If not, then a log message with the configured event code and level is logged. The log event code can be used to trigger a certain action in the master controller, e.g. sending warning emails. In this context a value can be reliable, doubtful, unreliable or missing. This check is useful for non-equidistant time series where the number of values per period (including missing values) is not fixed.</documentation>
					</annotation>
				</element>
				<element name="minNonMissingValuesCheck" type="fews:MinimumNumberOfNonMissingValuesCheckComplexType">
					<annotation>
						<documentation>Checks whether there are enough non-missing values within a configured period. If not, then a log message with the configured event code and level is logged. The log event code can be used to trigger a certain action in the master controller, e.g. sending warning emails. A non-missing value is a value that is reliable, doubtful or unreliable.</documentation>
					</annotation>
				</element>
				<element name="minReliableOrDoubtfulValuesCheck" type="fews:MinimumNumberOfReliableOrDoubtfulValuesCheckComplexType">
					<annotation>
						<documentation>Checks whether there are enough values that are reliable or doubtful within a configured period. If not, then a log message with the configured event code and level is logged. The log event code can be used to trigger a certain action in the master controller, e.g. sending warning emails.</documentation>
					</annotation>
				</element>
				<element name="minReliableValuesCheck" type="fews:MinimumNumberOfReliableValuesCheckComplexType">
					<annotation>
						<documentation>Checks whether there are enough reliable values within a configured period. If not, then a log message with the configured event code and level is logged. The log event code can be used to trigger a certain action in the master controller, e.g. sending warning emails.</documentation>
					</annotation>
				</element>
				<element name="seriesComparisonCheck" type="fews:SeriesComparisonCheckComplexType">
					<annotation>
						<documentation>Checks the specified expression for the available variables and alters the flags for the time steps where the expression succeeds. For instance, a check can compare the water flow before and after a river junction. It is required that all referenced variables in the expression have the same size. Either all variables are regular with the same timestep, or all variables are non-equidistant with the same times. The comparison can be for different parameters at one location or per location of a locationSet, or for one parameter at two locations or at one location and the locations of a location set, or between multiple equal location sets.</documentation>
					</annotation>
				</element>
				<element name="flagsComparisonCheck" type="fews:FlagsComparisonCheckComplexType">
					<annotation>
						<documentation>Overwrites the flag of the output timeseries with one of the flags of the input variables according to the following rules: Input flag 'missing' or 'unreliable' turns  output flag 'doubtful' and 'reliable' into unreliable. Input flag 'doubtful' turns output flag 'reliable' into 'doubtful'. The comparison can be for different parameters at one location or per location of a locationSet, or for one parameter at two locations or at one location and the locations of a location set, or between multiple equal location sets.</documentation>
					</annotation>
				</element>
				<element name="spatialHomogeneityCheck" type="fews:SpatialHomogeneityCheckComplexType">
					<annotation>
						<documentation>Overwrites the flag of the timeseries with unreliable or doubtful when the estimation of the value based on neighbouring values differs too much from the observed value. The criteria for that can be specified to be a maximum threshold or relative (i.e. percentage of the standard deviation) or both. The estimation is based upon a maximum number of closest by other locations within a maximum search radius. </documentation>
					</annotation>
				</element>
				<element name="mannKendallCheck" type="fews:MannKendallCheckComplexType">
					<annotation>
						<documentation>Overwrites the flag of the timeseries with unreliable or doubtful when there are at least ten observations and the Mann-Kendall detects a trend but the value does not follow the trend for the specified confidence balance. This check uses tiedValues and sameYearValues for the calculation.</documentation>
					</annotation>
				</element>
				<element name="flagPersistencyCheck" type="fews:FlagPersistencyCheckComplexType">
					<annotation>
						<documentation>This check operates with the manual persistency marker that can be set by the
							user in the TimeSeriesDialog. This check will copy a persistent flag to the next timestep
							and will mark this next timestep as persistent. This is repeated until a different manual
							flag source is found.
						</documentation>
					</annotation>
				</element>
			</choice>
		</sequence>
	</complexType>
	<complexType name="SecondaryValidationVariableDefinitionComplexType">
		<sequence>
			<element name="variableId" type="fews:idStringType">
				<annotation>
					<documentation>Identifier for this variable. Use this identifier to reference the time series set within the expression.</documentation>
				</annotation>
			</element>
			<element name="timeSeriesSet" type="fews:TimeSeriesSetComplexType">
				<annotation>
					<documentation>A time series set that can be used as input or output for a check.</documentation>
				</annotation>
			</element>
		</sequence>
	</complexType>
	<complexType name="SecondaryValidationVariableComplexType">
		<annotation>
			<documentation>Choose between a reference to a time series or an embedded definition of a time series.</documentation>
		</annotation>
		<choice>
			<element name="variableId" type="fews:idStringType">
				<annotation>
					<documentation>Identifier of a variable to use. Refers to a time series set defined at top level.</documentation>
				</annotation>
			</element>
			<element name="timeSeriesSet" type="fews:TimeSeriesSetComplexType">
				<annotation>
					<documentation>A time series set that can be used as input for a check.</documentation>
				</annotation>
			</element>
		</choice>
	</complexType>
    <complexType name="MinimumNumberOfValuesCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <sequence>
                    <element name="variable" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>One or more items that describe the data that need to be checked. If the
                                specified data contains multiple time series (e.g. for multiple locations), then each
                                time series is checked individually.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="checkRelativePeriod" type="fews:RelativePeriodComplexType">
                        <annotation>
                            <documentation>The check will only consider data in this time period. This time period is
                                relative to the timeZero of the task run in which this module instance runs. The start
                                and end of the period are included.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="minNumberOfValues" type="positiveInteger">
                        <annotation>
                            <documentation>The minimum required number of values.</documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.MinimumNumberOfValuesCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Optional element to define the name of the class that should be executed to
                                perform this secondary validation. Normally this element can be left out of the xml
                                configuration, and the default class name will be used. This default class name is
                                defined as the default value for this element in the xsd schema for this transformation.
                                Only use this element if you need to use a custom class that is present in the program
                                code.
                            </documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check. This is only used in log messages and exception
                            messages.
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="MinimumNumberOfNonMissingValuesCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <sequence>
                    <element name="variable" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>One or more items that describe the data that need to be checked. If the
                                specified data contains multiple time series (e.g. for multiple locations), then each
                                time series is checked individually.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="checkRelativePeriod" type="fews:RelativePeriodComplexType">
                        <annotation>
                            <documentation>The check will only consider data in this time period. This time period is
                                relative to the timeZero of the task run in which this module instance runs. The start
                                and end of the period are included.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="minNumberOfValues" type="positiveInteger">
                        <annotation>
                            <documentation>The minimum required number of values.</documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.MinimumNumberOfNonMissingValuesCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Optional element to define the name of the class that should be executed to
                                perform this secondary validation. Normally this element can be left out of the xml
                                configuration, and the default class name will be used. This default class name is
                                defined as the default value for this element in the xsd schema for this secondary validation.
                                Only use this element if you need to use a custom class that is present in the program
                                code.
                            </documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check. This is only used in log messages and exception
                            messages.
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="MinimumNumberOfReliableOrDoubtfulValuesCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <sequence>
                    <element name="variable" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>One or more items that describe the data that need to be checked. If the
                                specified data contains multiple time series (e.g. for multiple locations), then each
                                time series is checked individually.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="checkRelativePeriod" type="fews:RelativePeriodComplexType">
                        <annotation>
                            <documentation>The check will only consider data in this time period. This time period is
                                relative to the timeZero of the task run in which this module instance runs. The start
                                and end of the period are included.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="minNumberOfValues" type="positiveInteger">
                        <annotation>
                            <documentation>The minimum required number of values.</documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.MinimumNumberOfReliableOrDoubtfulValuesCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Optional element to define the name of the class that should be executed to
                                perform this secondary validation. Normally this element can be left out of the xml
                                configuration, and the default class name will be used. This default class name is
                                defined as the default value for this element in the xsd schema for this secondary
                                validation.
                                Only use this element if you need to use a custom class that is present in the program
                                code.
                            </documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check. This is only used in log messages and exception
                            messages.
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="MinimumNumberOfReliableValuesCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <sequence>
                    <element name="variable" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>One or more items that describe the data that need to be checked. If the
                                specified data contains multiple time series (e.g. for multiple locations), then each
                                time series is checked individually.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="checkRelativePeriod" type="fews:RelativePeriodComplexType">
                        <annotation>
                            <documentation>The check will only consider data in this time period. This time period is
                                relative to the timeZero of the task run in which this module instance runs. The start
                                and end of the period are included.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="minNumberOfValues" type="positiveInteger">
                        <annotation>
                            <documentation>The minimum required number of values.</documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.MinimumNumberOfReliableValuesCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Optional element to define the name of the class that should be executed to
                                perform this secondary validation. Normally this element can be left out of the xml
                                configuration, and the default class name will be used. This default class name is
                                defined as the default value for this element in the xsd schema for this secondary
                                validation.
                                Only use this element if you need to use a custom class that is present in the program
                                code.
                            </documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check. This is only used in log messages and exception
                            messages.
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="SeriesComparisonCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <annotation>
                    <documentation>Defines a series of variables and an expression. Variable definitions are first
                        searched for locally, if the variable is not found here it has to be available at the global
                        level.
                    </documentation>
                </annotation>
                <sequence>
                    <element name="variableDefinition" type="fews:SecondaryValidationVariableDefinitionComplexType"
                             minOccurs="0" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Definition of a variable to be used in the expression.</documentation>
                        </annotation>
                    </element>
                    <element name="expression" type="string">
                        <annotation>
                            <documentation>Formula stating the constraint to test, must be a comparison. Comparators
                                have to be in Fortran 77: .le. .eq. .ne. .gt. .ge. Logical expressions such as .and. or
                                .or. and bracelets are allowed as well. For instance,
                                (abs(a - b - c) .ge. abs(0.05*a) +abs(0.05*b) +abs(0.05*c)) .or. a .gt. 100

                                says that the difference between flow variables 'a' and the sum of variables 'b' and 'c'
                                should be smaller than the sum of the instrument errors, eg. 5% and that variable 'a'
                                should be smaller than 100. If the condition holds, the flag will be updated to the
                                specified output flag. NB: Variable names should not overlap with mathematical constants
                                or functions such as 'e' , 'pi' or 'sin'.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="validatingVariableId" type="fews:idStringType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Identifier of a variable for which the outputFlag has to be updated in case
                                the expression tests positive. Refers to a time series set defined in the
                                variableDefinitions.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputFlag" type="fews:flagEnumStringType" default="unreliable">
                        <annotation>
                            <documentation>Flag that will be set for all data values for which the expression
                                succeeds.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputMode" type="fews:secondaryValidationOutputModeEnumStringType"
                             default="flags_and_logs" minOccurs="0">
                        <annotation>
                            <documentation>When this option is set to 'logs_only', only log messages are generated, the
                                flags will not be updated.
                            </documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.SeriesComparisonCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Optional element to define the name of the class that should be executed to
                                perform this secondary validation. Normally this element can be left out of the xml
                                configuration, and the default class name will be used. This default class name is
                                defined as the default value for this element in the xsd schema for this secondary
                                validation.
                                Only use this element if you need to use a custom class that is present in the program
                                code.
                            </documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check.</documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="FlagsComparisonCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <annotation>
                    <documentation>Defines a series of input and output variables.</documentation>
                </annotation>
                <sequence>
                    <element name="variableDefinition" type="fews:SecondaryValidationVariableDefinitionComplexType"
                             minOccurs="0" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Definition of a variable to be used in the input and/or output variables.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="inputVariableId" type="fews:idStringType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Identifier of a variable of which the flags will be used. Refers to a time
                                series set defined in the variableDefinitions.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputVariableId" type="fews:idStringType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Identifier of a variable for which the outputFlag has to be updated in case
                                the input flag was more unreliable. Refers to a time series set defined in the
                                variableDefinitions.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputMode" type="fews:secondaryValidationOutputModeEnumStringType"
                             default="flags_and_logs" minOccurs="0">
                        <annotation>
                            <documentation>By default the flags that need updating are updated and log events are
                                generated for the updated flags. When this option is set to 'logs_only', the log events
                                are generated but the flags will not be updated.
                            </documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.FlagsComparisonCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Since 2014.02. Optional element to define the name of the class that should be executed to perform this secondary validation. Normally this element can be left out of the xml configuration, and the default class name will be used. This default class name is defined as the default value for this element in the xsd schema for this secondary validation. Only use this element if you need to use a custom class that is present in the program code.</documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check.</documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="spatialHomogeneityThresholdComplexType">
        <sequence>
            <sequence>
                <element name="absolute" type="fews:floatStringAttributeAndPropertyType" minOccurs="0">
                    <annotation>
                        <documentation>The output flag is applied when the difference between observed and
                            estimated exceeds this value.
                        </documentation>
                    </annotation>
                </element>
                <element name="relative" type="fews:floatStringAttributeAndPropertyType" minOccurs="0">
                    <annotation>
                        <documentation>The output flag is applied when the difference between observed and estimated is
                            bigger than this factor times the standard deviation of the neighbouring values.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
            <element name="appliesWhenWeightedNeighbors" type="fews:higherLowerEnumStringType" default="higherOrLower" minOccurs="0">
                <annotation>
                    <documentation>Specify whether the threshold applies when the neighbors have higher and or lower values.</documentation>
                </annotation>
            </element>
            <element name="outputFlag" type="fews:flagEnumStringType" default="unreliable">
                <annotation>
                    <documentation>Flag that will be set for all timesteps for which the check is to alter flags,
                        unreliable or doubtful.
                    </documentation>
                </annotation>
            </element>
            <element name="outputMode" type="fews:secondaryValidationOutputModeEnumStringType" default="flags_and_logs"
                     minOccurs="0">
                <annotation>
                    <documentation>By default the flags that need updating are updated and log events are generated for
                        the updated flags. When this option is set to 'logs_only', the log events are generated but the
                        flags will not be updated.
                    </documentation>
                </annotation>
            </element>
            <element name="sourceId" type="fews:idStringType" minOccurs="0">
                <annotation>
                    <documentation>Configurable flag source that will be set for all timesteps for which the check
                        alters the flags. This will override the standard flag source for this check. Refers to the
                        identifier in the CustomFlagSources schema in the RegionConfig.
                    </documentation>
                </annotation>
            </element>
            <group ref="fews:LogEventGroup"/>
            <element name="className" type="fews:nameStringType"
                     default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.SpatialHomogeneityCheck"
                     minOccurs="0">
                <annotation>
                    <documentation>Since 2014.02. Optional element to define the name of the class that should be executed to perform this secondary validation. Normally this element can be left out of the xml configuration, and the default class name will be used. This default class name is defined as the default value for this element in the xsd schema for this secondary validation. Only use this element if you need to use a custom class that is present in the program code.</documentation>
                </annotation>
            </element>
        </sequence>
    </complexType>
    <complexType name="SpatialHomogeneityCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <annotation>
                    <documentation>Defines a series of input and output variables.</documentation>
                </annotation>
                <sequence>
                    <element name="input" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>variable of which timeseries the flags will be used as input
                                (neighbouring locations).
                            </documentation>
                        </annotation>
                    </element>
                    <element name="searchRadius" type="double">
                        <annotation>
                            <documentation>Specifies the search radius in meters for the support locations (in meters).
                                Default
                                = Infinity. Specifying the search radius increases the performance since it limits the
                                candidate
                                points to be evaluated. Otherwise all possible points are considered. The searchRadius
                                criterion
                                is applied before the normalization with xMultiplier, yMultiplier and zMultiplier.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="distanceGeoDatum" type="fews:geoDatumStringType" minOccurs="0">
                        <annotation>
                            <documentation>Geo Datum used to calculate the distances in meters between the points. When
                                the input geometry is not in meters calculation of distances will be very slow and a
                                search all is required when there is no exact match
                            </documentation>
                        </annotation>
                    </element>
                    <choice>
                        <sequence>
                            <element name="numberOfPoints" type="positiveInteger" default="8">
                                <annotation>
                                    <documentation>Number of points used in SpatialHomogeneityCheck. The maximum number
                                        of neighbouring locations to base the estimation on. The neighbouring locations
                                        are established once per check. Missings are ignored. Default is 8 points.
                                    </documentation>
                                </annotation>
                            </element>
                            <element name="numberOfBackupPoints" type="nonNegativeInteger" default="0" minOccurs="0">
                                <annotation>
                                    <documentation>since 2012.02. Extra stations that are further away and are used in
                                        case of one or more missings in the base points. For every missing support point
                                        another neighbouring non-missing backup point is used.
                                    </documentation>
                                </annotation>
                            </element>
                        </sequence>
                        <sequence>
                            <element name="numberOfPointsPerQuadrant" type="positiveInteger">
                                <annotation>
                                    <documentation>since 2012.02. Determine whether to search per quadrant which may
                                        lead to a more balanced set of neighbouring stations. Number of points used in
                                        SpatialHomogeneityCheck. The maximum number of neighbouring locations to base
                                        the estimation on. The neighbouring locations are established once per check.
                                        Missings are ignored.
                                    </documentation>
                                </annotation>
                            </element>
                            <element name="numberOfBackupPointsPerQuadrant" type="nonNegativeInteger" default="0"
                                     minOccurs="0">
                                <annotation>
                                    <documentation>since 2012.02. Extra stations that are further away and are used in
                                        case of one or more missings in the base points. For every missing support point
                                        another neighbouring non-missing backup point is used.
                                    </documentation>
                                </annotation>
                            </element>
                        </sequence>
                    </choice>
                    <element name="includeAllBackupPointsInStandardDeviation" type="boolean" default="true" minOccurs="0">
                        <annotation>
                            <documentation>Specifies whether all backup points are included in the stDev calculation, default is true. When false only the backup points that are used to replace the closest points are used in the standard deviation calculation</documentation>
                        </annotation>
                    </element>
                    <element name="distancePower" type="double" default="2" minOccurs="0">
                        <annotation>
                            <documentation>Power of inverse distance, default is 2.</documentation>
                        </annotation>
                    </element>
                    <element name="xMultiplier" type="double" default="1.0" minOccurs="0">
                        <annotation>
                            <documentation>since 2012.02. Factor applied to the x-component of the distance function.
                                Default 1.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="yMultiplier" type="double" default="1.0" minOccurs="0">
                        <annotation>
                            <documentation>since 2012.02. Factor applied to the y-component of the distance function.
                                Default 1.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="zMultiplier" type="double" default="0.0" minOccurs="0">
                        <annotation>
                            <documentation>since 2012.02. Factor applied to the z-component of the distance function.
                                Default 0.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="threshold" type="fews:spatialHomogeneityThresholdComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Specifies the thresholds for the difference between observed and estimated.
                                When exceeded, the worst of the applicable flags will be applied.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="output" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Identifier of a variable for which timeseries the outputFlag has to be
                                updated in case the thresholds are exceeded (observed values). Refers to a time series
                                set defined in the variableDefinitions.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputSpatialMean" type="fews:SecondaryValidationVariableComplexType" minOccurs="0"
                             maxOccurs="unbounded">
                        <annotation>
                            <documentation>Specify this for writing the spatially weighted mean of the neighbouring
                                locations to the datastore, which is the estimation that is used in this check.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputSpatialStandardDeviation" type="fews:SecondaryValidationVariableComplexType"
                             minOccurs="0" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Specify this for writing the weighted standard deviation of the neighbouring
                                locations, which is used when using a relative threshold condition.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputSpatialRelativeDifference" type="fews:SecondaryValidationVariableComplexType"
                             minOccurs="0" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Specify this for writing the relative difference that is used to reject the values</documentation>
                        </annotation>
                    </element>
                    <element name="outputSpatialAbsoluteDifference" type="fews:SecondaryValidationVariableComplexType"
                             minOccurs="0" maxOccurs="unbounded">
                        <annotation>
							<documentation>Specify this for writing the absolute difference that is used to reject the values</documentation>
                        </annotation>
                    </element>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.SpatialHomogeneityCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Since 2014.02. Optional element to define the name of the class that should be executed to perform this secondary validation. Normally this element can be left out of the xml configuration, and the default class name will be used. This default class name is defined as the default value for this element in the xsd schema for this secondary validation. Only use this element if you need to use a custom class that is present in the program code.</documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check.</documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <simpleType name="secondaryValidationMannKendallTestTypeEnumStringType">
		<restriction base="string">
			<enumeration value="two-tailed"/>
			<enumeration value="upward"/>
			<enumeration value="downward"/>
		</restriction>
	</simpleType>
	<simpleType name="confidenceCoefficientSimpleType">
		<restriction base="double">
			<minExclusive value="0"/>
			<maxExclusive value="0.5"/>
		</restriction>
	</simpleType>
    <complexType name="MannKendallThresholdComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <sequence>
                    <element name="testTrend" type="fews:secondaryValidationMannKendallTestTypeEnumStringType"
                             default="two-tailed">
                        <annotation>
                            <documentation>Selects a two-tailed, upward or downward trend.</documentation>
                        </annotation>
                    </element>
                    <choice>
                        <element name="confidenceCoefficient" type="fews:confidenceCoefficientSimpleType">
                            <annotation>
                                <documentation>The confidence coefficient, also known as alpha, which is typically
                                    between 0 and 0.5, i.e. 0.05 (one-tailed) and 0.025 (two-tailed) correspond to a
                                    confidence level of 95%. This is the classical MannKendall test that uses the
                                    inverse cumulative distance function (inverseCDF).
                                </documentation>
                            </annotation>
                        </element>
                        <element name="maximumDrift" type="fews:positiveDouble">
                            <annotation>
                                <documentation>Instead of using the classical MannKendall test using the inverseCDF,
                                    this option will alter the flags and generate the logs when the maximum absolute
                                    drift is exceeded. Drift is the length of the checkRelativePeriod times the slope.
                                </documentation>
                            </annotation>
                        </element>
                    </choice>
                    <element name="outputFlag" type="fews:flagEnumStringType" default="unreliable">
                        <annotation>
                            <documentation>Flag that will be set for all data values for which the expression succeeds,
                                unreliable or doubtful.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="outputMode" type="fews:secondaryValidationOutputModeEnumStringType"
                             default="flags_and_logs" minOccurs="0">
                        <annotation>
                            <documentation>By default the flags that need updating are updated and log events are
                                generated for the updated flags. When this option is set to 'logs_only', the log events
                                are generated but the flags will not be updated.
                            </documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="MannKendallCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <sequence>
                    <element name="input" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Identifier of the timeseries the flags will be used as input
                                (neighbouring locations). Refers to a time series set defined in the
                                variableDefinitions.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="logSensSlope" type="boolean" default="true" minOccurs="0">
                        <annotation>
                            <documentation>Includes Sen's slope in the logging (default true). Since for large number of
                                steps and the algorithm is O(n^2) this can be switched of in order to speed up the
                                calculation. In the latter case, not the median of the slopes but the average of the
                                slopes is used for the estimation of the slope and drift.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="checkRelativePeriod" type="fews:RelativePeriodComplexType">
                        <annotation>
                            <documentation>The check will only consider data in this time period. This time period is
                                relative to the timeZero of the task run in which this module instance runs. The start
                                and end of the period are included.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="threshold" type="fews:MannKendallThresholdComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Specifies one or more trend tests. If multiple thresholds are specified, the
                                thresholds are ordered by log level and confidence level, Only the severest log message
                                will be generated.
                            </documentation>
                        </annotation>
                    </element>
                    <element name="output" type="fews:SecondaryValidationVariableComplexType" minOccurs="0">
                        <annotation>
                            <documentation>Identifier of a variable for which timeseries the outputFlag has to be
                                updated in
                                case the thresholds are exceeded (observed values). Refers to a time series set defined
                                in the
                                variableDefinitions.
                            </documentation>
                        </annotation>
                    </element>
					<group ref="fews:LogEventGroup" minOccurs="0"/>
					<element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.MannKendallCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Since 2014.02 Optional element to define the name of the class that should be executed to perform this secondary validation. Normally this element can be left out of the xml configuration, and the default class name will be used. This default class name is defined as the default value for this element in the xsd schema for this secondary validation. Only use this element if you need to use a custom class that is present in the program code.</documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType" use="required">
                    <annotation>
                        <documentation>Identifier of this check. This is only used in log messages and exception
                            messages.
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="FlagPersistencyCheckComplexType">
        <complexContent>
            <extension base="fews:SecondaryValidationBaseComplexType">
                <sequence>
                    <element name="input" type="fews:SecondaryValidationVariableComplexType" maxOccurs="unbounded">
                        <annotation>
                            <documentation>timeseries for which the flags should be persisted</documentation>
                        </annotation>
                    </element>
                    <group ref="fews:LogEventGroup"/>
                    <element name="className" type="fews:nameStringType"
                             default="nl.wldelft.fews.system.plugin.secondaryValidation.function.implementation.FlagPersistencyCheck"
                             minOccurs="0">
                        <annotation>
                            <documentation>Since 2014.02 Optional element to define the name of the class that should be executed to perform this secondary validation. Normally this element can be left out of the xml configuration, and the default class name will be used. This default class name is defined as the default value for this element in the xsd schema for this secondary validation. Only use this element if you need to use a custom class that is present in the program code.</documentation>
                        </annotation>
                    </element>
                </sequence>
                <attribute name="id" type="fews:idStringType">
                    <annotation>
                        <documentation>Identifier of this check. This is only used in log messages and exception
                            messages.
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>
	<simpleType name="higherLowerEnumStringType">
		<restriction base="string">
			<enumeration value="higher"/>
			<enumeration value="lower"/>
			<enumeration value="higherOrLower"/>
		</restriction>
	</simpleType>
</schema>
