The ordering is specified in the XML schema snippet on Page 25 of my copy
of the spec:
<xs:element name="Rule">
<xs:complexType>
<xs:sequence>
<xs:element ref="sld:Name" minOccurs="0"/>
<xs:element ref="sld:Title" minOccurs="0"/>
<xs:element ref="sld:Abstract" minOccurs="0"/>
<xs:element ref="sld:LegendGraphic" minOccurs="0"/>
<xs:choice minOccurs="0">
<xs:element ref="ogc:Filter"/>
<xs:element ref="sld:ElseFilter"/>
</xs:choice>
<xs:element ref="sld:MinScaleDenominator" minOccurs="0"/>
<xs:element ref="sld:MaxScaleDenominator" minOccurs="0"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="sld:LineSymbolizer"/>
<xs:element ref="sld:PolygonSymbolizer"/>
<xs:element ref="sld:PointSymbolizer"/>
<xs:element ref="sld:TextSymbolizer"/>
<xs:element ref="sld:RasterSymbolizer"/>
</xs:choice>
</xs:sequence>
Rules contain a Sequence (or ordered list) with <ogc:Filter> above line
symbolizer.
It looks like a call to normalize on the rule should fix the order.
Otherwise you can look to fix the python.
The second easiest way is to ignore the validator (GeoServer is relaxed
about the SLD it will ingest) and proceed.
Ian
On Mon, 14 May 2018 at 15:18, Kris Johnson <krist...@d.umn.edu> wrote:
> Hi Ian,
>
> Thanks for the response.
> Your answer is what I was afraid of.
> It's a bit frustrating because I couldn't find any mention of this order
> enforcement for rules in the official OGC specification.
> But, more to the point, the python library I'm using (
> https://github.com/azavea/python-sld) doesn't seem capable of enforcing
> this.
>
> Do you have any suggestions for dynamically creating SLDs (for ingestion
> into Geoserver via REST calls) using python?
>
>
> On Fri, May 11, 2018 at 1:46 PM, Ian Turton <ijtur...@gmail.com> wrote:
>
>> As the error message suggests your filter is in the wrong place. It
>> should be at the top of the rule.
>>
>> Ian
>>
>> On Fri, 11 May 2018, 18:48 Kris Johnson, <krist...@d.umn.edu> wrote:
>>
>>> Hello,
>>>
>>> I'm attempting to generate an SLD file in python.
>>> And while the output appears valid to me when I load it in as a new
>>> style in Geoserver and click "Validate" I get an error:
>>>
>>>> line 17: cvc-complex-type.2.4.a: Invalid content was found starting
>>>> with element 'ogc:Filter'. One of
>>>> '{"http://www.opengis.net/sld":Symbolizer}'
>>>> is expected.
>>>
>>>
>>> I'm assuming this occurs 18 times--once for each filter.
>>> The filter tag is correctly nested within the rule tag alongside a
>>> symbolizer, so I don't see what the issue is here.
>>> Here's the full SLD:
>>>
>>>
>>> <sld:StyledLayerDescriptor xmlns:ogc="http://www.opengis.net/ogc"
>>> xmlns:sld="http://www.opengis.net/sld"
>>> xmlns:xlink="http://www.w3.org/1999/xlink"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0">
>>> <sld:NamedLayer>
>>> <sld:Name>my style</sld:Name>
>>> <sld:UserStyle>
>>> <sld:FeatureTypeStyle>
>>> <sld:Rule>
>>> <sld:Title>White Pine Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#f490bd</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>White Pine</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Aspen-Oak Land Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#dfb1f9</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Aspen-Oak Land</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Mixed White Pine and Red Pine Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#7a40bc</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Mixed White Pine and Red Pine</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>River Bottom Forest Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#6ef46e</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>River Bottom Forest</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Lakes (open water) Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#65d14d</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Lakes (open water)</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Big Woods - Hardwoods (oak, maple, basswood, hickory)
>>> Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#5ff47f</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Big Woods - Hardwoods (oak, maple, basswood,
>>> hickory)</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Wet Prairie Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#c746f2</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Wet Prairie</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Prairie Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#e552cd</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Prairie</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Undefined Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#c933f7</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Undefined</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Aspen-Birch (trending to Conifers) Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#ef7cf9</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Aspen-Birch (trending to Conifers)</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Jack Pine Barrens and Openings Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#ff5ebe</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Jack Pine Barrens and Openings</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Mixed Hardwood and Pine (Maple, White Pine, Basswood,
>>> etc) Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#66dd9b</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Mixed Hardwood and Pine (Maple, White Pine,
>>> Basswood, etc)</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Aspen-Birch (trending to hardwoods) Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#882dd8</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Aspen-Birch (trending to hardwoods)</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Brush Prairie Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#8effb2</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Brush Prairie</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Pine Flats (Hemlock, Spruce, Fir, White Pine, Aspen)
>>> Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#119e9e</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Pine Flats (Hemlock, Spruce, Fir, White Pine,
>>> Aspen)</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Conifer Bogs and Swamps Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#ed3723</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Conifer Bogs and Swamps</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Open Muskeg Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#541184</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Open Muskeg</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> <sld:Rule>
>>> <sld:Title>Oak openings and barrens Rule</sld:Title>
>>> <sld:PolygonSymbolizer>
>>> <sld:Fill>
>>> <sld:CssParameter name="fill">#e83c33</sld:CssParameter>
>>> </sld:Fill>
>>> <sld:Stroke>
>>> <sld:CssParameter name="stroke">#000</sld:CssParameter>
>>> <sld:CssParameter name="stroke-width">1</sld:CssParameter>
>>> </sld:Stroke>
>>> </sld:PolygonSymbolizer>
>>> <ogc:Filter>
>>> <ogc:PropertyIsEqualTo>
>>> <ogc:PropertyName>xclass</ogc:PropertyName>
>>> <ogc:Literal>Oak openings and barrens</ogc:Literal>
>>> </ogc:PropertyIsEqualTo>
>>> </ogc:Filter>
>>> </sld:Rule>
>>> </sld:FeatureTypeStyle>
>>> </sld:UserStyle>
>>> </sld:NamedLayer>
>>> </sld:StyledLayerDescriptor>
>>>
>>> Thanks for any help you can provide.
>>>
>>>
>>> --
>>> Kris Johnson
>>> Natural Resources Research Institute
>>> 5013 Miller Trunk Highway, Duluth, MN 55811
>>> <https://maps.google.com/?q=5013+Miller+Trunk+Highway,+Duluth,+MN+55811&entry=gmail&source=g>
>>> p: 218.788.2767
>>> www.nrri.umn.edu
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> Geoserver-users mailing list
>>>
>>> Please make sure you read the following two resources before posting to
>>> this list:
>>> - Earning your support instead of buying it, but Ian Turton:
>>> http://www.ianturton.com/talks/foss4g.html#/
>>> - The GeoServer user list posting guidelines:
>>> http://geoserver.org/comm/userlist-guidelines.html
>>>
>>> If you want to request a feature or an improvement, also see this:
>>> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>>>
>>>
>>> Geoserver-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>>
>>
>
>
> --
> Kris Johnson
> Natural Resources Research Institute
> 5013 Miller Trunk Highway, Duluth, MN 55811
> p: 218.788.2767
> www.nrri.umn.edu
>
>
--
Ian Turton
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this
list:
- Earning your support instead of buying it, but Ian Turton:
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines:
http://geoserver.org/comm/userlist-guidelines.html
If you want to request a feature or an improvement, also see this:
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users