public static XMLStreamWriter startDocument(ByteArrayOutputStream outputStream,String prefix,String documentRootName,String nameSpaceURI) throws XMLStreamException {
  XMLStreamWriter writer=XML_OUTPUT_FACTORY.createXMLStreamWriter(outputStream,UTF_8.name());
  if (isNullOrEmpty(prefix)) {
    writer.writeStartElement(documentRootName);
    writer.setDefaultNamespace(nameSpaceURI);
    writer.writeDefaultNamespace(nameSpaceURI);
  }
 else {
    writer.writeStartElement(prefix,documentRootName,nameSpaceURI);
    writer.writeNamespace(prefix,nameSpaceURI);
  }
  return writer;
}

public static XMLStreamWriter startDocument ( ByteArrayOutputStream outputStream , String prefix , String documentRootName , String nameSpaceURI ) throws XMLStreamException { XMLStreamWriter writer = XML_OUTPUT_FACTORY . createXMLStreamWriter ( outputStream , UTF_8 . name ( ) ) ; if ( isNullOrEmpty ( prefix ) ) { writer . writeStartElement ( documentRootName ) ; writer . setDefaultNamespace ( nameSpaceURI ) ; writer . writeDefaultNamespace ( nameSpaceURI ) ; } else { writer . writeStartElement ( prefix , documentRootName , nameSpaceURI ) ; writer . writeNamespace ( prefix , nameSpaceURI ) ; } return writer ; }
creates document root with given name .
