Examples of StringDocumentTarget


Examples of org.semanticweb.owlapi.io.StringDocumentTarget

        // save in OWL/XML format
        m.saveOntology(o, new OWLXMLDocumentFormat(), documentIRI2);
        // save in RDF/XML
        m.saveOntology(o, documentIRI2);
        // print out the ontology
        StringDocumentTarget target = new StringDocumentTarget();
        m.saveOntology(o, target);
        // Remove the ontology from the manager
        m.removeOntology(o);
    }
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

                .createOntology(IRI("http://protege.org/ontologies"));
        OWLObjectSomeValuesFrom r = df.getOWLObjectSomeValuesFrom(prop,
                df.getOWLObjectUnionOf(led, crt));
        OWLSubClassOfAxiom axiom = df.getOWLSubClassOfAxiom(display, r);
        m.addAxiom(ontology, axiom);
        StringDocumentTarget target = saveOntology(ontology,
                new ManchesterSyntaxDocumentFormat());
        assertFalse(target.toString().contains(
                "((<urn:test#crt> or <urn:test#led>))"));
    }
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

     *        The format to use when doing the round trip.
     */
    public OWLOntology roundTripOntology(@Nonnull OWLOntology ont,
            @Nonnull OWLDocumentFormat format)
            throws OWLOntologyStorageException, OWLOntologyCreationException {
        StringDocumentTarget target = new StringDocumentTarget();
        OWLDocumentFormat fromFormat = m.getOntologyFormat(ont);
        if (fromFormat.isPrefixOWLOntologyFormat()
                && format.isPrefixOWLOntologyFormat()) {
            PrefixDocumentFormat fromPrefixFormat = fromFormat
                    .asPrefixOWLOntologyFormat();
            PrefixDocumentFormat toPrefixFormat = format
                    .asPrefixOWLOntologyFormat();
            toPrefixFormat.copyPrefixesFrom(fromPrefixFormat);
        }
        boolean addMissingTypes = true;
        if (format instanceof RDFDocumentFormat) {
            format.setAddMissingTypes(addMissingTypes);
        }
        if (logger.isTraceEnabled()) {
            StringDocumentTarget targetForDebug = new StringDocumentTarget();
            m.saveOntology(ont, format, targetForDebug);
            logger.trace(targetForDebug.toString());
        }
        m.saveOntology(ont, format, target);
        handleSaved(target, format);
        OWLOntology ont2 = OWLManager.createOWLOntologyManager()
                .loadOntologyFromOntologyDocument(
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

    @Nonnull
    protected StringDocumentTarget saveOntology(@Nonnull OWLOntology o,
            @Nonnull OWLDocumentFormat format)
            throws OWLOntologyStorageException {
        StringDocumentTarget t = new StringDocumentTarget();
        o.getOWLOntologyManager().saveOntology(o, format, t);
        return t;
    }
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

    @Deprecated
    public static void printOntology(OWLOntology o, PrintStream printer) {

        OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
        StringDocumentTarget tgt = new StringDocumentTarget();
        try {
            mgr.saveOntology(o, new RDFXMLOntologyFormat(), tgt);
        } catch (OWLOntologyStorageException e) {
            e.printStackTrace(printer);
        }
        printer.println(tgt.toString());

    }
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

  private Graph convertOntology(Collection<OWLAxiom> axioms, boolean filterTypes) throws Exception {
    return convertOntology( com.clarkparsia.owlapiv3.OWL.Ontology( axioms ), filterTypes );
  }
 
  private Graph convertOntology(OWLOntology ontology, boolean filterTypes) throws Exception {
    StringDocumentTarget output = new StringDocumentTarget();

    manager.saveOntology( ontology, new TurtleOntologyFormat(),  output );

    Model model = ModelFactory.createDefaultModel();
    model.read( new StringReader( output.toString() ), ontologyURI.toString(), "TTL" );

    if( filterTypes ) {
      Resource[] builtinTypes = {
          OWL.Ontology, OWL.Class, OWL.ObjectProperty, OWL.DatatypeProperty, OWL.Thing,
          RDF.List };
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

  private Graph convertOntology(Collection<OWLAxiom> axioms, boolean filterTypes) throws Exception {
    return convertOntology( com.clarkparsia.owlapiv3.OWL.Ontology( axioms ), filterTypes );
  }
 
  private Graph convertOntology(OWLOntology ontology, boolean filterTypes) throws Exception {
    StringDocumentTarget output = new StringDocumentTarget();

    manager.saveOntology( ontology, new TurtleOntologyFormat(),  output );

    Model model = ModelFactory.createDefaultModel();
    model.read( new StringReader( output.toString() ), ontologyURI.toString(), "TTL" );

    if( filterTypes ) {
      Resource[] builtinTypes = {
          OWL.Ontology, OWL.Class, OWL.ObjectProperty, OWL.DatatypeProperty, OWL.Thing,
          RDF.List };
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

        OWLDatatype anyURI = __factory.getOWLDatatype(IRI.create("http://www.w3.org/2001/XMLSchema#anyURI"));
        OWLLiteral hasIdValue = __factory.getOWLTypedLiteral(session.getID().toString(), anyURI);
        additions.add(new AddAxiom(ont, __factory.getOWLDataPropertyAssertionAxiom(hasId, iSes, hasIdValue)));
        mgr.applyChanges(additions);

        StringDocumentTarget tgt = new StringDocumentTarget();
        try {
            mgr.saveOntology(ont, new RDFXMLOntologyFormat(), tgt);
            return ont;
        } catch (OWLOntologyStorageException e) {
            LoggerFactory.getLogger(ScopeSetRenderer.class).error(
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

    }

    public static void printOntology(OWLOntology o, PrintStream printer) {

        OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
        StringDocumentTarget tgt = new StringDocumentTarget();
        try {
            mgr.saveOntology(o, new RDFXMLOntologyFormat(), tgt);
        } catch (OWLOntologyStorageException e) {
            e.printStackTrace(printer);
        }
        printer.println(tgt.toString());

    }
View Full Code Here

Examples of org.semanticweb.owlapi.io.StringDocumentTarget

                ontology);
            return ontology;
        }

        OWLOntology newOnt = null;
        OWLOntologyDocumentTarget tgt = new StringDocumentTarget();
        try {
            ontology.getOWLOntologyManager().saveOntology(ontology, tgt);

            newOnt = ontologyManager
                    .loadOntologyFromOntologyDocument(new StringDocumentSource(tgt.toString()));
        } catch (OWLOntologyStorageException e) {
            log.error("Failed to re-serialize ontology.", e);
        } catch (OWLOntologyCreationException e) {
            log.error("Failed to deserialize ontology.", e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.