1

I have created an SLD file from a layer in QGIS that I am trying to import into GeoServer 2.5 but am having some problems with an issue.

The error I am getting back is:

Parsing failed for Filter: java.lang.RuntimeException: Unable to find function Literal
line 23: cvc-complex-type.2.4.a: Invalid content was found starting with element 'ogc:Filter'. One of '{"http://www.opengis.net/ogc":expression}' is expected.
line 24: cvc-complex-type.2.4.a: Invalid content was found starting with element 'ogc:Literal'. One of '{"http://www.opengis.net/ogc":spatialOps, "http://www.opengis.net/ogc":comparisonOps, "http://www.opengis.net/ogc":logicOps, "http://www.opengis.net/ogc":_Id}' is expected.

The following is my SLD file:-

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>air_quality_management_areas</se:Name>
    <UserStyle>
      <se:Name>air_quality_management_areas</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:GraphicFill>
                <se:Graphic>
                  <se:Mark>
                    <se:WellKnownName>horline</se:WellKnownName>
                    <se:Stroke>
                      <se:SvgParameter name="stroke">#5c98e6</se:SvgParameter>
                      <se:SvgParameter name="stroke-width">0.25</se:SvgParameter>
                    </se:Stroke>
                  </se:Mark>
                  <se:Size>5</se:Size>
                  <se:Rotation>
                    <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
                      <ogc:Literal>45</ogc:Literal>
                    </ogc:Filter>
                  </se:Rotation>
                </se:Graphic>
              </se:GraphicFill>
            </se:Fill>
          </se:PolygonSymbolizer>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:GraphicFill>
                <se:Graphic>
                  <se:Mark>
                    <se:WellKnownName>horline</se:WellKnownName>
                    <se:Stroke>
                      <se:SvgParameter name="stroke">#5c98e6</se:SvgParameter>
                      <se:SvgParameter name="stroke-width">0.25</se:SvgParameter>
                    </se:Stroke>
                  </se:Mark>
                  <se:Size>5</se:Size>
                  <se:Rotation>
                    <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
                      <ogc:Literal>135</ogc:Literal>
                    </ogc:Filter>
                  </se:Rotation>
                  <se:Displacement>
                    <se:DisplacementX>0</se:DisplacementX>
                    <se:DisplacementY>0</se:DisplacementY>
                  </se:Displacement>
                </se:Graphic>
              </se:GraphicFill>
            </se:Fill>
          </se:PolygonSymbolizer>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#5c98e6</se:SvgParameter>
              <se:SvgParameter name="stroke-width">0.5</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
              <se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
            </se:Stroke>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

It looks to be a problem with how the angle of my diagonal lines are trying to be drawn. From my header I can see that the ogc link is there so am a bit confused with why it isn't displaying.

Does anyone have any suggestions to make?

0

3 Answers 3

1

QGIS is known to produce invalid SLD files and this belongs to those if the report from http://www.corefiling.com/opensource/schemaValidate.html can be trusted.enter image description here

I suggest to write mail to QGIS-users mailing list first and perhaps make a bug report if it is considered reasonable.

0

Old question, adding what i found while finding solution for this issue.

QGIS adds Filter tags in some places where "ogc:expression" is expected. Geotools does not seem to like this. Or it perhaps narrows the scope of function or expression within Filter package. If you remove the Filter tag and retain the Literal or other expression/function like "Add" or "Sub", things seem to go through without error.

In above issue, changing this:

<se:Rotation>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:Literal>135</ogc:Literal>
</ogc:Filter>
</se:Rotation>

to:

<se:Rotation>
<ogc:Literal>135</ogc:Literal>
</se:Rotation>

should fix the issue.

0

QGIS doesn't format some of the SLDs in a way that Geoserver likes. Refer to my answer here: https://gis.stackexchange.com/a/291495/123366

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.