If I want to unmarshal an XML document on to a class that doesn't have the
@XmlRootElement annotation, then I can use unmarshaller.unmarshal(source, Class)
to tell it which type to bind to, and it'll return me a JAXBElement for that type.
However, if I want to use JAXBResult to pipe a transform on to the same type, I
have no such option. JAXBResult gets a UnmarshallerHandler from the
Unmarshaller, but there's no mechanism for passing in the target type. And so,
JAXBResult can only target @XmlRootElement-annotated clases, which severely
limits its usefulness.
WOuld it be possible to have JAXBResult modified so that I can construct it with
a JAXBContext, plus a target type?
JAXBResult result = new JAXBResult(context, MyClass.class);
// perform transform on to result
JAXBElement output = result.getResult();
If I want to unmarshal an XML document on to a class that doesn't have the @XmlRootElement annotation, then I can use unmarshaller.unmarshal(source, Class) to tell it which type to bind to, and it'll return me a JAXBElement for that type.
However, if I want to use JAXBResult to pipe a transform on to the same type, I have no such option. JAXBResult gets a UnmarshallerHandler from the Unmarshaller, but there's no mechanism for passing in the target type. And so, JAXBResult can only target @XmlRootElement-annotated clases, which severely limits its usefulness.
WOuld it be possible to have JAXBResult modified so that I can construct it with a JAXBContext, plus a target type?
JAXBResult result = new JAXBResult(context, MyClass.class); // perform transform on to result JAXBElement output = result.getResult();
Environment
Operating System: All Platform: All
Affected Versions
[2.1.12]