I am creating a SLD for Geoserver wms layer. The SLD validates without error but the icons will not show in the map. I am using attribute based rules to compare strings to have the correct image show for the correct feature. Here is my code and thanks for any help!
<?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>Upper Shore Image Points</Name>
<UserStyle>
<Title>Vendor Points</Title>
<FeatureTypeStyle>
<Rule>
<Name>Famers Market</Name>
<Title>All Farmers Markets</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>farmers maket vendor</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Farmers Markets.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Fruit and Vegetable</Name>
<Title>All Fruit and Vegetable</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Fruit and Vegetable Farm</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Fruit and Vegetable Farms.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Horse Stable</Name>
<Title>All Horse Stables</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Horse Stable</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Horse Stable.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Wool Products</Name>
<Title>All Wool Products</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Wool Products</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Wool Products.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Restaurant</Name>
<Title>All Restaurants</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Restaurant</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Restaurant.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Coffee Roasting</Name>
<Title>All Coffee Roasting</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Coffee Roasting</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Coffee Roasting.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Charter Service</Name>
<Title>All Charter Services</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Charter Service</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Charter Service.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Apiary</Name>
<Title>All Apiaries</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Apiary</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Apiary.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Vineyard</Name>
<Title>All Vineyards</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Vineyard</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Vineyard.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Retail Seafood</Name>
<Title>All Retail Seafood</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Retail Seafood</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Retail Seafood.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Bakery</Name>
<Title>All Bakeries</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Bakery</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Bakery.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Dairy/Eggs</Name>
<Title>All Dairy/ Eggs</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Dairy/Eggs</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Dairy_Eggs.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Christmas Tree Farm</Name>
<Title>All Christmas Tree Farms</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Christmas Tree Farm</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Christmas Tree Farm.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Grains</Name>
<Title>All Grain Farms</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Grains</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Grains.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Meat Products</Name>
<Title>All Meat Products</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Meat Products</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Meat.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Nursery</Name>
<Title>All Nurseries</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Nursery</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Nursery.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Petting Zoo</Name>
<Title>All Petting Zoos</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Petting Zoo</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Petting Zoo.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
I realize this post is old but maybe someone will benefit from my answer.
I didn't succeed in using relative image paths so I turned to using URL paths.
Put image(s) in $GEOSERVER_DATA_DIR/styles and reference it with http://localhost:8081/geoserver/styles/some_image.png
For example
<ExternalGraphic>
<OnlineResource xlink:type="simple" xlink:href="http://localhost:8081/geoserver/styles/some_image.png"/>
<Format>image/png</Format>
</ExternalGraphic>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With