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

RE: Re:

Subject: RE: Re:
From: kakridge@xxxxxxxxxxxxx
Date: Fri, 9 Jan 2004 19:50:22 -0500
xslt tutor
The problem is that although it is grouped by grade, I need to group by
grade and tutor.  Here is the approach I have been trying:

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

This is a condensed version, but it is the gist of what I have been
trying to do.

I am not looking for anyone to do this for me... I just don't understand
some of the grouping methods.  I have read a few of the faq's and
helpful sites, but do not see anything that applies like this.  Maybe I
am overcomplicating it though.
-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Wendell Piez
Sent: Friday, January 09, 2004 6:58 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: 

Hi,

At 06:17 PM 1/9/2004, you 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?

They are already grouped by grade, so it appears you just need to group 
students by tutors.

Grouping in XSLT 1.0, while it is not trivial, is well-documented (in
part 
because it's not trivial), and you will find a wealth of resources on
line 
explaining various techniques of doing it, including both on the XSL FAQ

(http://www.dpawson.co.uk/xsl/sect2/sect21.html) and everyone's favorite

helper site for XSLT grouping, 
http://www.jenitennison.com/xslt/grouping/index.html.

Since you haven't said exactly what's got you stuck here, it's
impossible 
to offer more specific advice, short of simply writing the code to do
this. 
And that really wouldn't be much help, would it? While the list has an 
interest in helping and encouraging you to learn XSLT, we don't have
much 
interest in doing the job for you....

If you have a more specific or focused question on a point you find 
confusing, please don't hesitate to ask. (Oh, and use a subject line
next 
time too. :-)

Cheers,
Wendell


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


 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
  • [no subject]
    • kakridge - Fri, 9 Jan 2004 18:17:45 -0500 (EST)
      • Wendell Piez - Fri, 9 Jan 2004 19:06:16 -0500 (EST)
        • kakridge - Fri, 9 Jan 2004 19:51:00 -0500 (EST) <=
      • 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)

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.