W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > July 2006

Re: p:for-each

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 26 Jul 2006 09:20:15 +0100
Message-ID: <44C725BF.1090401@jenitennison.com>
To: public-xml-processing-model-wg <public-xml-processing-model-wg@w3.org>

Hi Alessandro,

Alessandro Vernet wrote:
> On 7/24/06, Norman Walsh <Norman.Walsh@sun.com> wrote:
>> Yikes! You're suggesting that if there are three documents on 
>> #pipe/document
>> (a, b, and c) and two stylesheets on #pipe/stylesheets (x and y), that
>> the step gets evaluated (a, x), (a, y), (b, x), (b, y), (c, x), (c, y) 
>> times?
>> I think that's *way* too confusing.
> 
> Jeni,
> 
> Do you have a use case in mind where this type of combination would be
> useful? For now, like Norm, I find this somewhat confusing. However I
> agree with you on allowing multiple outputs for the <p:for-each>; it
> definitely makes sense.

Yep: generation of conference proceedings for a CD. Each paper is a 
separate XML file, and we want to generate from each of them: (a) an 
abstract, (b) a table of contents, (c) HTML, (d) PDF.

But I'm fairly happy with *not* being able to do a join (iterating over 
multiple inputs at the same time), since anything you can do with a join 
  you can do with nested for-eaches, and to be honest, for reusability, 
I think you'd code the above use-case with something like:

<p:pipelines>

<p:pipeline name="process-paper">
   <p:declare-input name="paper" />
   <p:declare-output name="abstract" />
   <p:declare-output name="ToC" />
   <p:declare-output name="HTML" />
   <p:declare-output name="PDF" />
   <p:step kind="xslt">
     <p:input port="document" ref="#process-paper/paper" />
     <p:input port="stylesheet" href="abstract.xsl" />
     <p:output port="result" ref="#process-paper/abstract" />
   </p:step>
   <p:step kind="xslt">
     <p:input port="document" ref="#process-paper/paper" />
     <p:input port="stylesheet" href="ToC.xsl" />
     <p:output port="result" ref="#process-paper/ToC" />
   </p:step>
   <p:step kind="xslt">
     <p:input port="document" ref="#process-paper/paper" />
     <p:input port="stylesheet" href="HTML.xsl" />
     <p:output port="result" ref="#process-paper/HTML" />
   </p:step>
   <p:step kind="xslt">
     <p:input port="document" ref="#process-paper/paper" />
     <p:input port="stylesheet" href="PDF.xsl" />
     <p:output port="result" ref="#process-paper/PDF" />
   </p:step>
</p:pipeline>

<p:pipeline name="process-papers">
   <p:declare-input port="papers" />
   <p:declare-output name="abstracts" />
   <p:declare-output name="ToCs" />
   <p:declare-output name="HTMLs" />
   <p:declare-output name="PDFs" />
   <p:for-each name="iter">
     <p:declare-input port="paper" ref-each="papers" />
     <p:declare-output name="abstract" />
     <p:declare-output name="ToC" />
     <p:declare-output name="HTML" />
     <p:declare-output name="PDF" />
     <p:step kind="process-paper">
       <p:input port="paper" ref="#iter/paper" />
       <p:output port="abstract" ref="#iter/abstract" />
       <p:output port="ToC" ref="#iter/ToC" />
       <p:output port="HTML" ref="#iter/HTML" />
       <p:output port="PDF" ref="#iter/PDF" />
     </p:step>
   </p:for-each>
</p:pipeline>

</p:pipelines>

Cheers,

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com
Received on Wednesday, 26 July 2006 08:20:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:21:48 GMT