Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Treat last element differently [Thread Next] Re: Treat last element differentlyTo: NULL Date: 2/5/2005 11:14:00 AM "Jason" <jason@j...> wrote in message news:eNaKfiwCFHA.2568@T...... > The exact code you suggested doesn't work. Interestingly, I place: > > <xsl:value-of select="position()" /> > <xsl:value-of select="last()" /> > > in the same location, position() = 2 for the first element, 4 for the > second and so on. The value of last() is always one greater than the > position of the final element. If I use: > > <xsl:if test="position() + 1 < last()"> > <xsl:text>,</xsl:text> > </xsl:if> > > Then it works. However, I am now concerned by the initial value of > position() and why it increments by 2 each time. Can anyone explain this? > > Thank again, > > - Jason > > This is because you called apply-templates with no select, thus processing ALL children. This includes text nodes The carriage returns after the field elements) which are affecting your counting and position. If you add select="field" you should see the difference. -- Joe (MVP - XML) | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
