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

RE: Grouping problem persists

Subject: RE: Grouping problem persists
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 22 Aug 2003 15:08:44 +0100
picture grouping
> 
> I was unable to get following grouping to work:

So what technique are you using?

There are two main ways of doing positional grouping. One is to use
xsl:apply-templates recursively over the following-sibling axis: think
of the logical children of a node with @picture='MODULE' as being the
following sibling nodes that have this as their most recent such node,
i.e.

<xsl:template match="row[@picture='MODULE']">
<module>
  <xsl:variable name="this" select="generate-id($this)"/>
  <xsl:apply-templates select="following-sibling::row[
       generate-id(preceding-sibling::row[@picture='MODULE'][1]) =
$this]"/>
</module>
</xsl:template>

The other way is to treat it as a value-based grouping problem, using
Muenchian grouping with keys, where the grouping key value is 

generate-id(preceding-sibling::row[@picture='MODULE'][1])

Michael Kay

PS: Saxon 6.2.2 is getting rather long in the tooth.

> 
> Source (from Excel/VB):
> <list>
> <row num=" 4 ">
> <entry name="sp_code"></entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">MODULE:</entry>
> <entry name="qty"></entry>
> </row>
> <row num=" 5 ">
> <entry name="sp_code">2000402</entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">01_001_e.cgm</entry>
> <entry name="qty"></entry>
> </row>
> <row num=" 6 ">
> <entry name="ID">5</entry>
> <entry name="sp_code">5210558</entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">01_001_e.cgm</entry>
> <entry name="qty">2</entry>
> </row>
> ....
> <row num=" 35 ">
> <entry name="sp_code"></entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">MODULE:</entry>
> <entry name="qty"></entry>
> </row>
> ...
> </list>
> 
> What I need is structured output like:
> 
> <list>
> <module>
> <row num=" 4 ">
> <entry name="sp_code"></entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">MODULE:</entry>
> <entry name="qty"></entry>
> </row>
> <row num=" 5 ">
> <entry name="sp_code">2000402</entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">01_001_e.cgm</entry>
> <entry name="qty"></entry>
> </row>
> <row num=" 6 ">
> <entry name="ID">5</entry>
> <entry name="sp_code">5210558</entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">01_001_e.cgm</entry>
> <entry name="qty">2</entry>
> </row>
> ...
> </module>
> <module>
> <row num=" 35 ">
> <entry name="sp_code"></entry>
> <entry name="sn_from"></entry>
> <entry name="sn_to">-</entry>
> <entry name="picture">MODULE:</entry>
> <entry name="qty"></entry>
> </row>
> ...
> </module>
> </list>
> 
> So, every row-node containing entry of type "picture" with 
> text content of "MODULE:" would start a new "module" in output
> 
> I'm using Saxon 6.2.2
> 
> Thanks in advance, Martti
> 
> 
>  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

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.