Subject: RE: [xsl] How do you select all unique first-position characters? From: Jeff Beadle <Jbeadle@xxxxxxxx> Date: Thu, 21 Nov 2002 09:28:43 -0500 |
Greg, Thanks for the analysis, I didn't realize that the xsl:sort wouldn't effect futher axis operations within the given xsl:for-each, it just effects the order in which the xsl:for-each iterates across the given match. Very good thing to know. Anyway, looks like Wendell's got the ideal solution. I knew there was some grouping aspect to the problem and had to be a simpler approach. -Jeff -----Original Message----- From: Greg Faron [mailto:gfaron@xxxxxxxxxxxxxxxxxx] Sent: Wednesday, November 20, 2002 6:47 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] How do you select all unique first-position characters? At 03:39 PM 11/20/2002, you wrote: >I'm not sure if this what your going for, but the template below can either >retrieve you a text list (see comments) or a nodelist containing the nodes >of the all unique first letters where the assumption is which person node it >is doesn't matter. > >[snip] The template you offered only works for the particular xml data given. Simply add the element <person name="Greg" /> between Jim and Jason and you will see that it breaks. You are using "preceding-sibling::*[1]" for the comparison, thinking that you are comparing the elements in a sorted order. What you do not realize (and I only just discovered this myself while examining your template) is that it does not take into account the new sorting when dealing with node selection. The axes appear to be strictly related to the original order (at this point in the template anyway), so the first preceding-sibling element of 'Jim' is always going to be 'Amy', never 'Jason' as you might think after alphabetizing. The sort order is simply the order in which the original elements are processed; it does not recreate the document tree to reorder the nodes. For the original example (and using a JavaScript-like pseudo code) it works more like this: for index in (2, 3, 1, 5, 4) doSomethingWith(person[index]/@name); Greg Faron Integre Technical Publishing Co. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How do you select all uni, Greg Faron | Thread | RE: [xsl] How do you select all uni, Jeff Beadle |
Re: [xsl] javascript variable in XS, Jeni Tennison | Date | Re: [xsl] special characters in xml, Alice Fan |
Month |