Re: Here's a tricky one

/ Alessandro Vernet <avernet@orbeon.com> was heard to say:
| On 5/14/07, Norman Walsh <ndw@nwalsh.com> wrote:
|> <p:matching-documents>
|>   <p:input port="source">
|>     <p:inline>
|>       <odd/>
|>     </p:inline>
|>     <p:inline>
|>       <even/>
|>     </p:inline>
|>     <p:inline>
|>       <odd/>
|>     </p:inline>
|>     <p:inline>
|>       <even/>
|>     </p:inline>
|>     <p:inline>
|>       <odd/>
|>     </p:inline>
|>   </p:input>
|>   <p:option name="test" value="$p:position mod 2 = 1"/>
|> </p:matching-documents>
|>
|> We added $p:position for this very case.
|
| This is a good use case, and I agree: in this case you want that
| information to be made available the 'test' XPath expression. I only
| feel I should insist on two points:
|
| 1) That we clearly specify for each component what is exposed to XPath
| expression evaluated by the component.

Absolutely.

| 2) That we use functions. Sorry, I can't help coming back to this once
| again: this example would IMHO be clearer if instead of $p:position we
| had document-position(). In this case a function does a better job
| than a variable at conveying that the value can be different depending
| on when that function is called by the step. And the name does a
| better job at describing what the function does.

Yes, now that I see the distinction more clearly between expressions
evaluated by the pipeline processor and expressions evaluated by steps
that need access to state from the pipeline processor, I think functions
are definitely the right answer.

I think it's much easier to explain that the function hooks back into
the pipeline processor and retrieves some state than it is to say that
the pipeline processor mutates a variable while the step is running.

Following Alessandro's lead, I propose

  p:episode()
  p:document-position()
  p:index('stepname')

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | Do not try to live forever. You will
http://nwalsh.com/            | not succeed.--George Bernard Shaw

Received on Tuesday, 15 May 2007 11:18:06 UTC