public void renderOntology(OWLOntology ontology, Writer writer) throws RendererException { try { this.pw = new PrintWriter(writer); this.allURIs = OntologyHelper.allURIs(ontology); this.allOntologies = OntologyHelper.importClosure(ontology); this.visitor = new RenderingVisitor(this); this.definedURIs = new HashSet(); generateShortNames(); writeShortNames(); sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); gmt = java.util.TimeZone.getTimeZone("GMT"); sdf.setTimeZone(gmt); doneThing = false; random = new Random(); anonymousIndividuals = new HashMap(); for (Iterator ontoIt = allOntologies.iterator(); ontoIt.hasNext(); ) { OWLOntology onto = (OWLOntology) ontoIt.next(); pw.println(" ;; Ontology: " + onto.getURI()); pw.println(); pw.println(" ;; Classes "); pw.println(); for (Iterator it = orderedEntities(onto.getClasses()).iterator(); it.hasNext(); ) { renderClass(onto, (OWLClass) it.next()); } pw.println(" ;; Object Properties "); for (Iterator it = orderedEntities(onto.getObjectProperties()).iterator(); it.hasNext(); ) { renderObjectProperty(onto, (OWLObjectProperty) it.next()); } pw.println(" ;; Data Properties "); for (Iterator it = orderedEntities(onto.getDataProperties()).iterator(); it.hasNext(); ) { renderDataProperty(onto, (OWLDataProperty) it.next()); } pw.println(" ;; Individuals "); for (Iterator it = orderedEntities(onto.getIndividuals()).iterator(); it.hasNext(); ) { renderIndividual(onto, (OWLIndividual) it.next()); } pw.println(" ;; Class Axioms "); for (Iterator it = orderedEntities(onto.getDatatypes()).iterator(); it.hasNext(); ) { renderDataType(onto, (OWLDataType) it.next()); } pw.println(" ;;_Datatypes "); for (Iterator it = orderedEntities(onto.getClassAxioms()).iterator(); it.hasNext(); ) { renderClassAxiom((OWLClassAxiom) it.next()); } pw.println(" ;; Property Axioms "); for (Iterator it = orderedEntities(onto.getPropertyAxioms()).iterator(); it.hasNext(); ) { renderPropertyAxiom((OWLPropertyAxiom) it.next()); } pw.println(" ;; Individual Axioms "); for (Iterator it = orderedEntities(onto.getIndividualAxioms()).iterator(); it.hasNext(); ) { renderIndividualAxiom((OWLIndividualAxiom) it.next()); } } } catch (OWLException ex) { throw new RendererException(ex.getMessage()); } }
/** * Set the ontology that the validator will work with. Note that this performs some * initialisation. This particular implementation does not track ontology changes, so if the * ontology is changed before validation takes place, the results may not be as expected. * * @param ontology an <code>OWLOntology</code> value * @param checkImport if true, grab the imports closure and check the species of any imported * ontologies. If false, just look here. Allows us to catch situations where an ontology is * imported that has a higher expressivity, but the classes involved in that aren't explicitly * used in the importer. */ private int species(OWLOntology ontology, boolean checkImport) { int result = LITE; try { this.ontology = ontology; // logger.info( "Validating: " // + (checkImport?"[imports] ":"") // + ontology.getURI() ); if (reporter != null) { reporter.ontology(ontology); } /* Find the import closure */ this.allOntologies = OntologyHelper.importClosure(ontology); /* Do some initial processing */ gatherURIs(); /* Set up all the variables */ this.namespacesSeparated = true; this.correctOWLUsage = true; this.correctOWLNamespaceUsage = true; this.individualsTyped = true; this.classAxiomLevel = FULL; this.propertyAxiomLevel = FULL; this.expressivityLevel = FULL; /* A helper used when reporting stuff. */ objectRenderer = new ObjectRenderer(ontology); /* Now do all the relevant checks */ checkNamespaceSeparation(); checkCorrectOWLUsage(); checkCorrectOWLNamespaceUsage(); /* This should be done during parsing */ // checkIndividualTyping(); checkClassAxioms(); checkPropertyAxioms(); checkExpressivity(); if (!correctOWLNamespaceUsage) { /* * If there are things in the OWL namespace, we're in OTHER. See * http://lists.w3.org/Archives/Public/www-webont-wg/2003Feb/0157.html */ /* * This doesn't seem right though. I think it's actually the * case that any RDF document is an OWL FULL document. See * Section 1.3 of the Overview. */ // result = OTHER; result = FULL; } else if (!namespacesSeparated || !correctOWLUsage || !individualsTyped) { /* * If namespaces aren't separated, or redefinitions have * occurred, or individuals aren't all explicitly typed, we're * in Full */ result = FULL; } else { /* * Otherwise, it's the highest level that's used for classes, * properties and expressivity */ result = (classAxiomLevel | propertyAxiomLevel | expressivityLevel); } if (reporter != null) { reporter.done(level(result)); } } catch (OWLException e) { result = FULL; reporter.explain(FULL, UNKNOWN, "Exception occurred: " + e.getMessage()); } return result; }