Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » potential bug in moxy. Object unmarshalled in Binder doesn't match object from Unmarshaller
potential bug in moxy. Object unmarshalled in Binder doesn't match object from Unmarshaller [message #1793024] Fri, 27 July 2018 21:17
Steven Boscarine is currently offline Steven BoscarineFriend
Messages: 1
Registered: July 2018
Junior Member
I am trying to do what Blaise wrote about in
h t t p : //blog.bdoughan.com/2010/09/jaxb-xml-infoset-preservation.html I have a complex set of bindings to a complex XML schema.

Using the same String as input, I can correctly unmarshall the XML to my object with:
//Object returned shows all elements correctly.
return (Configs) ctx.createUnmarshaller().unmarshal(new StringReader(input));

However,
final JAXBContext ctx = GenericJAXBWrapper.initCtx(AccountInfo.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new ByteArrayInputStream(in.getBytes()));
Binder<Node> binder = ctx.createBinder();
AccountInfo configs = (AccountInfo) binder.unmarshal(document);
//This object is empty.
System.out.println(configs);

binder.updateXML(configs);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
final StringWriter buf = new StringWriter();
t.transform(new DOMSource(document), new StreamResult(buf));
//The XML returned is actually correct.
return buf.toString();

Is there any obvious mistake on my part? I changed my javax.xml.bind.context.factory in jaxb.properties and the code works great for a very simple schema, including preserving the comments and unrecognized elements like Blaise wrote about (didn't work in the default Java 8 JAXB as you probably know). However, the complex example is not unmarshalled correctly using the binder, but the Unmarshaller interface works fine.

I tried this on eclipselink 2.7.1 and 2.5.0.

Am I misusing the API?

Thanks so much!
Previous Topic:Eclipselink support - duplicate
Next Topic:How to use static metamodel from dependency project/library?
Goto Forum:
  


Current Time: Tue Apr 16 06:15:56 GMT 2024

Powered by FUDForum. Page generated in 0.63716 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top