1

I have Geoserver 2.19.1, using layers from both Postgres and Oracle, in two different workspaces. Most of the layers are based on identicaly described tables (same fields+datatypes, different content) on both sides, so I have e.g. the layer sdo_test.parcels (oracle) and pg_test.parcels (postgres).
The SLDs that decorate the layers are based on combinations of field (PropertyName) values. I want to use the same SLDs for both layers (many layers, fairly complex), but the obvious problem is that a field name (PropertyName, not referring to its content) is uppercase in oracle and lowercase in postgres.
I have tried the following in a simple SLD, but it does not validate, with Unable to find function if_then_else:

<?xml version="1.0" encoding="UTF-8"?>  
<StyledLayerDescriptor version="1.0.0" 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" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">  
  <NamedLayer>
  <Name>gr16_subilotsXtra_style</Name>
  <UserStyle>
    <Title>gr16_subilotsXtra_style</Title>
      <FeatureTypeStyle>
        <Rule><Name>   </Name>
          <PolygonSymbolizer>
            <Fill><CssParameter name="fill"><ogc:Literal>#330000</ogc:Literal></CssParameter>
             <CssParameter name="fill-opacity"><ogc:Literal>0.69</ogc:Literal></CssParameter>
               </Fill>
            <Stroke><CssParameter name="stroke"><ogc:Literal>#330000</ogc:Literal></CssParameter>
             <CssParameter name="stroke-opacity"><ogc:Literal>1</ogc:Literal></CssParameter>
             <CssParameter name="stroke-width"><ogc:Literal>2</ogc:Literal></CssParameter>
               </Stroke>
          </PolygonSymbolizer>
          <TextSymbolizer>


                <Label>
              <!-- <ogc:PropertyName>SRC_ID</ogc:PropertyName> - this is the original setting-->

              <!-- and this is what I tried:-->
              <ogc:Function name="if_then_else">
                  <ogc:Function name="PropertyExists">
                      <ogc:PropertyName>src_id</ogc:PropertyName>
                  </ogc:Function>
                      <ogc:PropertyName>src_id</ogc:PropertyName>
              <ogc:Function name="if_then_else">
                  <ogc:Function name="PropertyExists">
                      <ogc:PropertyName>SRC_ID</ogc:PropertyName>
                  </ogc:Function>
                      <ogc:PropertyName>SRC_ID</ogc:PropertyName>
                  </ogc:Function>
              </ogc:Function>
              <!-- end of trying -->

            </Label>
            

                <Font><CssParameter name="font-size">12</CssParameter></Font>
            <Halo>
                <Radius>1</Radius>
                <Fill><CssParameter name="fill">#FFFFFF</CssParameter></Fill>
                 </Halo>
            <Fill><CssParameter name="fill">#000000</CssParameter></Fill>
          <VendorOption name="polygonAlign">mbr</VendorOption>

          </TextSymbolizer>
        </Rule>
      </FeatureTypeStyle>
  </UserStyle>
2
  • I think you're opening the function twice
    – Ian Turton
    Apr 5, 2022 at 17:57
  • Thanks. That's from an answer I found here - and it made sense to me because I thought the 1st call is the IF...THEN and the 2nd call is the ELSE. But, I could be wrong...
    – GregStef
    Apr 5, 2022 at 19:13

1 Answer 1

0

I thought you could do something like:

         <ogc:Function name="if_then_else">
            <ogc:Function name="PropertyExists">
              <ogc:PropertyName>state_abbr</ogc:PropertyName>
            </ogc:Function>
            <ogc:PropertyName>state_abbr</ogc:PropertyName>
            <ogc:PropertyName>STATE_ABBR</ogc:PropertyName>
          </ogc:Function>

but this fails to render as the attribute state_abbr doesn't exist in the layer. So I don't think this approach will work, all I can think of is fixing the attribute names or creating views on one or the other database.

4
  • Thanks for your time and effort. I'll wait a little longer, just in case another answer comes, and then I'll accept yours.
    – GregStef
    Apr 6, 2022 at 9:47
  • 1
    Figuring out that the properties are optional from expression is going to be hard, but maybe GeoServer could have a new flag to just turn off style property validation. It was added many years ago, because people kept on reporting styling bugs that were due to typos, and it's good default, but for these cases having a way to turn it off (global, or even better, per style) could indeed be useful. Apr 7, 2022 at 16:01
  • I've created an issue so we don't forget this idea
    – Ian Turton
    Apr 8, 2022 at 9:09
  • @ian-turton, I couldn't figure out how to comment in the jira page, so I put my thoughts here. Not sure how your idea will function, could you perhaps elaborate? A vendor option that will be used in any SLD and will bypass all validations? Only those in TextSymbolizer? And, back to the current problem, I will still have to use "if_then_else"+"PropertyExists" to use case insensitivity?
    – GregStef
    Apr 10, 2022 at 19:47

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.