5

I have a problem with one of my SLD files and do not know what is causing the problem. The error message is pretty clear: line 18: cvc-complex-type.2.4.a: Invalid content was found starting with element 'ogc:Filter'. One of '{"http://www.opengis.net/sld":Symbolizer}' is expected. However, when I look into the example of the cookbook for attribute based or for zoom based polygons then I cannot figure out why I am getting the error. Have a look at the code below... I don't know why a symbolizer is expected in line 18, even though the example in the cookbook has the structure the same way as I do, or not!

Any suggestions on how to overcome the problem?

I am running Geoserver in version 2.3.2

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
 xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
 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">
  <NamedLayer>
    <Name>Baggrund NO2</Name>
    <UserStyle>
      <Title>Baggrund NO2</Title>
      <FeatureTypeStyle>
        <Rule>
          <Name>4,75 - 5,31</Name>
          <Title>4,75 - 5,31</Title>
          <MinScaleDenominator>23000</MinScaleDenominator>
          <MaxScaleDenominator>1000000000</MaxScaleDenominator>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>Type</ogc:PropertyName>
              <ogc:Literal>1.0000</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#1a9641</CssParameter>
              <CssParameter name="fill-opacity">0.40</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

1 Answer 1

7

Put the MinScaleDenominator and MaxScaleDenominator element after the ogc:Filter element:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
   xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
   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">
  <NamedLayer>
    <Name>Baggrund NO2</Name>
    <UserStyle>
      <Title>Baggrund NO2</Title>
      <FeatureTypeStyle>
        <Rule>
          <Name>4,75 - 5,31</Name>
          <Title>4,75 - 5,31</Title>             
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>Type</ogc:PropertyName>
              <ogc:Literal>1.0000</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <MinScaleDenominator>23000</MinScaleDenominator>
          <MaxScaleDenominator>1000000000</MaxScaleDenominator>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#1a9641</CssParameter>
              <CssParameter name="fill-opacity">0.40</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Order matters in a SLD file in order to validate and GeoServer is quite strict in validation.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.