2

I have an SLD called my_data.sld (created in QGIS 3.2.x) with looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" 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" version="1.1.0" xmlns:se="http://www.opengis.net/se" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc">
  <NamedLayer>
    <se:Name>my_data</se:Name>
    <UserStyle>
      <se:Name>my_data</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:PointSymbolizer>
            <se:Graphic>
              <se:Mark>
                <se:WellKnownName>circle</se:WellKnownName>
                <se:Fill>
                  <se:SvgParameter name="fill">#e15989</se:SvgParameter>
                </se:Fill>
                <se:Stroke>
                  <se:SvgParameter name="stroke">#232323</se:SvgParameter>
                  <se:SvgParameter name="stroke-width">0.5</se:SvgParameter>
                </se:Stroke>
              </se:Mark>
              <se:Size>7</se:Size>
            </se:Graphic>
          </se:PointSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

If I upload SLD file via the GeoServer control panel, then apply it to a layer, the layer is correctly styled, no problem.

However, I want to add upload this style to a workspace and apply it via the rest API, which I do via these commands (following the curl examples):

curl -v -u admin:pass -XPOST -H "Content-type: text/xml" -d "<style><name>my_data</name><filename>my_data.sld</filename></style>" https://localhost/geoserver/rest/workspaces/my_workspace/styles
curl -v -u admin:pass -XPUT -H "Content-type: application/vnd.ogc.sld+xml" -d @/home/sam/my_data.sld https://localhost/geoserver/rest/workspaces/my_workspace/styles/my_data

Both commands appear to work giving < HTTP/1.1 200 OK codes. I have the new style in my workspace but there's a problem with the content of the style. Inspecting the new style in the GeoServer Style Editor control panel shows:

<?xml version="1.0" encoding="UTF-8"?>
<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
  <sld:NamedLayer>
    <sld:Name>my_data</sld:Name>
    <sld:UserStyle>
      <sld:Name>my_data</sld:Name>
      <sld:FeatureTypeStyle>
        <sld:Name>name</sld:Name>
        <sld:Rule>
          <sld:Name>Single symbol</sld:Name>
          <sld:PointSymbolizer>
            <sld:Graphic>
              <sld:Mark>
                <sld:WellKnownName>circle</sld:WellKnownName>
                <sld:Fill/>
                <sld:Stroke/>
              </sld:Mark>
              <sld:Size>7</sld:Size>
            </sld:Graphic>
          </sld:PointSymbolizer>
        </sld:Rule>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </sld:NamedLayer>
</sld:StyledLayerDescriptor>

Clearly tags with se:SvgParameter have not been translated into whatever format the style is in now.

I've tried to modify the <StyledLayerDescriptor> to match the manual upload that worked, without success.

I thought the issue might be related to the "Content-type:application/vnd.ogc.sld+xml" but can't find an appropriate content type either.

What should I try next?

3

You are mixing an SLD 1.1.0 file (or Symbology Encoding) with the SLD 1.0.0 format so GeoServer is filtering out the 1.1.0 elements to make it compliant with 1.0.0. You need to set the content-type to application/vnd.ogc.se+xml as is documented in the manual though it would help if QGis made it clearer that it was exporting SE not SLD.

  • A style exported from QGIS using the "style", "save as" functionality in the style editor begins with "<StyledLayerDescriptor xmlns="opengis.net/sld" version="1.1.0" ", so it's clear it's SE. Not sure how the style above got "exported"? – Andrea Aime Jan 14 at 13:20
  • You are quite right, it's there in the manual, I didn't put it together though :) – SamFranklin Jan 14 at 13:20
  • @AndreaAime hi, thanks for commenting. To clarify, I exported the above pasted style from qgis 3.2.0-bonn via the "Symbology" Properties window, then "Style"-->"Save Style", then selecting "SLD File" option. Hope that's useful. – SamFranklin Jan 14 at 13:23
  • Doh right, I mixed up the two styles in the question, the one exported by QGIS states "1.1.0" – Andrea Aime Jan 14 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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