I am wondering whether it actually is an error. My assumption was that <ogc:Literal> is always a string.
The method, strSubstring (string:String, begin:Integer, end:Integer) clearly wants a string and two integers. So, you must give these types to that method. Hence, the correct form would be: <sld:Label> <ogc:Function name="strSubstring"> <ogc:PropertyName>STATIONNAME</ogc:PropertyName> //String - param[0] <ogc:Function name="parseInt"> //1. Int – param[1] <ogc:Literal>0</ogc:Literal> </ogc:Function> <ogc:Function name="parseInt"> //2. Int – param[2] <ogc:Literal>3</ogc:Literal> </ogc:Function> </ogc:Function> </sld:Label> That works for me and obviously for Ákos. If I wrap the first parseInt function into a <ogc:Literal> Like below I get: <sld:Label> <ogc:Function name="strSubstring"> <ogc:PropertyName>STATIONNAME</ogc:PropertyName> /<ogc:Literal>/<ogc:Function name="parseInt"> <ogc:Literal>0</ogc:Literal> </ogc:Function> /</ogc:Literal>/ <ogc:Function name="parseInt"> <ogc:Literal>3</ogc:Literal> </ogc:Function> </ogc:Function> </sld:Label> java.lang.IllegalArgumentException: Filter Function problem for function strSubstring argument #1 - expected type int at org.geotools.filter.function.FilterFunction_strSubstring.evaluate(FilterFunction_strSubstring.java:55). Fair enough, that is what I expect, because my integer is converted again into a string. Now when I put an AA instead of a number in there: <sld:Label> <ogc:Function name="strSubstring"> <ogc:PropertyName>STATIONNAME</ogc:PropertyName> <ogc:Function name="parseInt"> <ogc:Literal>AA</ogc:Literal> </ogc:Function> <ogc:Function name="parseInt"> <ogc:Literal>3</ogc:Literal> </ogc:Function> </ogc:Function> </sld:Label> Geoserver tries to think for me and puts a 0 in and displays the label. Well to assume that everything for the first parameter, which cannot be read or converted, is position 0, is fine. Now, trying to trick Geoserver, because it cannot make assumption about the end of the string gets the following result: <sld:Label> <ogc:Function name="strSubstring"> <ogc:PropertyName>STATIONNAME</ogc:PropertyName> <ogc:Function name="parseInt"> <ogc:Literal>0</ogc:Literal> </ogc:Function> <ogc:Function name="parseInt"> <ogc:Literal>BB</ogc:Literal> </ogc:Function> </ogc:Function> </sld:Label> This goes through the validation but at Submit I get the following error: 14 Nov 11:05:53 WARN [catalog.impl] - Catalog listener threw exception handling event. java.lang.NullPointerException at org.geoserver.gwc.layer.CatalogConfiguration.getLayerInfosFor(CatalogConfiguration.java:413) Nevertheless the style is submitted successfully, however, the map displays without label. My point is: I think this is actually enough, however, I would like to see an error message from parseInt or other functions, because if I write AA in an SLD, it is obvious, that this is no int. If the value comes from a database it is not. The implicit conversion would rather confuse me and there is no way to check beforehand if the string value to be converted is correct if it is a varialble. Furthermore, the implicit conversion from literal/String into the right Java type needs to be done either for all methods or for none. As these methods will increase. I am pretty sure the conversion will be forgotten for the odd method to be added in the future and that is bad. I think I would prefer an error message from parseInt instead of nothing and going through the documentation and change the wording that it becomes clear what type a function passes back and may be adding a few examples, so that people understand that types matter when using methods. ----- ____________________________ Dr Christian Maul Project Manager Information Services Branch Department of Sustainability and Environment Level13, Marland House, 570 Bourke Street Melbourne 3000 PO Box 500, East Melbourne Vic 3002 Telephone: +61-3-8636 2325 Telefax: +61-3-8636 2813 -- View this message in context: http://osgeo-org.1560.n6.nabble.com/Problem-with-strSubstring-function-in-SLD-tp5015967p5016135.html Sent from the GeoServer - User mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ Geoserver-users mailing list Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users