Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sszuev opened this issue Oct 20, 2024 · 0 comments

Comments

@sszuev
Copy link
Contributor

sszuev commented Oct 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant