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

RE: Complex grouping problem, please help.

Subject: RE: Complex grouping problem, please help.
From: kakridge@xxxxxxxxxxxxx
Date: Sat, 10 Jan 2004 21:32:47 -0500
sat for kindergarten
The approach I am taking with this has been to for-each the first
occurrence of every tutor in Grade node.  I then for-each a key matching
all Students to based on each tutor.  I keep trying to only limit the
key to the current grade, but I don't think it is working.

<xsl:key name="students-by-tutor" match="Grade/Students/Name"
use="Tutor"/>

<xsl:template match="School">
	<xsl:for-each select="Grade">
		<xsl:apply-templates select="."/>
	</xsl:for-each>
</xsl:template>


<xsl:template match="Grade">
	<xsl:for-each select="Students/Student/Name[Tutor[not(. =
preceding::Tutor)]]">
		<xsl:sort select="Tutor"/>
		<xsl:variable name="gradeName"
select="ancestor::Grade/Name"/>
		<xsl:for-each select=key('students-by-tutor ',
Tutor)[ancestor::Grade/Name = $gradeName]>
			<xsl:apply-templates select="."/>
		</xsl:for-each>
	</xsl:for each>
</xsl:template>

What am I missing?  The key doesn't seem to only return students in the
given grade. It returns all students in all grades for the tutor.


 --- kakridge@xxxxxxxxxxxxx wrote: > I have been
having a problem with grouping.  If I
> have:
> 
> <School>
> 	<Grade>
> 		<Students>
> 			<Student>
> 				<Name>Bob</Name>
> 				<Tutor>Mary Smith</Tutor>
> 			</Student>
> 			<Student>
> 				<Name>Joe</Name>
> 				<Tutor>Mike Smith</Tutor>
> 			</Student>
> 		<Students>
> 		<Name>Kindergarten</Name>
> 	</Grade>
> 	<Grade>
> 		<Students>
> 			<Student>
> 				<Name>Ted</Name>
> 				<Tutor>Mary Smith</Tutor>
> 			</Student>
> 			<Student>
> 				<Name>Sammy</Name>
> 				<Tutor>Mike Smith</Tutor>
> 			</Student>
> 		</Students>
> 		<Name>First</Name>
> 	</Grade>
> </School>
> 
> How can I group each grade, and within each grade,
> group all tutors with
> their students?
> 
> Something like this:
> 
> Grade: Kindergarten
> Tutor: Mary Smith
> Students: Bob,.,.,.
> 
> Grade: Kindergarten
> Tutor: Mike Smith
> Students: Joe,.,.,.
> 
> Grade: First
> Tutor: Mary Smith
> Students: Ted,.,.,.
> 
> etc.
> 
> Thanks



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


Current Thread
  • Re:, (continued)
    • Mukul Gandhi - Sat, 10 Jan 2004 01:37:41 -0500 (EST)
    • Mukul Gandhi - Sat, 10 Jan 2004 03:18:51 -0500 (EST)
      • kakridge - Sat, 10 Jan 2004 11:00:55 -0500 (EST)
        • kakridge - Sat, 10 Jan 2004 12:30:28 -0500 (EST)
        • kakridge - Sat, 10 Jan 2004 21:33:22 -0500 (EST) <=
        • G. Ken Holman - Sun, 11 Jan 2004 13:39:28 -0500 (EST)
        • kakridge - Sun, 11 Jan 2004 19:00:18 -0500 (EST)
    • G. Ken Holman - Sat, 10 Jan 2004 21:24:06 -0500 (EST)
      • kakridge - Sat, 10 Jan 2004 23:42:42 -0500 (EST)

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.