Re: RDF Test Cases Bug: The N-Triples Grammar is Ambiguous

On 11/1/07, Sean B. Palmer <sean@miscoranda.com> wrote:

> As far as I can tell, the N-Triples specification does provide a
> means of interpretation.

That was a typo: I meant of course that it *doesn't* provide a means
of interpretation. I've checked the specification of the EBNF grammar
that is used:

http://www.w3.org/TR/REC-xml/#sec-notation

And it doesn't way whether productions are greedy or not, but clearly
any interpretation would depend on matters such as that, and the fact
that only valid RDF URI references are allowed in the circumstance.

So my test case was as follows:

<p:> <> <q:> <> <r:> <> "s" .

And there are at least four ways of interpreting this:

[<p:> <> <q:> <> <r:>] [<>] ["s"] .
- Greedy, invalid RDF URI references

[<p:> <> <q:> <>] [<r:> <>] ["s"] .
- Greedy and valid RDF URI references

[<p:>] [<> <q:> <> <r:> <>] ["s"] .
- Non-greedy, invalid RDF URI references

[<p:> <>] [<q:> <> <r:> <>] ["s"] .
- Non-greedy, valid RDF URI references

The stakes here are that depending on what the interpretation is, it
mightn't be possible to express various RDF Graphs using N-Triples,
which, as far as I know, is supposed to be able to represent all
possible RDF Graphs.

For example, say we go with the following interpretation:

[<p:> <>] [<q:> <> <r:> <>] ["s"] .

Then how do you express the following?

[<p:> <> <q:> <>] [<r:> <>] ["s"] .

Whatever the resolution, this will undoubtedly make compliant
N-Triples parsing a lot harder than it prima facie appears if parsing
depends on checking whether potential resulting RDF URI references are
valid.

-- 
Sean B. Palmer, http://inamidst.com/sbp/

Received on Thursday, 1 November 2007 10:56:45 UTC