[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: For-each loop or recursion
> To be very honest, I am not totally sure myself about myarray1[i]. My pointwas that you said > > I have the following data (leaves in parallel branches): > > mystruct/myarray1[i]/myvar/var2 and But that isn't your input data it's just some bit of XPath which is syntactically correct but we can't give you any help as to whether it is doing the right thing as you have given no indication what your input document looks like, what your required output looks like or what transformation you are trying to achieve. > I need to compare current and next values of the node var2 [and var3] > and find the first occurrence when var2[position()] = var2[next, i.e. > position()+1] > Are you saying that is impossible to do in XSLT ? It's almost certainly possible to do what you want but your decription is pretty hard to follow. You need to describe the transformation that you want to do not just use bits of XPath and hope that we understand what you want. Xpath's position() function for example does not relate to the position of a node within a tree (a node can have any number of values returned buy position(), depending on how the node is selected). I'm _guessing_ that what you want to know is the sibling order of the node in the input tree in which case you might want following-sibling::*[1] but that is just a guess. I want from inside for-each loop mystruct/myarray1[i]/myvar [or does it require recursion?] compare the values is the parallel branch, of parallel "current" node ../../myarray2[i]/myvar/var3 and its "next node". Again, where: mystruct/myarray1[i]/myvar/var2 and mystruct/myarray2[i]/myvar/var3 Again you are just typing in syntactically correct XPath and asking "can I do that" since the Xpath you typed above is syntactically correct then clearly you can do that, but I have no idea if that will do what you want, as you've not said what you are trying to do. For example do your elements with name myarray1 have child elements with name i ? If they do not, then the above XPath's will select nothing. > Is there an easy way to find out the max value of the node (child elements) > without sorting it ? > The sequence of nodes I am dealing with is supposed to be in increasing order, If you know it's already sorted, just take the last select="*[last()]" or in your case take the last of each then you only have two itemsto compare which you can do with > to work out the overall maximum. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|