Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: why is count(xpath) != xpath[last()] ? [Thread Next] Re: why is count(xpath) != xpath[last()] ?To: NULL Date: 12/13/2007 11:30:00 AM <jfrensen@h...> wrote in message news:1781df7e-9c44-401c-b710-2a632eef7a6a@j...... > > > That's because Name elements aren't siblings. Each Name element is the > > only Name element row element contains, so at the point when Name > > element is selected, context node-set contains single Name element, so > > last() = 1. > > > You need (/root/Students/row/Name)[position() = last()] > > Thank you, Oleg. What confuses me is that the use of the predicate > filter seems to change the order of evaluation of the XPath > expression. > That is, > select="/root/Students/row/Name" > evaluates to a nodeset of two Names, and > select="count(/root/Students/row/Name)" > evaluates to the number 2. > > Given that, I had assumed that the XPath expression > select="/root/Students/row/Name[position() = last()]" > would be evaluated from left to right, yielding a nodeset, that would > then be filtered by [position() = last()]. But this does not seem to > be the case, if parentheses are required to change the order of > evaluation. You seem to be thinking of the predicate as an additional step in the path. It isn't. It is a modifier of the current step. Name[position()=last()] says get child elements with the TagName 'Name' which happen to be the last such in the element in the current context, a row element (NB 'a' in the singular). -- Anthony Jones - MVP ASP/ASP.NET | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
