I'm trying to get dynamic icon loading based on an attribute in GeoServer 2.9


    <sld:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="icons/$(strReplace(strReplace(iconPath,'.','/',true),'/vsd','.bmp', false)"/>

iconpath attribute example:

Spot.Undefiend Spot.vsd

wanted url path:

icons/Spot/Undefiend Spot.bmp

I can't seem to get this working, the log isn't helpful either.


If you read the strReplace documentation you will see that it is a thin wrapper around the Java replace method and provides a link to the Pattern Rules. This means that your function:


will replace every character (a . matches any character) in iconPath with a / - clearly not what you want. I would try something like:

$(strReplace(strReplace(iconPath,'\.','/',false),'\.vsd$','.bmp$', false)

I'm fairly sure turning the logging level up to Developer will show you what is being searched for. One other trick for debugging this sort of issue is to use a TextSymboliser to print the result in a label.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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