@Test public void testComplexTypeWithBaseType() throws XMLStreamException, EntityProviderException { final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" Alias=\"RS\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>" + "</EntityType>" + "<ComplexType Name=\"c_BaseType_for_Location\" Abstract=\"true\">" + "<Property Name=\"Country\" Type=\"Edm.String\"/>" + "</ComplexType>" + "<ComplexType Name=\"c_Location\" BaseType=\"RefScenario.c_BaseType_for_Location\">" + "</ComplexType>" + "<ComplexType Name=\"c_Other_Location\" BaseType=\"RS.c_BaseType_for_Location\">" + "</ComplexType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xml); DataServices result = parser.readMetadata(reader, true); assertEquals("2.0", result.getDataServiceVersion()); for (Schema schema : result.getSchemas()) { for (ComplexType complexType : schema.getComplexTypes()) { if ("c_Location".equals(complexType.getName())) { assertNotNull(complexType.getBaseType()); assertTrue(!complexType.isAbstract()); assertEquals("c_BaseType_for_Location", complexType.getBaseType().getName()); assertEquals("RefScenario", complexType.getBaseType().getNamespace()); } else if ("c_Other_Location".equals(complexType.getName())) { assertNotNull(complexType.getBaseType()); assertTrue(!complexType.isAbstract()); assertEquals("c_BaseType_for_Location", complexType.getBaseType().getName()); assertEquals("RS", complexType.getBaseType().getNamespace()); } else if ("c_BaseType_for_Location".equals(complexType.getName())) { assertNotNull(complexType.isAbstract()); assertTrue(complexType.isAbstract()); } else { assertTrue(false); } } } }
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.EDMX_TAG.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 (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } if (validate) { validate(); } dataServices.setSchemas(schemas); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
XmlMetadataConsumer { 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.EDMX_TAG.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 (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } if (validate) { validate(); } dataServices.setSchemas(schemas); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } } }
XmlMetadataConsumer { 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.EDMX_TAG.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 (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } if (validate) { validate(); } dataServices.setSchemas(schemas); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  }
XmlMetadataConsumer { 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.EDMX_TAG.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 (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } if (validate) { validate(); } dataServices.setSchemas(schemas); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  DataServices readMetadata(final XMLStreamReader reader, final boolean validate); }
XmlMetadataConsumer { 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.EDMX_TAG.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 (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } if (validate) { validate(); } dataServices.setSchemas(schemas); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  DataServices readMetadata(final XMLStreamReader reader, final boolean validate);  }