Re: For-each question

Alex,

Alex Milowski wrote:
> Jeni Tennison wrote:
>> My reasons for arguing against declaring all the inputs required by a 
>> <p:for-each> (or <p:choose>) are:
>>
>> 1. It's unnecessary (implementations can work out what extra inputs 
>> are required for themselves)
> 
> OK.  And extra outputs?  What happens to those?  Do they go to the bit
> bucket or do they produce a collection?

Well, you need to declare the outputs that you want to use (in order to 
give them a name). So if you produce another output, then either it's an 
error or it goes to the bit bucket: it depends on what our policy is for 
undeclared outputs in pipelines generally.

>> 2. It's tedious for users
> 
> I'm not convinced that it is that onerous.

I'm thinking of something like:

<p:pipeline name="validate-and-transform">
   <p:declare-input name="documents" />
   <p:declare-input name="schema" />
   <p:declare-input name="stylesheet" />
   <p:declare-output name="results" />

   <p:for-each name="loop">
     <p:declare-input name="document"
                      ref-each="#validate-and-transform/documents" />
     <p:declare-input name="schema"
                      ref="#validate-and-transform/schema" />
     <p:declare-input name="stylesheet"
                      ref="#validate-and-transform/stylesheet" />
     <p:declare-output name="results"
                       ref="#validate-and-transform/results" />
     <p:step kind="p:xsd" name="validate">
       <p:input name="document" ref="#loop/document" />
       <p:input name="schema" ref="#loop/schema" />
       <p:output name="result" />
     </p:step>
     <p:step kind="p:xslt" name="transform">
       <p:input name="document" ref="#validate/result" />
       <p:input name="stylesheet" ref="#loop/stylesheet" />
       <p:output name="result" ref="#loop/results" />
     </p:step>
   </p:for-each>
</p:pipeline>

It seems tedious to me to have to (re)declare the schema and stylesheet 
pipeline inputs as inputs for the for-each. The more inputs and 
parameters we have, the more tedious it gets.

>> 3. It's unlike iteration in other languages (you don't have to define 
>> all the variables used within a for loop in, say, Java)
> 
> Unlike iteration in other languages, that input must be replayed for
> each iteration.

I don't understand what you mean by 'replayed'? You mean that behind the 
scenes, the processor has to make copies of the other inputs? Why should 
the user care about what the processor has to do behind the scenes?

Cheers,

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

Received on Wednesday, 26 July 2006 08:04:49 UTC