Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] How to get MOXy to trim the text values?

Hi Matt,

Sure.  I created the enhancement request here:

I'll try what you suggested for the workaround.



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:
>>I mapped a field in my Java class to an XPath like
>>I find that when the XML looks like this:
>>                            <CountryCode listID='' listAgencyID=''
>>listAgencyName='' listName='' listVersionID='' name='' languageID=''
>>listURI='' listSchemeURI=''>
>>                            USA
>>                            </CountryCode>
>>The value that gets unmarshalled is "                            USA". 
>>those spaces that were used for formatting are preserved.  Is there a way
>>configure EclipseLink to trim the spaces on either end of the string and
>>just give me "USA"?
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx

View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top