phillord / horned-owl

GNU Lesser General Public License v3.0
62 stars 12 forks source link

UnexpectedEOF when parsing example from Wikipedia page. #49

Open filippodebortoli opened 1 year ago

filippodebortoli commented 1 year ago

This snippet of code:

let mut bytes = ontology.as_bytes();
let reader = horned_owl::io::owx::reader::read(&mut bytes).unwrap();

panics if I use the following example (taken from the OWL Wikipedia page):

let ontology = 
    r#"<Ontology ontologyIRI="http://example.org/tea.owl" ...>
    <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
    <Declaration>
        <Class IRI="Tea"/>
    </Declaration>
    </Ontology>"#;

and returns successfully if I add the xmlns attribute to the ontology:

let ontology = 
    r#"<Ontology xmlns="http://www.w3.org/2002/07/owl#" ontologyIRI="http://example.org/tea.owl" ...>
    <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
    <Declaration>
        <Class IRI="Tea"/>
    </Declaration>
    </Ontology>"#;

Is it intended behavior? I would expect the first ontology to be as well-formed as the second one.

phillord commented 1 year ago

I think the first one is well-formed in the XML sense but horned is complaining because of the lack of ontology tags inside. It doesn't know that "Ontology" or "Declaration" is OWL.

Horned could assume a default namespace if otherwise not given. I think that would be sensible outcome also.