[Geoserver-users] Help needed creating a complex SLD

  Hello all:

I am trying to create an SLD that has multiple rules for rendering polygons with different attribute-based styles at different scales. That is, at the largest zoom level, there are 3 different sets of polygon fill based on the value of an attribute. At the middle zoom level, there will be 3 new sets of polygon fill based on the same attribute. At the next level of zooming in, there will be an additional 3 sets of polygon fill.

In my first attempt, the <Rule> element appears at 2 different levels in the XML hierarchy. I think that this is causing the XML validation to fail.

Is there a different approach to accomplish the same goal?

The SLD is below.

Many thanks!
Dan Gillespie

  --------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
     xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
     xmlns="http://www.opengis.net/sld&quot;
     xmlns:ogc="http://www.opengis.net/ogc&quot;
     xmlns:xlink="http://www.w3.org/1999/xlink&quot;
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
<NamedLayer>
<Name>Scale and Attribute-based polygon style</Name>
<UserStyle>
<Title>RGA Score Attribute-based Crosshatch polygons</Title>
<FeatureTypeStyle>
<Rule>
<Name>Coarse Viewing Scale</Name>
<MaxScaleDenominator>100000000</MaxScaleDenominator>
<Rule>
<Name>Fine Requirement Scale</Name>
<Title>low</Title>
<ogc:Filter>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>5.5</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#FF0000</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>16</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>Medium Requirement Scale</Name>
<Title>medium</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>7.5</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#00FF00</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>11</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>Coarse Requirement Scale</Name>
<Title>high</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>9.0</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#0000FF</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>5</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
</Name>
</Rule>
<Rule>
<Name>Medium Viewing Scale</Name>
<MinScaleDenominator>100000000</MinScaleDenominator>
<MaxScaleDenominator>200000000</MaxScaleDenominator>
<Rule>
<Name>Fine Requirement Scale</Name>
<Title>low</Title>
<ogc:Filter>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>5.5</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#FF0000</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>21</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>Medium Requirement Scale</Name>
<Title>medium</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>7.5</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#00FF00</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>16</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>Coarse Requirement Scale</Name>
<Title>high</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>9.0</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#0000FF</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>9</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
</Name>
</Rule>
<Rule>
<Name>Fine Viewing Scale</Name>
<MinScaleDenominator>200000000</MinScaleDenominator>
<Rule>
<Name>Fine Requirement Scale</Name>
<Title>low</Title>
<ogc:Filter>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>5.5</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#FF0000</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>26</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>Medium Requirement Scale</Name>
<Title>medium</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>7.5</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#00FF00</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>21</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>Coarse Requirement Scale</Name>
<Title>high</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>score</ogc:PropertyName>
<ogc:Literal>9.0</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>shape://times</WellKnownName>
<Stroke>
<CssParameter name="stroke">#0000FF</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>14</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
</Name>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

On Fri, Sep 24, 2010 at 10:33 AM, daniel.gillespie
<Daniel.Gillespie@anonymised.com> wrote:

Hello all:

I am trying to create an SLD that has multiple rules for rendering
polygons with different attribute-based styles at different scales.
That is, at the largest zoom level, there are 3 different sets of
polygon fill based on the value of an attribute. At the middle zoom
level, there will be 3 new sets of polygon fill based on the same
attribute. At the next level of zooming in, there will be an additional
3 sets of polygon fill.

In my first attempt, the <Rule> element appears at 2 different levels in
the XML hierarchy. I think that this is causing the XML validation to fail.

Is there a different approach to accomplish the same goal?

You can't nest <Rule> elements. You just need to have them listed
serially. I've attached a fixed version - I can't be sure it does what
you expect but is valid xml.

Ian
--
Ian Turton

complex.sld (9.15 KB)