[xsl] Problem with index-position in for-each

Subject: [xsl] Problem with index-position in for-each
From: Timothy Marc <timothymarc@xxxxxxxxxx>
Date: Tue, 18 Dec 2007 18:39:33 +0100
Hi all,

i've a strange problem. I want to select some elements by their index
via predicate expression. The source looks like:
<statics mapTo="xyz">...</statics>
<statics mapTo="xyz">...</statics>
<dynamics mapTo="xyz">...</dynamics>
<statics mapTo="xyz">...</statics>

Now, i want to iterate over all statics-child elements, depending on
their position. Therefore, i have created an for-each-loop like this:

<xsl:for-each select="1 to count($staticParts/tree/statics)">

and inside the loop, i want to get the value of @mapTo with

<xsl:value-of select="$staticParts/tree/statics[position()]/@mapTo"/>

I want to do this with the explicit position, because i generate some
sql insert statements, where @mapTo defines the sql rowname and the
value of the element defines the column data. But the result is really
unexpected. I allways get the values of all @mapTo in this tree-element,
like this:

page tree location locationdescription ...

I 'm wondering because when i replace the position() function with an
static integer like [1] i only get the @mapTo value i want.
Hope, that somebody could help me.


Current Thread