9

I have two SLD rules one using PropertyIsEqualTo and another using PropertyIsLike

Using PropertyIsEqualTo

<Rule>
          <Name>Vendor FirstVendor</Name>
          <Title>FristVendor</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>Vendor</ogc:PropertyName>
            <ogc:Literal>firstVendor</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#0033CC</CssParameter>
                </Fill>
              </Mark>
              <Size>8</Size>
            </Graphic>
          </PointSymbolizer>              
     </Rule>

Using PropertyIsLike

<ogc:Filter>
            <ogc:PropertyIsLike  wildCard="*" singleChar="." escape="!">
            <ogc:PropertyName>Vendor</ogc:PropertyName>
            <ogc:Literal>firstVendor*</ogc:Literal>
            </ogc:PropertyIsLike>
</ogc:Filter>

The SLD using Like works fine where as using equal does not work at all.I have seen the string in database well there is not leading or trailing spaces.

Geoserver is taking space at the end of literal. That was the issue. I added space to PropertyName eg Vendor_

3
  • Did you manage to find a solution to your problem. I seem to be having the exact same issue using PropertyIsEqualTo. I have looked at the resulting query that Geoserver creates and run this on the database. The database returns the results as expected but geoserver does not seem to render anything for the layer. Any help is much appreciated. Apologies for not posting this as a comment but it won't allow me to as I just created an account.
    – k9ty
    Commented Nov 23, 2012 at 14:30
  • 1
    @k9ty yes I found the solution the problem is there is some kind of bug or I don't know what's it the sld won't work you should use <ogc:Filter> <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> <ogc:PropertyName>Vendor</ogc:PropertyName> <ogc:Literal>V1*</ogc:Literal> </ogc:PropertyIsLike> </ogc:Filter>
    – kinkajou
    Commented Nov 26, 2012 at 3:55
  • @k9ty here we have used the query "like" it the solution for now I guess. I could not solbe the problem with captDragon solution as there was validation error.
    – kinkajou
    Commented Nov 26, 2012 at 3:56

2 Answers 2

4

Try adding matchCase="true" like this:

<ogc:PropertyIsEqualTo matchCase="true">
    <ogc:PropertyName>Vendor</ogc:PropertyName>
    <ogc:Literal>firstVendor</ogc:Literal>
</ogc:PropertyIsEqualTo>

I know it doesn't really make sense, but comparing yours to mine, that's the only difference i see.

9
  • 1
    Attribute 'matchCase' is not allowed to appear in element 'ogc:PropertyIsEqualTo'
    – kinkajou
    Commented Feb 29, 2012 at 3:59
  • What is not allowing you? It's part of the OGC spec.
    – CaptDragon
    Commented Feb 29, 2012 at 13:40
  • it works partially but geoserver validate button generates error
    – kinkajou
    Commented Mar 1, 2012 at 4:58
  • What's the error? And do you have this xmlns:ogc="http://www.opengis.net/ogc" at the top of the xml file?
    – CaptDragon
    Commented Mar 1, 2012 at 13:54
  • 1
    "Attribute 'matchCase' is not allowed to appear in element 'ogc:PropertyIsEqualTo'" This is the error :)
    – kinkajou
    Commented Mar 7, 2012 at 4:40
1

This answer is quite late but I was just struggling with this same issue.

I used "excapeChar" instead of "escape" and GeoServer accepted it:

<ogc:PropertyIsLike wildCard="%" singleChar="#" escapeChar="!">
<ogc:PropertyName>Name</ogc:PropertyName>
<ogc:Literal>%Value%</ogc:Literal>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.