- From: Gregg Kellogg <gregg@greggkellogg.net>
- Date: Sat, 16 Mar 2013 14:08:46 -0700
- To: "public-rdf-wg@w3.org WG" <public-rdf-wg@w3.org>, JSON-LD JSON <public-linked-json@w3.org>
(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?). = 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 = 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 Saturday, 16 March 2013 21:09:15 UTC