public DataServices readMetadata(final XMLStreamReader reader, final boolean validate)
throws EntityProviderException {
try {
initialize();
DataServices dataServices = new DataServices();
List<Schema> schemas = new ArrayList<Schema>();
while (reader.hasNext()
&& !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI())
&& XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader.getLocalName()))) {
reader.next();
if (reader.isStartElement()) {
extractNamespaces(reader);
if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) {
edmNamespace = reader.getNamespaceURI();
checkEdmNamespace();
schemas.add(readSchema(reader));
} else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader
.getLocalName())) {
dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion"));
}
}
}
if (validate) {
validate();
}
dataServices.setSchemas(schemas);
reader.close();
return dataServices;
} catch (XMLStreamException e) {
throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
.getSimpleName()), e);