Re: [xsl] position() > 1 not working

Subject: Re: [xsl] position() > 1 not working
From: "Alan Painter alan.painter@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 5 Mar 2021 19:40:58 -0000
Needs to be:

<xsl:if test="position() gt 1" />

with gt instead of > as the operator.

On Fri, Mar 5, 2021, 20:37 Martin Honnen martin.honnen@xxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> On 05.03.2021 20:22, Michele R Combs mrrothen@xxxxxxx wrote:
>
> > Ah.  Ok, so if I understand correctly, I need to change the variable
> > assignment to grab the position of the <DATA> element within the parent
> > <ROW>, rather than within the for-each?  How would I do that?
>
>
> I think what David tries to say is that you want e.g.
>    ../../fmp:COL[3]/fmp:DATA[$parent-position + 1]
> instead of
>    ../../fmp:COL[3]/fmp:DATA[$parent-position]
>
> (and the same for the other values.)
>
> Or you would need to use
>    ../../fmp:COL[3]/fmp:DATA[position() >  1][$parent-position]
>    ../../fmp:COL[4]/fmp:DATA[position() >  1][$parent-position]
>    ../../fmp:COL[5]/fmp:DATA[position() >  1][$parent-position]
> and so on to work in the same range your for-each works with.
>
>
>
> > there are 4 DATA children so
> >
> > <xsl:for-each select="fmp:COL[3]/fmp:DATA[position() > 1]">
> >
> > selects the 2nd, 3rd and  4th
> >
> > the scope of that position() is just that step of the xpath, within the
> > body of the for-each, position() counts the selected items
> >
> > so as there are three items selected position() as stored in
> > $parent-position  will have values 1,2,3 which is one less than you
> > expected.

Current Thread