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
JSON-LD in HTML #231
Comments
An alternative would be to define an alias for <script type="application/ld+json">
{
"@context": "http://example.org/context.jsonld",
"data": {
"name": "Gregg Kellogg"
}
}
</script> |
RESOLUTION: Add the JSON-LD in HTML feature to the JSON-LD Syntax specification without support for |
One alternative to @data-context which has no real support, would be to combine the context along with the mime type in the @type attribute. According to the definition of valid MIME Type in HTML5, a mime-type can contain type parameters. If we were to add back a media parameter to specify the context, we could potentially do something like the following, which does not rely on any additional attribute:
One concern about specifying the context outside of the fragment itself is that if it were missing, some agents may choose to assume that it was intended (e.g., http://schema.org). This could be quite dangerous, the sense of the group is to not support this, but require that the context be included in the document itself. This could be done generically as follows:
Provided that "data", in this case, is aliased to "@graph". The ensures that the document content will always be interpreted as JSON-LD, and will survive copy-paste into some other tool. |
Gregg, have you perhaps already checked how quoting of the value of the context media type parameter works in that case? Usually you would have to wrap the value in quotes, but in this case you can’t because the whole media type (including the parameter) is already in quotes. |
RFC 2616 makes no recommendations on quoting parameters; it has very little to say at all. I believe this is up to the format definition to describe what quoting and/or escaping requirements are. Of course, you could use quotes within quotes, either escaping them, or using "'" instead of '"', but I would say that we would require the value to be URI escaped, and explicitly unescaped prior to dereference; for most cases, this won't be necessary. |
Yes. Specifically, according to RFC 2616, section 3.7:
In section 3.6, (non-token) attribute values are defined as <script type='application/ld+json;context="http://schema.org/"'>
</script> However, back go Gregg's point. The "MAY" in 3.7 means that we can get away with another form. Granted, perhaps that in turn might cause trouble in some mime-type parser implementations. That remains to be tested. Otherwise, this possibility (using a mime-type parameter for the context) seems feasible. |
@gkellogg, was there a reason why you choose such a complex example? If not, I think this is much simpler and illustrates the mechanisms just as well. I've also removed the part which says "For text/html, text inside of the script tags does not need to be escaped." Which is wrong, see http://www.w3.org/TR/html5/scripting-1.html#restrictions-for-contents-of-script-elements This addresses #231.
This is something completely orthogonal to the rest of the spec. I think moving it to the end makes that text flow better. This addresses #231.
Looks like in HTML5 using double-quotes inside single quotes is the preferred way to deal with this, see e.g. HTML5's source element: <source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'> The MAY in RFC2616 just means that there may be parameters or there may be none. It is very clear about the fact that non-token values have to enclosed in double quotes.
That being said, I would still prefer to require that the |
True, it's either double quoted or no parameters (I read that "MAY" way too late at night). It would be nice to have a way of specifying the context out-of-band here in a simple way. And the mime-type with quoted parameters seems most correct, though arguably cumbersome in an HTML attribute. It's interesting to see the same pattern used in the (I think it's a nice feature for content negotiation as well. With support for specifying a context in JSON-LD-based mime-types, a client can request a specific form which it either has (or is prepared to fetch) the context definition for, or whose "surface syntax" is sufficient for its needs.) Perhaps an option is to support this form, and also define the token form to have special meaning; specifically a domain name? E.g.: <script type="application/ld+json; context=schema.org"> could imply a content-negotiable context at |
In my (cursory) review of the RFC, I looked for, but didn't find the detailed syntax. Saying "context=schema.org" has a clear meaning, so having it expand to an IRI would clearly be the intention, and in-line with how browsers turn domain names into URLs. I agree that it's better to include the context inline, and we'll see how this resolves. Ideally, we can simply drop the context parameter altogether. |
Sorry, I think I have to disagree. Having such an implicit from to specify a context opens a can of worms. Is it HTTP or HTTPS? Will it use HTML5 URL parsing or something else.. We should not go down that route but try to advocate the use of @context inside the document. |
I did ask this already in c728c6b but would like to record it also here as commit discussions are somewhat difficult to find and I don't wanna forget this. The section currently says:
Markus: Can we drop this part? I think it doesn't add much value but sounds overly complicated for people just wanting to use it as JSON-LD. Gregg: It's important to give guidance when there are multiple script tags, so that the result is clear. We could say that the result is the merge of all such documents. When extracting RDF, JSON-LD could be combined with other formats (microdata, RDFa, Turtle in HTML). In this case, it's also necessary to say what the expected result it. Without this statement, it won't be clear what to do. Markus: I understand where you are coming from, but that’s an orthogonal aspect that is application dependent. In our spec we should define how JSON-LD can be embedded in HTML. How such data is used is beyond the scope of this spec. I would strongly prefer to remove this part. |
See also discussion at http://lists.w3.org/Archives/Public/public-linked-json/2013Mar/0038.html This addresses #231.
See also discussion at http://lists.w3.org/Archives/Public/public-linked-json/2013Mar/0038.html |
The section has been added to the syntax specification. Unless I hear objections, I will close this issue in 24 hours. |
@gkellogg proposed a new, non-normative feature that would allow JSON-LD to be embedded in HTML documents:
http://lists.w3.org/Archives/Public/public-linked-json/2013Mar/0019.html
The feature would allow developers to embed JSON-LD by doing something like this:
The text was updated successfully, but these errors were encountered: