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

Re: Grouping by an attribute of a child

Subject: Re: Grouping by an attribute of a child
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 14 Apr 2003 15:45:47 +0100
Re:  Grouping by an attribute of a child
You haven't really shown the necessary parts of your stylesheet,
but guessing...

If this template:

   <xsl:template match="Invoices/Invoice/Activity">
     <xsl:if test="position()!=1">
         <xsl:if test="Attribute[@Name='Railcar
Number']/Value=preceding-sibling

Is called by an xl:apply-templates that is using xsl:sort, then

position() will refer to the sorted order as you intend, but
preceding-sibling:: always refers to nodes in the input tree so is
unaffected by xsl:sort.

For simple cases your problem is a grouping problem solvable by keys see
Jeni Tennison's site or at least three answers already posted today
on this list. However if you need to do any complicated totalling and
reporting of the sorted/grouped set it will be much easier to do it in
two passes.

First group the input nodes sorting them into order and wrapping each
group in a wrapper element.

then process this new tree, using the template for the wrapper element
to trigger adding total lines etc.

You can either generate a temporary document and process on teh second
pass with a new stylesheet, or do it all in one pass using xalan's
node-set extension function.

David

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