final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
final Prefixer prefixer = new Prefixer();
for (final Node topElement : schema.topElements) {
outputStreamFactory.stream("", sanitize(schema.name + "_" + topElement.name.localPart) + ".xml", new Streamer() {
public void stream(OutputStream outputStream) throws XMLStreamException {
XMLStreamWriter xmlStreamWriter = outputFactory.createXMLStreamWriter(outputStream);
tweakStreamWriter(xmlStreamWriter);
xmlStreamWriter.writeStartDocument();
writeChildren(xmlStreamWriter, topElement, 0, prefixer);