public void writeMetadataDocument() throws ODataRenderException {
  try {
    xmlWriter.writeStartElement(EDMX_NS,EDMX);
    xmlWriter.writeNamespace(EDMX_PREFIX,EDMX_NS);
    xmlWriter.writeAttribute(VERSION,ODATA_VERSION);
    xmlWriter.writeStartElement(EDMX_NS,EDMX_DATA_SERVICES);
    boolean entityContinerWritten=false;
    for (    Schema schema : entityDataModel.getSchemas()) {
      xmlWriter.writeStartElement(SCHEMA);
      xmlWriter.writeDefaultNamespace(EDM_NS);
      xmlWriter.writeAttribute(NAMESPACE,schema.getNamespace());
      for (      Type type : schema.getTypes()) {
switch (type.getMetaType()) {
case ENTITY:
          entityTypeWriter.write((EntityType)type);
        break;
case COMPLEX:
      complexTypeWriter.write((ComplexType)type);
    break;
case ENUM:
  enumTypeWriter.write((EnumType)type);
break;
default :
LOG.error("Unexpected type: {}",type.getFullyQualifiedName());
throw new ODataRenderException("Unexpected type: " + type.getFullyQualifiedName());
}
}
if (!entityContinerWritten) {
writeEntityContainer(entityDataModel.getEntityContainer());
entityContinerWritten=true;
}
xmlWriter.writeEndElement();
}
xmlWriter.writeEndElement();
}
 catch (XMLStreamException e) {
LOG.error("Not possible to start stream XML");
throw new ODataRenderException("Not possible to start stream XML: ",e);
}
}

public void writeMetadataDocument ( ) throws ODataRenderException { try { xmlWriter . writeStartElement ( EDMX_NS , EDMX ) ; xmlWriter . writeNamespace ( EDMX_PREFIX , EDMX_NS ) ; xmlWriter . writeAttribute ( VERSION , ODATA_VERSION ) ; xmlWriter . writeStartElement ( EDMX_NS , EDMX_DATA_SERVICES ) ; boolean entityContinerWritten = false ; for ( Schema schema : entityDataModel . getSchemas ( ) ) { xmlWriter . writeStartElement ( SCHEMA ) ; xmlWriter . writeDefaultNamespace ( EDM_NS ) ; xmlWriter . writeAttribute ( NAMESPACE , schema . getNamespace ( ) ) ; for ( Type type : schema . getTypes ( ) ) { switch ( type . getMetaType ( ) ) { case ENTITY : entityTypeWriter . write ( ( EntityType ) type ) ; break ; case COMPLEX : complexTypeWriter . write ( ( ComplexType ) type ) ; break ; case ENUM : enumTypeWriter . write ( ( EnumType ) type ) ; break ; default : LOG . error ( "Unexpected type: {}" , type . getFullyQualifiedName ( ) ) ; throw new ODataRenderException ( "Unexpected type: " + type . getFullyQualifiedName ( ) ) ; } } if ( ! entityContinerWritten ) { writeEntityContainer ( entityDataModel . getEntityContainer ( ) ) ; entityContinerWritten = true ; } xmlWriter . writeEndElement ( ) ; } xmlWriter . writeEndElement ( ) ; } catch ( XMLStreamException e ) { LOG . error ( "Not possible to start stream XML" ) ; throw new ODataRenderException ( "Not possible to start stream XML: " , e ) ; } }
write the ' metadata document ' .
