public void startDocument() throws ODataRenderException {
  outputStream=new ByteArrayOutputStream();
  try {
    xmlWriter=XML_OUTPUT_FACTORY.createXMLStreamWriter(outputStream,UTF_8.name());
    entityTypeWriter=new MetadataDocumentEntityTypeWriter(xmlWriter,entityDataModel);
    complexTypeWriter=new MetadataDocumentComplexTypeWriter(xmlWriter,entityDataModel);
    enumTypeWriter=new MetadataDocumentEnumTypeWriter(xmlWriter);
    entitySetWriter=new MetadataDocumentEntitySetWriter(xmlWriter);
    singletonWriter=new MetadataDocumentSingletonWriter(xmlWriter);
    xmlWriter.writeStartDocument(UTF_8.name(),XML_VERSION);
    xmlWriter.setPrefix(EDMX_PREFIX,EDMX_NS);
  }
 catch (  XMLStreamException e) {
    LOG.error("Not possible to start stream XML");
    throw new ODataRenderException("Not possible to start stream XML: ",e);
  }
}

public void startDocument ( ) throws ODataRenderException { outputStream = new ByteArrayOutputStream ( ) ; try { xmlWriter = XML_OUTPUT_FACTORY . createXMLStreamWriter ( outputStream , UTF_8 . name ( ) ) ; entityTypeWriter = new MetadataDocumentEntityTypeWriter ( xmlWriter , entityDataModel ) ; complexTypeWriter = new MetadataDocumentComplexTypeWriter ( xmlWriter , entityDataModel ) ; enumTypeWriter = new MetadataDocumentEnumTypeWriter ( xmlWriter ) ; entitySetWriter = new MetadataDocumentEntitySetWriter ( xmlWriter ) ; singletonWriter = new MetadataDocumentSingletonWriter ( xmlWriter ) ; xmlWriter . writeStartDocument ( UTF_8 . name ( ) , XML_VERSION ) ; xmlWriter . setPrefix ( EDMX_PREFIX , EDMX_NS ) ; } catch ( XMLStreamException e ) { LOG . error ( "Not possible to start stream XML" ) ; throw new ODataRenderException ( "Not possible to start stream XML: " , e ) ; } }
start the xml stream document by defining things like the type of encoding , and prefixes used . it needs to be used before calling any write method .
