I am trying to organize a file using a Visio XML schema , which consists of 3 schema files and creates three packages when the java source is generated using XJC:
- com.microsoft.schemas.visio._2003.core
- com.microsoft.schemas.visio._2006.extension
- com.microsoft.schemas.office.visio._2010.extension
The root element VisioDocument, and all the classes that I use, are in the package 2003.
Here is my approach to sorting my XML file:
VisioDocumentType visioDoc = new VisioDocumentType();
... manipulated here ...
JAXBContext jc = JAXBContext.newInstance("com.microsoft.schemas.visio._2003.core");
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(new JAXBElement<VisioDocumentType>(new QName("uri","local"), VisioDocumentType.class, visioDoc), bw);
On execution, I get this error:
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "com.microsoft.schemas.visio._2003.core.PagePropsType" as an element because it is missing an @XmlRootElement annotation]
I use PagePropsType, but this is not the root element. Why does JAXB consider this?
Chris source
share