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/";
if (next.getNamespaceURI().equals(SDOConstants.SDO_URL)) {
schemaLocation += "sdoModel.xsd";
} else if (next.getNamespaceURI().equals(SDOConstants.SDOXML_URL)) {
schemaLocation += "sdoXML.xsd";
} else if (next.getNamespaceURI().equals(SDOConstants.SDOJAVA_URL)) {
schemaLocation += "sdoJava.xsd";
}
try {
new URL(schemaLocation);
theImport.setSchemaLocation(schemaLocation);
} catch (MalformedURLException e) {
// DO NOTHING - fix for bug 6054754 to add custom schemalocation if possible
}
generatedSchema.getImports().add(theImport);
}
}
}
XMLLogin login = new XMLLogin();
login.setDatasourcePlatform(new DOMPlatform());
p.setDatasourceLogin(login);
XMLContext context = new XMLContext(p);
XMLMarshaller marshaller = context.createMarshaller();