}
/** a list type */
public Resource toOWL(OntModel ont, String uri, boolean createAnon, Context ctx) {
OntClass cls = null;
// try to establish the list member type (may be anonymous)
String type = expandQName(ctx.getDefaultNS(),itemType, ont);
// we don't like anonymous lists
if (uri==null || (type!=null && type.startsWith(schema.XSD_URI) && !schema.isValidDatatype(type))) {
// pass over anonymous simple types
if (uri!=null) {
cls = ont.createClass(uri);
cls.addSuperClass(RDF.List);
return cls;
} else return RDF.List;
}
// the type may be null for embedded simpleType
Resource first = null;
if (type==null) {
simpleType t = get_type(ctx);
first = t.toOWL(ctx);
}
else first = schema.toOWL(ont,type);
if (uri!=null || createAnon) {
cls = ont.createClass(uri);
if (uri!=null) ctx.putOntClass(uri, cls);
cls.addSuperClass(RDF.List);
if (first!=null) {
// add the item type as range of rdf:first
cls.addSuperClass(ont.createAllValuesFromRestriction(null,RDF.first,first));
// add the class itself as the range of rdf:rest
cls.addSuperClass(ont.createAllValuesFromRestriction(null,RDF.rest,cls));
}
}
return cls;
}