1

I'm trying to set up an sld style in Geoserver which references a column in a PostGIS view "Route Type". I'd like to have spaces in my column names as my goal is to create user friendly views for all my spatial data. With the sld below I get an error. I've tried a substituting the space for &nbsp; &#160; as well as <![CDATA[Property Name]]> None of these resolve the issue.

Is it possible to have spaces in propertyName?

<?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>Truck Routes and Restrictions</Name>
   <UserStyle>
     <Title>Truck Routes and Restrictions</Title>
     <FeatureTypeStyle>
       <Rule>
         <Name>Designated Municipal Truck Route</Name>
         <ogc:Filter>
         <ogc:PropertyIsLike  wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>Route Type</ogc:PropertyName>
           <ogc:Literal>*Designated Municipal Truck Route*</ogc:Literal>
         </ogc:PropertyIsLike>
         </ogc:Filter>
         <LineSymbolizer>
        <Stroke>
          <CssParameter name="stroke">#006600</CssParameter>
          <CssParameter name="stroke-width">3</CssParameter>
        </Stroke>
      </LineSymbolizer>
       </Rule>
     </FeatureTypeStyle>
   </UserStyle>
 </NamedLayer>
</StyledLayerDescriptor>
giscoder12
  • 25
  • 4

1 Answers1

1

As I read here PropertyName should be able to be retrieved by Web Feature Service. And next I read How to request WFS propertyName containing parentheses, where I read all this kind of elements must match XML element naming, which don't allows any spaces.

So you can't use space in PropertyName. You should use "my column names" in way that will be not able to see for yours users.

Leszek Mazur
  • 2,443
  • 1
  • 14
  • 28
  • In addition if "my column names" mean SQL columns, you can use view to change column names for yours users – Leszek Mazur Dec 16 '20 at 22:29
  • Thanks. What I ended up doing is using the "raw dataset" which has field names with no spaces as the 'display layer'. This means that all sld styles are based off of these column names (which never include spaces). A view is created for each "raw dataset" which has nicely formatted column names (including spaces). This view is used only for getFeatureInfo requests to display pop-ups with nicely formatted field names while the raw dataset displays the styled geographic features. – giscoder12 Dec 17 '20 at 21:21
  • Good to hear that I helped :) – Leszek Mazur Dec 18 '20 at 14:57