-
Notifications
You must be signed in to change notification settings - Fork 156
JSON-LD grammar #114
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
Comments
RESOLVED: In general, if the author's intent is clear, we should transform the input into proper JSON-LD (keeping the processor mode, if any, in mind - in strict mode, throw exceptions, in lax mode, attempt to interpret the value). |
I think the initial description of the issue was not clear enough, so here's another attempt. While the syntax of JSON-LD is already specified by JSON , the current JSON-LD Syntax spec lacks a formal specification of the allowed grammar, i.e., what constructs are allowed where. The outcome of this issue should be exactly that. This grammar will then form the base for what JSON-LD processors MUST be able to process. Maybe we will also come up with some constructs that are either ignored or automatically corrected. Let me first introduce a number of definitions that I'll use later:
The following description of what I think should be the valid grammar for JSON-LD is a bit a mixture of ABNF, pseudo-code and prose. I hope it's understandable. I numbered the statements so that we can easily reference them.
The question is first of all if we agree on this grammar and secondly what should happen if a input document violates this grammar. Should a processor throw an error and stop processing? Should it ignore that statement (and possible the whole subtree) and try to continue? |
I think if we're going to define a grammar for JSON-LD, we should probably do it in W3C EBNF. It so happens, I'm working on a parser for it, but there are a number of other existing resources. I'll start work on such a grammar myself. It might start something like this:
Establishing specific semantics of possible property/value limitations will be more challenging, but is doable. |
Agree that it should be a bit more formal, but before that we should agree on the grammar itself.. that's what this issue is all about. I'm not so sure that we all agree yet. E.g. 21) and 22) might need some discussion as well as where exactly we allow relative IRIs and where not. |
Does these added rules in the specification currently allow:
It seems that item 8 there doesn't permit it? |
It does:
|
That seems to take care of using it within a JSON object (i.e. in a term definition). But in the case above the value associated with the |
Oh I see, I read it too fast. I think that's included in 7) in the spec. But as I said on the telecon there are things that got lost. Let's discuss based on the list in this issue. It goes a bit around this specific issue since in point 9 is not very well defined what the |
RESOLVED: Express the JSON-LD Grammar in prose with supporting tables/examples. Clarify that violating the grammar does not necessarily mean that a JSON-LD processor will not process the document. |
I think I was the one who initially raised this issue and while I really appreciate Gregg’s efforts, this is not really what I had in mind. Gregg did a terrific job in summarizing the spec from about 35 to roughly 6 pages. Maybe we should look at the spec and try to apply this style in more places. For the grammar section however, I think six pages are still way too much. It’s not really the length that worries me. It’s more the fact that it is still written completely in prose. I agree that EBNF goes too far and isn’t really suitable for such a set of conventions but a short list or some other schema-like description would be more suitable in my opinion. Definitions of what something is and examples shouldn’t be part of a grammar IMO. The grammar should allow an implementer to see all possible values it should expect and thus handle. Everything else should trigger an error. Thoughts? |
The grammar section is not so much an attempt to summarize the spec, as to show the legal productions for each type of syntactic element using something that is not EBNF. The examples are gratuitous, but I was responding to feedback from Andy. If the group feels that the grammar doesn't benefit from repeating usage examples, and that some of the motivation that's included in the grammar are repetitive of normative text in the main body, then I can go along with trimming that out, but I think it makes it easier to read; I think we should solicit feedback from @afs and others in the RDF WG who commented on the grammar. |
I went into the spec with the intent to clean up the JSON-LD Grammar section. After reading through it with fresh eyes, I think it's fine. I agree with the principle of what Markus is saying, which is why I went in trying to clean up the section. However, I don't see how we could apply the principle to the Grammar section and not lose something. I think we should close this issue unless Markus has specific spec text to replace what we have right now. Markus, if you could take what is there right now and do what you did here: That may allow us to resolve this issue once and for all. |
I will do that once the spec is complete, i.e., all other issues have been resolved and the spec has been updated accordingly. I marked this issue as on-hold for the time being. |
RESOLVED: Move all examples in the JSON-LD Grammar section of the spec to the main body and point to them with links. |
As agreed in json-ld#114, I moved all the examples that appeared in the grammar section to the "Basic Concepts" and "Advanced Concepts" sections when appropriate. I dropped examples that were already duplicates of examples in these sections as well as examples that were very close to other examples. The grammar section does not directly link to the examples in the other sections but links to relevant sections each time. That seems enough to me (and that also simplifies things since ReSpec does not naturally create IDs for examples, making it a pain to link to them directly).
As agreed in #114, I moved all the examples that appeared in the grammar section to the "Basic Concepts" and "Advanced Concepts" sections when appropriate. I dropped examples that were already duplicates of examples in these sections as well as examples that were very close to other examples. The grammar section does not directly link to the examples in the other sections but links to relevant sections each time. That seems enough to me (and that also simplifies things since ReSpec does not naturally create IDs for examples, making it a pain to link to them directly). (cherry picked from commit 4710e9a) (cherry picked from commit 9249686) (cherry picked from commit dc1f63f) This addresses #114
@lanthaler @tidoust - where are we on this issue? Do more edits need to be made to the document? |
I think there are still some errors in the grammar section. I will review it as soon as language maps, property generators, and annotations have been added to the spec. |
Language maps are covered in appendix B.3. I believe that addresses all of the remaining issues for the JSON-LD grammar. @tidoust and @lanthaler do you concur? If so, let's send notice out to the mailing list and close this issue. |
I will review it in the coming days.. btw. json-ld.org seems to be down |
json-ld.org is back up - root cause was a power supply failure. ACK on all of your other comments - I'll wait for you to close those issues (although, please make sure to either action me to change stuff that needs to be changed, change the language yourself, or make it clear that something is blocked and needs immediate attention). |
I've reviewed the grammar and fixed the last remaining issues. Unless I hear objections I will therefore close this issue in 24 hours. |
This was "Value space of keywords" before. Pleas read the comment below for an updated description.
In #91 we decided to not change the value space of
@type
but to allow the use ofrdf:type
for use cases that require different forms. Nevertheless, in 67a0909, the algorithms were changed to allow also other forms of@type
. expand-0026-in.jsonld basically contains:So, what do we wanna do with this? Do we wanna allow it or not?
A similar issue exists for the
@graph
keyword. Do we wanna allow@value
objects there? So, would the following snippet be valid?Just to make sure we all agree on the value space of all of our keywords, here a list of what I think is the value space (perhaps we should include this in some form in the syntax spec):
@context
: (array of) object | string@graph
: (array of) object (not@value
,@list
,@set
objects) | string@id
: string@value
: string | number | boolean | null@language
: string@type
: (array of) string@container
: string@list
: (array of) object | string | number | boolean | null@set
: (array of) object | string | number | boolean | nullThe text was updated successfully, but these errors were encountered: