Re: Data Literals

On Wed, Feb 24, 2016 at 11:07 AM, Henry S. Thompson <ht@inf.ed.ac.uk> wrote:
> Further to the discussion just now, and thanks to Alex for the link to
> moustache [1], I claim that e.g.
>
> data "application/json" '{"fruit": "orange"}' -> x:mustache($options)>> $output
>
> works only because it includes no actual templating, so functions as the
> identity step, and e.g.

That should never work because mustache operates on strings.

>
> let $options := {"count" : count($source/*/para)}
> data "application/json" '{"numParas" : {{count}}}' -> x:mustache($options)
>
> will just cause a JSON parse error, before it ever gets to the mustache step.

Yes.  That is correct as the literal is not JSON.

Lacking a media type for mustache, expect this to work as:

 let $options := {"count" : count($source/*/para)}
 data "text/plain" '{"numParas" : {{count}}}' -> x:mustache($options)
-> parse-json()


-- 
--Alex Miłowski
"The excellence of grammar as a guide is proportional to the paucity of the
inflexions, i.e. to the degree of analysis effected by the language
considered."

Bertrand Russell in a footnote of Principles of Mathematics

Received on Wednesday, 24 February 2016 23:07:06 UTC