WFS request with OGC filter in XML payload not returning matching results if there are multiple whitespaces in the literal value

Observed an issue that, WFS request with OGC filter in XML payload not returning matching results if there are multiple whitespaces in the literal value. We could see in the GeoServer log that, the multiple spaces has been replaced with single space on the filter and it couldn’t find any matching data on the database.

For example: There is a text value “WFS filter testing” in the database table. When we applying filter with this, in the GeoServer the text is replaced as “WFS filter testing” and its not returning zero results.

Below is the sample XML payload we are using:

> <wfs:GetFeature xmlns:wfs='XXX' xmlns:ogc='XXX' xmlns:gml='XXX' xmlns:cgf='XXX' version='1.0.0' outputFormat='JSON' service='wfs'>
>     <wfs:Query typeName='SurveyPolygon' srsName='urn:ogc:def:crs:EPSG::3857' encoding="UTF-8">
>         <ogc:Filter>
>             <ogc:PropertyIsEqualTo>
>                 <ogc:PropertyName>SurveyName</ogc:PropertyName>
>                 <ogc:Literal>WFS filter   testing</ogc:Literal>
>             </ogc:PropertyIsEqualTo>
>         </ogc:Filter>
>     </wfs:Query>
> </wfs:GetFeature>

We could see below from the GeoServer log that, the multiple spaces has been replaced with single space:

10 Sep 12:49:11 INFO   [geoserver.wfs] - 
Request: getFeature
    service = wfs
    version = 1.0.0
    baseUrl = http://localhost:8080/geoserver/
    query[0]:
        filter = [ SurveyName = WFS filter testing ]
        srsName = urn:ogc:def:crs:EPSG::3857
        typeName[0] = {Versal}SurveyPolygon
    outputFormat = JSON
    resultType = results
10 Sep 12:49:11 INFO   [wfs.json] - about to encode JSON

Appreciate if someone could help on resolving the issue.

I think this is a case where use of CDATA can be useful?

This need to be exact about whitespace is often found with labeling, as shown here Labeling — GeoServer 2.26.x User Manual

Jody is right, the filter spec has defined whitespace handling at the XML
schema level that would make the parser drop, if memory serves me right,
leading, trailing and repeated spaces. Using CDATA will ensure the text is
not touched

Cheers
Andrea

Il mar 10 set 2024, 22:08 Jody Garnett via OSGeo Discourse <
noreply@discourse.osgeo.org> ha scritto:

jive https://discourse.osgeo.org/u/jive Leader
September 10

I think this is a case where use of CDATA can be useful?

This need to be exact about whitespace is often found with labeling, as
shown here Labeling — GeoServer 2.26.x User Manual
https://docs.geoserver.org/latest/en/user/styling/sld/reference/labeling.html

Visit Topic
https://discourse.osgeo.org/t/wfs-request-with-ogc-filter-in-xml-payload-not-returning-matching-results-if-there-are-multiple-whitespaces-in-the-literal-value/50894/2
or reply to this email to respond.

To unsubscribe from these emails, click here
https://discourse.osgeo.org/email/unsubscribe/4eb9092e63a28a878b4e68e56d5f84d342d6294c17254561e26dfb1b4039c519
.