RE: JSON-LD in HTML

Hi,

just saw this thread and haven't thought much about it yet.. So just two
questions (no offence intended):

- What problem are why trying to solve here? I mean which use case are we
trying to address? Why would someone want to embed JSON-LD in HTML? I
haven't seen much JSON embedded into HTML in the wild.. and JSON is
extremely popular.

- If we are embedding JSON-LD (not JSON), why do we need to add another
mechanism to reference a context? People embedding JSON-LD obviously need to
understand it.. so what's the problem with @context?


Cheers,
Markus


--
Markus Lanthaler
@markuslanthaler




> -----Original Message-----
> From: Ivan Herman [mailto:ivan@w3.org]
> Sent: Sunday, March 17, 2013 12:28 PM
> To: Niklas Lindström
> Cc: Gavin Carothers; Gregg Kellogg; public-rdf-wg@w3.org WG; JSON-LD
> JSON
> Subject: Re: JSON-LD in HTML
> 
> 
> On Mar 17, 2013, at 12:13 , Niklas Lindström <lindstream@gmail.com>
> wrote:
> 
> > How about:
> >
> >    <link rel="http://www.w3.org/ns/json-ld#context"
> > href="http://schema.org/context.jsonld" />
> >
> > Perhaps more precise with an @about and a script @id, like:
> >
> >    <link about="#jsonld" rel="http://www.w3.org/ns/json-ld#context"
> > href="http://schema.org/context.jsonld" />
> >    <script type="application/ld+json" id="jsonld">...</script>
> 
> The goal is to make JSON-LD palatable and usable for people outside
> 'our' community. I am a little bit afraid that this approach would lead
> to errors (missing <link> statements, that sort of things).
> 
> :-(
> 
> Ivan
> 
> >
> > Cheers,
> > Niklas
> >
> >
> > On Sun, Mar 17, 2013 at 11:46 AM, Ivan Herman <ivan@w3.org> wrote:
> >>
> >> On Mar 17, 2013, at 04:13 , Gavin Carothers <gavin@carothers.name>
> wrote:
> >>
> >>>
> >>>
> >>>
> >>> On Sat, Mar 16, 2013 at 2:08 PM, Gregg Kellogg
> <gregg@greggkellogg.net> wrote:
> >>> (Retry, as my mailer seemed to have chosen a personal email address
> to send it out before. Sorry if it comes twice).
> >>>
> >>> This proposal provides a means for embedding JSON-LD in HTML
> documents, =
> >>> much in the same way that Turtle can be embedded in HTML documents.
> This =
> >>> is important for certain constituencies who have shown problems in
> =
> >>> providing correct RDFa or microdata, but who are familiar with
> JSON. =
> >>> Embedding JSON-LD in HTML, along with a JSON-LD context, allows
> fairly =
> >>> straight-forward JSONto be used for specifying metadata within an
> HTML =
> >>> document.
> >>>
> >>> The use of the @data-context attribute below is not ideal, as
> @data-* =
> >>> attributes are intended for use by other specifications, but it
> seems =
> >>> inappropriate to either re-purpose some existing HTML (or
> HTML+RDFa) =
> >>> attribute, or to define a new attribute specifically for this
> narrow =
> >>> case.
> >>>
> >>> After section 6.8 in JSON-LD Syntax, add the following section:
> >>>
> >>> Section 6.9 (new/non-normative) Embedding JSON-LD in HTML documents
> >>>
> >>> HTML script tags can be used to embed blocks of data in documents.
> =
> >>> JSON-LD can be easily embedded in HTML this way.
> >>>
> >>> <script type=3D"application/ld+json">
> >>> {
> >>> "@context": {
> >>>  "@vocab": "http://purl.org/vocab/frbr/core#",
> >>>  "@language": "en",
> >>>  "dc": "http://purl.org/dc/terms/",
> >>> },
> >>> "@id": "http://books.example.com/works/45U8QJGZSQKDH8N",
> >>> "@type": "Work",
> >>> "dc:creator": "Wil Wheaton",
> >>> "dc:title": "Just a Geek",
> >>> "realization": [{
> >>>  "@id": "http://books.example.com/products/9780596007683.BOOK",
> >>>  "@type": "Expression";
> >>>  "dc:type": "http://books.example.com/product-types/BOOK"
> >>> }, {
> >>>  "@id": "http://books.example.com/products/9780596802189.EBOOK"
> >>>  "dc:type": "http://books.example.com/product-types/EBOOK"
> >>> }]
> >>> }
> >>> </script>
> >>>
> >>> JSON-LD content should be placed in a script element with the @type
> =
> >>> attribute set to application/ld+json. For text/html, text inside of
> the =
> >>> script tags does not need to be escaped (issue: use CDATA for
> XHTML?). =
> >>>
> >>> http://dev.w3.org/html5/html-xhtml-author-guide/#script-and-style
> No, XHTML for the web can non contain script tags that contain any form
> of < or & or ]]> or --. JSON does not provide for anyway to escape
> those that I'm aware of, therefor you basically can't use JSON-LD
> inside an XHTML document intended for the web.
> >>>
> >>> ... everything else sounds great! Well... except...
> >>>
> >>> The character encoding of the embedded JSON-LD fragment will match
> the =
> >>> HTML documents encoding.
> >>>
> >>> If a processor extracts the JSON-LD content into RDF, it should
> expand =
> >>> the JSON-LD fragment into an RDF dataset using the algorithm
> defined in =
> >>> [JSON-LD-Processing] section 10.6 "Convert to RDF Algorithm". If
> the =
> >>> HTML file contains multiple JSON-LD script tags, or other RDF
> statements =
> >>> are extracted, the result is the RDF merge of the datasets.
> >>>
> >>> Other processors implementing this mechanism may choose to expand
> the =
> >>> JSON-LD and return the expanded JSON-LD output.
> >>>
> >>> Section 6.9.1 Specifying Remote Context
> >>>
> >>> In addition to the mechanism defined in section 6.9, if the =
> >>> @data-context attribute is present on the script element, its value
> is =
> >>>
> >>> @data-* SHOULD/MUST? not be used for this.
> >>>
> >>> "These attributes are not intended for use by software that is
> independent of the site that uses the attributes."
> >>>
> >>
> >> Having been part of the initial discussions on this, I have found
> exactly the same problem. However... at this point I am not sure what
> the alternatives are. We can do three things:
> >>
> >> - introducing our own attribute, eg, @context; but that is a big no-
> no with the HTML WG, and it would take a loooong time to convince them
> of the necessity of one (consider the raws that surrounded @longdesc,
> @role, or the RDFa attributes). These examples worked out but for
> standard only, whereas this proposal is for an informal feature, much
> like Turtle in HTML. Bottom line: that has no chance of getting
> through, meaning that resulting HTML files would be invalid.
> >> - re-using an RDFa attribute, namely @vocab. But that means that
> validation of such a file would require validating an HTML file with an
> RDFa flag (eg, when validator.nu is used) which is strange because this
> feature has nothing to do with RDFa. And, apart from validation, it is
> conceptually wrong to reuse an attribute that has nothing to do with
> RDFa but which would introduced _for_ RDFa. So this may not be an
> option after all
> >> - using the data-* mechanism which, well, has the drawback you
> mention.
> >>
> >> We have not found any other approach:-( Anybody has a bright idea?
> >>
> >> Ivan
> >>
> >>
> >>> Cheers,
> >>> Gavin
> >>>
> >>>
> >>> provided to the JSON-LD processor in a manner equivalent to the =
> >>> treatment of the HTTP Link Header with the =
> >>> http://www.w3.org/ns/json-ld#context link relation as specified in
> =
> >>> section 6.8, except that the inline specified JSON-LD need not have
> have =
> >>> embedded context information. For example:
> >>>
> >>> <script type=3D"application/ld+json" data-
> context=3D"http://schema.org/">
> >>>
> >>
> >>
> >> ----
> >> Ivan Herman, W3C Semantic Web Activity Lead
> >> Home: http://www.w3.org/People/Ivan/
> >> mobile: +31-641044153
> >> FOAF: http://www.ivan-herman.net/foaf.rdf
> >>
> >>
> >>
> >>
> >>
> >>
> >
> 
> 
> ----
> Ivan Herman, W3C Semantic Web Activity Lead
> Home: http://www.w3.org/People/Ivan/
> mobile: +31-641044153
> FOAF: http://www.ivan-herman.net/foaf.rdf
> 
> 
> 
> 

Received on Sunday, 17 March 2013 14:38:56 UTC