in engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/SchemaUtil.java [182:255]
private void addSchema(String docBaseURI, Schema schema) {
//String docBaseURI = schema.getDocumentBaseURI();
Element schemaEle = schema.getElement();
if (schemaList.get(docBaseURI) == null) {
schemaList.put(docBaseURI, schemaEle);
} else if (schemaList.get(docBaseURI) != null && schemaList.containsValue(schemaEle)) {
// do nothing
} else {
String tns = schema.getDocumentBaseURI() + "#"
+ schema.getElement().getAttribute("targetNamespace");
if (schemaList.get(tns) == null) {
schemaList.put(tns, schema.getElement());
}
}
//handle imports
Map<String, List> imports = CastUtils.cast(schema.getImports());
if (imports != null && imports.size() > 0) {
for (Entry<String, List> ent : imports.entrySet()) {
String importNamespace = ent.getKey();
List<SchemaImport> schemaImports = CastUtils.cast(imports.get(importNamespace));
for (SchemaImport schemaImport : schemaImports) {
Schema tempImport = schemaImport.getReferencedSchema();
String key = schemaImport.getSchemaLocationURI();
if (importNamespace == null && tempImport != null) {
importNamespace = tempImport.getDocumentBaseURI();
}
if (tempImport != null && !catalogResolved.containsKey(key)) {
key = tempImport.getDocumentBaseURI();
}
if (tempImport != null
&& !isSchemaParsed(key, importNamespace)
&& !schemaList.containsValue(tempImport.getElement())) {
addSchema(key, tempImport);
}
if (tempImport != null) {
//keep this imported schema inline
inlineTransformer(key, tempImport.getElement(), schema.getElement(), false);
}
}
}
}
//handle includes
List<SchemaReference> includes = CastUtils.cast(schema.getIncludes());
if (includes != null && includes.size() > 0) {
String includeNamespace = schema.getElement().getAttribute("targetNamespace");
for (SchemaReference schemaInclude : includes) {
Schema tempInclude = schemaInclude.getReferencedSchema();
String key = tempInclude.getDocumentBaseURI();
if (includeNamespace == null && tempInclude != null) {
includeNamespace = tempInclude.getDocumentBaseURI();
}
if (tempInclude != null && !catalogResolved.containsKey(key)) {
key = tempInclude.getDocumentBaseURI();
}
if (tempInclude != null && !isSchemaParsed(key, includeNamespace)
&& !schemaList.containsValue(tempInclude.getElement())) {
addSchema(key, tempInclude);
}
if (tempInclude != null) {
//keep this included schema inline
inlineTransformer(key, tempInclude.getElement(), schema.getElement(), true);
}
}
}
}