我正在寻找最好的做法来编组一个可以处理String,Long等的XMLAnyElement ......我找到了Serializing with JAXB and the Any,但是我需要避免使用ElementNS并解决附加的案例
DOMHandler是最好的方式吗?
public static void main(String[] args) throws JAXBException {
JAXBContext jc = JAXBContext.newInstance(Payload.class, Foo.class, ObjectFactory.class);
Payload payload = new Payload();
payload.any = new ArrayList<>();
payload.any.add(new Bar());
payload.any.add(new Foo());
payload.any.add("pepe");
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(payload, System.out);
}