rdfjs / N3.js

Lightning fast, spec-compatible, streaming RDF for JavaScript
http://rdf.js.org/N3.js/
Other
714 stars 130 forks source link

Improve N3Writer Support For Gist Style Guide Instances #302

Open svirgilgood opened 2 years ago

svirgilgood commented 2 years ago

According to the Gist Style guide (and other conventions), Instance local names start with an underscore, the N3Writer currently expects all prefixed local names to start with an alphabetic character.

Is there a reason we wouldn't want underscores to be recognized by this Regex?

This issue has been addressed in this pr

jeswr commented 2 years ago

Is there a reason we wouldn't want underscores to be recognized by this Regex?

Underscores are not allowed at the start of a prefix according to the turtle production grammar and I don't imagine any other grammars for the RDF syntaxes supported by this library would be different (though if they are any please correct me!).

svirgilgood commented 2 years ago

I am sorry for the confusion: its an underscore at the start of a local name. For example: https://example.org/_instance_1. I think the N3Writer should produce the following:

@prefix ex: <https://example.org/> .

ex:_instance_1 a ex:ExampleClass .

But with the current implementation the writer would produce the following:

@prefix ex: <https://example.org/> . 

<https://example.org/_instance_1>  a ex:ExampleClass .
TallTed commented 2 years ago

@e2dubba --

Both your "should" and "current" examples include the invalid @prefix <https://example.org/> .

I'm guessing that was intended to be @prefix : <https://example.org/> . but I'm not certain.

This error makes me wonder if there are other errors in your comment, which I suggest you review and revise to be certain it's saying what you intend.

svirgilgood commented 2 years ago

@TallTed, thank you for pointing out the typos in my comment. I had forgotten to include the prefix (the very thing we are talking about). But it is corrected now.