OWLWriterImpl.java revision 2
/*
* Created on Dec 12, 2004
*/
/**
* @author Evren Sirin
*/
public class OWLWriterImpl implements OWLWriter {
private List prettyTypes;
private boolean showXmlDeclaration;
private Charset defaultCharset;
public OWLWriterImpl() {
prettyTypes = new ArrayList();
showXmlDeclaration = true;
}
public boolean isShowXmlDeclaration() {
return showXmlDeclaration;
}
public void setShowXmlDeclaration( boolean showXmlDeclaration ) {
this.showXmlDeclaration = showXmlDeclaration;
}
if (theOntology instanceof OWLKnowledgeBaseImpl)
{
// want to serialize a kb, lets create the output model as a union
// of all the ontologies that make up the kb
// create ontology node for imports
}
// if this was read into the kb and not imported
// lets add its model to the output model
}
else {
// otherwise, lets just add an imports stmt for the ontology
}
}
}
else {
// model and use that for the output.
}
// we don't want literals to be used as attributes
writer.setProperty("blockRules", new Resource[] {RDFSyntax.propertyAttr, RDFSyntax.sectionListExpand});
// show xml header <?xml version="..." ...?>
}
}
if (theOntology instanceof OWLOntology)
// else if (theOntology instanceof OWLKnowledgeBase)
// handleImports((OWLKnowledgeBase)theOntology,aOutModel, baseURI);
}
{
// imports stuff
// search for existing ontology nodes in the model...
// i dont think jena auto-serializes imports as blanks, we can ignore this case
}
// this is likely the case, jena will output the Ontology object
// named with the URI of the ontology
if (theBaseURI != null)
}
}
// if we didnt find an ontology tag, create it
aOntNode = (Ontology)theModel.listSubjectsWithProperty(RDF.type,OWL.Ontology).nextResource().as(Ontology.class);
else
{
if (theBaseURI != null)
else {
}
}
}
// add imports statements to the output model
}
}
// private void handleImports(OWLKnowledgeBase theKB, OntModel theModel, URI theBaseURI)
// {
// Iterator aIter = theKB.getOntologies().iterator();
// while (aIter.hasNext())
// {
// OWLOntology aOntology = (OWLOntology)aIter.next();
// handleImports(aOntology,theModel, theBaseURI);
// }
// }
/* (non-Javadoc)
* @see org.mindswap.owl.OWLWriter#setNsPrefix(java.lang.String, java.net.URI)
*/
}
/* (non-Javadoc)
* @see org.mindswap.owl.OWLWriter#addPrettyType(org.mindswap.owl.OWLClass)
*/
public void addPrettyType(OWLClass c) {
}
/* (non-Javadoc)
* @see org.mindswap.owl.OWLWriter#write(org.mindswap.owl.OWLModel, java.io.Writer)
*/
}
/* (non-Javadoc)
* @see org.mindswap.owl.OWLWriter#write(org.mindswap.owl.OWLModel, java.io.Writer, java.net.URI)
*/
}
/* (non-Javadoc)
* @see org.mindswap.owl.OWLWriter#write(org.mindswap.owl.OWLModel, java.io.OutputStream)
*/
}
/* (non-Javadoc)
* @see org.mindswap.owl.OWLWriter#write(org.mindswap.owl.OWLModel, java.io.OutputStream, java.net.URI)
*/
}
// URI aURI = URI.create("http://www.mindswap.org/2004/owl-s/1.1/ZipCodeFinder.owl");
// OWLKnowledgeBase aKb = OWLFactory.createKB();
// aKb.read(aURI);
// aKb.getBaseOntology().write(System.err);
//
// OWLOntology aOnt = aKb.getOntology(aURI);
// aOnt.addImport(OWLFactory.createOntology(URI.create("http://www.mindswap.org/2004/owl-s/1.1/Process.owl")));
//
// System.err.println(aKb.getBaseOntology().equals(aURI));
//
// aOnt.write(System.err);
OWLOntology aOnt = OWLFactory.createOntology(URI.create("http://www.mindswap.org/2004/owl-s/1.1/ZipCodeFinder.owl"));
aOnt.addImport(OWLFactory.createOntology(URI.create("http://www.mindswap.org/2004/owl-s/1.1/Process.owl")));
// aOnt.addImport(OWLFactory.createOntology(URI.create("")));
//System.err.println(aOnt.getIndividuals().size());
//((com.hp.hpl.jena.rdf.model.Model)aOnt.getImplementation()).write(System.err);
}
}