- From: Gavin Carothers <gavin@carothers.name>
- Date: Sat, 16 Mar 2013 20:13:15 -0700
- To: Gregg Kellogg <gregg@greggkellogg.net>
- Cc: "public-rdf-wg@w3.org WG" <public-rdf-wg@w3.org>, JSON-LD JSON <public-linked-json@w3.org>
- Message-ID: <CAPqY83xCwctAnrg_R3tztHwJ9urzoEii0LZO8tf=_ODyNN0qAQ@mail.gmail.com>
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." 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/"> >
Received on Sunday, 17 March 2013 03:13:43 UTC