geostyler / geostyler-sld-parser

GeoStyler-Style-Parser implementation for SLD
BSD 2-Clause "Simplified" License
51 stars 31 forks source link

SLD Parser does not support element order #246

Closed hwbllmnn closed 1 year ago

hwbllmnn commented 5 years ago

PARSER

SLD

BUG

Description:

The SLD parser (or specifically the underlying xml2js library) does not properly support element order. For reading this could work if we'd use the appropriate xml2js options, but for writing these are not supported. This means that writing out a style like this may rearrange elements. Example:

{
  "name": "Demo Style",
  "rules": [
    {
      "name": "Rule 1",
      "symbolizers": [
        {
          "kind": "Text",
          "label": "Your Label{{value}}My label{{name}}{{other}}Something",
          "size": 12
        }
      ]
    }
  ]
}

Paste this in the demo, switch to SLD, copy the SLD, reload and paste the SLD back in and you'll get:

{
  "name": "Demo Style",
  "rules": [
    {
      "name": "Rule 1",
      "symbolizers": [
        {
          "kind": "Text",
          "label": "Your Label{{value}}My label{{name}}Something{{other}}",
          "size": 12
        }
      ]
    }
  ]
}

This is currently the only place I can think of where it might cause problems, but once we'll support functions which get a list of parameters this will cause problems.

It's also not very nice on the filter level because filters of the same type on the same level will always be grouped together, regardless of the original definition.

IMHO we should switch to a different way of XML generation.

glenselle commented 5 years ago

I was looking at libraries to parse XML before I stumbled on the geostyler suite of libs. I'm not sure if fast-xml-parser solves the problem here in the issue, but it does seem to be much more performant than xml2js. Just throwing it out there

KaiVolland commented 1 year ago

Solved with #682