This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XSL Grouping



--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I have implemented this:

			<xsl:for-each select=3D"Transaction[count(. | key('TransactionsByStatus'=
, 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> confirmed=
 transaction</xsl:text>
							</xsl:when>
							<xsl:when test=3D"Status=3D'A'">
								<xsl:value-of
select=3D"count(key('TransactionsByStatus', Status))"/><xsl:text> accepted,=
 awaiting confirmation</xsl:text>
							</xsl:when>
							<xsl:when test=3D"Status=3D'R'">
								<xsl:value-of
select=3D"count(key('TransactionsByStatus', Status))"/><xsl:text> rejected<=
/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> transacti=
on 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> transacti=
on 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)

[generate-id() =3D

generate-id(key('TransactionsByStatusAndCurrencyCode',

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',

concat(Status, '::', CurrencyCode))">


and I'm getting all transaction repeated for all currencycode, so if there =
are three transactions in the group, I
get three under each unique currencycode, hrm. :)

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

David B. Bitton
david@codenoevil.com

Diversa ab illis virtute valemus.

--VbJkn9YxBvnuCH5J
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

iD8DBQE78B5ZMNOMzNRRk50RAgtgAKCYiotIClYWsfszhXwP4TagEjP4ngCghux4
I6X/zAP4CsZa2pGlTFeC03k=
=voof
-----END PGP SIGNATURE-----

--VbJkn9YxBvnuCH5J--

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]