Program: 18065
Project: 18065
Buggy source:
public static void writeMetadata(DataServices metadata,Writer writer) throws EntityProviderException {
  try {
    XMLStreamWriter xmlStreamWriter=XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
    xmlStreamWriter.writeStartDocument();
    xmlStreamWriter.setPrefix(Edm.PREFIX_EDMX,Edm.NAMESPACE_EDMX_2007_06);
    xmlStreamWriter.setPrefix(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08);
    xmlStreamWriter.setDefaultNamespace(Edm.NAMESPACE_EDM_2008_09);
    xmlStreamWriter.writeStartElement(Edm.NAMESPACE_EDMX_2007_06,"String_Node_Str");
    xmlStreamWriter.writeAttribute("String_Node_Str","String_Node_Str");
    xmlStreamWriter.writeNamespace(Edm.PREFIX_EDMX,Edm.NAMESPACE_EDMX_2007_06);
    xmlStreamWriter.writeStartElement(Edm.NAMESPACE_EDMX_2007_06,"String_Node_Str");
    xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str",metadata.getDataServiceVersion());
    xmlStreamWriter.writeNamespace(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08);
    Collection<Schema> schemas=metadata.getSchemas();
    if (schemas != null) {
      for (      Schema schema : schemas) {
        xmlStreamWriter.writeStartElement("String_Node_Str");
        if (schema.getAlias() != null) {
          xmlStreamWriter.writeAttribute("String_Node_Str",schema.getAlias());
        }
        xmlStreamWriter.writeAttribute("String_Node_Str",schema.getNamespace());
        xmlStreamWriter.writeDefaultNamespace(Edm.NAMESPACE_EDM_2008_09);
        writeAnnotationAttributes(schema.getAnnotationAttributes(),xmlStreamWriter);
        Collection<Using> usings=schema.getUsings();
        if (usings != null) {
          for (          Using using : usings) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",using.getNamespace());
            xmlStreamWriter.writeAttribute("String_Node_Str",using.getAlias());
            writeAnnotationAttributes(using.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(using.getDocumentation(),xmlStreamWriter);
            writeAnnotationElements(using.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<EntityType> entityTypes=schema.getEntityTypes();
        if (entityTypes != null) {
          for (          EntityType entityType : entityTypes) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",entityType.getName());
            if (entityType.getBaseType() != null) {
              xmlStreamWriter.writeAttribute("String_Node_Str",entityType.getBaseType().toString());
            }
            if (entityType.isAbstract()) {
              xmlStreamWriter.writeAttribute("String_Node_Str","String_Node_Str");
            }
            if (entityType.isHasStream()) {
              xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str","String_Node_Str");
            }
            writeCustomizableFeedMappings(entityType.getCustomizableFeedMappings(),xmlStreamWriter);
            writeAnnotationAttributes(entityType.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(entityType.getDocumentation(),xmlStreamWriter);
            Key key=entityType.getKey();
            if (key != null) {
              xmlStreamWriter.writeStartElement("String_Node_Str");
              writeAnnotationAttributes(key.getAnnotationAttributes(),xmlStreamWriter);
              Collection<PropertyRef> propertyRefs=entityType.getKey().getKeys();
              for (              PropertyRef propertyRef : propertyRefs) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                writeAnnotationAttributes(propertyRef.getAnnotationAttributes(),xmlStreamWriter);
                xmlStreamWriter.writeAttribute("String_Node_Str",propertyRef.getName());
                writeAnnotationElements(propertyRef.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
              writeAnnotationElements(key.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
            }
            Collection<Property> properties=entityType.getProperties();
            if (properties != null) {
              writeProperties(properties,xmlStreamWriter);
            }
            Collection<NavigationProperty> navigationProperties=entityType.getNavigationProperties();
            if (navigationProperties != null) {
              for (              NavigationProperty navigationProperty : navigationProperties) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getName());
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getRelationship().toString());
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getFromRole());
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getToRole());
                writeAnnotationAttributes(navigationProperty.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(navigationProperty.getDocumentation(),xmlStreamWriter);
                writeAnnotationElements(navigationProperty.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            writeAnnotationElements(entityType.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<ComplexType> complexTypes=schema.getComplexTypes();
        if (complexTypes != null) {
          for (          ComplexType complexType : complexTypes) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",complexType.getName());
            if (complexType.getBaseType() != null) {
              xmlStreamWriter.writeAttribute("String_Node_Str",complexType.getBaseType().toString());
            }
            if (complexType.isAbstract()) {
              xmlStreamWriter.writeAttribute("String_Node_Str","String_Node_Str");
            }
            writeAnnotationAttributes(complexType.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(complexType.getDocumentation(),xmlStreamWriter);
            Collection<Property> properties=complexType.getProperties();
            if (properties != null) {
              writeProperties(properties,xmlStreamWriter);
            }
            writeAnnotationElements(complexType.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<Association> associations=schema.getAssociations();
        if (associations != null) {
          for (          Association association : associations) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",association.getName());
            writeAnnotationAttributes(association.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(association.getDocumentation(),xmlStreamWriter);
            writeAssociationEnd(association.getEnd1(),xmlStreamWriter);
            writeAssociationEnd(association.getEnd2(),xmlStreamWriter);
            ReferentialConstraint referentialConstraint=association.getReferentialConstraint();
            if (referentialConstraint != null) {
              xmlStreamWriter.writeStartElement("String_Node_Str");
              writeAnnotationAttributes(referentialConstraint.getAnnotationAttributes(),xmlStreamWriter);
              writeDocumentation(referentialConstraint.getDocumentation(),xmlStreamWriter);
              ReferentialConstraintRole principal=referentialConstraint.getPrincipal();
              xmlStreamWriter.writeStartElement("String_Node_Str");
              xmlStreamWriter.writeAttribute("String_Node_Str",principal.getRole());
              writeAnnotationAttributes(principal.getAnnotationAttributes(),xmlStreamWriter);
              for (              PropertyRef propertyRef : principal.getPropertyRefs()) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",propertyRef.getName());
                xmlStreamWriter.writeEndElement();
              }
              writeAnnotationElements(principal.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
              ReferentialConstraintRole dependent=referentialConstraint.getPrincipal();
              xmlStreamWriter.writeStartElement("String_Node_Str");
              xmlStreamWriter.writeAttribute("String_Node_Str",dependent.getRole());
              writeAnnotationAttributes(dependent.getAnnotationAttributes(),xmlStreamWriter);
              for (              PropertyRef propertyRef : dependent.getPropertyRefs()) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",propertyRef.getName());
                xmlStreamWriter.writeEndElement();
              }
              writeAnnotationElements(dependent.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
              writeAnnotationElements(referentialConstraint.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
            }
            writeAnnotationElements(association.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<EntityContainer> entityContainers=schema.getEntityContainers();
        if (entityContainers != null) {
          for (          EntityContainer entityContainer : entityContainers) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",entityContainer.getName());
            if (entityContainer.getExtendz() != null) {
              xmlStreamWriter.writeAttribute("String_Node_Str",entityContainer.getExtendz());
            }
            if (entityContainer.isDefaultEntityContainer()) {
              xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str","String_Node_Str");
            }
            writeAnnotationAttributes(entityContainer.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(entityContainer.getDocumentation(),xmlStreamWriter);
            Collection<EntitySet> entitySets=entityContainer.getEntitySets();
            if (entitySets != null) {
              for (              EntitySet entitySet : entitySets) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",entitySet.getName());
                xmlStreamWriter.writeAttribute("String_Node_Str",entitySet.getEntityType().toString());
                writeAnnotationAttributes(entitySet.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(entitySet.getDocumentation(),xmlStreamWriter);
                writeAnnotationElements(entitySet.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            Collection<AssociationSet> associationSets=entityContainer.getAssociationSets();
            if (associationSets != null) {
              for (              AssociationSet associationSet : associationSets) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",associationSet.getName());
                xmlStreamWriter.writeAttribute("String_Node_Str",associationSet.getAssociation().toString());
                writeAnnotationAttributes(associationSet.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(associationSet.getDocumentation(),xmlStreamWriter);
                writeAssociationSetEnd(associationSet.getEnd1(),xmlStreamWriter);
                writeAssociationSetEnd(associationSet.getEnd2(),xmlStreamWriter);
                writeAnnotationElements(associationSet.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            Collection<FunctionImport> functionImports=entityContainer.getFunctionImports();
            if (functionImports != null) {
              for (              FunctionImport functionImport : functionImports) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",functionImport.getName());
                if (functionImport.getReturnType() != null) {
                  xmlStreamWriter.writeAttribute("String_Node_Str",functionImport.getReturnType().toString());
                }
                if (functionImport.getEntitySet() != null) {
                  xmlStreamWriter.writeAttribute("String_Node_Str",functionImport.getEntitySet());
                }
                if (functionImport.getHttpMethod() != null) {
                  xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str",functionImport.getHttpMethod());
                }
                writeAnnotationAttributes(functionImport.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(functionImport.getDocumentation(),xmlStreamWriter);
                Collection<FunctionImportParameter> functionImportParameters=functionImport.getParameters();
                if (functionImportParameters != null) {
                  for (                  FunctionImportParameter functionImportParameter : functionImportParameters) {
                    xmlStreamWriter.writeStartElement("String_Node_Str");
                    xmlStreamWriter.writeAttribute("String_Node_Str",functionImportParameter.getName());
                    xmlStreamWriter.writeAttribute("String_Node_Str",functionImportParameter.getType().getFullQualifiedName().toString());
                    if (functionImportParameter.getMode() != null) {
                      xmlStreamWriter.writeAttribute("String_Node_Str",functionImportParameter.getMode());
                    }
                    writeFacets(xmlStreamWriter,functionImportParameter.getFacets());
                    writeAnnotationAttributes(functionImportParameter.getAnnotationAttributes(),xmlStreamWriter);
                    writeDocumentation(functionImportParameter.getDocumentation(),xmlStreamWriter);
                    writeAnnotationElements(functionImportParameter.getAnnotationElements(),xmlStreamWriter);
                    xmlStreamWriter.writeEndElement();
                  }
                }
                writeAnnotationElements(functionImport.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            writeAnnotationElements(entityContainer.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        xmlStreamWriter.writeEndElement();
        writeAnnotationElements(schema.getAnnotationElements(),xmlStreamWriter);
      }
    }
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeEndDocument();
    xmlStreamWriter.flush();
  }
 catch (  XMLStreamException e) {
    throw new EntityProviderException(EntityProviderException.COMMON,e);
  }
catch (  FactoryConfigurationError e) {
    throw new EntityProviderException(EntityProviderException.COMMON,e);
  }
}

Fixed version (ground truth):
public static void writeMetadata(DataServices metadata,Writer writer) throws EntityProviderException {
  try {
    XMLStreamWriter xmlStreamWriter=XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
    xmlStreamWriter.writeStartDocument();
    xmlStreamWriter.setPrefix(Edm.PREFIX_EDMX,Edm.NAMESPACE_EDMX_2007_06);
    xmlStreamWriter.setPrefix(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08);
    xmlStreamWriter.setDefaultNamespace(Edm.NAMESPACE_EDM_2008_09);
    xmlStreamWriter.writeStartElement(Edm.NAMESPACE_EDMX_2007_06,"String_Node_Str");
    xmlStreamWriter.writeAttribute("String_Node_Str","String_Node_Str");
    xmlStreamWriter.writeNamespace(Edm.PREFIX_EDMX,Edm.NAMESPACE_EDMX_2007_06);
    xmlStreamWriter.writeStartElement(Edm.NAMESPACE_EDMX_2007_06,"String_Node_Str");
    xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str",metadata.getDataServiceVersion());
    xmlStreamWriter.writeNamespace(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08);
    Collection<Schema> schemas=metadata.getSchemas();
    if (schemas != null) {
      for (      Schema schema : schemas) {
        xmlStreamWriter.writeStartElement("String_Node_Str");
        if (schema.getAlias() != null) {
          xmlStreamWriter.writeAttribute("String_Node_Str",schema.getAlias());
        }
        xmlStreamWriter.writeAttribute("String_Node_Str",schema.getNamespace());
        xmlStreamWriter.writeDefaultNamespace(Edm.NAMESPACE_EDM_2008_09);
        writeAnnotationAttributes(schema.getAnnotationAttributes(),xmlStreamWriter);
        Collection<Using> usings=schema.getUsings();
        if (usings != null) {
          for (          Using using : usings) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",using.getNamespace());
            xmlStreamWriter.writeAttribute("String_Node_Str",using.getAlias());
            writeAnnotationAttributes(using.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(using.getDocumentation(),xmlStreamWriter);
            writeAnnotationElements(using.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<EntityType> entityTypes=schema.getEntityTypes();
        if (entityTypes != null) {
          for (          EntityType entityType : entityTypes) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",entityType.getName());
            if (entityType.getBaseType() != null) {
              xmlStreamWriter.writeAttribute("String_Node_Str",entityType.getBaseType().toString());
            }
            if (entityType.isAbstract()) {
              xmlStreamWriter.writeAttribute("String_Node_Str","String_Node_Str");
            }
            if (entityType.isHasStream()) {
              xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str","String_Node_Str");
            }
            writeCustomizableFeedMappings(entityType.getCustomizableFeedMappings(),xmlStreamWriter);
            writeAnnotationAttributes(entityType.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(entityType.getDocumentation(),xmlStreamWriter);
            Key key=entityType.getKey();
            if (key != null) {
              xmlStreamWriter.writeStartElement("String_Node_Str");
              writeAnnotationAttributes(key.getAnnotationAttributes(),xmlStreamWriter);
              Collection<PropertyRef> propertyRefs=entityType.getKey().getKeys();
              for (              PropertyRef propertyRef : propertyRefs) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                writeAnnotationAttributes(propertyRef.getAnnotationAttributes(),xmlStreamWriter);
                xmlStreamWriter.writeAttribute("String_Node_Str",propertyRef.getName());
                writeAnnotationElements(propertyRef.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
              writeAnnotationElements(key.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
            }
            Collection<Property> properties=entityType.getProperties();
            if (properties != null) {
              writeProperties(properties,xmlStreamWriter);
            }
            Collection<NavigationProperty> navigationProperties=entityType.getNavigationProperties();
            if (navigationProperties != null) {
              for (              NavigationProperty navigationProperty : navigationProperties) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getName());
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getRelationship().toString());
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getFromRole());
                xmlStreamWriter.writeAttribute("String_Node_Str",navigationProperty.getToRole());
                writeAnnotationAttributes(navigationProperty.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(navigationProperty.getDocumentation(),xmlStreamWriter);
                writeAnnotationElements(navigationProperty.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            writeAnnotationElements(entityType.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<ComplexType> complexTypes=schema.getComplexTypes();
        if (complexTypes != null) {
          for (          ComplexType complexType : complexTypes) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",complexType.getName());
            if (complexType.getBaseType() != null) {
              xmlStreamWriter.writeAttribute("String_Node_Str",complexType.getBaseType().toString());
            }
            if (complexType.isAbstract()) {
              xmlStreamWriter.writeAttribute("String_Node_Str","String_Node_Str");
            }
            writeAnnotationAttributes(complexType.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(complexType.getDocumentation(),xmlStreamWriter);
            Collection<Property> properties=complexType.getProperties();
            if (properties != null) {
              writeProperties(properties,xmlStreamWriter);
            }
            writeAnnotationElements(complexType.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<Association> associations=schema.getAssociations();
        if (associations != null) {
          for (          Association association : associations) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",association.getName());
            writeAnnotationAttributes(association.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(association.getDocumentation(),xmlStreamWriter);
            writeAssociationEnd(association.getEnd1(),xmlStreamWriter);
            writeAssociationEnd(association.getEnd2(),xmlStreamWriter);
            ReferentialConstraint referentialConstraint=association.getReferentialConstraint();
            if (referentialConstraint != null) {
              xmlStreamWriter.writeStartElement("String_Node_Str");
              writeAnnotationAttributes(referentialConstraint.getAnnotationAttributes(),xmlStreamWriter);
              writeDocumentation(referentialConstraint.getDocumentation(),xmlStreamWriter);
              ReferentialConstraintRole principal=referentialConstraint.getPrincipal();
              xmlStreamWriter.writeStartElement("String_Node_Str");
              xmlStreamWriter.writeAttribute("String_Node_Str",principal.getRole());
              writeAnnotationAttributes(principal.getAnnotationAttributes(),xmlStreamWriter);
              for (              PropertyRef propertyRef : principal.getPropertyRefs()) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",propertyRef.getName());
                xmlStreamWriter.writeEndElement();
              }
              writeAnnotationElements(principal.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
              ReferentialConstraintRole dependent=referentialConstraint.getDependent();
              xmlStreamWriter.writeStartElement("String_Node_Str");
              xmlStreamWriter.writeAttribute("String_Node_Str",dependent.getRole());
              writeAnnotationAttributes(dependent.getAnnotationAttributes(),xmlStreamWriter);
              for (              PropertyRef propertyRef : dependent.getPropertyRefs()) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",propertyRef.getName());
                xmlStreamWriter.writeEndElement();
              }
              writeAnnotationElements(dependent.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
              writeAnnotationElements(referentialConstraint.getAnnotationElements(),xmlStreamWriter);
              xmlStreamWriter.writeEndElement();
            }
            writeAnnotationElements(association.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        Collection<EntityContainer> entityContainers=schema.getEntityContainers();
        if (entityContainers != null) {
          for (          EntityContainer entityContainer : entityContainers) {
            xmlStreamWriter.writeStartElement("String_Node_Str");
            xmlStreamWriter.writeAttribute("String_Node_Str",entityContainer.getName());
            if (entityContainer.getExtendz() != null) {
              xmlStreamWriter.writeAttribute("String_Node_Str",entityContainer.getExtendz());
            }
            if (entityContainer.isDefaultEntityContainer()) {
              xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str","String_Node_Str");
            }
            writeAnnotationAttributes(entityContainer.getAnnotationAttributes(),xmlStreamWriter);
            writeDocumentation(entityContainer.getDocumentation(),xmlStreamWriter);
            Collection<EntitySet> entitySets=entityContainer.getEntitySets();
            if (entitySets != null) {
              for (              EntitySet entitySet : entitySets) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",entitySet.getName());
                xmlStreamWriter.writeAttribute("String_Node_Str",entitySet.getEntityType().toString());
                writeAnnotationAttributes(entitySet.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(entitySet.getDocumentation(),xmlStreamWriter);
                writeAnnotationElements(entitySet.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            Collection<AssociationSet> associationSets=entityContainer.getAssociationSets();
            if (associationSets != null) {
              for (              AssociationSet associationSet : associationSets) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",associationSet.getName());
                xmlStreamWriter.writeAttribute("String_Node_Str",associationSet.getAssociation().toString());
                writeAnnotationAttributes(associationSet.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(associationSet.getDocumentation(),xmlStreamWriter);
                writeAssociationSetEnd(associationSet.getEnd1(),xmlStreamWriter);
                writeAssociationSetEnd(associationSet.getEnd2(),xmlStreamWriter);
                writeAnnotationElements(associationSet.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            Collection<FunctionImport> functionImports=entityContainer.getFunctionImports();
            if (functionImports != null) {
              for (              FunctionImport functionImport : functionImports) {
                xmlStreamWriter.writeStartElement("String_Node_Str");
                xmlStreamWriter.writeAttribute("String_Node_Str",functionImport.getName());
                if (functionImport.getReturnType() != null) {
                  xmlStreamWriter.writeAttribute("String_Node_Str",functionImport.getReturnType().toString());
                }
                if (functionImport.getEntitySet() != null) {
                  xmlStreamWriter.writeAttribute("String_Node_Str",functionImport.getEntitySet());
                }
                if (functionImport.getHttpMethod() != null) {
                  xmlStreamWriter.writeAttribute(Edm.PREFIX_M,Edm.NAMESPACE_M_2007_08,"String_Node_Str",functionImport.getHttpMethod());
                }
                writeAnnotationAttributes(functionImport.getAnnotationAttributes(),xmlStreamWriter);
                writeDocumentation(functionImport.getDocumentation(),xmlStreamWriter);
                Collection<FunctionImportParameter> functionImportParameters=functionImport.getParameters();
                if (functionImportParameters != null) {
                  for (                  FunctionImportParameter functionImportParameter : functionImportParameters) {
                    xmlStreamWriter.writeStartElement("String_Node_Str");
                    xmlStreamWriter.writeAttribute("String_Node_Str",functionImportParameter.getName());
                    xmlStreamWriter.writeAttribute("String_Node_Str",functionImportParameter.getType().getFullQualifiedName().toString());
                    if (functionImportParameter.getMode() != null) {
                      xmlStreamWriter.writeAttribute("String_Node_Str",functionImportParameter.getMode());
                    }
                    writeFacets(xmlStreamWriter,functionImportParameter.getFacets());
                    writeAnnotationAttributes(functionImportParameter.getAnnotationAttributes(),xmlStreamWriter);
                    writeDocumentation(functionImportParameter.getDocumentation(),xmlStreamWriter);
                    writeAnnotationElements(functionImportParameter.getAnnotationElements(),xmlStreamWriter);
                    xmlStreamWriter.writeEndElement();
                  }
                }
                writeAnnotationElements(functionImport.getAnnotationElements(),xmlStreamWriter);
                xmlStreamWriter.writeEndElement();
              }
            }
            writeAnnotationElements(entityContainer.getAnnotationElements(),xmlStreamWriter);
            xmlStreamWriter.writeEndElement();
          }
        }
        xmlStreamWriter.writeEndElement();
        writeAnnotationElements(schema.getAnnotationElements(),xmlStreamWriter);
      }
    }
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeEndDocument();
    xmlStreamWriter.flush();
  }
 catch (  XMLStreamException e) {
    throw new EntityProviderException(EntityProviderException.COMMON,e);
  }
catch (  FactoryConfigurationError e) {
    throw new EntityProviderException(EntityProviderException.COMMON,e);
  }
}