Re: XProc document templates - a question about undeclared variables

  Hi,

  If you want {$foo} to be resolved in the resulting document
(regardless it is an XQuery embedded in an XML document or whatever),
just leave it as {$foo}.  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}}.

  This is the same rule as in XQuery or as for XSLT's AVTs.

  Regards,

-- 
Florent Georges
http://fgeorges.org/


On 8 November 2010 14:00, Philip Fennell wrote:
> With respect to the recent announcement regarding Document Templates:
>
> <http://norman.walsh.name/2010/11/07/xproc-document-templates>
>
>> The <p:document-template> step searches for XPath expressions, delimited by curly
>> braces, in a template document and replaces each with the result of evaluating the
>> expression. All of the parameters passed to the <p:document-template> step are
>> available as in-scope variable names when evaluating each XPath expression.
>
> 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>
>    ...
>
> 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.
>
> Does the document template step only look for those expressions it has matching parameters for or does it try to evaluate all expressions in curly braces. Would it throw an exception if it didn't find a matching parameter? I guess the same situation would occur in XSLT document templates too where you've used AVTs.
>
>
> Regards
>
>
> Philip Fennell
> Consultant
>
> Mark Logic Corporation
> www.marklogic.com
>
> E-mail: philip.fennell@marklogic.com
> Mobile: +44 (0)7824 830 866
>

Received on Monday, 8 November 2010 14:08:19 UTC