nameSpaceinfo.getURI());
}
}
// would result in 1 xsd:include if schema location is specified
try {
FeatureType featureType = featureTypeInfos[0].getFeatureType();
Object schemaUri = featureType.getUserData().get("schemaURI");
if (schemaUri != null) {
// should always be a string.. set in AppSchemaDataAccessConfigurator
assert schemaUri instanceof String;
// schema is supplied by the user.. just include the top level schema instead of
// building the type
if (!findTypeInSchema(featureTypeInfos[0], schema, factory)) {
addInclude(schema, factory, targetNamespace, (String) schemaUri);
}
return schema;
}
} catch (IOException e) {
logger.warning("Unable to get schema location for feature type '"
+ featureTypeInfos[0].getPrefixedName() + "'. Reason: '" + e.getMessage()
+ "'. Building the schema manually instead.");
}
// user didn't define schema location
// import gml schema
XSDImport imprt = factory.createXSDImport();
imprt.setNamespace(gmlNamespace);
imprt.setSchemaLocation(ResponseUtils.buildSchemaURL(baseUrl, gmlSchemaLocation));
XSDSchema gmlSchema = gmlSchema();
imprt.setResolvedSchema(gmlSchema);
schema.getContents().add(imprt);
schema.getQNamePrefixToNamespaceMap().put(gmlPrefix, gmlNamespace);
schema.getQNamePrefixToNamespaceMap().put("gml", "http://www.opengis.net/gml");
// then manually build schema
for (int i = 0; i < featureTypeInfos.length; i++) {
try {
buildSchemaContent(featureTypeInfos[i], schema, factory, baseUrl);
} catch (Exception e) {
logger.log(Level.WARNING, "Could not build xml schema for type: "
+ featureTypeInfos[i].getName(), e);
}
}
} else {
//different namespaces, write out import statements
ArrayList<String> importedNamespaces = new ArrayList<String>(
ns2featureTypeInfos.size() + 1);
for (Iterator i = ns2featureTypeInfos.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
String prefix = (String) entry.getKey();
List types = (List) entry.getValue();
StringBuffer typeNames = new StringBuffer();
String namespaceURI;
for (Iterator t = types.iterator(); t.hasNext();) {
FeatureTypeInfo info = (FeatureTypeInfo) t.next();
FeatureType featureType = info.getFeatureType();
Object schemaUri = featureType.getUserData().get("schemaURI");
if (schemaUri != null) {
// should always be a string.. set in AppSchemaDataAccessConfigurator
assert schemaUri instanceof String;
// schema is supplied by the user.. just import the top level schema instead of
// building
// the type
namespaceURI = featureType.getName().getNamespaceURI();
addImport(schema, factory, namespaceURI,
(String) schemaUri, importedNamespaces);
// ensure there's only 1 import per namespace