Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Specify an element in a nodeset directly [Thread Next] Re: Specify an element in a nodeset directlyTo: NULL Date: 10/8/2006 6:07:00 AM eric.goforth@g... wrote: > roy axenov wrote: > > So what does it do? > > > > $rates/rate selects a nodeset of <rate> nodes. The > > predicate [position()=thingcode] filters this nodeset, > > dropping all the nodes that don't have a <thingcode> > > child with content that is equal to the position of the > > <rate> node in the $rates/rate nodeset. Since there are > > no <rate> nodes with <thingcode> children in your > > document, the resulting nodeset is, naturally, empty. I > > already explained the solution in my previous reply. > > I played around with your example, but it doesn't seem to > work when I have multiple xyzzy elements, for example: > > <foo> > <bar> > <xyzzy> > <int>3</int> > </xyzzy> > <xyzzy> > <int>4</int> > </xyzzy> > <xyzzy> > <int>5</int> > </xyzzy> > </bar> > <nodeset> > <node> > <str>wrong (1)</str> > <int>3</int> > </node> > <node> > <str>wrong (2)</str> > <int>2</int> > </node> > <node> > <str>right (3)</str> > <int>1</int> > </node> > </nodeset> > </foo> It *is* working. I'm not sure what the hell you were trying to do with the input file like this, though. Pray tell me, what did you expect as a result? It is supposed to look up the nth <node> in the document for each <xyzzy>, where n is the value of an <int> child of <xyzzy> in question. Since there are only *three* <node>s in the document, naturally, <xyzzy>'s with <int> of 4 and 5 don't return bloody anything. > I'm wondering if it's not possible to do what I'm trying > to do. It's been explained no less than three times in this thread that what you're trying to do is possible, that your problem lies in messed-up contexts, that to get the context of the current node you need to use the current() XPath function. If you're still unable to grasp that, I recommend hiring yourself an XSLT expert. Seriously, that'll save you an awful lot of trouble, time and money. -- roy axenov | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
