Hi,
When I try to obtain an SLD from GeoServer REST API that have an WellKnownName element that use some ogc:function I don't get the expected result.
Lets say I have following SLD:
<?xml version="1.0" encoding="utf-8"?>
<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld"
xmlns:sld="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
<sld:NamedLayer>
<sld:Name>test</sld:Name>
<sld:UserStyle>
<sld:FeatureTypeStyle>
<sld:Rule>
<sld:PointSymbolizer>
<sld:Graphic>
<sld:Mark>
<sld:WellKnownName>
<ogc:Function name="strToUpperCase">
<ogc:Literal>shape</ogc:Literal>
</ogc:Function>
</sld:WellKnownName>
</sld:Mark>
</sld:Graphic>
</sld:PointSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
</sld:NamedLayer>
</sld:StyledLayerDescriptor>
The request /geoserver/rest/styles/test.sld will return:
<?xml version="1.0" encoding="utf-8"?>
<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld"
xmlns:sld="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
<sld:NamedLayer>
<sld:Name>test</sld:Name>
<sld:UserStyle>
<sld:Name>test</sld:Name>
<sld:FeatureTypeStyle>
<sld:Name>name</sld:Name>
<sld:Rule>
<sld:PointSymbolizer>
<sld:Graphic>
<sld:Mark>
<sld:WellKnownName>strToUpperCase([shape])</sld:WellKnownName>
</sld:Mark>
</sld:Graphic>
</sld:PointSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
</sld:NamedLayer>
</sld:StyledLayerDescriptor>
I don't know if this is a bug or the expected output, the SLDTransformer class in Geotools handles the WellKnownName element as a simple element and only do a simple toString:
public void visit(Mark mark) {
start("Mark");
if (mark.getWellKnownName() != null && !"square".equals(mark.getWellKnownName().evaluate(null))) {
element("WellKnownName", mark.getWellKnownName().toString());
}
if (mark.getFill() != null) {
mark.getFill().accept(this);
}
if (mark.getStroke() != null) {
mark.getStroke().accept(this);
}
end("Mark");
}
In my point of view the WellKnownName should have a full conversion, i.e. instead of:
element("WellKnownName", mark.getWellKnownName().toString());
we should have:
encodeValue("WellKnownName", null, mark.getWellKnownName(), null);
If this is not the expect behavior I can make a pull request in Geotools and if this is the expected behavior can someone give-me some explanation about ?
Best regards,
Nuno Oliveira