W3C home > Mailing lists > Public > public-csv-wg@w3.org > June 2014

RE: How to distinguish field (cell) references in JSON, and other questions about templates

From: Tandy, Jeremy <jeremy.tandy@metoffice.gov.uk>
Date: Thu, 12 Jun 2014 09:00:23 +0000
To: Gregg Kellogg <gregg@greggkellogg.net>
CC: "public-csv-wg@w3.org" <public-csv-wg@w3.org>, Andy Seaborne <andy@apache.org>
Message-ID: <2624871D9A05174691BD59F8EFD68AE208847080@EXXCMPD1DAG3.cmpd1.metoffice.gov.uk>
Thanks Gregg. The summary: "braces are sufficient for the templates in all syntaxes".

Regards, Jeremy

> -----Original Message-----
> From: Gregg Kellogg [mailto:gregg@greggkellogg.net]
> Sent: 11 June 2014 16:06
> To: Tandy, Jeremy
> Cc: public-csv-wg@w3.org; Andy Seaborne
> Subject: Re: How to distinguish field (cell) references in JSON, and
> other questions about templates
> 
> On Jun 11, 2014, at 3:17 AM, "Tandy, Jeremy"
> <jeremy.tandy@metoffice.gov.uk> wrote:
> >
> > Hi - having read through the [Generating RDF from Tabular Data on the
> Web][1] doc, I wonder how the [field references][2] work in a JSON
> template ...
> >
> > (aside: should "field references" now be "cell references" given last
> > week's agreement on terminology?)
> >
> > The field reference is a column (short) name enclosed in braces; but
> JSON also makes extensive use of braces. How would an application
> reading a JSON template distinguish a field reference from normal JSON?
> 
> I think this was captured on the call today; the template mechanism
> works over text, rather than JSON, so the fact that JSON also uses
> curly braces does not factor in. Basically, a template has a possible
> prefix (e.g., '=') followed by a string that MUST denote a column
> heading, followed by an optional modifier starting with a colon (':'),
> all enclosed in curly bracess. Note that this can't match valid JSON,
> where the curly brace will always precede a double quote ('"') with
> optional white space.
> 
> > Perhaps a the "template" definition in the CSV metadata should
> specify the character used to enclose field references?
> 
> Unnecessary complication, IMO. Plus, we're simply leveraging the URI
> Template RDF, which uses curly braces.
> 
> > Assuming the JSON syntax from the [Metadata Vocabulary][3] doc e.g.
> >
> > ...
> >  "template ": {
> >    "name": "My JSON transformation template",
> >    "source": "my-json-template.json",
> >    "hasFormat": "application/json",
> >    "description": "blah blah blah",
> >    "type": "template",
> >    "cell-ref-enclosure": ["%%","%%"]
> >  }
> > ...
> >
> > The keys are taken from the list in the Metadata Vocabulary (these
> are from Dublin Core Terms), with the exception of "cell-ref-enclosure"
> which I've used to specify the "cell reference escape character
> sequence"; I think there must be a better name!
> >
> > The value must be an array of length 2; the start and finish
> character might not be the same: e.g. the default brace enclosure would
> be:
> > ...
> >    "cell-ref-enclosure": ["{","}"]
> > ...
> >
> > Given the escape sequence "%%" & "%%"; the JSON template might then
> include statements like:
> >
> > ...
> >  "result": {
> >      "def-op:airTemperature_C": { "value": "%%air-temp%%" },
> >      "def-op:dewPointTemperature_C": { "value": "%%dew-point%%" }  }
> > ...
> >
> > You'll also notice that I've assumed that the template is not
> _inlined_ in the CSV metadata document; I've used (perhaps incorrectly)
> "source" to refer to the target.
> >
> > It also occurs to me that the template definition in the CSV metadata
> should specify the Content-Type created by a target transformation - a
> given CSV metadata doc might include references to multiple
> transformation templates; and users should be able to ask for _one_ of
> those by name. I've used "hasFormat" to specify this.
> 
> That would be useful, particularly given the templates process simple
> text strings. We should also describe how the result is treated if it
> is not valid for the specified content-type.
> 
> Gregg
> 
> > Jeremy
> >
> > [1]: http://w3c.github.io/csvw/csv2rdf/
> > [2]: http://w3c.github.io/csvw/csv2rdf/#dfn-field-reference
> > [3]: http://w3c.github.io/csvw/metadata/index.html
Received on Thursday, 12 June 2014 09:00:51 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:21:40 UTC