The parsing and generation of UserLayer inline features is not consistent. The class org.geotools.styling.SLDParser expects to parse xml elements without namespace prefix:
<sld:InlineFeature>
<FeatureCollection>
<featureMember>
<gml:_Feature>
<geometryProperty>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>-127,51 -110,51 -110,41 -127,41 -127,51</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</geometryProperty>
<title>Pacific NW</title>
</gml:_Feature>
</featureMember>
</FeatureCollection>
</sld:InlineFeature>
Note the <_Feature> element MUST have the gml: namespace prefix otherwise it does not parse. If the above is parsed successfully then using org.geotools.styling.SLDTransformer adds the the gml prefix and produces the following:
<sld:InlineFeature>
<FeatureCollection>
<gml:boundedBy>
<gml:Box>
<gml:coordinates xmlns:gml="http: decimal="." cs="," ts=" ">-127,41 -110,51</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<_Feature fid="fid-666c37dc_1562bf17e97_-8000">
<gml:geometryProperty>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates xmlns:gml="http: decimal="." cs="," ts=" ">-127,51 -110,51 -110,41 -127,41 -127,51</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:geometryProperty>
<:title>Pacific NW</:title>
</:_Feature>
</gml:featureMember>
</FeatureCollection>
</sld:InlineFeature>
If a complete SLD file was written to a file containing the above xml and then org.geotools.styling.SLDParser was used to read the file the SLD file is not recreated successfully. Attached is a complete working user layer SLD file. |