Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have created my SLD's in QGIS and want to use them in Geoserver. I have imported and validated them without any problems

but when I try to view the data using Layer Preview --> OpenLayers-->Go it tries to download the data rather than let me view it. With the default symbology it works fine.

Is there something fundamental that I have to change in the SLD from Geoserver for it to work?

One of the simple and 2 complex SLD's are below (roads at different zoom levels)

Roads - Simple

    <?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>Roads_GHD_20121121</se:Name>
    <UserStyle>
      <se:Name>Roads_GHD_20121121</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>GHD Roads</se:Name>
          <se:MaxScaleDenominator>250000</se:MaxScaleDenominator>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
              <se:SvgParameter name="stroke-width">0.4</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
              <se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
              <se:SvgParameter name="stroke-dasharray">5 2</se:SvgParameter>
            </se:Stroke>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Roads - Complex

<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>Road with border</Name>
        <UserStyle>
            <Title>Road with border</Title>

            <!-- Local Roads -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">12</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFFFF</CssParameter>
                            <CssParameter name="stroke-width">11</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFFFF</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- Local Roads 1787 - 3573-->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">7</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFFFF</CssParameter>
                            <CssParameter name="stroke-width">6</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFFFF</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>                        
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- Local Roads 3573 - 28573-->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <MaxScaleDenominator>28573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">4</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>

Points Complex with SVG files.

                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <MaxScaleDenominator>28573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFFFF</CssParameter>
                            <CssParameter name="stroke-width">3</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFFFF</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- Local Roads 28573 - 114287 -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>28573</MinScaleDenominator>
                    <MaxScaleDenominator>114287</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#D7C29E</CssParameter>
                            <CssParameter name="stroke-width">1</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- State Roads - 0 - 1787 -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">13</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFF00</CssParameter>
                            <CssParameter name="stroke-width">12</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFF00</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- State Roads - 1787 - 3572 -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">7</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFF00</CssParameter>
                            <CssParameter name="stroke-width">6</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFF00</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>                        
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- State Roads - 3572 - infinity -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">5</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFF00</CssParameter>
                            <CssParameter name="stroke-width">4</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFF00</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>                        
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>
share|improve this question
3  
that isn't data it is trying to download it's the error message - look at the file or check the log and add the actual error to your question –  iant Jun 18 '13 at 9:11
2  
You also have to know that Geoserver does not currently support completely the SLD produced by QGIS... There is a version mismatch here that you have to take into account –  Etienne Desgagné Jun 18 '13 at 12:31
    
@iant Thanks...I did not know that this file was an error report. That will help in resolving the issue. –  GeorgeC Jun 18 '13 at 13:29
    
@iant -I just looked at the file and for some reason one of the attributes was renamed. Once I corrected this GS shows the correct symbology in the Layers--Properties--publishing--default style column but when you view the data, you can't see anything. –  GeorgeC Jun 19 '13 at 0:09
add comment

1 Answer

up vote 1 down vote accepted

QGIS produces SLD 1.1 while Geoserver only seems to support SLD 1.0 currently. The Geoserver blog indicates that they are working on it though, e.g. http://blog.geoserver.org/2013/02/26/geoserver-2-3-rc1-released/

share|improve this answer
    
-thanks. Can we downgrade QGIS to produce SLD 1.0. I had a look at qgis.org/api/… but it's not clear and I haven't implemented qgis python before. –  GeorgeC Jun 18 '13 at 20:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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