nvkp / turtle

Golang package for parsing and serializing the Turtle format used for representing RDF data
MIT License
3 stars 0 forks source link

Invalid IRI When Outputting Triples #11

Closed nvkp closed 3 weeks ago

nvkp commented 3 weeks ago

Hello,

Thank you. I really appreciate the fix. I can now parse the file completely. What I noticed is that when outputting the triples, some IRI fragments start with a slash, and some do not. E.g. http://www.w3.org/1999/02/22-rdf-syntax-ns#type and http://www.w3.org/1999/02/22-rdf-syntax-ns#/Property. I do not think that the / is correct here, but I am not too familiar with the turtle standard.

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .

schema:identifier a rdf:Property ;
    rdfs:label "identifier" ;
    rdfs:comment """The identifier property represents any kind of identifier for any kind of [[Thing]], such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See [background notes](/docs/datamodel.html#identifierBg) for more details.
        """ ;
    owl:equivalentProperty dcterms:identifier ;
    schema:domainIncludes schema:Thing ;
    schema:rangeIncludes schema:PropertyValue,
        schema:Text,
        schema:URL .

results in

Subject:   https://schema.org/identifier
Predicate: http://www.w3.org/1999/02/22-rdf-syntax-ns#type
Object:    http://www.w3.org/1999/02/22-rdf-syntax-ns#/Property

Subject:   https://schema.org/identifier
Predicate: http://www.w3.org/2000/01/rdf-schema#/label
Object:    identifier

...

Originally posted by @jonnyschaefer in https://github.com/nvkp/turtle/issues/9#issuecomment-2154713744

nvkp commented 3 weeks ago

I really appreciate your help!

The IRI http://www.w3.org/1999/02/22-rdf-syntax-ns#/Property is indeed invalid. When outputting the triples, I should append the slash to the prefix and base string only when the string does not end with number sign. Should be fixed in the version v1.0.4 that I just released.

Petr