Why OWL API's RDFXMLParser cannot resolve IRI with two hashes?

373 views Asked by At

I am trying to load an ontology with OWL API.

one of the resources' IRI is http://example.com/#1#2'.

The following exception happens:

Parser: RDFXMLParser
org.semanticweb.owlapi.rdf.syntax.RDFParserException: [line=129:column=52] IRI 'http://example.com/#1#2' cannot be resolved against curent base IRI http://example.com/ontology/demo.owl

If I change that IRI to http://example.com/#1', then everything is fine.

Why OWL API's RDFXMLParser cannot resolve IRI with two hashes?

1

There are 1 answers

3
Joshua Taylor On

http://example.com/#1#2 isn't a legal IRI, so you shouldn't be able to treat is as one. For instance, if you paste it into the SPARQLer IRI Validator, you get the output:

IRI Report

http://example.com/#1#2 ==> http://example.com/#1#2
<http://example.com/#1#2> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.

If you created the ontology, then you need to be more careful about the IRIs that you're using. If someone else created it, then you should let them know that they're producing bad data. As a workaround, you might preprocess the ontology in some way to do something with these bad IRIs (e.g., URLencode the text after the first #).