Skip to content

ReaderDocumentSource: "OWLOntologyCreationIOException: java.net.MalformedURLException: unknown protocol: reader" #1156

@sszuev

Description

@sszuev

ver 5.5.1

the following testcase (taken from old version of BOMSafeInputStreamAndParseTestCase - until it was rewritten) fails:

    public static void main(String[] args) throws Exception {
        String input = "@prefix owl: <http://www.w3.org/2002/07/owl#> .\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n<"
                + IRI.getNextDocumentIRI("http://www.example.org/ISA14#o")
                + "> rdf:type owl:Ontology .\n<http://www.example.org/ISA14#Researcher> rdf:type owl:Class .";
        OWLOntologyManager m = OntManagers.createOWLAPIImplManager();
        int[] b = new int[]{0xFF, 0xFE, 0x00, 0x00};
        OWLOntologyDocumentSource src = new ReaderDocumentSource(new InputStreamReader(in(b, input)));
        m.loadOntologyFromOntologyDocument(src);
    }

    private static InputStream in(int[] b, String s) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        for (int i : b) {
            out.write(i);
        }
        out.write(s.getBytes());
        byte[] byteArray = out.toByteArray();
        return new ByteArrayInputStream(byteArray);
    }

exception:

Exception in thread "main" org.semanticweb.owlapi.io.OWLOntologyCreationIOException: OWLOntologyCreationIOException: java.net.MalformedURLException: unknown protocol: reader
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:216)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1105)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1055)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1005)
	at com.github.owlcs.ontapi.tmp.TmpOWLAPIReaderTest.main(TmpOWLAPIReaderTest.java:25)
Caused by: org.semanticweb.owlapi.io.OWLOntologyInputSourceException: java.net.MalformedURLException: unknown protocol: reader
	at org.semanticweb.owlapi.io.DocumentSources.getInputStream(DocumentSources.java:218)
	at org.semanticweb.owlapi.io.DocumentSources.wrapInput(DocumentSources.java:143)
	at org.semanticweb.owlapi.rio.RioParserImpl.parseDocumentSource(RioParserImpl.java:197)
	at org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:134)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:195)
	... 4 more
Caused by: java.net.MalformedURLException: unknown protocol: reader
	at java.base/java.net.URL.<init>(URL.java:681)
	at java.base/java.net.URL.fromURI(URL.java:748)
	at java.base/java.net.URI.toURL(URI.java:1139)
	at org.semanticweb.owlapi.io.DocumentSources.getInputStream(DocumentSources.java:190)
	... 8 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions