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

Re: XProc document templates - a question about undeclared variables

From: Norman Walsh <ndw@nwalsh.com>
Date: Mon, 08 Nov 2010 09:37:41 -0500
To: XProc Dev <xproc-dev@w3.org>
Message-ID: <m28w1398zu.fsf@nwalsh.com>
Philip Fennell <Philip.Fennell@marklogic.com> writes:

> Florent,
>
>> 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.

Not quite. If the input was

  ... element {{$foo}} {$param} ...

The output would be

  ... element {$foo} whatever the param variable was ...

Of course, if you want to interpolate XQuery (or XSLT) with p:document-template,
yes things are going to get a little complicated. For example, unless $param
already contains curly braces, you probably need something like this:

  ... element {{$foo}} {{{$param}}} ...

So that there are curly braces in the resulting XQuery. And, even worse,
if you've got a mixture of markup in there, I'm not sure you'd get the
right escaping of markup characters.

If you're going to send the result through XQuery, it's probably easier to
just declare the variables that you want to come from XProc as external
and do all the interpolation in XQuery:

  declare variable $param external;
  ...
  let $foo as xs:string := 'bar'
  return
    element {$foo} {$param}

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
www.marklogic.com

Received on Monday, 8 November 2010 14:38:15 GMT

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