sweetrdf / easyrdf

Maintained EasyRdf fork: a PHP library designed to make it easy to consume and produce RDF.
Other
17 stars 4 forks source link

Unable to load GeoSPARQL TTL #42

Open flamsens opened 9 months ago

flamsens commented 9 months ago

Parsing the GeoSPARQL ontology as TTL throws an error:

<?php
require('vendor/autoload.php');
$g = new \EasyRdf\Graph('https://www.opengis.net/ont/geosparql');
$g->load();

PHP Warning:  Uncaught EasyRdf\Parser\Exception: Turtle Parse Error: illegal subject type: literal on line 122, column 15 in /vendor/sweetrdf/easyrdf/lib/Parser/Turtle.php:340
Stack trace:
#0 /vendor/sweetrdf/easyrdf/lib/Parser/Turtle.php(261): EasyRdf\Parser\Turtle->parseSubject()
#1 /vendor/sweetrdf/easyrdf/lib/Parser/Turtle.php(150): EasyRdf\Parser\Turtle->parseTriples()
#2 /vendor/sweetrdf/easyrdf/lib/Parser/Turtle.php(116): EasyRdf\Parser\Turtle->parseStatement()
#3 /vendor/sweetrdf/easyrdf/lib/Graph.php(252): EasyRdf\Parser\Turtle->parse()
#4 /vendor/sweetrdf/easyrdf/lib/Graph.php(387): EasyRdf\Graph->parse()
#5 php shell code(1): EasyRdf\Graph->load()
#6 {main}
  thrown in vendor/sweetrdf/easyrdf/lib/Parser/Turtle.php on line 340

The Turtle file loads here: https://service.tib.eu/webvowl/#iri=http://www.opengis.net/ont/geosparql

k00ni commented 9 months ago

Thank you for reporting.

I tried your file with Protégé and it was able to read the file. It seems EasyRdf is not able to handle certain Turtle code, such as:

# copied from line 99 - 110 of your ontology file
:gmlLiteral
    a rdfs:Datatype ;
    rdfs:isDefinedBy
        : ,
        <http://www.opengis.net/spec/geosparql/1.0/req/geometry-extension/gml-literal> ,
        <http://www.opengis.net/spec/geosparql/1.1/req/geometry-extension/gml-literal> ;
    skos:definition """A GML serialization of a Geometry object."""@en ;
    rdfs:seeAlso <https://portal.ogc.org/files/?artifact_id=20509> ;
    skos:prefLabel "GML Literal"@en ;
    skos:example
        spec11:B.1.2.4 ; #            <==== it fails here
.

If I understand Turtle specification (https://www.w3.org/TR/turtle/#grammar-production-PN_LOCAL) correctly, even though the part ...

    skos:example
        spec11:B.1.2.4 ;
.

.. looks weird, it is valid Turtle.

Unfortunately I don't have the time right now to do more research how to fix this. But if you like to contribute a bug fix, I would be happy to help.