[GIS] line 15: cvc-complex-type.2.4.a: Invalid content was found starting with element ‘Filter’

geoservergeoserver-rest-apilayerssld

I have defined the following SLD rule for my layer. It says that if the property Weekday is greater than or equal to 0 and less than or equal to 3, then the color of a polygon must be #680000.

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <Name>green</Name>
    <UserStyle>
      <Name>Adjustable</Name>
      <Title>Triangle</Title>
      <Abstract>Direction and volume</Abstract>
      <FeatureTypeStyle>
        <Rule>
          <Title>Volume control</Title>
          <Abstract>Volume control</Abstract>
          <Filter>
            <And>
              <PropertyIsGreaterThanOrEqualTo>
                <PropertyName>Weekday</PropertyName>
                <Literal>1</Literal>
              </PropertyIsGreaterThanOrEqualTo>
              <PropertyIsLessThanOrEqualTo>
                <PropertyName>Weekday</PropertyName>
                <Literal>3</Literal>
              </PropertyIsLessThanOrEqualTo>
            </And>
          </Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#680000</CssParameter>
            </Fill>
            <Stroke/>
          </PolygonSymbolizer>
        </Rule>      
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

When I validate this rule in Geoserver 2.11, I get the following error:

line 15: cvc-complex-type.2.4.a: Invalid content was found starting
with element 'Filter'. One of
'{"http://www.opengis.net/sld":LegendGraphic,
"http://www.opengis.net/ogc":Filter,
"http://www.opengis.net/sld":ElseFilter,
"http://www.opengis.net/sld":MinScaleDenominator,
"http://www.opengis.net/sld":MaxScaleDenominator,
"http://www.opengis.net/sld":Symbolizer}' is expected.

Line 15 is <Filter>. I checked the documentation of SLD and it looks like I defined all mandatory fields. Why do I get this error message and how can I solve this error?

Best Answer

You need to use the correct namespace for the filter element as the error message says.

Filter is in OGC name space so you need to use ogc: as a prefix and make sure you have declared it.

Related Question