[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Sorting Problem

Subject: RE: Sorting Problem
From: "Dev Chandramani" <devc33@xxxxxxxxxxx>
Date: Wed, 12 Sep 2001 21:15:06 +0100
Hi Joerg,
	Thanks for your reply.
	Basically - the second part of the problem is this :

As well is listing the unique <name> fields based on their frequency I also
want to display
a corresponding <school> field.
So if the name Smith occurs once then it is fine - I just display the
school field with that name.
But if the name Smith occurs twice - one with <school>Oxford</school> and
one with <school>Eton</school> i want to be able to display the school field
I rank the highest e.g. Oxford.
Understand ?
Will your solution allow me to pull out any corresponding <school> field
aswell as
the <name> field currently ?


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jörg Heinicke
Sent: 12 September 2001 20:25
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: 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"
    <xsl:output indent="yes"/>
    <xsl:key name="pupils" match="pupil" use="name"/>

    <xsl:template match="records">
                <xsl:sort select="count(key('pupils',name))"

    <xsl:template match="pupil">
            <xsl:apply-templates select="name"/>

    <xsl:template match="name">
            <xsl:value-of select="."/>
            <xsl:value-of select="count(key('pupils',.))"/>

With your second wish I have my problems, I don't understand it. Maybe tell
us more.


> 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
> 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

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.