[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Sorting Problem
> I have the following example input XML doc : > > <records> > <pupil> > <name>Smith</name> > <school>Oxford</school> > </pupil> > <pupil> > <name>Jones</name> > <school>Eton</school> > </pupil> > <pupil> > <name>Davis</name> > <school>Eton</school> > </pupil> > <pupil> > <name>Jones</name> > <school>Oxford</school> > </pupil> > <pupil> > <name>Davis</name> > <school>Oxford</school> > </pupil> > <pupil> > <name>Davis</name> > <school>Cambridge</school> > </pupil> > </records> > > And I want the output similar to : > > <records> > <pupil> > <name>Davis</name> > </pupil> > <pupil> > <name>Jones</name> > </pupil> > <pupil> > <name>Smith</name> > </pupil> > <records> > > Based on the frequency of the value in the <pupil> tag. I think you need a two-pass approach (using a result tree fragment for the intermediate results, and using the xx:node-set() extension to grab this as input to the second pass.) The first pass is a grouping problem: use either Muenchian grouping or pupil[not(name=previous-sibling::pupil/name)] to get the distinct values, and put these as nodes on the RTF, together with a count attribute that indicates how often they occur. The second pass is a sort: sort the nodes in the RTF using the count attribute. > Also I want to introduce a weighting system ... Let's tackle that when you've done the first part. Mike Kay > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|