Hi Steffen,
it's possible to hide a field from being marshalled but there is simply no
way to create more than one element (or attribute) from a single class
field, not with adapters or anything else.
A clean and simple solution would be to hide the original double field and
add doubleFormatA, B and C, as strings (possibly by subclassing). I think
the getters would be sufficient, converting from "value" on the fly. (You
don't need setters because you can't unmarshal back to the original double
anyway.)
Alternatively, marshal the XML containing <value> as a double and
post-process with a (very simple!) XSLT.
-W
On Mon, May 3, 2010 at 11:38 PM, Steffen Bleul <StBleul_at_gmx.de> wrote:
> Hello,
>
> I am marshalling Java objects, an XML schema is not available. The objects
> are database entities and business objects. Therefore, I try to avoid
> adjustmen of my java classes with additional fields or properties because
> this is view specific code. A solution purely per configuration would be
> great but currently im open to any suggestions.
>
> Best regards,
> Steffen Bleul
>
>
> Am 03.05.2010 16:19, schrieb Wolfgang Laun:
>
> Are you generating Java classes from an XML schema (Is it possible to
>> modify it?) or are you using hand coded Java classes?
>> -W
>>
>> On Mon, May 3, 2010 at 3:26 PM, Steffen Bleul<stbleul_at_gmx.de> wrote:
>>
>>
>>> Hello,
>>>
>>> I have a question regarding JAXB customizing with JaxbAdapters.
>>>
>>> I have a field in my object with type Double, in my case its necessary
>>> that this Double needs to be formatted/marshalled in 3 differents formats
>>> inside the same XML.
>>>
>>> public Double value = ...;
>>>
>>> Double: 0.1233554233
>>> 1. Format, no commas: 0
>>> 2. Format, 3 digits after comma: 0.123
>>> 3. Format, 2 digits after comma: 0.12
>>>
>>> The resulting xml:
>>> <doubleFormatA>0</doubleFormatA>
>>> <doubleFormatB>0.123</doubleFormatB>
>>> <doubleFormatC>0.12</doubleFormatC>
>>>
>>> Whats the best approach to do this in JAXB?
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>