W3C home > Mailing lists > Public > xproc-dev@w3.org > November 2010

Re: XProc document templates - a question about undeclared variables

From: Alex Muir <alex.g.muir@gmail.com>
Date: Mon, 8 Nov 2010 15:05:01 +0000
Message-ID: <AANLkTin8-eYuC6VwpTVt+9WRX3xWpK6+Pd51RA7P-iA3@mail.gmail.com>
To: Florent Georges <fgeorges@fgeorges.org>
Cc: Philip Fennell <Philip.Fennell@marklogic.com>, XProc Dev <xproc-dev@w3.org>
I use 3 tilda to surround the placeholder/parameter in my templates.

Something that is unlikely to exist elsewhere and easily spotted..

~~~variableName~~~

Also configurable is the regex to identify the placeholder/parameter.
Having this configurable somewhere may add complexity but may be a nice
feature for users given they would likely just set it once to something they
like and forget it.

<configuration parameterMarkerRegex="~~~([^~]*?)~~~">









On Mon, Nov 8, 2010 at 2:56 PM, Florent Georges <fgeorges@fgeorges.org>wrote:

> On 8 November 2010 14:15, Philip Fennell wrote:
>
> >> If you want the resulting document to contain the 6 chars {,
> >> $, f, o, o and }, then you have to escape the curly braces by
> >> doubling them: {{$foo}}.
>
> > If that were the case then I'd have to un-escape the expression
> > before I tried to evaluate the query using p:xquery. I'd be
> > exchanging one complication for another.
>
>   I am not quite sure we are actually speaking about the same
> thing.  Let's say we have the following passed to the step
> p:document-template:
>
>    <elem>{{ $foo }}</elem>
>
> This will resolve in the following:
>
>    <elem>{ $foo }</elem>
>
> which, if it is in turn passed to the xquery step, will resolve
> to (say $foo is bound to 42 in the query):
>
>    <elem>42</elem>
>
>  That's the principle of double-escaping we find in any language
> generating another piece of code (in the same language or
> another).  Here, if you try to generate XQuery (which uses curly
> braces as special characters), you need to escape them in the
> step p:document-template (which also use the curly braces as
> special characters).
>
>  Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
>
>
Received on Monday, 8 November 2010 15:05:29 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 8 November 2010 15:05:30 GMT