Re: Tricky samples of position()

/ Innovimax SARL <innovimax@gmail.com> was heard to say:

Because you've used 'select' in each of these examples, the value of
position() is going to be whatever value the containing step provided.
In fact, none of these options accept XPath expressions, so that was
really your only choice.

Let's assume the containing step is a for-each because that's the
interesting case.

| 1)
|
| <p:head>
|  <p:option name="count" select="position()"/>
| </p:head>

This selects the first document of it's sequence on the first
iteration, the first two documents on the second, etc.

| idem for
|
| 1 bis)
|
| <p:tail>
|  <p:option name="count" select="position()"/>
| </p:tail>

The last, then the last two, then the last three, etc.

| 2)
|
| <p:wrap-sequence>
| <p:option name="wrapper" select="concat('wrapper', position())"/>
| </p:wrap-sequence>

The wrapper is 'wrapper1' on the first iteration, wrapper2 on the
second, etc.

| 3)
|
| <p:xslt2>
|  <p:option name="initial-mode" select="concat('template', position())"/>
| </p:xslt2>

For better or worse, this makes the initial-mode template1 for the
first iteration, template2 for second, etc.

If the containing step was a viewport, then you'd get the same sort of
results except that position() would vary over the matched nodes.

If the containing step was a group, pipeline, or other non-iterating
step, then the position() would simply be 1 in each case.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | All the labors of the ages, all the
http://nwalsh.com/            | devotion, all the inspiration, all the
                              | noonday brightness of human genius, are
                              | destined to extinction.--Bertrand
                              | Russell

Received on Thursday, 7 June 2007 12:19:43 UTC