@Test
public void testSchemaGen() throws JAXBException, IOException, TransformerException, Exception {
ExtensionPointRegistry extensionPointRegistry = ((NodeImpl)node).getExtensionPointRegistry();
JAXBTypeHelper typeHelper = new JAXBTypeHelper(extensionPointRegistry);
JAXBContextHelper contextHelper = new JAXBContextHelper(extensionPointRegistry);
//typeHelper.getSchemaDefinitions(factory, resolver, intf);
Package pkg = CBean.class.getPackage();
String pkgName = pkg.getName();
Annotation[] pkgAnnotations = pkg.getAnnotations();
boolean genPkgInfo = true;
for (Annotation annotation : pkgAnnotations){
if (annotation instanceof XmlSchema){
XmlSchema schemaAnnotation = (XmlSchema)annotation;
if (schemaAnnotation.namespace() != null){
genPkgInfo = false;
break;
}
}
}
JAXBContext context = null;
if (genPkgInfo){
System.out.println("There is no package info so generate one");
/* Can gen the annotation but then what?
Class<?> genClass = generatePackageInfo(pkgName, "http://sometestsnamespace");
Package pkgGen = aClass.getPackage();
String pkgGenName = pkg.getName();
Annotation[] pkgGenAnnotations = pkg.getAnnotations();
XmlSchema schemaAnnotation = null;
for (Annotation annotation : pkgGenAnnotations){
if (annotation instanceof XmlSchema){
schemaAnnotation = (XmlSchema)annotation;
}
}
pkgAnnotations = pkgGenAnnotations;
*/
/* Can't pass the generarted package into JAXB. It has to
* be properly referenced as a package of a class you're trying
* generate.
Class<?>[] classes = {aClass, genClass};
context = contextHelper.createJAXBContext(classes);
*/
} else {
System.out.println("There is package info");
}
Class<?>[] classes = {ABean.class, BBean.class, CBean.class, DBean.class};
context = contextHelper.createJAXBContext(classes);
DOMResolverImpl resolver = new DOMResolverImpl();
context.generateSchema(resolver);
String toNamespace = null;