How to Create XML Fragments
If you want to create an XML fragment (a XML snippet without XML declaration that can be included into other XML documents) instead of a document, you need to set the JAXB_FRAGMENT property of the Marshaller:
MovieLibrary library = ...;
JAXBContext ctx = JAXBContext.newInstance(MovieLibrary.class);
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.marshal(new JAXBElement<MovieLibrary>(new QName("movieLibrary"),
MovieLibrary.class, library),
new FileOutputStream("/tmp/library.xml"));

