Hi Ray,

This is a real issue with some XML documents, but it's pretty easy to handle. Just define a serializer for String to strip off the whitespace, along these lines:

public static String stripString(String text) {
if (text == null) {
return null;
} else {
return text.trim();
}
}

then either use this directly as the deserializer, make it a named format, or make it the default format for String - whichever approach best suits your needs. See the <format> element doc page for details on the last two options.

- Dennis

Raymond N. Ritz wrote:

I was wondering if there is a preferred way to handle whitespace contained in element values in an XML document from within jibx?

For example:

I have

<structure name="Item" field="item">

<value name="FieldA" field="fieldA" />

<value name="FieldB" field="fieldB" usage="optional"/>

</structure>

That corresponds to the xml of

<Item>

<FieldA>5555</FieldA>

<FieldB>

E000028901

</FieldB>

</ItemID>

Notice the whitespace that is in the FieldB element. I could easily have the bean that this binding maps to handle the “trim” operation, but should I perhaps consider the use of a deserializer, or other mechanism within jibx itself?

Or perhaps I am splitting hairs….

Any comments are appreciated.

Ray




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to