For-each question

/ 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?

  <p:step kind="validate" name="valid">
    <p:input port="document" href="doc.xml"/>
    <p:input port="schema" href="doc.xsd"/>
    <p:output port="result"/>
  <p:step>

  <p:step kind="transform" name="build-stylesheet">
    <p:input port="document" href="make-chapter-template.xsl"/>
    <p:input port="stylesheet" href="complete-template.xsl"/>
    <p:output port="result"/>
  </p:step>

  <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>

  <p:step kind="tidy" name="tidy">
    <p:input port="document" ref="#loop/chapter-docs"/>
  </p:step>

The transform inside the for-each will get run an arbitrary number of
times. Do reads from inside a for-each automatically get a copy of the
referenced input? I suppose they have to.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
XML Standards Architect
Sun Microsystems, Inc.

Received on Friday, 21 July 2006 21:26:55 UTC