Package org.semanticweb.owlapi.io

Examples of org.semanticweb.owlapi.io.StringDocumentTarget


    @Test
    public void testWriteReadConvertedOWL() throws Exception {
        OBODoc oboDoc = parseOBOFile("namespace-id-rule.obo");
        OWLOntology owlOntology = convert(oboDoc);
        OWLOntologyManager manager = owlOntology.getOWLOntologyManager();
        StringDocumentTarget documentTarget = new StringDocumentTarget();
        manager.saveOntology(owlOntology, new OWLXMLDocumentFormat(),
                documentTarget);
        String owlString = documentTarget.toString();
        OWLOntologyDocumentSource documentSource = new StringDocumentSource(
                owlString);
        OWLOntology reloadedOwl = OWLManager.createOWLOntologyManager()
                .loadOntologyFromOntologyDocument(documentSource);
        assertEquals(owlOntology.getAxiomCount(), reloadedOwl.getAxiomCount());
View Full Code Here


    private void roundTrip(@Nonnull OWLDocumentFormat ontologyFormat)
            throws OWLOntologyCreationException, OWLOntologyStorageException {
        OWLOntologyManager man = OWLManager.createOWLOntologyManager();
        OWLOntology ont = man.createOntology();
        man.addAxiom(ont, rule);
        StringDocumentTarget documentTarget = new StringDocumentTarget();
        man.saveOntology(ont, ontologyFormat, documentTarget);
        OWLOntologyManager man2 = OWLManager.createOWLOntologyManager();
        OWLOntology ont2 = man2
                .loadOntologyFromOntologyDocument(new StringDocumentSource(
                        documentTarget.toString(),
                        OWLOntologyDocumentSourceBase
                                .getNextDocumentIRI("string:ontology"),
                        ontologyFormat, null));
        Set<SWRLRule> rules = ont2.getAxioms(AxiomType.SWRL_RULE);
        assertThat(rules.size(), is(1));
View Full Code Here

    @Ignore("man syntax does not like annotations")
    @Test
    public void shouldDoCompleteRoundtripWithAnnotationsMan() throws Exception {
        OWLOntology ontology = prepareOntology();
        OWLDocumentFormat f = new ManchesterSyntaxDocumentFormat();
        StringDocumentTarget save = saveOntology(ontology, f);
        OWLOntology ontology2 = loadOntologyFromString(save);
        equal(ontology, ontology2);
        for (OWLAxiom r : ontology2.getAxioms(AxiomType.SWRL_RULE)) {
            assertFalse(r.getAnnotations(df.getRDFSLabel()).isEmpty());
        }
View Full Code Here

            w.flush();
            w.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return new StringDocumentTarget();
    }
View Full Code Here

    }

    @Nonnull
    protected StringDocumentTarget writeOWL(@Nonnull OWLOntology ontology,
            @Nonnull OWLDocumentFormat format) {
        StringDocumentTarget target = new StringDocumentTarget();
        OWLOntologyManager manager = ontology.getOWLOntologyManager();
        try {
            manager.saveOntology(ontology, format, target);
        } catch (OWLOntologyStorageException e) {
            throw new OWLRuntimeException(e);
View Full Code Here

    protected static void renderOWL(@Nonnull OWLOntology owlOntology)
            throws OWLOntologyStorageException {
        OWLOntologyManager manager = owlOntology.getOWLOntologyManager();
        manager.saveOntology(owlOntology, new OWLXMLDocumentFormat(),
                new StringDocumentTarget());
    }
View Full Code Here

    }

    @Override
    protected OWLOntology convertOBOFile(String fn) {
        OWLOntology ontology = convert(parseOBOFile(fn));
        StringDocumentTarget target = new StringDocumentTarget();
        try {
            ontology.getOWLOntologyManager().saveOntology(ontology,
                    new RDFXMLDocumentFormat(), target);
            return OWLManager.createOWLOntologyManager()
                    .loadOntologyFromOntologyDocument(
View Full Code Here

        InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner,
                gens);
        iog.fillOntology(man.getOWLDataFactory(), infOnt);
        // Save the inferred ontology. (Replace the URI with one that is
        // appropriate for your setup)
        man.saveOntology(infOnt, new StringDocumentTarget());
    }
View Full Code Here

                .getOWLDisjointClassesAxiom(man, woman);
        manager.addAxiom(ont, disjointClassesAxiom);
        // Ontology Management //Having added axioms to out ontology we can now
        // save it (in a variety of formats). RDF/XML is the default format
        // System.out.println("RDF/XML: ");
        manager.saveOntology(ont, new StringDocumentTarget());
        // OWL/XML
        // System.out.println("OWL/XML: ");
        manager.saveOntology(ont, new OWLXMLDocumentFormat(),
                new StringDocumentTarget());
        // Manchester Syntax
        // System.out.println("Manchester syntax: ");
        manager.saveOntology(ont, new ManchesterSyntaxDocumentFormat(),
                new StringDocumentTarget());
        // Turtle
        // System.out.println("Turtle: ");
        manager.saveOntology(ont, new TurtleDocumentFormat(),
                new StringDocumentTarget());
    }
View Full Code Here

    public void testOntologyLoadingFromStringSource() throws OWLException {
        OWLOntologyManager m = create();
        OWLOntology o = loadPizzaOntology(m);
        assertNotNull(o);
        // save an ontology to a document target which holds all data in memory
        StringDocumentTarget target = new StringDocumentTarget();
        m.saveOntology(o, target);
        // remove the ontology from the manager, so it can be loaded again
        m.removeOntology(o);
        // create a document source from a string
        StringDocumentSource documentSource = new StringDocumentSource(target);
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.io.StringDocumentTarget

Copyright © 2018 www.massapicom. 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.