0

I have one jaxb-created Class, that is (logically) not annotated with @XMLRootElement, because it's a child-node. In one special case, I would like to (un)marshall this single node by using an JAXBElement-Wrapper.

With <jxb:globalBindings generateElementProperty="true" /> one can force jaxb to create ObjectFactory-methods that return JAXBElement's.

I would like jaxb not to create all methods that way, but to create that on additional method.

PS: I use ant/xjc to create that classes. That binding is from a binding-file used by xjc.

Sammy
  • 1,178
  • 1
  • 14
  • 27
  • How you generated your classes? jaxb2-maven-plugin? – Xstian Sep 18 '14 at 07:20
  • Sry, I added that information (ant/xjc with bindingfile) – Sammy Sep 18 '14 at 07:23
  • Try to add in your global binding see [here](https://jaxb.java.net/2.1.2/docs/vendorCustomizations.html#simple) in order to add @XmlRootElement on each class generates. In this way should be generate a correct ObjectFactory. – Xstian Sep 18 '14 at 07:28
  • `` should be inserted in the xsd, right? In my actual case, xsd is under my control, but what, if not? – Sammy Sep 18 '14 at 08:19
  • You can externalize the binding in another file .. see this [link](http://stackoverflow.com/a/24953369/3364187) – Xstian Sep 18 '14 at 08:22
  • Added `` to my bindingsfile, what didn't help (beside differences in the generated lists). I think, I will go with an custom wrapper-class of my own ;-) – Sammy Sep 18 '14 at 08:52
  • Maybe you need this method: http://docs.oracle.com/javaee/5/api/javax/xml/bind/Unmarshaller.html#unmarshal(javax.xml.transform.Source, java.lang.Class) – lexicore Sep 18 '14 at 09:11

0 Answers0