allTypes = types;
generateSchema(uri, types);
//Now we have a built schema model
Project p = new SchemaModelProject();
Vector generatedNamespaces = generatedSchema.getNamespaceResolver().getNamespaces();
XMLDescriptor desc = ((XMLDescriptor)p.getDescriptor(Schema.class));
for (int i = 0; i < generatedNamespaces.size(); i++) {
Namespace next = (Namespace)generatedNamespaces.get(i);
desc.getNamespaceResolver().put(next.getPrefix(), next.getNamespaceURI());
if (next.getNamespaceURI().equals(SDOConstants.SDO_URL) || next.getNamespaceURI().equals(SDOConstants.SDOXML_URL) || next.getNamespaceURI().equals(SDOConstants.SDOJAVA_URL)) {
if (!importExists(generatedSchema.getImports(), next.getNamespaceURI())) {
Import theImport = new Import();
theImport.setNamespace(next.getNamespaceURI());
String schemaLocation = "classpath:/xml/";
String customLocation = null;
if (next.getNamespaceURI().equals(SDOConstants.SDO_URL)) {
if(schemaLocationResolver != null) {
customLocation = schemaLocationResolver.resolveSchemaLocation(firstType, SDOConstants.SDO_BOOLEAN);
}
if(customLocation != null) {
schemaLocation = customLocation;
} else {
schemaLocation += "sdoModel.xsd";
}
} else if (next.getNamespaceURI().equals(SDOConstants.SDOXML_URL)) {
if(schemaLocationResolver != null) {
customLocation = schemaLocationResolver.resolveSchemaLocation(firstType, new SDOType(SDOConstants.SDOXML_URL, "XMLInfo"));
}
if(customLocation != null) {
schemaLocation = customLocation;
} else {
schemaLocation += "sdoXML.xsd";
}
} else if (next.getNamespaceURI().equals(SDOConstants.SDOJAVA_URL)) {
if(schemaLocationResolver != null) {
customLocation = schemaLocationResolver.resolveSchemaLocation(firstType, SDOConstants.SDO_BOOLEANOBJECT);
}
if(customLocation != null) {
schemaLocation = customLocation;
} else {
schemaLocation += "sdoJava.xsd";
}
}
theImport.setSchemaLocation(schemaLocation);
generatedSchema.getImports().add(theImport);
}
}
}
XMLLogin login = new XMLLogin();
login.setDatasourcePlatform(new DOMPlatform());
p.setDatasourceLogin(login);
XMLContext context = new XMLContext(p);
XMLMarshaller marshaller = context.createMarshaller();