JAXBParser parser = newJAXBParser();
InputSource isource = new InputSource(new StringReader(schemaSource));
isource.setSystemId("testClass1.xsd");
JAXBSchema schema = (JAXBSchema) parser.parse(isource);
JAXBType a = (JAXBType) schema.getType(new XsQName((String) null, "a"));
assertNotNull(a);
JAXBClass jaxbClass = a.getJAXBClass();
assertNotNull(jaxbClass);
assertEquals("b", jaxbClass.getName());
assertEquals("com.b.c", jaxbClass.getImplClass());
XSParticle p1 = assertComplexContent(assertComplexType(a));
XSGroup group = assertGroup(p1);
XSParticle[] particles = group.getParticles();
assertEquals(2, particles.length);
JAXBElement f = (JAXBElement) assertElement(particles[1]);
jaxbClass = f.getJAXBClass();
assertNotNull(jaxbClass);
assertEquals("x", jaxbClass.getName());
assertNull(jaxbClass.getImplClass());
JAXBElement g = (JAXBElement) schema.getElement(new XsQName((String) null, "g"));
assertNotNull(g);
assertNull(g.getJAXBClass());
JAXBGroup m = (JAXBGroup) schema.getGroup(new XsQName((String) null, "m"));
jaxbClass = m.getJAXBClass();
assertNotNull(jaxbClass);
assertEquals("k", jaxbClass.getName());
assertEquals("com.b.i", jaxbClass.getImplClass());
}
{
final String schemaSource =
"<?xml version='1.0'?>\n" +
"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'" +
" xmlns:jaxb='" + JAXBParser.JAXB_SCHEMA_URI + "'>\n" +
" <xs:complexType name='d'>\n" +
" <xs:sequence>\n" +
" <xs:element name='e'>\n" +
" <xs:complexType name='a'>\n" +
" <xs:annotation>\n" +
" <xs:appinfo>\n" +
" <jaxb:class name='b'/>\n" +
" </xs:appinfo>\n" +
" </xs:annotation>\n" +
" <xs:sequence>\n" +
" <xs:element name='x' type='xs:int'/>\n" +
" </xs:sequence>\n" +
" <xs:attribute name='y' type='xs:string'/>\n" +
" </xs:complexType>\n" +
" </xs:element>\n" +
" <xs:element name='f' type='xs:string'>\n" +
" <xs:annotation>\n" +
" <xs:appinfo>\n" +
" <jaxb:class name='x'/>\n" +
" </xs:appinfo>\n" +
" </xs:annotation>\n" +
" </xs:element>\n" +
" <xs:element name='g' type='xs:string'/>\n" +
" </xs:sequence>\n" +
" </xs:complexType>\n" +
"</xs:schema>";
JAXBParser parser = newJAXBParser();
InputSource isource = new InputSource(new StringReader(schemaSource));
isource.setSystemId("testJAXBClass2.xsd");
JAXBSchema schema = (JAXBSchema) parser.parse(isource);
JAXBType d = (JAXBType) schema.getType(new XsQName((String) null, "d"));
assertNotNull(d);
XSGroup dGroup = assertGroup(assertComplexContent(assertComplexType(d)));
assertSequence(dGroup);
XSParticle[] particles = dGroup.getParticles();
assertEquals(3, particles.length);
JAXBElement e = (JAXBElement) assertElement(particles[0]);
JAXBType a = (JAXBType) e.getType();
JAXBClass jaxbClass = a.getJAXBClass();
assertNotNull(jaxbClass);
assertEquals("b", jaxbClass.getName());
assertNull(jaxbClass.getImplClass());
JAXBElement f = (JAXBElement) assertElement(particles[1]);
assertEquals(new XsQName((String) null, "f"), f.getName());
assertNotNull(f);
jaxbClass = f.getJAXBClass();
assertNotNull(jaxbClass);
assertEquals("x", jaxbClass.getName());
assertNull(jaxbClass.getImplClass());
JAXBElement g = (JAXBElement) assertElement(particles[2]);
assertEquals(new XsQName((String) null, "g"), g.getName());
assertNotNull(g);
assertNull(g.getJAXBClass());
}
{