Skip to main content

I am trying to parse an SLD file (which is XML) and generate a CSV output based on the rules within it. The following is a sample of the SLD structure

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"

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">

<NamedLayer>

<Name>Standard style</Name>

<UserStyle>

<Title>Line</Title>

<Abstract>Line Style</Abstract>

<FeatureTypeStyle>

<Rule>

<Name>Line - 1:0 to 1:4,000</Name>

<ogc:Filter>

<ogc:PropertyIsEqualTo>

<ogc:PropertyName>code</ogc:PropertyName>

<ogc:Literal>2</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

<MinScaleDenominator>0</MinScaleDenominator>

<MaxScaleDenominator>4000</MaxScaleDenominator>

<LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">

<Stroke>

<CssParameter name="stroke">#FF00FF</CssParameter>

<CssParameter name="stroke-width">0.3</CssParameter>

<CssParameter name="stroke-dasharray">1.5 0.8</CssParameter>

</Stroke>

</LineSymbolizer>

</Rule>

</FeatureTypeStyle>

</UserStyle>

</NamedLayer>

</StyledLayerDescriptor>

 

The output I am trying to create is

 

Title, Abstract, RuleName, FilterProperty, FilterValue, Min, Max, Type, StrokeColour, StrokeWdith, StrokeStyle

 

Line, Line Style, Line - 1:0 - 1:4,000, code, 2, 0, 4000, Stroke, #FF00FF, 0.3, 1.5 0.8

I add a standard XML Reader using the Feature Paths

 

And the use the Elements to Match set to the Rule which is what I am interested about

 

Which works but does not expose all the attributes I need. It seems to expose the Stroke/CSSParameter as a list {}.

 

At this point I thought I should be using the XMLFlatterner or the XMlFragmenter but both do not export a list object.

I have read a number of the FME Tutorials but still unsure how I should 'flattern' the StrokeCSSParameters for each Rule.

Using FME 2020 64Bit on Windows.

Have you looked at the custom transformer ListKeyValuePairExtractor, this should allow you to convert your list items into attributes


Have you looked at the custom transformer ListKeyValuePairExtractor, this should allow you to convert your list items into attributes

So I added that transformer and pointed it to my list but I still get a dialogue saying that it is not execting a list object, but I can still us list{0}. However it still does not unpack the data.


Reply