Re: Cardinality of inputs & outputs

Innovimax SARL wrote:
> On 5/22/07, Jeni Tennison <jeni@jenitennison.com> wrote:
>> The reason I asked about this is precisely the situation where you want
>> to supply an optional document: it seems weird that to do this you have
>> to define the input as a sequence.
> 
> Do you have any use case in mind ?

An optional pre/post-processing step. If the 'preprocess' step has a 
document on it, use it to transform the source prior to the other 
processing; if not, then just use the source as-is. Another example is 
the 'source' input on the p:xslt2 step: not all transformations require 
source documents.

> If it is the case, I would go *in the step declaration for
> required=yes/no* better than allowing an empty sequence as input...

I discounted this possibility because it seemed that it would require 
too much reworking of the rest of the spec and because it leads to 
tedious code when you have 'wrapper' pipelines that simply mirror an 
internal step. For example, how would I test whether a particular input 
has been specified or not? How would we distinguish between defaulting 
an input and not supplying it? Say I have a pipeline that uses p:xslt2, 
with the source input on the pipeline linking to the source input of the 
p:xslt2 step: I would have to do something like:

<p:pipeline>
   <p:input port="source" required="no" />
   ...
   <p:choose>
     <p:when test="...source is supplied...">
       <p:xslt2>
         <!--DEFAULTED:
           <p:input port="source">
             <p:pipe step="pipe" source="source" />
           </p:input>
         -->
         ...
       </p:xslt2>
     </p:when>
     <p:otherwise>
       <p:xslt2>
         <p:input port="source"><p:not-supplied /></p:input>
         ...
       </p:xslt2>
     </p:otherwise>
   </p:choose>
</p:pipeline>

I think that using inputs-with-no-documents gives a much cleaner solution:

<p:pipeline>
   <p:input port="source" cardinality="zero-or-one" />
   ...
   <p:xslt2>
     <!--DEFAULTED:
       <p:input port="source">
         <p:pipe step="pipe" source="source" />
       </p:input>
     -->
     ...
   </p:xslt2>
</p:pipeline>

Cheers,

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

Received on Tuesday, 22 May 2007 20:38:33 UTC