Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Parallel data traversal [Thread Next] Re: Parallel data traversalTo: NULL Date: 9/10/2007 10:19:00 PM Vojta wrote: > Hi, > > I have some xml data looking like this > <root> > <items1> > <i1>..</i1> > <i1>..</i1> > </items1> > <items2> > <i2>..</i2> > <i2>..</i2> > </items2> > </root> > > If my context node is the k-th node in items1 is to possible to create > XPath that finds a k-th node in items2? Something like "../../ > items2[position() = position(.)]" - which does not work because "." is > bound to some "i2" node inside the square brackets. > > Some motivation: we use a "repeater" component that traverses child > nodes of one node. The current node in the repeater is the context > node. The user then uses xpaths relative to the current node to get > the data. And I need some hack to be able to reference nodes at the > same position but inside a different node. > > Obviously the most natural solution is to do some data preprocessing > to "zip" items1 and items2 together or modify our repeater to be able > to have multiple context nodes. But isn't there any pure xpath way to > do this? > > Thanks > not pure xpath1 you need xslt1 or a similar host language that can bind xpath variables. however in xpath2 you can express this, for example for $p in 1+count(preceding-sibling::i1) return ../preceding-sibling::items2/i2[$p] David -- http://dpcarlisle.blogspot.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
