[GIS] SLD filter with embedded strTrim function in Geoserver

filtergeoserversld

Using Geoserver 2.2.2 (GeoTools Version 8.4) on Windows 7, I'm trying to create a SLD that trims the leading and trailing spaces of a string property (using the strTrim function) and compares it to a given string pattern (using PropertyIsLike) for filtering. Here is the code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
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">

  <NamedLayer>
    <Name>style1</Name>
    <UserStyle>
      <Title>style1</Title>
      <Abstract>style1</Abstract>
      <FeatureTypeStyle>
        <Rule>
          <Name>Fauche</Name>
          <Title>Fauche</Title>
          <ogc:Filter>
            <ogc:PropertyIsLike wildCard="*" singleChar="#" escape="!">
              <ogc:Function name="strTrim">
              <ogc:PropertyName>type</ogc:PropertyName>
              </ogc:Function>
              <ogc:Literal>Testword</ogc:Literal>
            </ogc:PropertyIsLike>
          </ogc:Filter>
          <PolygonSymbolizer>      
            <Fill>
              <CssParameter name="fill">#FF8C00</CssParameter>
              <CssParameter name="fill-opacity">0.6</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>

  </FeatureTypeStyle>   
</UserStyle>

When validating the SLD, I get the following error:

cvc-complex-type.2.4.a: Invalid content was found starting with
element 'ogc:Function'. One of
'{"http://www.opengis.net/ogc":PropertyName}' is expected.

Where is the mistake?

Best Answer

This was caused by a GeoTools bug and the fix will be available in GeoTools versions 20 and beyond.

Related Question