select in for-each and iteration-source

I assume in the rest of the email, that select in for-each does give
access to all node matching the select expression and not only the
outermost

[Note en passant : it means that in a for-each the same node could be
provided multiple times]

Let's say we have a sequence in step="generate-sequence" port="result"

Here are multiple way to access to doc elements in this sequence
In this sequence we would have all use cases :
a. some documents in the sequence do not contains any doc element
b. some documents in the sequence do contains doc that are not
themselves descendant of a doc element
c. some documents in the sequence do contains doc that are descendant
of doc element

The goal is to apply the same select at different places to see what
are the difference . I know it is totally arbitrary but it gives a
opportunity to be sure of what we mean by selecting at those level

Here are the different classes of construct

== simple case ==

[S1]
<p:for-each select="//doc">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  subpipeline
</p:for-each>

it would give to the subpipeline all the doc elements dispatched in
the sequence (b and c)

[S2]
<p:for-each>
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  subpipeline
</p:for-each>

it would give to the subpipeline all the doc elements that are not b (only c).

[Note en passant : I assume that select on
p:input/p:iteration-source/etc. throw out empty matchs, please confirm
!]

== Nested case ==

[N4]
<p:for-each name="outer">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

With this one the sequence is splitted document by document (wether or
not they contain doc) and then S1 is applied
so you get [S1]+[context on each doc of the sequence included a) ]

[Note en passant : do we have a way to know that the inner p:for-each
had match anything in case of a) ?]

[N5]
<p:for-each name="outer" select="//doc">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

This one starts to be interesting
from the outer one you get all the doc element (b and c)
And in the inner loop you resplit

So you would get for subpipeline element b) only once but element c) a
number of time equal to count(ancestor::doc)

And of course, you will get the context of each doc node

[N6]
<p:for-each name="outer">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

This one, you will get a sequence of doc that have no doc ancestor
And you apply a for each
so you will get [S1]+[context of doc in the original sequence but a) removed ]


[N8]
<p:for-each name="outer">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each>
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

With this one the sequence is splitted document by document (wether or
not they contain doc) and then S2 is applied
so you get [S2]+[context on each doc of the sequence included a) ]


Are those interpretations correct ?


Mohamed





SEE DETAIL BELOW IF NEEDED

== simple case ==

[S1]
<p:for-each select="//doc">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  subpipeline
</p:for-each>

it would give to the subpipeline all the doc elements dispatched in
the sequence (b and c)

[S2]
<p:for-each>
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  subpipeline
</p:for-each>

it would give to the subpipeline all the doc elements that are not b (only c).
[Note en passant : I assume that select on
p:input/p:iteration-source/etc. throw out empty matchs, please confirm
!]

[S3]
<p:for-each select="//doc">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  subpipeline
</p:for-each>

It would give to the subpipeline all the doc elements dispatched in
the sequence (b and c) SO THE SAME AS [S1]

== Nested case ==

[N1]
<p:for-each name="outer" select="//doc">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each>
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

Same as [S1] : the inner for-each is useless

[N2]
<p:for-each name="outer">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each>
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

Same as [S2] : the inner for-each is useless

[N3]
<p:for-each name="outer" select="//doc">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each>
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

Same as [S3] : the inner for-each is useless ALSO same as [S1]

[N4]
<p:for-each name="outer">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

With this one the sequence is splitted document by document (wether or
not they contain doc) and then S1 is applied
so you get [S1]+[context on each doc of the sequence even a) ]

[Note en passant : do we have a way to know that the inner p:for-each
has not been executed in case of a) ?]

[N5]
<p:for-each name="outer" select="//doc">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

This one starts to be interesting
from the outer one you get all the doc element (b and c)
And in the inner loop you resplit

So you would get for subpipeline element b) only once but element c) a
number of time equal to count(ancestor::doc)

And of course, you will get the context of each doc

[N6]
<p:for-each name="outer">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

This one, you will get a sequence of doc that have not doc ancestor
And you apply a for each
so you will get [S1]+[context of doc in the original sequence but a)]

[N7]
<p:for-each name="outer" select="//doc">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source>
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

Same as [N5]

[N8]
<p:for-each name="outer">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each>
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

With this one the sequence is splitted document by document (wether or
not they contain doc) and then S2 is applied
so you get [S2]+[context on each doc of the sequence even a) ]


[N9]
<p:for-each name="outer" select="//doc">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each>
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

This is the same as [N1] which is the same as [S1]

[N10]
<p:for-each name="outer">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each >
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

This is the same as [N2] which is the same as [S2]

[N11]
<p:for-each name="outer" select="//doc">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each>
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

This is the same as [N3] which is the same as [S3] and [S1]

[N12]
<p:for-each name="outer">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

With this one the sequence is splitted document by document (wether or
not they contain doc) and then S3 is applied
so you get [S1]+[context on each doc of the sequence even a) ]

Same as [N4]

[N13]
<p:for-each name="outer" select="//doc">
  <p:iteration-source>
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

Same as [N5]

[N14]
<p:for-each name="outer">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

Same as ...

[N15]
<p:for-each name="outer" select="//doc">
  <p:iteration-source select="//doc">
    <p:pipe step="generate-sequence" port="result"/>
  </p:iteration-source>
  <!-- here we can get information and put them in options -->
  <p:for-each select="//doc">
    <p:iteration-source select="//doc">
      <p:pipe step="outer" port="current"/>
    </p:iteration-source>
    subpipeline
  </p:for-each>
</p:for-each>

Same as ...

-- 
Innovimax SARL
Consulting, Training & XML Development
9, impasse des Orteaux
75020 Paris
Tel : +33 8 72 475787
Fax : +33 1 4356 1746
http://www.innovimax.fr
RCS Paris 488.018.631
SARL au capital de 10.000 €

Received on Sunday, 20 May 2007 07:06:16 UTC