users@jaxb.java.net

Re: JAXB Binder issues

From: Adam Lantos <hege_at_playma.org>
Date: Tue, 20 Apr 2010 13:37:27 +0200

Hi Pavel,

On Tue, Apr 20, 2010 at 12:56 PM, Pavel Bucek <Pavel.Bucek_at_sun.com> wrote:
>
> Hello Adam,
>
>
> Adam Lantos wrote:
>>
>> Hi,
>>
>> I am planning on using JAXB Binder for synchronizing DOM/JAXBElement
>> hierarchies, and I have several problems with it.
>>
>> I seem to be affected by
>> https://jaxb.dev.java.net/issues/show_bug.cgi?id=459, even with the
>> newest-greatest 2.2 version:
>>
>> Exception in thread "main" java.lang.NullPointerException
>>        at
>> com.sun.xml.bind.v2.runtime.BinderImpl.updateXML(BinderImpl.java:194)
>>        at
>> com.sun.xml.bind.v2.runtime.BinderImpl.updateXML(BinderImpl.java:182)
>>
>
> looks like fix for that issue was reverted and I didn't update original
> issue (sorry for that) - reopened.

thanks, I haven't looked at the CVS to see the actual commits...

>>
>> Secondly, even though the jsr-222 specs and Binder API docs says that
>> it should preserve XML comments and formatting, calling the updateXML
>> method yields reformatted XML with many whitespaces (in fact almost
>> all whitespaces) and all comments removed.
>>
>
> feel free to file a new issue, preferably with a testcase

okay, I will try to produce a minimal failing case.

>> Thirdly, I need to have pretty-formatted XML. With Marshaller, I can
>> do this with the jaxb.formatted.output property, but Binder ignores
>> that. Do you have any ideas how to deal with pretty-formatting wrt the
>> Binder implementation?
>>
>
> that should work - do you get PropertyException when you try
> Binder.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); ?

no, I didn't get any exceptions, it just didn't format the output.

Even Marshaller does weird things, consider the following code:

marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
Document doc = docBuilder.newDocument();
marshaller.marshal(jaxbElement, doc);
Transformer tf = tfF.newTransformer();
tf.transform(new DOMSource(doc), new StreamResult(System.out));

this produces wrongly formatted XML, but

marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(jaxbElement, System.out);

does pretty-formatting well.

I'm using the maven artifact com.sun.xml.bind:jaxb-impl-2.2, if that's
of any help.


thanks,
 Adam