Re: [xslt] Creating absolute XPath path to the node - problem with position()



> Now, the position() returns always 1, so It write:
> /root[1]/element[1]/subelement[1]/sub[1]
> I tested it and this template walks over good elements (I distinguished it by
> the attribute).
> 
> So, what's wrong? Is it the bug or feature? And if it is a feature, how can I
> obtain the absolute XPath with positions to the current element?

When applying templates to the parent node (select="..") you are applying
against a node-set containing one element.  position() is not position of the
node relative to it's siblings but it's position in the current working
node-set.  So the current element in the template is correctly the first
element in the current expression object. 
http://www.zvon.org/xxl/XSLTreference/W3C/xpath.html#function-position

I do this type of operation all the time and have simply written an xslt
extension function that wraps the xmlNodeGetPath API, which works great.  Note:
 the documents I use this with don't use namespaces.
  



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]