Re: The semantics of position() -- trying to be very explicit

/ Innovimax SARL <innovimax@gmail.com> was heard to say:
| if we state that p:position() is bounded to the position of the input sequence
| then
| "div[p:position()=2]" would select the divs of the second document in
| the sequence in a for-each

Just to be sure I understand: his would be in a match on a viewport
inside a for-each and it would match all the div elements that were
the second children of their parents in the second document in the
for-each sequence and no divs in any other document, right?

If you wanted that, and if you we use the context position instead of
a p:position() function, you can still get the behavior you need:

  <p:for-each>
    ...
    <p:option name="iteration" select="position()"/>
    ...
    <p:viewport match="div[$iteration = 2]">
      ...
    </p:viewport>
  </p:for-each>

Yes, you have to work a little harder for this case, but I think this
qualifies as making hard things possible :-)

In fact, if we had a p:position() function, I don't think this:

  <p:viewport match="div[p:position() = 2]">

would work anyway. Inside the viewport p:position() would return "0"
until a div had been matched. Since div[0=2] will never match
anything, you'd ... never match anything.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | I'm NOT in denial!
http://nwalsh.com/            | 

Received on Thursday, 7 June 2007 12:11:14 UTC