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

Re: For-each question

From: Alex Milowski <alex@milowski.org>
Date: Sat, 22 Jul 2006 07:20:19 -0700
Message-ID: <44C23423.70108@milowski.org>
To: public-xml-processing-model-wg@w3.org

Norman Walsh wrote:
> / Jeni Tennison <jeni@jenitennison.com> was heard to say:
> | I would much rather <p:choose> (and <p:for-each>) *weren't*
> | self-contained, and could point to inputs from their ancestors.
> 
> What does it mean when a for-each points to inputs among its ancestors
> and preceding siblings?

You mean when a step inside a for-each does that, right?

>   <p:for-each select="//chapter" ref="#valid/result" name="loop">
>     <p:declare-output port="result" name="chapter-docs"/>
> 
>     <p:step kind="transform" name="makehtml"/>
>       <p:input port="document" ref="#loop/#matched"/>
>       <!-- somehow we have to expose the matched regions as documents;
>            here I'm imagining that for-each always declares a magically
>            named input port which will be used for that purpose -->
>       <p:input port="stylesheet" ref="#build-stylesheet/result"/>
>       <p:output port="result" ref="#loop/chapter-docs"/>
>     </p:step>
>   </p:for-each>

I'd call this an error.  The for-each is like a mini-pipeline and
needs to have that extra input declared:

<p:for-each select="//chapter" ref="#valid/result" name="loop">
     <p:declare-input port="#build-stylesheet/result"
                      name="the-stylesheet"/>
     <p:declare-output port="result" name="chapter-docs"/>

     <p:step kind="transform" name="makehtml"/>
       <p:input port="document" ref="#loop/#matched"/>
       <!-- somehow we have to expose the matched regions as documents;
            here I'm imagining that for-each always declares a magically
            named input port which will be used for that purpose -->
       <p:input port="stylesheet" ref="the-stylesheet"/>
       <p:output port="result" ref="#loop/chapter-docs"/>
     </p:step>
   </p:for-each>

That give you the ability to rename the input too--which might be very
nice if the reference is strange.

--Alex Milowski
Received on Saturday, 22 July 2006 14:20:31 GMT

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