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

Re: How do I change a XSL style sheet to group data t

Subject: Re: How do I change a XSL style sheet to group data together under one heading
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 18 May 2007 02:12:39 +0200
Re:  How do I change a XSL style sheet to group data  t
kieters c wrote:

Thank you. I copied your code into an xsl file and use it with the flat file. It grouped it all by date. Just one additional question data is grouped by a selection of variables. As you would have noticed in the first example: sample_date_time, cp_name, imis_cp_ext and two other. How do I combine it in the key name instruction?


Incidently this may be the only instance that I may be using it.


if there's no overlap in the values (i.e., when you concatenate them that they create the uniqueness you want), you can do this:


<xsl:key name="sample" match="sample" use="concat(sample_date_time, cp_name)" />

in addition, of course, you also change the key(...) functions throughout with the same as in you the use attribute.

When the values do overlap, you can make them more unique when adding a separator, like in concat(sample_date_time, ':', cp_name). Of course, you can concat as many values as you want. Make sure that the xpaths you provide are correct when seen as relative to the match attribute of the key (in this case, the sample node). And think of moving to XSLT 2.0 as soon as possible if you have more of this kind of problems. You can simply use:

<xsl:for-each-group select="sample" group-by="yourgroupbyclausehere" >....

and many other handy constructs (i.e., you can group by nodes that are separated by a node with a certain value, or that are siblings of one another by some rule etc etc). It's all possible in XSLT 1.0 too, but much harder and not with a single statement. And if you have little XSLT knowledge, it can be very hard.

Please read up on the tutorials as well, you may want to know how it all works: http://www.jenitennison.com/xslt/grouping/muenchian.html

Cheers,
-- Abel Braaksma

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-2011 All Rights Reserved.