@@ -226,16 +226,27 @@ void QgsRuleBasedRendererV2::Rule::toSld( QDomDocument& doc, QDomElement &elemen
226
226
QDomElement ruleElem = doc.createElement ( " se:Rule" );
227
227
element.appendChild ( ruleElem );
228
228
229
+ // XXX: <se:Name> is the rule identifier, but our the Rule objects
230
+ // have no properties could be used as identifier. Use the label.
229
231
QDomElement nameElem = doc.createElement ( " se:Name" );
230
232
nameElem.appendChild ( doc.createTextNode ( mLabel ) );
231
233
ruleElem.appendChild ( nameElem );
232
234
233
- if ( !mDescription .isEmpty () )
235
+ if ( !mLabel . isEmpty () || ! mDescription .isEmpty () )
234
236
{
235
237
QDomElement descrElem = doc.createElement ( " se:Description" );
236
- QDomElement abstractElem = doc.createElement ( " se:Abstract" );
237
- abstractElem.appendChild ( doc.createTextNode ( mDescription ) );
238
- descrElem.appendChild ( abstractElem );
238
+ if ( !mLabel .isEmpty () )
239
+ {
240
+ QDomElement titleElem = doc.createElement ( " se:Title" );
241
+ titleElem.appendChild ( doc.createTextNode ( mLabel ) );
242
+ descrElem.appendChild ( titleElem );
243
+ }
244
+ if ( !mDescription .isEmpty () )
245
+ {
246
+ QDomElement abstractElem = doc.createElement ( " se:Abstract" );
247
+ abstractElem.appendChild ( doc.createTextNode ( mDescription ) );
248
+ descrElem.appendChild ( abstractElem );
249
+ }
239
250
ruleElem.appendChild ( descrElem );
240
251
}
241
252
@@ -477,33 +488,35 @@ QgsRuleBasedRendererV2::Rule* QgsRuleBasedRendererV2::Rule::createFromSld( QDomE
477
488
{
478
489
if ( childElem.localName () == " Name" )
479
490
{
480
- label = childElem.firstChild ().nodeValue ();
491
+ // <se:Name> tag contains the rule identifier,
492
+ // so prefer title tag for the label property value
493
+ if ( label.isEmpty () )
494
+ label = childElem.firstChild ().nodeValue ();
481
495
}
482
496
else if ( childElem.localName () == " Description" )
483
497
{
484
498
// <se:Description> can contains a title and an abstract
485
- // prefer Abstract if available
486
- QDomElement abstractElem = childElem.firstChildElement ( " Abstract" );
487
499
QDomElement titleElem = childElem.firstChildElement ( " Title" );
488
- if ( !abstractElem .isNull () )
500
+ if ( !titleElem .isNull () )
489
501
{
490
- description = abstractElem .firstChild ().nodeValue ();
502
+ label = titleElem .firstChild ().nodeValue ();
491
503
}
492
- else if ( !titleElem.isNull () && description.isEmpty () )
504
+
505
+ QDomElement abstractElem = childElem.firstChildElement ( " Abstract" );
506
+ if ( !abstractElem.isNull () )
493
507
{
494
- description = titleElem .firstChild ().nodeValue ();
508
+ description = abstractElem .firstChild ().nodeValue ();
495
509
}
496
510
}
497
511
else if ( childElem.localName () == " Abstract" )
498
512
{
499
- // <sld:Abstract>
513
+ // <sld:Abstract> (v1.0)
500
514
description = childElem.firstChild ().nodeValue ();
501
515
}
502
516
else if ( childElem.localName () == " Title" )
503
517
{
504
- // <sld:Title>
505
- if ( description.isEmpty () )
506
- description = childElem.firstChild ().nodeValue ();
518
+ // <sld:Title> (v1.0)
519
+ label = childElem.firstChild ().nodeValue ();
507
520
}
508
521
else if ( childElem.localName () == " Filter" )
509
522
{
0 commit comments