Re: p:for-each

On 7/26/06, Jeni Tennison <jeni@jenitennison.com> wrote:
> 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>

Jeni,

I agree: multiple inputs to the for-each is syntactic sugar for nested
for-each. IMHO, nested for-each will be less confusing for the author.
All in all it looks like we don't have a strong case for multiple
inputs to the for-each, and so that we should only keep one input.

Alex
-- 
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/

Received on Wednesday, 26 July 2006 22:45:22 UTC