Welcome to this Blog. I am Software Engineer and work for Zühlke Engineering AG in Bern. This is my private blog, in which I will post mainly about technical stuff like Software Engineering or IT related topics. The views expressed herein do not necessarily represent those of my employer.
25.06.2008
We use JiBX in our current project and had the problem, that JiBX won’t trim whitespaces automatically. For example, a XML tag like <test> asdf </test> get’s stored as “ asdf “ instead of “asdf”.
To solve this problem, we created an user-defined formatter for Strings.
package ch.stefanjaeger.formatter; public class StringFormatter { public static String trimString(String untrimmed) { return untrimmed.trim(); } }
Now just update the binding file of JiBX and JiBX will trim whitespaces:
<format deserializer="ch.stefanjaeger.formatter.StringFormatter.trimString" type="java.lang.String" />
Comments
Leave a comment
