Skip to content

RDFlib makes invalid Turtle cURIs #1395

@Ga11u

Description

@Ga11u

Some cURIs cannot be parsed with RDFlib, even those produced by RDFlib.

For example:

If we have the following RDF/TURTLE:

@prefix ex: <https://example.org/term#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<http://example.org/entity> ex:anchorOf "This press"^^xsd:string ;
            a <http://dbpedia.org/resource/This_(journal)> .

We load the TTL using g.parse(data=ttl) and we serialize it with g.serialize() we get:

@prefix dbr: <http://dbpedia.org/resource/> .
@prefix ex: <https://example.org/term#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/entity> a dbr:This_(journal) ;
    ex:anchorOf "This press"^^xsd:string .

Then, if we load the output again with g.parse(data=ttl, format="turtle"), we get the following errorr:

rdflib.plugins.parsers.notation3.BadSyntax: at line 5 of <>:
Bad syntax (expected '.' or '}' or ']' at end of statement) at ^ in:
"...b'/2001/XMLSchema#> .\n\nhttp://example.org/entity a dbr:This_'^b'(journal) ;\n ex:anchorOf "This press"^^xsd:string .'"

The error is cause by dbr:This_(journal), more presicely by the '(' and ')'. It seems RDFlib does not like its own output.

Any ideas on what may be happing here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingformat: TurtleRelated to the Turtle format.serializationRelated to serialization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions