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:33:44 -0500
To: XProc Dev <xproc-dev@w3.org>
Message-ID: <m2d3qf996f.fsf@nwalsh.com>
Philip Fennell <Philip.Fennell@marklogic.com> writes:
> What would happen if I had chosen to in-line an XQuery main module
> in the document template thus (completely arbitrary example but
> illustrates the problem):
> <p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
>             xmlns:c="http://www.w3.org/ns/xproc-step"
>             name="main" version="1.0">
>   <p:option name="param" required="true"/>
>   <p:in-scope-names name="vars"/>
>   <p:document-template>
>     <p:input port="template">
>       <p:inline>
>         <c:query>
>           xquery version "1.0" encoding "utf-8";
>           let $foo as xs:string := 'bar'
>           return 
>             element {$foo} {$param}
>         </c:query>
>       <p:/inline>
>     </p:input>
>     ...

The template isn't evaluated as an XQuery module, it's simply passed
through with curly-brace delimited expressions evaluated. So that example
would raise an error when {$foo} was encountered, because there's no variable
(from p:in-scope-names) that's named "foo".

> Here I have two XPath expressions containing variable names, one of
> which is bound to the XQuery let declaration and the other to the
> XProc pipeline option.

The p:document-template step knows from nothing about the XQuery

Two of the alternatives to p:document-template are to use an XQuery
step, but that requires all sorts of escaping in the general case, and
to use an XSLT step (with a simplified stylesheet).

                                        Be seeing you,

Norman Walsh
Lead Engineer
MarkLogic Corporation

Received on Monday, 8 November 2010 14:34:21 UTC

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