[
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,
I was going to wait for the enhancement request to be implemented, but that
has moved to version 2.0. So now I need to implement a fix for our project.
:)
Can you give me some advice as to whether the Converter or the
AttributeAccessor is better? It seems to me that if I go the Converter
route, it might interfere with enums. So if I go the AttributeAccessor
route, I need to create two accessors--one to extend
InstanceVariableAttributeAccessor and one to extend MethodAttributeAccessor.
Then I would override the setAttributeValueInObject() method. Does that
sound right?
Just as an example, when I *don't* trim the string, I get this error with
enums. Which approach do you recommend for fixing this?
Thanks!!
--Polly
Caused by: Exception [EclipseLink-116] (Eclipse Persistence Services - 1.0.2
(Build 20081024)): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [
] in field [text()].
Mapping:
org.eclipse.persistence.oxm.mappings.XMLDirectMapping[code-->text()]
Descriptor: XMLDescriptor(com.infor.common.model.fields.ResponseCode --> [])
at
org.eclipse.persistence.exceptions.DescriptorException.noFieldValueConversionToAttributeValueProvided(DescriptorException.java:1021)
at
org.eclipse.persistence.mappings.converters.ObjectTypeConverter.convertDataValueToObjectValue(ObjectTypeConverter.java:140)
at
org.eclipse.persistence.mappings.converters.EnumTypeConverter.convertDataValueToObjectValue(EnumTypeConverter.java:101)
at
org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getAttributeValue(XMLDirectMapping.java:267)
...
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@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>
--
View this message in context: http://www.nabble.com/How-to-get-MOXy-to-trim-the-text-values--tp17653021p20625329.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.