« Return to Thread: How to get MOXy to trim the text values?
Matt MacIvor wrote:Hi Polly,
Currently EclipseLink MOXy considers everything inside an element to be
significant, and therefore doesn't trim the value. You can work around
this in a couple of ways.
One would be to implement a Converter (see
org.eclipse.persistence.mappings.converters.Converter interface) and add
this to your mapping with a session customization. This would allow you
to manually trim the value before it's set in your object. You could
also do this with a custom attribute accessor. (see
org.eclipse.persistence.mappings.AttributeAccessor).
I agree there should be an easier way to do this. We should be able to
just add a flag on XMLDirectMapping to indicate that string values
should be trimmed.
Could you enter an enhancement request to this effect?
Thanks,
-Matt
amphoras wrote:
>Hi,
>
>I mapped a field in my Java class to an XPath like "ns1:CountryCode/text()".
>
>I find that when the XML looks like this:
> <CountryCode listID='' listAgencyID=''
>listAgencyName='' listName='' listVersionID='' name='' languageID=''
>listURI='http://www.foo.com' listSchemeURI='http://www.foo.com'>
> USA
> </CountryCode>
>
>The value that gets unmarshalled is " USA". All
>those spaces that were used for formatting are preserved. Is there a way to
>configure EclipseLink to trim the spaces on either end of the string and
>just give me "USA"?
>
>Thanks!
>--Polly
>
>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
« Return to Thread: How to get MOXy to trim the text values?
| Free embeddable forum powered by Nabble | Forum Help |