I'm new with GeoServer.

I'm trying to style a Geoserver layer. The features come from a PostGIS table.

The feature are all lines. I'd like to style them based on attributes (of the table). I can do that. I created rules that say "if myfield = value1 draw a red line, if myfield = value2 draw a blue line, ..." and so on.

I'd like to write a default style for the line: "if none of the above rules is true than draw the line yellow".

I didn't find in the Geoserver SLD documentation anything to accomplish that. Or my way of reasoning is different from that of SLD.

In the docs there's a UserStyle is Default property but I think it's not what I'm looking for.

I Googled too to no avail.

Any suggestion?

  • 2
    look at else rules
    – Ian Turton
    Commented Jun 25, 2014 at 12:38
  • Thank you for the tip. I used ElseFilter (undocumented on geoserver docs): <FeatureTypeStyle> <Rule> <Name>myname</Name> <ogc:Filter> ... <Rule> <Name>Default</Name> <ElseFilter /> <LineSymbolizer> ...
    – user32823
    Commented Jun 25, 2014 at 16:18

2 Answers 2


Yes, you can try styling your data with QGIS. But if you want to create a rule based sld or an sld with more options (fill opacity, rules, outline etc) I recommend you to use uDig. With you uDig you can style your data with many options and then export slds that will work 99,9% when uploaded on geoserver.

More about sld editor and uDig here.


You could try styling it the way you like in qGIS and then exporting the SLD and using it in GeoServer.

Check out this article and try it out since I find it much easier to use than styling in the SLD itself or through GeoServer's interface.


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.