I'm using the JAXB_FRAGMENT property for my marshaller to marshal at the WorkSet level. The problem is that when I marshal it's giving the WorkSet element the xmlns attribute everytime. Is there a way to marshal so that it doesn't attach the xmlns attribute? Here's what my XML looks like.
<Import>
<WorkSets>
<WorkSet xmlns="http://www.namespace.com">
<Work>
<Work>
...
..
...
</WorkSet>
<WorkSet xmlns="http://www.namespace.com">
<Work>
<Work>
...
</WorkSet>
</WorkSets>
</Import>
Here's the code I'm using the create the above:
FileOutputStream fos = new FileOutputStream("import.xml");
XMLStreamWriter writer = XMLOutputFactory.newFactory().createXMLStreamWriter(fos);
JAXBContext jc = JAXBContext.newInstance(WorkSet.class);
Marshaller m = jc.createMarshaler();
m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
writer.writeStartDocument();
writer.writeStartElement("Import");
writer.writeAttribute("xmlns","http://www.namespace.com");
writer.writeStartElement("WorkSets");
while(hasWorkSet){
m.marshal(workSet, writer)
}
writer.writeEndDocument();
writer.close();