Re: Option or parameter?

Alessandro Vernet wrote:
> When should a component designer use an option vs. a parameter?
> 
> The spec reads (2.3): "The distinction between options and parameters
> is simply that options are used by the XProc processor to configure
> the step; the step never sees them. Parameters are passed to the step
> for its use, the XProc processor does not use them."
> 
> What does "passed to the step" mean here? If the value of an option
> wasn't passed to the corresponding step, it wouldn't be of much use,
> would it?

I agree with Alex V. that we should make the distinction between options 
and parameters a lot clearer.

At a theoretical level, I propose that we say that options are used when 
the names of arguments are known in advance (at the design of the 
component), and that parameters are used when the names of arguments 
aren't known in advance. Since you can't know what parameter names are 
going to be passed in to a pipeline, you shouldn't rely on particular 
parameters being present.

At a practical level, I propose that we say that parameters can never be 
accessed using variable references within XPath expressions. So you can do:

<p:pipeline>
   <p:option name="schema-uri" />
   <p:load>
     <p:option name="href" select="$schema-uri" />
   </p:load>
   ...
</p:pipeline>

but can't do:

<p:pipeline>
   <p:parameter name="schema-uri" />
   <p:load>
     <p:option name="href" select="$schema-uri" />
   </p:load>
   ...
</p:pipeline>

That means the only way you can pass parameters into steps is through 
<p:import-parameter>. You can turn options into parameters, but you 
can't turn parameters into options.

The consequences would be:

  * it's OK for an option and a parameter to have the same name
  * the eventual target for all parameters will be an atomic step that
    accepts parameters, such as p:xslt
  * pipelines will mostly use options rather than parameters

Cheers,

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

Received on Wednesday, 25 April 2007 08:11:17 UTC