Parameter types (Was: Re: Variables and parameters)

Hi,

Norm Walsh wrote:
> / Jeni Tennison <jeni@jenitennison.com> was heard to say:
> | If parameters could be documents then I'd be left wondering what the
> | difference was between an input document and a parameter document? Are
> | there additional restrictions, such as parameter documents being
> | static (not generated by the pipeline)? Or perhaps parameters can be
> | left unset (and have a default) whereas inputs can't?
> 
> Yes, I think those are the two areas where we'd have to say something.
> Actually, I'd be inclined to allow parameter documents to be generated
> by the pipeline. The only distinction would be that parameters would
> be optional.

Thinking about it, I'm not sure that saying inputs are required and 
parameters optional really works as a distinction: I think there are 
some "inputs" that should be optional. For example, the initial source 
document for an XSLT 2.0 transformation should be optional (I have loads 
of stylesheets that are initiated by calling a named template rather 
than processing a document node), but it feels really weird calling that 
a parameter.

> The use case that keeps me wishing half-heartedly for parameter
> documents is this one:
> 
>   <p:step name="xslt">
>     <p:input name="document" ref="$input"/>
>     <p:input name="stylesheet" href="style.xsl"/>
>     <p:output name="result" label="result"/>
>     <p:param name="parameters">
>       <xsl:param name="base.dir" select="'/tmp'"/>
>       <xsl:param name="chunk" select="1"/>
>     </p:param>
>   </p:step>
> 
> But maybe there are better ways to solve that problem.

I was going to argue for tackling this by saying that inputs are 
optional and that XSLT parameters are an input to the XSLT component.

   <p:step name="xslt">
     <p:input name="document" ref="$input"/>
     <p:input name="stylesheet" href="style.xsl"/>
     <p:input name="parameters">
       <xslparams>
         <xsl:param name="base.dir" select="'/tmp'"/>
         <xsl:param name="chunk" select="1"/>
       </xsl:params>
     </p:input>
     <p:output name="result" label="result"/>
   </p:step>

but suspected that I would get shouted down and we'd end up with 
something hideous like:

   <p:step name="xslt">
     <p:input name="document" ref="$input"/>
     <p:input name="stylesheet" href="style.xsl"/>
     <p:param name="parameters"
       select="'base.dir=&quot;/tmp&quot;
                chunk=&quot;1&quot;'" />
     <p:output name="result" label="result"/>
   </p:step>

The other issue about parameters is how to handle QNames, which are 
fairly common. For example, the initial mode for a XSLT 2.0 
transformation is a QName. Do we recommend a particular syntax for that, 
such as:

   <p:param name="initial-mode"
            select="'{http://www.example.com/}mode'" />

or is the component provided with namespace bindings to enable it to 
expand QNames in parameter values?

Cheers,

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com

Received on Friday, 26 May 2006 10:12:05 UTC