This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Multiple grouping with substrings
- From: Ben Fry <Ben_Fry at amt-sybex dot com>
- To: XSL Mulberry <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 13 Aug 2002 16:53:15 +0100
- Subject: [xsl] Multiple grouping with substrings
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi All,
I have a grouping problem I cannot work out. I have done a couple of
stylesheets with keys but this one has me
befuddled.
I am having trouble declaring and using a key like this; (I am new to keys
so go easy here)
<xsl:key name="xprogs" match="doc/prog[contains(.,'msx']"
use="substring(.,4,1)"/>
My algorithm is
a). Group by 3rd character of prog node ie 'x' in msx123 followed
by 'y' in msy123
b). For each unique 4th character of prog node list prog nodes 4 (or
ideally custom value)
per line separated by a single space (produce new line when a
different 4th character
encountered).
xml;
<doc>
<prog>msx123</prog>
<prog>msx124</prog>
<prog>msx125</prog>
<prog>msx126</prog>
<prog>msx127</prog>
<prog>msx128</prog>
<prog>msx129</prog>
<prog>msx213</prog>
<prog>msx332</prog>
<prog>msx423</prog>
<prog>msx424</prog>
<prog>msx643</prog>
<prog>msx743</prog>
<prog>msx843</prog>
<prog>msy123</prog>
<prog>msy223</prog>
<prog>msy224</prog>
<prog>msy423</prog>
</doc>
desired output text format;
xxx123 xxx124 xxx125 xxx126
xxx127 xxx128 xxx129
xxx213
xxx332
xxx423 xxx424
xxx643
xxx743
xxx843
yyy123
yyy223 yyy224
yyy423
Regards,
Ben
=====================================================================
DISCLAIMER
1. The information contained in this E-mail is confidential.
It is intended only for the stated addressee(s) and access
to it by any other person is unauthorised.
If you are not an addressee, you must not disclose, copy,
circulate or in any other way use or rely on the information
contained in this E-mail. Such unauthorised use may be unlawful.
If you have received this E-mail in error, please inform us
immediately and delete it and all copies from your system.
2. The views expressed in this E-mail are those of the author,
and do not represent the views of AMT-Sybex Group Ltd., its
associates or subsidiaries, unless otherwise expressly indicated.
In the avoidance of doubt, the insertion of the name of AMT-Sybex
Group Ltd., its associate or subsidiary under the name of the sender
may constitute an express indication that the views stated in the Mail
are those of the named company.
=====================================================================
For more information on the AMT Sybex group visit: http://www.amt-sybex.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list