|
Subject: RE: [xsl] Grouping problem persists From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 22 Aug 2003 15:08:44 +0100 |
>
> 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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Grouping problem persists, Martti Poutanen | Thread | RE: [xsl] Grouping problem persists, Américo Albuquerque |
| [xsl] Question about Page-Masters, Lehming, Thea | Date | [xsl] XSLT and external calls, Manolis Mavrikis |
| Month |