XProc document templates - a question about undeclared variables

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:00:48 UTC