RE: XProc document templates - a question about undeclared variables

Norm,

> The template isn't evaluated as an XQuery module, it's simply passed 
> through with curly-brace delimited expressions evaluated.

Yes I understand that.

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

Yes, I understand that too. I was talking conceptually with respect to the variable $foo.


Regards

Philip

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

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 declaration.

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,
                                          norm

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

Received on Monday, 8 November 2010 14:45:31 UTC