Scenario
Consider the following class (import omitted):
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class Test {
@XmlAttribute
public int id;
@XmlAnyAttribute
public Map<QName,String> any;
}
What is the behavior when I do the following:
Test t = new Test();
t.id = 5;
t.any = new HashMap<QName,String>();
t.any.put(new QName("id"), "10");
JAXBContext jc = JAXBContext.newInstance(Test.class);
Marshaller m = jc.createMarshaller();
m.setEventHandler(myEventHandler);
m.marshal(t, System.out);
The obvious problem:
An XML element must be generated for the instance Test. But the obvious problem: with what attributes? <test id="5"/>? Or <test id="10"/>? Or invalid XML <test id="5" id="10"/>?
Answer, please:
Will marshalling succeed (or will there be an exception?)
It will be called handleEvent(ValidationEvent)of myEventHandler? If so, with what?
What can you expect on System.out, i.e., XML output? (If 1. the answer is positive)
Will (standardly appropriate) JAXB marshaller generate well-formed XML? (The circuit is not involved)
, <test id="5" id="10"/> , JAXB?
, :
, . Javadoc JAXB. , , .