owlcs / owlapi

OWL API main repository
813 stars 314 forks source link

Triple parsing errors triggered by annotations on XSD datatypes #1116

Open jmkeil opened 7 months ago

jmkeil commented 7 months ago

I am facing triple parsing errors triggered by annotations on XSD datatypes. Unfortunately, I was not able to come up with clear reproduction steps yet. The problem occurs in Protege as well as in ROBOT. Therefore, I think it is an OWL API problem.

If a datatype is annotated with some property (e.g xsd:decimal rdfs:isDefinedBy <http://example.org/my/ontology#> ., e.g. due to ontodev/robot#1163; also with other properties; property might be declared or undeclared -> not #1026), Protege sometimes shows the datatype in the class hierarchy too (see first image) or sometimes it is replaced in some restrictions with an Error resource (see second image) or sometimes both. However, the error does not occur always for the same file and if it occurs, not always for all restrictions that use the datatype. But an occurrence seems to become more likely for larger ontology files. Each occurrence comes together with an parsing error in the logs:

ERROR  09:25:56  Entity not properly recognized, missing triples in input? http://org.semanticweb.owlapi/error#Error1 for type Class
INFO  09:25:56  Unparsed triple: _:genid-nodeid-node1hg06utqmx78 -> http://www.w3.org/2002/07/owl#withRestrictions -> _:genid-nodeid-node1hg06utqmx79
INFO  09:25:56  Unparsed triple: _:genid-nodeid-node1hg06utqmx78 -> http://www.w3.org/2002/07/owl#onDatatype -> http://www.w3.org/2001/XMLSchema#decimal

But the triples in the TTL file are fine:

[…]
  owl:someValuesFrom [ rdf:type rdfs:Datatype ;
                       owl:onDatatype xsd:decimal ;
                       owl:withRestrictions ( [ xsd:maxInclusive 0.01
                                              ]
                                            )
                     ]
[…]

The same error log entry is sometimes shown by ROBOT.

Screenshot 2023-11-24 092401 Screenshot 2023-11-24 092751

ignazio1977 commented 7 months ago

ErrorX is a hallmark of missing essential triples, usually the type triple itself. Can you show the top of the file in question? I'm wondering about namespaces. Also xsd:maxInclusive 0.01 might be missing a datatype declaration for the literal.

jmkeil commented 7 months ago

Can you show the top of the file in question? I'm wondering about namespaces.

[…]
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix vann: <http://purl.org/vocab/vann/> .
@prefix schema: <https://schema.org/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
[…]

Also xsd:maxInclusive 0.01 might be missing a datatype declaration for the literal.

0.01 is syntactic sugar for "0.01"^^xsd:decimal in TTL, so that is fine.

ErrorX is a hallmark of missing essential triples, usually the type triple itself.

I do not think that a syntactic error or a missing triple is causing this issue, because the error does not deterministically occur:

Unfortunately, I can not share the file and I was not able to produce an minimal working example yet. I first would need to dig a little bit into ontology anonymization …