[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Group and sort by group element occurrences


Subject: [xsl] Group and sort by group element occurrences
From: "Simerman, Joshua Michael" <jsimerma@xxxxxxxxxxx>
Date: Mon, 18 Aug 2003 22:42:42 -0500

Long time reader, first time poster.

I have an xml doc that is the result of a keyword search, which list the
keyword, and all pages by id that have that instance of the keyword. The
output looks like this.

<?xml version="1.0" encoding="UTF-8"?>
<docroot>
	<token>apply
		<pageid>1</pageid>
		<pageid>3</pageid>
		<pageid>84</pageid>
	</token>
	<token>international
		<pageid>3</pageid>
		<pageid>5</pageid>
		<pageid>84</pageid>
	</token>
		<token>financial aid
		<pageid>5</pageid>
		<pageid>84</pageid>
	</token>
</docroot>

I need to transform this this into a grouped and sorted list of page
id's, so that the instances of pageid that occur the most frequently are
first, and so that each pageid is listed only once. The above xml would
then look like this.

<docroot>
	<pageid>84</pageid>
	<pageid>3</pageid>
	<pageid>5</pageid>
	<pageid>1</pageid>
</docroot>

It seems like a fairly simple transform, but I just cant get it to sort
properly and then have only the unique page ids. I just end up with a
flat list of the original document, or nothing at all.

Thanks,

Josh Simerman
Graduate Assistant, Web Developer
Systems & Accounting Graduate Programs
Indiana University, Kelley School of Business


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



Current Thread
Keywords
xml