javaee / jaxb-v2

Other
211 stars 101 forks source link

JAXBResult cannot be initialized with target type #690

Open glassfishrobot opened 14 years ago

glassfishrobot commented 14 years ago

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]

glassfishrobot commented 14 years ago

Reported by skaffman

glassfishrobot commented 14 years ago

snajper said: This requires api change, changing subcomponent.

glassfishrobot commented 14 years ago

Was assigned to snajper

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB-690