1

I want to upload a SLD file, to a specific workspace, by using gsconfig-py3 1.0.8 , create_style function, however I get an error.

with open(fpath) as f:
    cat.create_style("railroad", f.read())

Error:

No such style handler: format = application/xml

Style file generated from QGIS as SLD file:

<?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>file_style</sld:Name>
        <sld:UserStyle>
            <sld:Name>file_style</sld:Name>
            <sld:FeatureTypeStyle>
                <sld:Name>name</sld:Name>
                <sld:Rule>
                    <sld:Name>from</sld:Name>
                    <sld:Title>from</sld:Title>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>from_to</ogc:PropertyName>
                            <ogc:Literal>from</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <sld:LineSymbolizer>
                        <sld:Stroke>
                            <sld:CssParameter name="stroke">#d08760</sld:CssParameter>
                            <sld:CssParameter name="stroke-linecap">square</sld:CssParameter>
                            <sld:CssParameter name="stroke-linejoin">bevel</sld:CssParameter>
                            <sld:CssParameter name="stroke-width">7</sld:CssParameter>
                            </sld:Stroke>
                    </sld:LineSymbolizer>
                </sld:Rule>
                <sld:Rule>
                    <sld:Name>to</sld:Name>
                    <sld:Title>to</sld:Title>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                        <ogc:PropertyName>from_to</ogc:PropertyName>
                        <ogc:Literal>to</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <sld:LineSymbolizer>
                        <sld:Stroke>
                            <sld:CssParameter name="stroke">#22dc60</sld:CssParameter>
                            <sld:CssParameter name="stroke-linecap">square</sld:CssParameter>
                            <sld:CssParameter name="stroke-linejoin">bevel</sld:CssParameter>
                            <sld:CssParameter name="stroke-width">7</sld:CssParameter>
                        </sld:Stroke>
                    </sld:LineSymbolizer>
                </sld:Rule>
                <sld:Rule>
                    <sld:Name/>
                        <sld:Title>from_to is ''</sld:Title>
                        <ogc:Filter>
                            <ogc:Or>
                                <ogc:PropertyIsEqualTo>
                                    <ogc:PropertyName>from_to</ogc:PropertyName>
                                    <ogc:Literal/>
                                </ogc:PropertyIsEqualTo>
                                <ogc:PropertyIsNull>
                                    <ogc:PropertyName>from_to</ogc:PropertyName>
                                </ogc:PropertyIsNull>
                            </ogc:Or>
                        </ogc:Filter>
                    <sld:LineSymbolizer>
                        <sld:Stroke>
                            <sld:CssParameter name="stroke">#996bee</sld:CssParameter>
                            <sld:CssParameter name="stroke-linecap">square</sld:CssParameter>
                            <sld:CssParameter name="stroke-linejoin">bevel</sld:CssParameter>
                            <sld:CssParameter name="stroke-width">7</sld:CssParameter>
                        </sld:Stroke>
                    </sld:LineSymbolizer>
                </sld:Rule>
            </sld:FeatureTypeStyle>
        </sld:UserStyle>
    </sld:NamedLayer>
</sld:StyledLayerDescriptor>
3
  • That looks like a correct use of gsconfig - what does the GeoServer log file have to say? – Ian Turton Sep 5 '20 at 8:00
  • 1
    Your sld file is invalid - the opening StyledLayerDescriptor tag is not closed with> – Ian Turton Sep 5 '20 at 8:07
  • @IanTurton that was fixed, however it still does not upload the style. It gives a really long list of errors, in java code: 2020-09-07 07:17:34,442 WARN [annotation.ExceptionHandlerExceptionResolver] - Resolved [java.lang.RuntimeException: No such style handler: format = application/xml] 2020-09-07 07:17:54,884 ERROR [geoserver.rest] - No such style: style_layer org.geoserver.rest.ResourceNotFoundException 404 NOT_FOUND: No such style: style_layer, then the list of java errors – Paul Nicoara Sep 7 '20 at 7:22
1

This is working on my machine, which fooled me but then I remembered I had "fixed" my local version of gsconfig - you need to change line 894 to text/xml from application/xml.

I'll try to push my fix to the repository for future users.

2

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.