@Test
public void testXSD() throws Exception {
ProcessorContext context = new ProcessorContext();
URL url = getClass().getResource("/xsd/greeting.xsd");
XSDefinition definition = (XSDefinition)documentProcessor.read(null, URI.create("xsd/greeting.xsd"), url, context);
Assert.assertNull(definition.getSchema());
Assert.assertEquals("http://greeting", definition.getNamespace());
URL url1 = getClass().getResource("/xsd/name.xsd");
XSDefinition definition1 = (XSDefinition)documentProcessor.read(null, URI.create("xsd/name.xsd"), url1, context);
Assert.assertNull(definition1.getSchema());
Assert.assertEquals("http://greeting", definition1.getNamespace());
resolver.addModel(definition, context);
XSDefinition resolved = resolver.resolveModel(XSDefinition.class, definition, context);
XmlSchemaObjectCollection collection = resolved.getSchema().getIncludes();
Assert.assertTrue(collection.getCount() == 1);
XmlSchemaType type =
((XmlSchemaInclude)collection.getItem(0)).getSchema().getTypeByName(new QName("http://greeting", "Name"));
Assert.assertNotNull(type);
resolver.addModel(definition1, context);
resolved = resolver.resolveModel(XSDefinition.class, definition, context);
collection = resolved.getSchema().getIncludes();
Assert.assertTrue(collection.getCount() == 2);
XmlSchemaType type1 =
((XmlSchemaInclude)collection.getItem(0)).getSchema().getTypeByName(new QName("http://greeting", "Name"));
XmlSchemaType type2 =
((XmlSchemaInclude)collection.getItem(1)).getSchema().getTypeByName(new QName("http://greeting", "Name"));