Bug report #5795

Export as SLD generates non valid SLD

Added by Jorge Rocha almost 12 years ago. Updated almost 12 years ago.

Status:Closed
Priority:Normal
Assignee:Giuseppe Sucameli
Category:Symbology
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:15286

Description

Hi,

1) Open new point layer
2) Change symbology from Simple marker to svg marker.
3) Save style as SLD

The SLD written is not valid.

xmlstarlet val -e -s http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd mcdonalds.sld
mcdonalds.sld:13.54: Element '{http://www.opengis.net/sld}OnlineResource': This element is not expected. Expected is one of ( {http://www.opengis.net/se}OnlineResource, {http://www.opengis.net/se}InlineContent ).
mcdonalds.sld - invalid

The written style has:

                <OnlineResource xlink:type="simple" xlink:href="/usr/share/qgis/svg/symbol/Star1.svg"/>
                <Format>image/svg+xml</Format>

where it should have:

                <se:OnlineResource xlink:type="simple" xlink:href="/usr/share/qgis/svg/symbol/Star1.svg"/>
                <se:Format>image/svg+xml</se:Format>

QGIS version
1.8.0-Lisboa
QGIS code revision
exported
Compiled against Qt
4.8.1
Running against Qt
4.8.1
Compiled against GDAL/OGR
1.7.3
Running against GDAL/OGR
1.7.3
GEOS Version
3.2.2
PostgreSQL Client Version
9.1.4
SpatiaLite Version
3.0.0-beta
QWT Version
5.2.2

mcdonalds.sld - The generated style (1.04 KB) Jorge Rocha, 2012-06-13 03:02 PM

exported.sld - SLD file created by QGIS (3.76 KB) Rui Pedro Henriques, 2012-06-18 12:57 PM

import_ok.sld - SLD file with "PropertyIsEqualTo" filters (1.57 KB) Rui Pedro Henriques, 2012-06-18 12:57 PM

import_fail.sld - SLD file with "PropertyIsBetween" filters (7.9 KB) Rui Pedro Henriques, 2012-06-18 12:57 PM

exported.qml - QGIS style file with the same style as "exported.sld" (7.32 KB) Rui Pedro Henriques, 2012-06-18 12:57 PM

Associated revisions

Revision 6e855d8c
Added by Giuseppe Sucameli almost 12 years ago

fix export from Graduated renderingV2 to SLD, generate valid SLD docs (fix #5795):

Description tag must have a child tag,
OnlineResource tag and its child Format tag must have SE namespace,
Filter tag created and never appended to the Rule element exporting from a Graduated rendering,
fix convertion between PropertyIsBetween tag and QgsExpression

History

#1 Updated by Giovanni Manghi almost 12 years ago

  • Operating System deleted (Ubuntu)
  • OS version deleted (12.04)
  • Assignee set to Giuseppe Sucameli

#2 Updated by Giuseppe Sucameli almost 12 years ago

  • Priority changed from Low to Normal

Right, those tags must have SE prefix.
It's late for fixing it on the master branch, I must wait QGis 1.8 is released.

#3 Updated by Giuseppe Sucameli almost 12 years ago

Found another problem when validating another SLD file:

Element '{http://www.opengis.net/se}Description':
Character content other than whitespace is not allowed because the
content type is 'element-only'.

The Description tag in SE must contain a Title and/or an Abstract tag, so the description string must be moved within one of those tags.

#4 Updated by Rui Pedro Henriques almost 12 years ago

Hello,

When creating a SLD file from a "graduated" simbology, the filters are not created.

What I've done (EXPORT):
1. Open a polygon layer;
2. On "Layer properties" > "Style" choose "Graduated"
3. Choose a (numeric) column, 10 classes and Natural Breaks mode.
4. Classify
5. Export Style as SLD.

The exported style has the rules for the created classes, however the filters that enforce those rules are not created.

I've manually created the filters for the rules in order to use with mapserver.

When importing, QGIS manages to import filters in the form of "PropertyIsEqualTo" but is not able to import "PropertyIsBetween".

Files attached:
exported.sld: SLD file created by QGIS
import_ok.sld: SLD file with "PropertyIsEqualTo" filters
import_fail.sld: SLD file with "PropertyIsBetween" filters
exported.qml: QGIS style file with the same style as "exported.sld"

#5 Updated by Giuseppe Sucameli almost 12 years ago

  • Status changed from Open to In Progress

Looking at the code, the filter element is created but never appended to the xml document.

#6 Updated by Giuseppe Sucameli almost 12 years ago

  • Status changed from In Progress to Closed

Also available in: Atom PDF