I am using Openlayers 2.11 and need to style a layer with a sld file version 1.1.0. the error it says is Uncaught Can't find a SLD parser for version 1.1.0. i have also tried it with Openlayers 2.12.
2 Answers
No, OpenLayers 2.13.1 does not parse 1.1.0 SLD- I get the same error as the OP when using a 1.1.0 SLD file for a GeoJSON layer. Fortunately I found a (sloppy) workaround via some find-and-replace magic in the SLD file:
Changed beginning of file (xml prologue is it called??) to match 1.0 standards:
<?xml version="1.0" encoding="UTF-8"?> <sld:StyledLayerDescriptor version="1.0.0" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
- Changed all instances of
SvgParameter
toCssParameter
(credit to the suggestion at the end of this post). - Changed all instances of
<se:whatever>stuff</se:whatever>
to<sld:whatever>stuff</sld:whatever>
(this may have been just a QGIS feature, I am not sure).
Like I said, not pretty, but it allowed me to adapt a 1.1.0 SLD file exported from QGIS and then parse it in OpenLayers.
Check OpenLayers 2.13 it might have a solutin