W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > June 2007

Re: Tricky samples of position()

From: Norman Walsh <ndw@nwalsh.com>
Date: Thu, 07 Jun 2007 08:19:34 -0400
To: public-xml-processing-model-wg@w3.org
Message-ID: <877iqghs89.fsf@nwalsh.com>
/ 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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:21:53 GMT