jakartaee / jakartaee/jaxb-api
JAXBResult cannot be initialized with target type
- Dominant language
- Java
- Stars
- 79
- Forks
- 48
- Avg merge
- 7h 12m
- Merged PRs (30d)
- 2
Description
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]
Contributor guide
Assessment
This issue has not been assessed yet.