3

I created a custom style on QGis and saved as SLD file. When I added to GeoServer, after validation it, I got an errors about parsing.

Here is the error message below:

Parsing failed for Filter: java.lang.RuntimeException: Unable to find function Literal
line 26: 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 27: 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.

<?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>Some_Name</se:Name>
    <UserStyle>
      <se:Name>Some_Name</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:GraphicStroke>
                <se:Graphic>
                  <se:Mark>
                    <se:WellKnownName>line</se:WellKnownName>
                    <se:Fill>
                      <se:SvgParameter name="fill">#ff0000</se:SvgParameter>
                    </se:Fill>
                    <se:Stroke>
                      <se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
                    </se:Stroke>
                  </se:Mark>
                  <se:Size>3</se:Size>
                </se:Graphic>
                <se:Gap>
                  <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
                    <ogc:Literal>1.2</ogc:Literal>
                  </ogc:Filter>
                </se:Gap>
              </se:GraphicStroke>
            </se:Stroke>
          </se:LineSymbolizer>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
              <se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
              <se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
            </se:Stroke>
            <se:PerpendicularOffset>1</se:PerpendicularOffset>
          </se:LineSymbolizer>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
              <se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
              <se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
            </se:Stroke>
            <se:PerpendicularOffset>-0.6</se:PerpendicularOffset>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

How can I resolve the parsing issue?

6
  • More information about the data added to qgis, i.e. data type - format - also more about the custom style you created. please EDIT the original question with information that will help the investigation of this issue. Especially anything to help someone duplicate the problem.
    – Brad Nesom
    Commented Jun 16, 2014 at 14:41
  • i try to add the sdf file that exported from qgis. But accours parsing eror.
    – bashkan
    Commented Jun 16, 2014 at 14:53
  • Are you seeing any red text within the xml after you validate? This may help flag the problem section.
    – artwork21
    Commented Jun 16, 2014 at 15:23
  • No, there isn't such a feature geoserver's editor, just showing validation parsing error info.
    – bashkan
    Commented Jun 16, 2014 at 15:46
  • 1
    Geoserver supports SLD 1.1.0 only partly docs.geoserver.org/stable/en/user/styling/sld-reference/… Perhaps that could be part of a problem.
    – user30184
    Commented Jun 16, 2014 at 21:24

3 Answers 3

3

QGIS puts the filter tags but leaves out some essential parts that are needed by the validator in geoserver. So here's what you need to do:

in your filter tag add a PropertyIsEqualTo tag and within that add the PropertyName tag and the Literal tag.

So this:

  <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
    <ogc:Literal>1.2</ogc:Literal>
  </ogc:Filter>

Becomes this:

  <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
    <ogc:PropertyIsEqualTo>
      <ogc:PropertyName>FIELDNAME</ogc:PropertyName>
      <ogc:Literal>1.2</ogc:Literal>
    </ogc:PropertyIsEqualTo>
  </ogc:Filter>

Where FIELDNAME is the name of the field on which the filter is based. Then it should validate correctly.

2

if you change the StyleLayerDescriptor to this...it does validate

<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"
xmlns:se="http://www.opengis.net/se">

It might look similar but geoserver is a bit odd when it comes to SLDs

0

The parser is expecting an Expression at line 26 where you have a filter. So try removing the filter and just using the Literal (which is an expression).

I don't know if the GeoServer SLD parser will like it anyway as the Symbology Encoding support is patchy.

1
  • thanks @iant but no luck!, when i remove the 26. line validation control is okay, but doesnt show on vector line :(
    – bashkan
    Commented Jun 16, 2014 at 14:56

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.