Skip to content

Hashtag (#) from @base prefix is lost during parsing? #15

Closed
@Lenostatos

Description

@Lenostatos

Hello,

when I execute the example code from the README with the following turtle data, the resulting quads are not what I am expecting.

import ParserN3 from '@rdfjs/parser-n3'
import { Readable } from 'readable-stream'

const parserN3 = new ParserN3()

const input = Readable.from(`
@base <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <../../1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <> .
@prefix owl: <../../2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .

<>
    dc:title "The RDF Schema vocabulary (RDFS)" ;
    a owl:Ontology ;
    rdfs:seeAlso <rdf-schema-more> .

rdfs:Class
    a rdfs:Class ;
    rdfs:comment "The class of classes." ;
    rdfs:isDefinedBy <> ;
    rdfs:label "Class" ;
    rdfs:subClassOf rdfs:Resource .
`)

const output = parserN3.import(input)

output.on('data', quad => {
  console.log(`quad: ${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
})

output.on('prefix', (prefix, ns) => {
  console.log(`prefix: ${prefix} ${ns.value}`)
})

Please note the missing hash symbol (#) at the end of the rdfs prefix in line 2, which is propagated to every place where the prefix was used in the turtle data:
image

I hope this is not just me being stupid, but at least on this website, the turtle is parsed as expected.

Thank you for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions