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

Re: Grouping problem (?)

Subject: Re: Grouping problem (?)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 15 Sep 2003 12:03:35 +0100
Re:  Grouping problem (?)


> [step 1]
> Show the first person's name and address
> [step 2]
> For each person,
>     if the address is the same as the first listed person's
>           then display the name in the same table as the first person's
> information, adding '1' to the first person's number
> [step 3]
> For each person
>     If the address is different than the first listed person's
>         then display the name in a new table with the number incremented by
> 1.
> 

That description (which is very imperative, you'd be better giving a
declarative, functional, description when thinking about xslt)
doesn't seem to match your suggested output.
which appears to be all in one table (despite step 3) and the number
incremented for all perople whether or not they have the same address
(despite your step 2)

You want to use a grouping technique (eg look up muenchian grouping
on Jeni's site) with a key that expresses the address eg

<xsl:key name="x" match="address"
use="concat(street,',',city,',',state,',',postcode,',',country)"/>

The details will depend a bit on whet exactly your criteria are, and
whether you can assume that the input document is already in the right
order, or whether you first need to reorder to bring people with the
same address together.

David


one comment more or less unrelated to your grouping problem.

> <xsl:for-each select="//person

you probably don't (hardly ever) want to use // as it is very expensive
causing the system to search the entire document to arbitrary depth
looking for person elements. You may know there areno person elements
inside <state>, but the system doesn't.


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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


Current Thread

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.