6

I have a org.w3c.dom.Element that I'm returning from my XmlAdapter for a custom @XmlElement and I'd like to include it as part of a JAXB object as arbitrary XML (I'm aware I'll have to hand-craft the XSD). However, JAXB complains with

org.w3c.dom.Element is an interface, and JAXB can't handle interfaces.

Apparently the w3c XML types are not supported as Java types, which is a shame. But further than this, I get the same error when I use javax.xml.transform.Result which is apparently supported.

How can I include arbitrary XML elements as elements in JAXB?

Note: as per https://forums.oracle.com/thread/1668210 I've also tried

MessageFactory factory = MessageFactory.newInstance();
message = factory.createMessage();          
SOAPElement element = message.getSOAPBody().addDocument(doc);

but that is also giving the same error.

4

1 に答える 1