This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XSL Grouping
--qcHopEYAB45HaUaB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Don'w worry, I had an extra for-each. All is great now. Thanks alot! Als=
o, Jeni, do you ever lecture on the
subject in or around the New York area?
On Mon, Nov 12, 2001 at 02:09:13PM -0500, David B. Bitton wrote:
> I have implemented this:
>=20
> <xsl:for-each select=3D"Transaction[count(. | key('TransactionsByStatu=
s', Status)[1]) =3D
> 1]">
> <xsl:sort select=3D"Status"/>
> <tr class=3D"Report">
> <td colspan=3D"8">
> <b>
> <xsl:choose>
> <xsl:when test=3D"Status=3D'C'">
> <xsl:value-of
> select=3D"count(key('TransactionsByStatus', Status))"/><xsl:text> confirm=
ed transaction</xsl:text>
> </xsl:when>
> <xsl:when test=3D"Status=3D'A'">
> <xsl:value-of
> select=3D"count(key('TransactionsByStatus', Status))"/><xsl:text> accepte=
d, awaiting confirmation</xsl:text>
> </xsl:when>
> <xsl:when test=3D"Status=3D'R'">
> <xsl:value-of
> select=3D"count(key('TransactionsByStatus', Status))"/><xsl:text> rejecte=
d</xsl:text>
> </xsl:when>
> <xsl:when test=3D"Status=3D'Y' or Status =3D 'N'">
> <xsl:value-of
> select=3D"count(key('TransactionsByStatus', Status))"/><xsl:text> transac=
tion awaiting submission</xsl:text>=20
> </xsl:when> =09
> <xsl:when test=3D"Status=3D'2' or Status=3D'3' or Status=3D'4'
> or Status=3D'5' or Status=3D'6' or Status=3D'7' or Status=3D'8' or Status=
=3D'9'">
> <xsl:value-of
> select=3D"count(key('TransactionsByStatus', Status))"/><xsl:text> transac=
tion awaiting </xsl:text> <xsl:value-of
> select=3D"Status" /><xsl:text> more approvals</xsl:text>
> </xsl:when>
> </xsl:choose>
> </b>
> </td>
> </tr>
> <xsl:for-each select=3D"key('TransactionsByStatus', Status)">
> <xsl:sort select=3D"*[local-name() =3D string($sortby)]"
> data-type=3D"{$datatype}" order=3D"{$order}"/>
> =09
> <xsl:for-each select=3D"key('TransactionsByStatus', Status)
>=20
> [generate-id() =3D
>=20
> generate-id(key('TransactionsByStatusAndCurrencyCode',
>=20
> concat(Status, '::', CurrencyCode))[1])]">
> =09
> <tr><td class=3D"ReportD" colspan=3D"8"><xsl:value-of
> select=3D"CurrencyCode"/></td></tr>
> =09
> <xsl:for-each
> select=3D"key('TransactionsByStatusAndCurrencyCode',
>=20
> concat(Status, '::', CurrencyCode))">
>=20
>=20
> and I'm getting all transaction repeated for all currencycode, so if ther=
e are three transactions in the group, I
> get three under each unique currencycode, hrm. :)
>=20
> On Mon, Nov 12, 2001 at 05:56:22PM +0000, Jeni Tennison wrote:
> > Hi David,
> >=20
> > > This is one transaction. First we group by Status, no prob. Now I
> > > want to group by CurrencyCode within each Status group. I'm just not
> > > seeming to get the right combo of xsl:key and key() XPath in the sub
> > > for-each. Can someone lend a hand? Tx :)
> >=20
> > Sure. The key that you use for the second level group has to index
> > each Transaction by a combination of its Status and its CurrencyCode.
> > The easiest way to get such a combination value is using the concat()
> > function, so try:
> >=20
> > <xsl:key name=3D"TransactionsByStatusAndCurrencyCode"
> > match=3D"Transaction"
> > use=3D"concat(Status, '::', CurrencyCode)" />
> >=20
> > [Obviously you don't have to use such a long name, I'm just doing so
> > to make things clear.]
> >=20
> > At the point where currently you're retrieving all the Transaction
> > elements with a particular status, you need to filter that set to
> > include only those that have that Status *and* have a unique
> > CurrencyCode, with something like:
> >=20
> > key('TransactionsByStatus', $status)
> > [generate-id() =3D
> > generate-id(key('TransactionsByStatusAndCurrencyCode',
> > concat($status, '::', CurrencyCode))[1])]
> >=20
> > And once you're processing such a Transaction, you can get all the
> > other Transaction elements with the same Status and CurrencyCode with:
> >=20
> > key('TransactionsByStatusAndCurrencyCode'
> > concat(Status, '::', CurrencyCode))
> >=20
> > I hope that helps,
> >=20
> > Jeni
> >=20
> > ---
> > Jeni Tennison
> > http://www.jenitennison.com/
> >=20
> >=20
> > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>=20
> --=20
>=20
> David B. Bitton
> david@codenoevil.com
>=20
> Diversa ab illis virtute valemus.
--=20
David B. Bitton
david@codenoevil.com
Diversa ab illis virtute valemus.
--qcHopEYAB45HaUaB
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD4DBQE78CoMMNOMzNRRk50RAmbHAJdsWRJYHstLSagMfAovYTAleUWfAKCLeMNY
qeCAmx1x6AYlpahNiJt92A==
=d7lw
-----END PGP SIGNATURE-----
--qcHopEYAB45HaUaB--
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list