Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize subject and predicate literals correctly #330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joachimvh
Copy link

Closes #329

This does have as disadvantage that invalid turtle will be generated if quads get added to the writer that can not be represented in turtle. If that is a problem, an alternative solution would be to have variants of the writer, similarly to how n-quads get handled, where the turtle version throws an error if it encounters a literal in the subject/predicate position and the N3 version handles it correctly. Let me know what you prefer and I can update the PR.

@RubenVerborgh
Copy link
Member

RubenVerborgh commented Mar 24, 2023

invalid turtle will be generated if quads get added to the writer that can not be represented in turtle

I wonder if this has repercussions for #339; should we have a generic flag for "out of syntax features"?

Copy link
Member

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should still keep _encodeSubject and _encodeObject around, just so we can error in those functions as needed.

@jeswr
Copy link
Collaborator

jeswr commented Mar 24, 2023

I wonder if this has repercussions for #339; should we have a generic flag for "out of syntax features"?

...perhaps, though I worry about performance degradation doing it internally; we could just supply validTurtleQuad, validN3Quad etc. functions that consumers can optionally pass their data through first to validate.

@jeswr
Copy link
Collaborator

jeswr commented Mar 24, 2023

As an aside - are there any RDF syntaxes that don't support a shortand in the subject or object position? If not then the following logic could just be moved to _encodeTerm

return predicate.value === rdf.type ? 'a' : this._encodeTerm(predicate);

@joachimvh
Copy link
Author

As an aside - are there any RDF syntaxes that don't support a shortand in the subject or object position?

Turtle only allows it in the predicate position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serializing literal subjects returns invalid results
3 participants