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

RE: XProc document templates - a question about undeclared variables

From: Philip Fennell <Philip.Fennell@marklogic.com>
Date: Mon, 8 Nov 2010 06:48:22 -0800
To: Norman Walsh <ndw@nwalsh.com>, XProc Dev <xproc-dev@w3.org>
Message-ID: <D20C296D14127D4EBD176AD949D8A75A46E7E5EE@EXCHG-BE.marklogic.com>

I guess then that I hadn't fully taken in the third expression in you example such that any XPath expression could be evaluated, not just attempting to bind variables to parameters.

In that case Florent's suggestion does actually make sense.



-----Original Message-----
From: xproc-dev-request@w3.org [mailto:xproc-dev-request@w3.org] On Behalf Of Norman Walsh
Sent: 08 November, 2010 2:38 PM
To: XProc Dev
Subject: Re: XProc document templates - a question about undeclared variables

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'
    element {$foo} {$param}

                                        Be seeing you,

Norman Walsh
Lead Engineer
MarkLogic Corporation
Received on Monday, 8 November 2010 14:48:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:03:07 UTC