-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add support for empty graphs in the subject and object positions #374
base: versions/2.0.0
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -663,8 +663,23 @@ export default class N3Parser { | |
const graph = this._graph; | ||
|
||
// Store the last quad of the formula | ||
if (this._subject !== null) | ||
this._emit(this._subject, this._predicate, this._object, graph); | ||
|
||
if (this._subject !== null) { | ||
// Catch the empty graph being closed when parsing N3. | ||
// In this case, we emit the empty graph as the value "true"^^xsd:boolean | ||
if (!this._predicate && !this._object) { | ||
const outerGraph = this._contextStack[this._contextStack.length - 1].graph; | ||
this._emit( | ||
graph, | ||
this._namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#value'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want to use a constant for this. |
||
this._literal('true', this._namedNode('http://www.w3.org/2001/XMLSchema#boolean')), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want to use a constant for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was an error on my part. |
||
outerGraph | ||
); // Restore the parent context containing this formula | ||
} | ||
else { | ||
this._emit(this._subject, this._predicate, this._object, graph); | ||
} | ||
} | ||
|
||
// Restore the parent context containing this formula | ||
this._restoreContext('formula', token); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it sufficient to check that there is no predicate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The predicate check should be sufficient, as the flow goes as follows:
at the start of the formula the
this._readSubject
function is called. This one sets the this._predicate value to null.As the token here is
}
, thethis._readPunctuation
function is called, that then calls thethis._readFormulaTail
function.In here, we find this code. So I concluded that we should only check on the
this._predicate
value being null, and not thethis._object
, as the predicate value alone should be enough of an indicator and I am unsure how the object gets there in all flows.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. so let's do
if (this._predicate === null)
indeed.