* @param base of the ontology
* @return ontology
*/
public OntModel xsd_to_owl(File source, String base) throws Exception {
schema xs = loadSchema(source.toURL());
if (xs==null) return null;
schemaMap.put(source.toURL(),xs);
String suffix = "owl";
String name = XMLBean.changeSuffix(source.getName(),suffix);
// derive target
File t = this.target!=null?new File(this.target):null, target = t;
if (t!=null && (t.isDirectory() || t.getName().indexOf('.')<0)) {
if (!t.exists()) t.mkdirs();
target = new File(t, name);
}
// derive base
if (base!=null && base.endsWith("/") && name!=null) base += name;
URI b = null;
if (base!=null) b = new URI(base);
else if (target!=null) b = target.toURI();
else b = source.toURI();
// create a context gathering global definitions
Context ctx = new Context(b,xmlns,ModelFactory.createDefaultModel(),schemaMap,this);
String ns = xs.getTargetNamespace();
if (ns==null) ns = ctx.getDefaultNS();
initSchema(new URI(ns),source.toURL(),schemaMap);
// load rules and initialise reasoner
InputStream rules = Gloze.class.getResourceAsStream(RULES);
BufferedReader br = new BufferedReader(new InputStreamReader(rules));
List l = Rule.parseRules(Rule.rulesParserFromReader(br));
GenericRuleReasoner r = new GenericRuleReasoner(l);
r.setTraceOn(trace!=null && trace.equals("true"));
ctx.setReasoner(r);
OntModel m = xs.toOWL(target, name, false, ctx);
// ctx.getModel().write(System.out,"RDF/XML-ABBREV");
return m;
}