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

Re: Multi-level grouping across multiple input files

Subject: Re: Multi-level grouping across multiple input files question.
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 13 Oct 2004 12:19:15 +0100
xsl multi level grouping
> then by the month of <actual>,
 <actual>5/7/2004 8:34:00 AM </actual>

horrible format you have for dates:-) (single digits so not fixed length
strings) (also I can't tell if you are using the inverted "amercian"
order, so is that 5 or 7 you want? (apply suitable combinations of
substring-before or substring-after below, then use format-number to
force it to two digits.

Then you want something like

<xsl:variable name="input" select="
  document('april.xml') |
  document('may.xml') |
  document('june.xml') |
  document('july.xml') |
  document('august.xml') |
  document('september.xml')
"/>

<xsl:key name="a" match="claim" use="vendorname"/>
<xsl:key name="b" match="claim"
use="concat(vendorname,':',format-number(substring-before...))"/>
<xsl:key name="c" match="claim"
use="concat(vendorname,':',format-number(substring-before...),':',loadnum)"/>

<!--
that sets up keys for all three levels, the code below just does the
first level group (this would be a lot easier in xslt2 draft)
-->

<xsl:for-each select="$input/claims/claim">

<!--
process all claims
-->

 <xsl:variable name="ids">
 <xsl:for-each select="$input">
  <xsl:value-of select="generate-id(key('a',vendorname)")
  <xsl:text>:</xsl:text>
 </xsl:for-each>
 </xsl:variable>

<!--
That has the id of the first claim in each doc that has this vendorname
-->


 <xsl:if test="generate-id(.)=substring-before($ids,':')">

<!--
 if this is true then we are on the first claim with this vendor in the
 collection, so proceess the group of all claims with this vendor,
 otherwise do nothing.
 -->

 heading: <xsl:value-of select="vendorname"/>
<!--
make a heading for the group
-->

  <xsl:for-each select="$inputs">
    <xsl:apply-templates  select="key('a',vendorname)"/>
  </xsl:for-each>

<!--
 apply templates to all claims in this group (this will need to do
 essentially the same again but with keys b and c to do the subgroups)
-->

 </xsl:if>
</xsl:for-each>

<!-- finish up -->


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. 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
________________________________________________________________________

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.