How to trim trailing spaces of an attribute