## Re: [xsl] Trying to undestand why template works

 Subject: Re: [xsl] Trying to undestand why template works From: "James A. Robinson" Date: Thu, 23 Feb 2006 10:47:10 -0800
```> <xsl:with-param name="node" select="\$node[position() &gt; 1]"/>
>
> I just don't understand how the select="\$node[position() &gt; 1]" bit
> works. I assume that with each recursion this is selecting the next
> child of the input node (param "node"), but have no idea how or why.

so \$node[position() &gt; 1] is going to select a sequence of nodes, it
will evalute to whatever remains in \$node which isn't the first item
in the set.

if \$node is <a/><b/><c/>
then \$node[position() &gt; 1] is going to select <b/><c/>.

The thing to keep in mind is that position() in this case is relative
to an internal loop the processor is running.  For every item in
\$node, it runs the test "is the position of the current item I'm
examining greater than one?" When it is finished with this internal
loop, you get the resulting sequence of nodes.

The way your stylesheet is laid out, you are running down the list of
items in the node set, computing the last item first, returning it to
its parent caller, and then running your computation, and so forth.

So if you had the sequence 1 2 3 4 5 the following sequence would be
applied in reverse order: 5 4 3 2 1.  If your \$hourVal was 1, you
would see it performing this computation:

0 + number(5 * 1)
5 + number(4 * 1)
9 + number(3 * 1)
12 + number(2 * 1)
14 + number(1 * 1)

Jim

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press      http://highwire.stanford.edu/
+1 650 7237294 (Work)                   +1 650 7259335 (Fax)

```