xsl-list
[Top] [All Lists]

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

2007-12-18 10:43:41
Hi all,

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

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.

thx
mfw

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>