Re: Sorting Problem
Hello Dev, your first problem will be solved with the following stylesheet: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:key name="pupils" match="pupil" use="name"/> <xsl:template match="records"> <xsl:copy> <xsl:apply-templates select="pupil[count(.|key('pupils',name))=1]"> <xsl:sort select="count(key('pupils',name))" order="descending"/> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="pupil"> <xsl:copy> <xsl:apply-templates select="name"/> </xsl:copy> </xsl:template> <xsl:template match="name"> <xsl:copy> <xsl:value-of select="."/> </xsl:copy> <number-of-occurence> <xsl:value-of select="count(key('pupils',.))"/> </number-of-occurence> </xsl:template> </xsl:stylesheet> With your second wish I have my problems, I don't understand it. Maybe tell us more. Joerg > Based on the frequency of the value in the <pupil> tag. > Any ideas would be greatly appreciated. > Also I want to introduce a weighting system so I can > then add the school field to the results based on > the weights I give each school. > > For example if I had the following weights with 1 being the greatest: > > Cambridge=1 > Oxford=2 > Eton=3 > > I could then produce results such as : > > <records> > <pupil> > <name>Davis</name> > <school>Cambridge</school> > </pupil> > <pupil> > <name>Jones</name> > <school>Oxford</school> > </pupil> > <pupil> > <name>Smith</name> > <school>Oxford</school> > </pupil> > <records> > > I also would like <name> fields that only occur once being ordered using the > weighting system as well. > > A tough problem I know but any advice on where to start would be greatly > appreciated. > Thanks in advance. > > Regards, > Dev. 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