Re: Reflection on the special telco of CSVW - more details on Alternative 2.5

On Sep 17, 2014, at 11:50 AM, Ivan Herman <ivan@w3.org> wrote:
> 
> 
>> On 17 Sep 2014, at 12:42 , Dan Brickley <danbri@google.com> wrote:
>> 
>>> On 10 September 2014 08:58, Ivan Herman <ivan@w3.org> wrote:
>>> 
>>> As a followup on my previous mail...
>>> 
>>> I wanted to see whether it is complicated to implement a very simple template (Alternative 2.5 in [1]) using existing tools, ie, to make it quickly available, with some extra work, to the community at large. I think the answer is yes;
>> 
>> Personal opinion: I think the answer is 'yes' too, after some similar
>> experimentation and talking to a bunch of people. I believe we have a
>> very good chance of doing substantially better than 100% mechanistic
>> mappings, roughly around the level of Mustache ("Logic-less", but with
>> simple conditionals) with some regex pre-processing and a few
>> W3C-oriented supporting functions.
> 
> Actually, what I have is even simpler. In the 'filtered-templates' branch of the repo[1] what I have in the readme is:
> 
> [[[
> - `{{#rows}}` - `{{\rows}}` (where `rows` is a fixed symbol) at the beginning of a line means that the full templates enclosed between these two lines are to be repeated for all rows of the CSV content.
> - `{{name}}` has two possible roles:
>    - if used *within* a `{{#rows}}` - `{{\rows}}` context, `{{name}}` refers to a column name, and the template is replaced with the content of the corresponding cell
>    - if used *outside* a `{{#rows}}` - `{{\rows}}` context, `{{name}}` refers to a top-level key in the metadata **if its value is a string**; the template is replaced with the corresponding value
> - `{{name}}` can also have *filters*. The tag can have the format: ``{{name.f1.f2.….fn}}``, where ``f1,…,fn`` are filter functions. A filter function may have argument, i.e., it may look like ``fi("a","b")``; the arguments are strings surrounded by the ``"`` or the ``'`` characters. If there are no arguments, the argument list can be dropped altogether. Filter functions are invoked with: the output of the previous filter or the value corresponding ``{{name}}``; the reference to the metadata object; the list of the arguments (strings) if applicable. The filter function must return a replacement for the template value.
> 
> The list of available filter functions will be specified by the WG, and a mechanism to add a user-defined filter will be provided. At present, there are only a few filters, these are ``upper``, ``lower``, ``concat(str)``, ``replace(regexp,str)``.
> ]]]
> 
> That is it. Ie, no conditional and variables, nor any regex preprocessing (except for the "replace" filter)

+1 modulo referencing micro syntax expressions and substitution patterns, although there may be a simpler way to accomplish this.

Gregg

> Ivan
> 
> 
> [1] https://github.com/w3c/csvw/tree/filtered-templates
> 
> 
> 
>> I believe there is also a very good chance that a *simple* technology
>> like this will be picked up by search engines as a way of getting
>> graph-oriented data (schema.org and suchlike). But I also believe that
>> we could find this effort bedevilled by creeping complexity and that
>> there's some risk it might not make it to W3C REC. It's worth trying
>> though!
>> 
>> </opinion>
>> 
>> Dan
>> 
>> 
>>> look at:
>>> 
>>> https://github.com/w3c/csvw/tree/gh-pages/experiments/simple-templates-jquery
>>> 
>>> for further details. See
>>> 
>>> https://github.com/w3c/csvw/tree/gh-pages/experiments/simple-templates-jquery/simple_test
>>> 
>>> for the test I used so far.
>>> 
>>> The implementation is rough at the edges, and I am still in the process to make it a bit better code-wise. But that still gives, I hope, an idea of where this *may* go.
>>> 
>>> [1] http://lists.w3.org/Archives/Public/public-csv-wg/2014Sep/0006.html
>>> 
>>> ----
>>> Ivan Herman, W3C
>>> Digital Publishing Activity Lead
>>> Home: http://www.w3.org/People/Ivan/
>>> mobile: +31-641044153
>>> GPG: 0x343F1A3D
>>> WebID: http://www.ivan-herman.net/foaf#me
> 
> 
> ----
> Ivan Herman, W3C 
> Digital Publishing Activity Lead
> Home: http://www.w3.org/People/Ivan/
> mobile: +31-641044153
> GPG: 0x343F1A3D
> WebID: http://www.ivan-herman.net/foaf#me
> 
> 
> 
> 
> 

Received on Wednesday, 17 September 2014 12:24:31 UTC