-
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
Literals should be valid subjects in text/n3 #328
Comments
Are you sure this is an issue? I happen to be looking into something related and can confirm that the following code does not throw an error: const n3 = `"1"^^<http://www.w3.org/2001/XMLSchema#boolean> <http://example.com/p> <https://example.com/s> .`;
const parser = new Parser({ format: 'text/n3' });
const store = new Store(parser.parse(n3)); It does throw an error if you use |
The example complains if we just have a plain string const n3 = `"1" <http://example.com/p> <https://example.com/s> .`;
const parser = new Parser({ format: 'text/n3' });
const store = new Store(parser.parse(n3)); with the following log
|
@joachimvh I've been having some more fun with this ... I think the following dupes #329 - but for completeness import { Parser, Writer } from 'n3';
const parser = new Parser({ format: 'text/n3' });
const writer = new Writer({ format: 'text/n3' });
console.log(writer.quadsToString(parser.parse('true => true .'))) writes (note the lack of braces on the datatype) "true"^^http://www.w3.org/2001/XMLSchema#boolean <http://www.w3.org/2000/10/swap/log#implies> true . import { Parser, Writer } from 'n3';
const parser = new Parser({ format: 'text/n3' });
console.log(parser.parse('{} => true .')) outputs a quad with undefined subject predicate and object [
Quad {
id: '',
_subject: undefined,
_predicate: null,
_object: undefined,
_graph: BlankNode { id: '_:n3-0' }
},
Quad {
id: '',
_subject: BlankNode { id: '_:n3-0' },
_predicate: NamedNode { id: 'http://www.w3.org/2000/10/swap/log#implies' },
_object: Literal { id: '"true"^^http://www.w3.org/2001/XMLSchema#boolean' },
_graph: DefaultGraph { id: '' }
}
] and consequently crashes if you try to re-serialize it. |
As an actionable item could we please get the following tests passing in N3Parser-test.js describe('A Parser instance for the N3 format', () => {
function parser() { return new Parser({ baseIRI: BASE_IRI, format: 'text/n3' }); }
it('should parse an integer literal as subject',
shouldParse(parser, '1 <a> <b>.', ['"1"^^http://www.w3.org/2001/XMLSchema#integer', 'a', 'b']));
it('should parse a string literal as subject',
shouldParse(parser, '"1" <a> <b>.', ['"1"', 'a', 'b']));
it('should parse a string literal as subject list element',
shouldParse(parser, '("1") <a> <b>.',
['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '"1"'],
['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
['_:b0', 'a', 'b']));
it('should parse a string literal as object list element',
shouldParse(parser, '<a> <b> ("1") .', ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '"1"'],
['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
['a', 'b', '_:b0']));
it('should parse a string literal as predicate',
shouldParse(parser, '<a> "1" <b>.', ['a', '"1"', 'b']));
it('should parse a string literal as object',
shouldParse(parser, '<a> <b> "1".', ['a', 'b', '"1"']));
}); |
And a test case for |
See eyereasoner/eye#76 (comment). Currently an error is thrown when they are encountered.
The text was updated successfully, but these errors were encountered: